From 862e948ae9b2b4359c5e97deee14b9643743601c Mon Sep 17 00:00:00 2001 From: jirkamotejl Date: Fri, 6 Mar 2026 07:24:17 +0100 Subject: [PATCH 01/34] fix(files): add additional_html to CANCAN_MAPPINGS read group (CS-167) The additional_html action was missing from Folio::File::CANCAN_MAPPINGS[:read], causing CanCan::AccessDenied (401) for non-superadmin roles (editors, redactors) when accessing the file detail API endpoint in console. --- app/models/folio/file.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/folio/file.rb b/app/models/folio/file.rb index a3f0cdc40..6277cbd76 100644 --- a/app/models/folio/file.rb +++ b/app/models/folio/file.rb @@ -42,6 +42,7 @@ class Folio::File < Folio::ApplicationRecord update_thumbnails_crop ], read: %i[ + additional_html batch_bar batch_download batch_download_failure From 569086a07180ea64754d448d9c66fc7afdf3247f Mon Sep 17 00:00:00 2001 From: "zaneta.gebka" Date: Thu, 5 Mar 2026 14:28:38 +0100 Subject: [PATCH 02/34] When file is updated it should be reflected on articles where this file is added (#525) * When file is updated it should be reflected on articles where this file is added --- app/jobs/folio/files/after_save_job.rb | 26 ++++- app/models/folio/file.rb | 5 +- test/models/folio/file_placement_test.rb | 119 +++++++++++++++++++++++ 3 files changed, 148 insertions(+), 2 deletions(-) diff --git a/app/jobs/folio/files/after_save_job.rb b/app/jobs/folio/files/after_save_job.rb index d55465cee..105c9cc4e 100644 --- a/app/jobs/folio/files/after_save_job.rb +++ b/app/jobs/folio/files/after_save_job.rb @@ -10,13 +10,18 @@ class Folio::Files::AfterSaveJob < Folio::ApplicationJob # use SQL commands only! # save/update would cause an infinite loop as this is hooked in after_save - def perform(file) + def perform(file, changed_attrs = {}) return if Rails.env.test? && !Rails.application.config.try(:folio_testing_after_save_job) placements = file.file_placements file.update_column(:file_placements_count, placements.size) + # Sync description/alt/headline to placements if file metadata changed + if changed_attrs.present? + sync_metadata_to_placements(file, placements, changed_attrs) + end + # touch placements to bust cache placements.find_each do |placement| if placement.placement @@ -24,4 +29,23 @@ def perform(file) end end end + + private + + def sync_metadata_to_placements(file, placements, changed_attrs) + if changed_attrs.key?("description") + old_desc, new_desc = changed_attrs["description"] + placements.where(description: [old_desc, nil, ""]).update_all(description: new_desc) + end + + if changed_attrs.key?("alt") + old_alt, new_alt = changed_attrs["alt"] + placements.where(alt: [old_alt, nil, ""]).update_all(alt: new_alt) + end + + if changed_attrs.key?("headline") + old_headline, new_headline = changed_attrs["headline"] + placements.where(title: [old_headline, nil, ""]).update_all(title: new_headline) + end + end end diff --git a/app/models/folio/file.rb b/app/models/folio/file.rb index 6277cbd76..d57b0390a 100644 --- a/app/models/folio/file.rb +++ b/app/models/folio/file.rb @@ -238,7 +238,10 @@ def run_after_save_job # updating placements return if ENV["SKIP_FOLIO_FILE_AFTER_SAVE_JOB"] return if Rails.env.test? && !Rails.application.config.try(:folio_testing_after_save_job) - Folio::Files::AfterSaveJob.perform_later(self) + + changed_attrs = saved_changes.slice("description", "alt", "headline") + + Folio::Files::AfterSaveJob.perform_later(self, changed_attrs) end def process_attached_file diff --git a/test/models/folio/file_placement_test.rb b/test/models/folio/file_placement_test.rb index 1b882261d..13aa69d17 100644 --- a/test/models/folio/file_placement_test.rb +++ b/test/models/folio/file_placement_test.rb @@ -37,6 +37,125 @@ def setup end end end + + test "file metadata syncs to placements on update" do + perform_enqueued_jobs do + file = create(:folio_file_image, + description: "Original caption", + alt: "Original alt", + headline: "Original headline") + + page1 = create(:folio_page) + page1.cover = file + page1.save! + + page2 = create(:folio_page) + page2.cover = file + page2.save! + + placement1 = page1.cover_placement.reload + placement2 = page2.cover_placement.reload + + assert_equal "Original caption", placement1.description + assert_equal "Original alt", placement1.alt + assert_equal "Original headline", placement1.title + + file.update!( + description: "Updated caption", + alt: "Updated alt", + headline: "Updated headline" + ) + + assert_equal "Updated caption", placement1.reload.description, + "Placement 1 description should sync from file" + assert_equal "Updated alt", placement1.alt, + "Placement 1 alt should sync from file" + assert_equal "Updated headline", placement1.title, + "Placement 1 title should sync from file" + + assert_equal "Updated caption", placement2.reload.description, + "Placement 2 description should sync from file" + assert_equal "Updated alt", placement2.alt, + "Placement 2 alt should sync from file" + assert_equal "Updated headline", placement2.title, + "Placement 2 title should sync from file" + end + end + + test "file metadata sync preserves custom placement overrides" do + perform_enqueued_jobs do + file = create(:folio_file_image, description: "File caption") + + page = create(:folio_page) + page.cover = file + page.save! + + placement = page.cover_placement.reload + + placement.update_column(:description, "Custom placement caption") + + file.update!(description: "New file caption") + + assert_equal "Custom placement caption", placement.reload.description, + "Custom placement description should be preserved" + end + end + + test "file metadata sync works for partial updates" do + perform_enqueued_jobs do + file = create(:folio_file_image, + description: "Original caption", + alt: "Original alt", + headline: "Original headline") + + page = create(:folio_page) + page.cover = file + page.save! + + placement = page.cover_placement.reload + + file.update!(description: "Updated caption only") + + placement.reload + assert_equal "Updated caption only", placement.description + assert_equal "Original alt", placement.alt + assert_equal "Original headline", placement.title + end + end + + test "file metadata sync handles blank placements" do + perform_enqueued_jobs do + file = create(:folio_file_image, description: "File caption") + + page = create(:folio_page) + page.cover = file + page.save! + + placement = page.cover_placement.reload + placement.update_column(:description, nil) + file.update!(description: "New file caption") + + assert_equal "New file caption", placement.reload.description, + "Blank placement should be updated with new file value" + end + end + + test "file metadata sync updates to nil value" do + perform_enqueued_jobs do + file = create(:folio_file_image, description: "Original caption") + page = create(:folio_page) + page.cover = file + page.save! + + placement = page.cover_placement.reload + assert_equal "Original caption", placement.description + + file.update!(description: nil) + + assert_nil placement.reload.description, + "Placement should be updated to nil when file is updated to nil" + end + end end # == Schema Information From 806cebf08fc665fa2c9a282e4f8ec1c82baa36ce Mon Sep 17 00:00:00 2001 From: "zaneta.gebka" Date: Mon, 9 Mar 2026 09:51:30 +0100 Subject: [PATCH 03/34] extend fix for autocomplete with minimum query length (#548) --- CHANGELOG.md | 1 + .../console/api/autocompletes_controller.rb | 23 +++++- .../api/autocompletes_controller_test.rb | 79 +++++++++++++++++++ 3 files changed, 101 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c15cef472..0f9184a17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file. ### Fixed +- **Autocomplete performance**: Extended minimum query length guard to `select2`, `selectize`, and `react_select` actions in `AutocompletesController`. All autocomplete endpoints now reject queries shorter than 3 characters without hitting the database, preventing cascade PostgreSQL connection pool exhaustion. Completes the fix from 7.4.0 which only covered the `show` action. - add change event handler for select inline edits - prevent long filenames from overflowing dropdown - S3 ping retry loop no longer runs infinitely after 10 failures — stops retrying, shows a non-blocking flash instead of a blocking `window.alert()`, and resets the loading state diff --git a/app/controllers/folio/console/api/autocompletes_controller.rb b/app/controllers/folio/console/api/autocompletes_controller.rb index e719bdc03..6fa96ce97 100644 --- a/app/controllers/folio/console/api/autocompletes_controller.rb +++ b/app/controllers/folio/console/api/autocompletes_controller.rb @@ -155,7 +155,14 @@ def selectize scope = filter_by_atom_setting_params(scope) - scope = scope.by_label_query(q) if q.present? + if q.present? + if q.length >= AUTOCOMPLETE_QUERY_MIN_LENGTH + scope = scope.by_label_query(q) + else + render_selectize_options([]) + return + end + end scope, has_type_ordering = apply_ordered_for_folio_console_selects(scope, klass) @@ -197,7 +204,14 @@ def select2 scope = filter_by_atom_setting_params(scope) - scope = scope.by_label_query(q) if q.present? + if q.present? + if q.length >= AUTOCOMPLETE_QUERY_MIN_LENGTH + scope = scope.by_label_query(q) + else + render_select2_options([]) + return + end + end scope, has_type_ordering = apply_ordered_for_folio_console_selects(scope, klass) @@ -237,6 +251,11 @@ def react_select p_without = params[:without] p_page = params[:page]&.to_i || 1 + if q.present? && q.length < AUTOCOMPLETE_QUERY_MIN_LENGTH + render json: { data: [], meta: { page: 1, pages: 1, from: nil, to: nil, count: 0, next: nil } } + return + end + if class_names # Show model names when there are multiple classes, or when a single class forces it show_model_names = class_names.size > 1 diff --git a/test/controllers/folio/console/api/autocompletes_controller_test.rb b/test/controllers/folio/console/api/autocompletes_controller_test.rb index 5cb8d4225..5405c9044 100644 --- a/test/controllers/folio/console/api/autocompletes_controller_test.rb +++ b/test/controllers/folio/console/api/autocompletes_controller_test.rb @@ -275,4 +275,83 @@ class Folio::Console::Api::AutocompletesControllerTest < Folio::Console::BaseCon # Clean up Folio::Page.singleton_class.remove_method(:ordered_for_folio_console_selects) end + + test "selectize ignores short queries below minimum length" do + create(:folio_page, title: "Foo bar baz") + + # 1-char query should return empty (below min length of 3) + get selectize_console_api_autocomplete_path(klass: "Folio::Page", q: "f") + json = JSON.parse(response.body) + assert_equal([], json["data"]) + + # 2-char query should return empty (below min length of 3) + get selectize_console_api_autocomplete_path(klass: "Folio::Page", q: "fo") + json = JSON.parse(response.body) + assert_equal([], json["data"]) + + # 3-char query should trigger search and return results + get selectize_console_api_autocomplete_path(klass: "Folio::Page", q: "foo") + json = JSON.parse(response.body) + assert_equal(1, json["data"].size) + assert_equal("Foo bar baz", json["data"][0]["text"]) + end + + test "select2 ignores short queries below minimum length" do + create(:folio_page, title: "Foo bar baz") + + # 1-char query should return empty (below min length of 3) + get select2_console_api_autocomplete_path(klass: "Folio::Page", q: "f") + json = JSON.parse(response.body) + assert_equal([], json["results"]) + + # 2-char query should return empty (below min length of 3) + get select2_console_api_autocomplete_path(klass: "Folio::Page", q: "fo") + json = JSON.parse(response.body) + assert_equal([], json["results"]) + + # 3-char query should trigger search and return results + get select2_console_api_autocomplete_path(klass: "Folio::Page", q: "foo") + json = JSON.parse(response.body) + assert_equal(1, json["results"].size) + assert_equal("Foo bar baz", json["results"][0]["text"]) + end + + test "react_select ignores short queries below minimum length" do + create(:folio_page, title: "Foo bar baz") + + # 1-char query should return empty (below min length of 3) + get react_select_console_api_autocomplete_path(class_names: "Folio::Page", q: "f") + json = JSON.parse(response.body) + assert_equal([], json["data"]) + assert_equal(1, json["meta"]["page"]) + assert_equal(1, json["meta"]["pages"]) + + # 2-char query should return empty (below min length of 3) + get react_select_console_api_autocomplete_path(class_names: "Folio::Page", q: "fo") + json = JSON.parse(response.body) + assert_equal([], json["data"]) + assert_equal(1, json["meta"]["page"]) + assert_equal(1, json["meta"]["pages"]) + + # 3-char query should trigger search and return results + get react_select_console_api_autocomplete_path(class_names: "Folio::Page", q: "foo") + json = JSON.parse(response.body) + assert_equal(1, json["data"].size) + assert_equal("Foo bar baz", json["data"][0]["text"]) + end + + test "react_select with multiple classes ignores short queries" do + create(:folio_page, title: "Foo page") + + # 2-char query should return empty for multiple classes + get react_select_console_api_autocomplete_path(class_names: "Folio::Page", q: "fo") + json = JSON.parse(response.body) + assert_equal([], json["data"]) + assert_equal(1, json["meta"]["page"]) + + # 3-char query should return results + get react_select_console_api_autocomplete_path(class_names: "Folio::Page", q: "foo") + json = JSON.parse(response.body) + assert json["data"].size > 0 + end end From eff01d3f83c593be1b6d38856887313827bf465a Mon Sep 17 00:00:00 2001 From: Nikolaj Kolesnik Date: Tue, 10 Mar 2026 12:30:48 +0100 Subject: [PATCH 04/34] feat(aside_style): optimize and clean up css code --- .../stylesheets/folio/tiptap/_styles.scss | 46 +++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/app/assets/stylesheets/folio/tiptap/_styles.scss b/app/assets/stylesheets/folio/tiptap/_styles.scss index 110f97e40..389d6bf03 100644 --- a/app/assets/stylesheets/folio/tiptap/_styles.scss +++ b/app/assets/stylesheets/folio/tiptap/_styles.scss @@ -416,9 +416,13 @@ $f-tiptap__media-min-width--desktop: 708px !default; } .f-tiptap-float__aside { - margin-bottom: var(--f-tiptap-float__aside-margin-y); position: relative; z-index: 2; + margin-bottom: var(--f-tiptap-float__aside-margin-y); + margin-right: var(--f-tiptap-float__aside-margin-x); + margin-left: var(--f-tiptap-float__aside-offset); + width: var(--f-tiptap-float__aside-width); + float: var(--f-tiptap-float__aside-side); } .f-tiptap-editor & .f-tiptap-column::before, @@ -555,7 +559,28 @@ $f-tiptap__media-min-width--desktop: 708px !default; } } + .f-tiptap-float[data-f-tiptap-float-side="right"] .f-tiptap-float__aside { + margin-right: var(--f-tiptap-float__aside-offset); + margin-left: var(--f-tiptap-float__aside-margin-x); + } + + .f-tiptap-float[data-f-tiptap-float-size="small"] .f-tiptap-float__aside { + width: var(--f-tiptap-float__aside-width); + } + + .f-tiptap-float[data-f-tiptap-float-size="large"] .f-tiptap-float__aside { + width: var(--f-tiptap-float__aside-width); + } + + .f-tiptap-float[data-f-tiptap-float-side="right"] .f-tiptap-float__aside { + float: var(--f-tiptap-float__aside-side); + } + /* Mobile first - Aside width and spacing */ + .f-tiptap-float { + --f-tiptap-float__aside-side: left; + --f-tiptap-float__aside-width: 100%; + } @container (min-width: #{$f-tiptap__media-min-width--tablet}) { .f-tiptap-float { @@ -564,6 +589,7 @@ $f-tiptap__media-min-width--desktop: 708px !default; --f-tiptap-float__aside-side: left; --f-tiptap-float__aside-margin-x: var(--f-tiptap-float__aside-margin-x--tablet); --f-tiptap-float__aside-offset: var(--f-tiptap-float__aside-offset--tablet); + --f-tiptap-float__aside-margin-y: var(--f-tiptap__spacer); &::after { content: ""; @@ -586,30 +612,12 @@ $f-tiptap__media-min-width--desktop: 708px !default; .f-tiptap-float__aside { float: left; - margin-right: var(--f-tiptap-float__aside-margin-x); - margin-bottom: var(--f-tiptap__spacer); - margin-left: var(--f-tiptap-float__aside-offset); - width: var(--f-tiptap-float__aside-width); position: relative; container-type: inline-size; box-sizing: border-box; min-height: 2rem; } - .f-tiptap-float[data-f-tiptap-float-side="right"] .f-tiptap-float__aside { - float: right; - margin-right: var(--f-tiptap-float__aside-offset); - margin-left: var(--f-tiptap-float__aside-margin-x); - } - - .f-tiptap-float[data-f-tiptap-float-size="small"] .f-tiptap-float__aside { - width: var(--f-tiptap-float__aside-width); - } - - .f-tiptap-float[data-f-tiptap-float-size="large"] .f-tiptap-float__aside { - width: var(--f-tiptap-float__aside-width); - } - .f-tiptap-columns { display: grid; grid-auto-columns: 1fr; From 7e3eff9cbc8bd2b753bde8e2a607816be99cfa82 Mon Sep 17 00:00:00 2001 From: Petr Marek Date: Mon, 9 Mar 2026 07:20:19 +0100 Subject: [PATCH 05/34] chore(db): migrate --- app/models/folio/file.rb | 1 + app/models/folio/file/audio.rb | 1 + app/models/folio/file/document.rb | 1 + app/models/folio/file/image.rb | 1 + app/models/folio/file/video.rb | 1 + test/dummy/db/schema.rb | 3 ++- 6 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/folio/file.rb b/app/models/folio/file.rb index d57b0390a..dd44804f1 100644 --- a/app/models/folio/file.rb +++ b/app/models/folio/file.rb @@ -563,6 +563,7 @@ def dispatch_destroyed_message # index_folio_files_on_by_author (to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((author)::text, ''::text)))) USING gin # index_folio_files_on_by_file_name (to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((file_name)::text, ''::text)))) USING gin # index_folio_files_on_by_file_name_for_search (to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((file_name_for_search)::text, ''::text)))) USING gin +# index_folio_files_on_by_label_query ((((to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((file_name_for_search)::text, ''::text))) || to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((headline)::text, ''::text)))) || to_tsvector('simple'::regconfig, folio_unaccent(COALESCE(description, ''::text)))))) USING gin # index_folio_files_on_created_at (created_at) # index_folio_files_on_created_by_folio_user_id (created_by_folio_user_id) # index_folio_files_on_file_name (file_name) diff --git a/app/models/folio/file/audio.rb b/app/models/folio/file/audio.rb index 2cfa27270..7ac7452ec 100644 --- a/app/models/folio/file/audio.rb +++ b/app/models/folio/file/audio.rb @@ -58,6 +58,7 @@ def self.human_type # index_folio_files_on_by_author (to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((author)::text, ''::text)))) USING gin # index_folio_files_on_by_file_name (to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((file_name)::text, ''::text)))) USING gin # index_folio_files_on_by_file_name_for_search (to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((file_name_for_search)::text, ''::text)))) USING gin +# index_folio_files_on_by_label_query ((((to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((file_name_for_search)::text, ''::text))) || to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((headline)::text, ''::text)))) || to_tsvector('simple'::regconfig, folio_unaccent(COALESCE(description, ''::text)))))) USING gin # index_folio_files_on_created_at (created_at) # index_folio_files_on_created_by_folio_user_id (created_by_folio_user_id) # index_folio_files_on_file_name (file_name) diff --git a/app/models/folio/file/document.rb b/app/models/folio/file/document.rb index b3c4bad8b..1739dd358 100644 --- a/app/models/folio/file/document.rb +++ b/app/models/folio/file/document.rb @@ -56,6 +56,7 @@ def thumbnailable? # index_folio_files_on_by_author (to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((author)::text, ''::text)))) USING gin # index_folio_files_on_by_file_name (to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((file_name)::text, ''::text)))) USING gin # index_folio_files_on_by_file_name_for_search (to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((file_name_for_search)::text, ''::text)))) USING gin +# index_folio_files_on_by_label_query ((((to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((file_name_for_search)::text, ''::text))) || to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((headline)::text, ''::text)))) || to_tsvector('simple'::regconfig, folio_unaccent(COALESCE(description, ''::text)))))) USING gin # index_folio_files_on_created_at (created_at) # index_folio_files_on_created_by_folio_user_id (created_by_folio_user_id) # index_folio_files_on_file_name (file_name) diff --git a/app/models/folio/file/image.rb b/app/models/folio/file/image.rb index bbc803ef3..df4f0f39f 100644 --- a/app/models/folio/file/image.rb +++ b/app/models/folio/file/image.rb @@ -140,6 +140,7 @@ def extract_metadata_async # index_folio_files_on_by_author (to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((author)::text, ''::text)))) USING gin # index_folio_files_on_by_file_name (to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((file_name)::text, ''::text)))) USING gin # index_folio_files_on_by_file_name_for_search (to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((file_name_for_search)::text, ''::text)))) USING gin +# index_folio_files_on_by_label_query ((((to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((file_name_for_search)::text, ''::text))) || to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((headline)::text, ''::text)))) || to_tsvector('simple'::regconfig, folio_unaccent(COALESCE(description, ''::text)))))) USING gin # index_folio_files_on_created_at (created_at) # index_folio_files_on_created_by_folio_user_id (created_by_folio_user_id) # index_folio_files_on_file_name (file_name) diff --git a/app/models/folio/file/video.rb b/app/models/folio/file/video.rb index ed21baf2a..bb5e9a842 100644 --- a/app/models/folio/file/video.rb +++ b/app/models/folio/file/video.rb @@ -74,6 +74,7 @@ def self.human_type # index_folio_files_on_by_author (to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((author)::text, ''::text)))) USING gin # index_folio_files_on_by_file_name (to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((file_name)::text, ''::text)))) USING gin # index_folio_files_on_by_file_name_for_search (to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((file_name_for_search)::text, ''::text)))) USING gin +# index_folio_files_on_by_label_query ((((to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((file_name_for_search)::text, ''::text))) || to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((headline)::text, ''::text)))) || to_tsvector('simple'::regconfig, folio_unaccent(COALESCE(description, ''::text)))))) USING gin # index_folio_files_on_created_at (created_at) # index_folio_files_on_created_by_folio_user_id (created_by_folio_user_id) # index_folio_files_on_file_name (file_name) diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index 31d87898f..e4666cfec 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2026_01_27_081153) do +ActiveRecord::Schema[8.0].define(version: 2026_03_02_084244) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" enable_extension "pg_trgm" @@ -353,6 +353,7 @@ t.integer "published_usage_count", default: 0, null: false t.jsonb "thumbnail_configuration" t.bigint "created_by_folio_user_id" + t.index "(((to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((file_name_for_search)::text, ''::text))) || to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((headline)::text, ''::text)))) || to_tsvector('simple'::regconfig, folio_unaccent(COALESCE(description, ''::text)))))", name: "index_folio_files_on_by_label_query", using: :gin t.index "to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((author)::text, ''::text)))", name: "index_folio_files_on_by_author", using: :gin t.index "to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((file_name)::text, ''::text)))", name: "index_folio_files_on_by_file_name", using: :gin t.index "to_tsvector('simple'::regconfig, folio_unaccent(COALESCE((file_name_for_search)::text, ''::text)))", name: "index_folio_files_on_by_file_name_for_search", using: :gin From a5c7cccb3fc44acb5473a10a20a9099fe23346b3 Mon Sep 17 00:00:00 2001 From: Petr Marek Date: Mon, 9 Mar 2026 07:18:15 +0100 Subject: [PATCH 06/34] chore(gemfile): version 7.4.0 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3612e587d..5fef481a1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,7 +10,7 @@ GIT PATH remote: . specs: - folio (7.3.0) + folio (7.4.0) aasm activejob-uniqueness (>= 0.3.0) acts-as-taggable-on From 139b5ae4fead0e5b99349a772e46fa0d6f49af32 Mon Sep 17 00:00:00 2001 From: Petr Marek Date: Mon, 9 Mar 2026 07:17:47 +0100 Subject: [PATCH 07/34] fix(tiptap): new_record_alert i18n non-nominative case --- .../tiptap/simple_form_wrap/autosave_info_component.slim | 2 +- config/locales/console/tiptap.cs.yml | 2 +- config/locales/console/tiptap.en.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/components/folio/console/tiptap/simple_form_wrap/autosave_info_component.slim b/app/components/folio/console/tiptap/simple_form_wrap/autosave_info_component.slim index 7990f4f6b..e6b0d1714 100644 --- a/app/components/folio/console/tiptap/simple_form_wrap/autosave_info_component.slim +++ b/app/components/folio/console/tiptap/simple_form_wrap/autosave_info_component.slim @@ -4,7 +4,7 @@ = render(Folio::Console::Ui::AlertComponent.new(variant: :warning, class_name: "m-0", closable: false)) - = t('.new_record_alert', model: object.class.model_name.human.downcase) + = t('.new_record_alert') - elsif has_unsaved_changes? .f-c-tiptap-simple-form-wrap-autosave-info__unsaved_changes data=stimulus_target("unsavedChanges") .f-c-tiptap-simple-form-wrap-autosave-info__top diff --git a/config/locales/console/tiptap.cs.yml b/config/locales/console/tiptap.cs.yml index 740be1908..6d6c6ceed 100644 --- a/config/locales/console/tiptap.cs.yml +++ b/config/locales/console/tiptap.cs.yml @@ -11,7 +11,7 @@ cs: words: Slov characters: Znaků autosave_info_component: - new_record_alert: Rozepsané změny v editoru se neukládají, dokud %{model} poprvé neuložíte. + new_record_alert: Rozepsané změny v editoru se neukládají, dokud záznam poprvé neuložíte. title: Editor obsahuje neuložené rozepsané změny. continue: Použít moji verzi discard: Použít verzi jiného uživatele diff --git a/config/locales/console/tiptap.en.yml b/config/locales/console/tiptap.en.yml index 632df4a4f..52842ccfd 100644 --- a/config/locales/console/tiptap.en.yml +++ b/config/locales/console/tiptap.en.yml @@ -11,7 +11,7 @@ en: words: Words characters: Characters autosave_info_component: - new_record_alert: Draft changes in the editor are not saved until you first save the %{model}. + new_record_alert: Draft changes in the editor are not saved until you first save the record. title: The editor contains unsaved draft changes. continue: Continue editing draft discard: Discard draft changes From c6a8f21aadd248b0ce345d32bf7701473cffa369 Mon Sep 17 00:00:00 2001 From: Petr Marek Date: Tue, 10 Mar 2026 06:36:05 +0100 Subject: [PATCH 08/34] chore(changelog): mv entries to released --- CHANGELOG.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f9184a17..f689c9767 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +## [7.4.0] - 2026-03-04 + ### Added - add support YouTube shorts embeds links @@ -13,11 +15,6 @@ All notable changes to this project will be documented in this file. - add change event handler for select inline edits - prevent long filenames from overflowing dropdown - S3 ping retry loop no longer runs infinitely after 10 failures — stops retrying, shows a non-blocking flash instead of a blocking `window.alert()`, and resets the loading state - -## [7.4.0] - 2026-03-04 - -### Fixed - - **Autocomplete performance**: Added minimum query length guard (`AUTOCOMPLETE_QUERY_MIN_LENGTH = 3`) to `AutocompletesController#show` — queries shorter than 3 characters no longer trigger expensive fulltext DB scans. Increased debounce delay in `f-input-autocomplete` Stimulus controller from 150ms to 500ms to reduce concurrent parallel requests during typing. Added combined GIN index `index_folio_files_on_by_label_query` on `folio_files` covering `(file_name_for_search, headline, description)` — resolves cascade PostgreSQL overload from unindexed fulltext scans. - tiptap blank documents now get saved as nil - previously a doc with an empty paragraph was saved instead From b28e4bd3af8459ffb0a147243f2a2285964c7d9c Mon Sep 17 00:00:00 2001 From: pj258 Date: Tue, 10 Mar 2026 06:39:40 +0100 Subject: [PATCH 09/34] fix(audited-dropdown): flex-wrap and full-width label/small in component (#549) * fix(audited-dropdown): flex-wrap and full-width label/small in component Made-with: Cursor * chore(changelog): log audited dropdown fix --------- Co-authored-by: Jiri Prusek Co-authored-by: Petr Marek --- CHANGELOG.md | 4 ++++ app/components/folio/console/audited/dropdown_component.sass | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f689c9767..2143a6e32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Fixed + +- audited dropdown css layout + ## [7.4.0] - 2026-03-04 ### Added diff --git a/app/components/folio/console/audited/dropdown_component.sass b/app/components/folio/console/audited/dropdown_component.sass index 77554401a..d53cd81e8 100644 --- a/app/components/folio/console/audited/dropdown_component.sass +++ b/app/components/folio/console/audited/dropdown_component.sass @@ -23,6 +23,7 @@ overflow-y: auto &__item + flex-wrap: wrap font-weight: $font-weight-normal color: #495057 white-space: normal @@ -34,6 +35,9 @@ &, &:hover, &:focus background: #E6F4FA + &__label, &__small + width: 100% + &__small color: #212529 From 6c0b8eb9404dcec4d44e0f52d6d85475b973767d Mon Sep 17 00:00:00 2001 From: Vlada Date: Tue, 10 Mar 2026 18:56:51 +0100 Subject: [PATCH 10/34] fix(tiptap):link handling - close on confirm/delete, don't autofocus link popover input --- CHANGELOG.md | 1 + tiptap/dist/assets/folio-tiptap.js | 48 +++++++++---------- .../folio-editor/folio-editor-toolbar.tsx | 45 ++++++++++++++++- .../tiptap-ui-primitive/popover/popover.tsx | 10 +++- .../tiptap-ui/link-popover/link-popover.tsx | 13 +++-- 5 files changed, 88 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2143a6e32..7181cbca9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. ### Fixed - audited dropdown css layout +- tiptap link handling - close on confirm/delete, don't autofocus link popover input ## [7.4.0] - 2026-03-04 diff --git a/tiptap/dist/assets/folio-tiptap.js b/tiptap/dist/assets/folio-tiptap.js index 2509a2afb..696956996 100644 --- a/tiptap/dist/assets/folio-tiptap.js +++ b/tiptap/dist/assets/folio-tiptap.js @@ -1,24 +1,24 @@ -var fN=Object.defineProperty;var hN=(t,e,n)=>e in t?fN(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var df=(t,e,n)=>hN(t,typeof e!="symbol"?e+"":e,n);function pN(t,e){for(var n=0;nr[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();function t9(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var jg={exports:{}},Oc={};var p7;function mN(){if(p7)return Oc;p7=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,o){var l=null;if(o!==void 0&&(l=""+o),i.key!==void 0&&(l=""+i.key),"key"in i){o={};for(var c in i)c!=="key"&&(o[c]=i[c])}else o=i;return i=o.ref,{$$typeof:t,type:r,key:l,ref:i!==void 0?i:null,props:o}}return Oc.Fragment=e,Oc.jsx=n,Oc.jsxs=n,Oc}var m7;function gN(){return m7||(m7=1,jg.exports=mN()),jg.exports}var S=gN(),Vg={exports:{}},ke={};var g7;function yN(){if(g7)return ke;g7=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),g=Symbol.iterator;function y(D){return D===null||typeof D!="object"?null:(D=g&&D[g]||D["@@iterator"],typeof D=="function"?D:null)}var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,x={};function k(D,Z,W){this.props=D,this.context=Z,this.refs=x,this.updater=W||C}k.prototype.isReactComponent={},k.prototype.setState=function(D,Z){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,Z,"setState")},k.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function A(){}A.prototype=k.prototype;function N(D,Z,W){this.props=D,this.context=Z,this.refs=x,this.updater=W||C}var R=N.prototype=new A;R.constructor=N,w(R,k.prototype),R.isPureReactComponent=!0;var L=Array.isArray;function z(){}var _={H:null,A:null,T:null,S:null},q=Object.prototype.hasOwnProperty;function J(D,Z,W){var se=W.ref;return{$$typeof:t,type:D,key:Z,ref:se!==void 0?se:null,props:W}}function U(D,Z){return J(D.type,Z,D.props)}function ne(D){return typeof D=="object"&&D!==null&&D.$$typeof===t}function le(D){var Z={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(W){return Z[W]})}var oe=/\/+/g;function G(D,Z){return typeof D=="object"&&D!==null&&D.key!=null?le(""+D.key):Z.toString(36)}function P(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(z,z):(D.status="pending",D.then(function(Z){D.status==="pending"&&(D.status="fulfilled",D.value=Z)},function(Z){D.status==="pending"&&(D.status="rejected",D.reason=Z)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function H(D,Z,W,se,de){var ye=typeof D;(ye==="undefined"||ye==="boolean")&&(D=null);var Ee=!1;if(D===null)Ee=!0;else switch(ye){case"bigint":case"string":case"number":Ee=!0;break;case"object":switch(D.$$typeof){case t:case e:Ee=!0;break;case h:return Ee=D._init,H(Ee(D._payload),Z,W,se,de)}}if(Ee)return de=de(D),Ee=se===""?"."+G(D,0):se,L(de)?(W="",Ee!=null&&(W=Ee.replace(oe,"$&/")+"/"),H(de,Z,W,"",function(Nn){return Nn})):de!=null&&(ne(de)&&(de=U(de,W+(de.key==null||D&&D.key===de.key?"":(""+de.key).replace(oe,"$&/")+"/")+Ee)),Z.push(de)),1;Ee=0;var Rt=se===""?".":se+":";if(L(D))for(var tt=0;tt>>1,ae=H[re];if(0>>1;rei(W,B))sei(de,W)?(H[re]=de,H[se]=B,re=se):(H[re]=W,H[Z]=B,re=Z);else if(sei(de,B))H[re]=de,H[se]=B,re=se;else break e}}return j}function i(H,j){var B=H.sortIndex-j.sortIndex;return B!==0?B:H.id-j.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var l=Date,c=l.now();t.unstable_now=function(){return l.now()-c}}var d=[],f=[],h=1,m=null,g=3,y=!1,C=!1,w=!1,x=!1,k=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;function R(H){for(var j=n(f);j!==null;){if(j.callback===null)r(f);else if(j.startTime<=H)r(f),j.sortIndex=j.expirationTime,e(d,j);else break;j=n(f)}}function L(H){if(w=!1,R(H),!C)if(n(d)!==null)C=!0,z||(z=!0,le());else{var j=n(f);j!==null&&P(L,j.startTime-H)}}var z=!1,_=-1,q=5,J=-1;function U(){return x?!0:!(t.unstable_now()-JH&&U());){var re=m.callback;if(typeof re=="function"){m.callback=null,g=m.priorityLevel;var ae=re(m.expirationTime<=H);if(H=t.unstable_now(),typeof ae=="function"){m.callback=ae,R(H),j=!0;break t}m===n(d)&&r(d),R(H)}else r(d);m=n(d)}if(m!==null)j=!0;else{var D=n(f);D!==null&&P(L,D.startTime-H),j=!1}}break e}finally{m=null,g=B,y=!1}j=void 0}}finally{j?le():z=!1}}}var le;if(typeof N=="function")le=function(){N(ne)};else if(typeof MessageChannel<"u"){var oe=new MessageChannel,G=oe.port2;oe.port1.onmessage=ne,le=function(){G.postMessage(null)}}else le=function(){k(ne,0)};function P(H,j){_=k(function(){H(t.unstable_now())},j)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(H){H.callback=null},t.unstable_forceFrameRate=function(H){0>H||125re?(H.sortIndex=B,e(f,H),n(d)===null&&H===n(f)&&(w?(A(_),_=-1):w=!0,P(L,B-re))):(H.sortIndex=ae,e(d,H),C||y||(C=!0,z||(z=!0,le()))),H},t.unstable_shouldYield=U,t.unstable_wrapCallback=function(H){var j=g;return function(){var B=g;g=j;try{return H.apply(this,arguments)}finally{g=B}}}})(Fg)),Fg}var b7;function bN(){return b7||(b7=1,Pg.exports=vN()),Pg.exports}var $g={exports:{}},vn={};var C7;function CN(){if(C7)return vn;C7=1;var t=Ou();function e(d){var f="https://react.dev/errors/"+d;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),$g.exports=CN(),$g.exports}var x7;function wN(){if(x7)return Dc;x7=1;var t=bN(),e=Ou(),n=r9();function r(s){var a="https://react.dev/errors/"+s;if(1ae||(s.current=re[ae],re[ae]=null,ae--)}function W(s,a){ae++,re[ae]=s.current,s.current=a}var se=D(null),de=D(null),ye=D(null),Ee=D(null);function Rt(s,a){switch(W(ye,a),W(de,s),W(se,null),a.nodeType){case 9:case 11:s=(s=a.documentElement)&&(s=s.namespaceURI)?zC(s):0;break;default:if(s=a.tagName,a=a.namespaceURI)a=zC(a),s=BC(a,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}Z(se),W(se,s)}function tt(){Z(se),Z(de),Z(ye)}function Nn(s){s.memoizedState!==null&&W(Ee,s);var a=se.current,u=BC(a,s.type);a!==u&&(W(de,s),W(se,u))}function Or(s){de.current===s&&(Z(se),Z(de)),Ee.current===s&&(Z(Ee),Mc._currentValue=B)}var Me,He;function Te(s){if(Me===void 0)try{throw Error()}catch(u){var a=u.stack.trim().match(/\n( *(at )?)/);Me=a&&a[1]||"",He=-1e in t?fN(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var df=(t,e,n)=>hN(t,typeof e!="symbol"?e+"":e,n);function pN(t,e){for(var n=0;nr[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();function t9(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var jg={exports:{}},Oc={};var p7;function mN(){if(p7)return Oc;p7=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,o){var l=null;if(o!==void 0&&(l=""+o),i.key!==void 0&&(l=""+i.key),"key"in i){o={};for(var c in i)c!=="key"&&(o[c]=i[c])}else o=i;return i=o.ref,{$$typeof:t,type:r,key:l,ref:i!==void 0?i:null,props:o}}return Oc.Fragment=e,Oc.jsx=n,Oc.jsxs=n,Oc}var m7;function gN(){return m7||(m7=1,jg.exports=mN()),jg.exports}var S=gN(),Vg={exports:{}},ke={};var g7;function yN(){if(g7)return ke;g7=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),g=Symbol.iterator;function y(D){return D===null||typeof D!="object"?null:(D=g&&D[g]||D["@@iterator"],typeof D=="function"?D:null)}var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,x={};function k(D,Z,W){this.props=D,this.context=Z,this.refs=x,this.updater=W||C}k.prototype.isReactComponent={},k.prototype.setState=function(D,Z){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,Z,"setState")},k.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function A(){}A.prototype=k.prototype;function N(D,Z,W){this.props=D,this.context=Z,this.refs=x,this.updater=W||C}var R=N.prototype=new A;R.constructor=N,w(R,k.prototype),R.isPureReactComponent=!0;var L=Array.isArray;function z(){}var _={H:null,A:null,T:null,S:null},$=Object.prototype.hasOwnProperty;function J(D,Z,W){var le=W.ref;return{$$typeof:t,type:D,key:Z,ref:le!==void 0?le:null,props:W}}function U(D,Z){return J(D.type,Z,D.props)}function ne(D){return typeof D=="object"&&D!==null&&D.$$typeof===t}function se(D){var Z={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(W){return Z[W]})}var oe=/\/+/g;function G(D,Z){return typeof D=="object"&&D!==null&&D.key!=null?se(""+D.key):Z.toString(36)}function P(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(z,z):(D.status="pending",D.then(function(Z){D.status==="pending"&&(D.status="fulfilled",D.value=Z)},function(Z){D.status==="pending"&&(D.status="rejected",D.reason=Z)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function H(D,Z,W,le,de){var ye=typeof D;(ye==="undefined"||ye==="boolean")&&(D=null);var Ee=!1;if(D===null)Ee=!0;else switch(ye){case"bigint":case"string":case"number":Ee=!0;break;case"object":switch(D.$$typeof){case t:case e:Ee=!0;break;case h:return Ee=D._init,H(Ee(D._payload),Z,W,le,de)}}if(Ee)return de=de(D),Ee=le===""?"."+G(D,0):le,L(de)?(W="",Ee!=null&&(W=Ee.replace(oe,"$&/")+"/"),H(de,Z,W,"",function(Nn){return Nn})):de!=null&&(ne(de)&&(de=U(de,W+(de.key==null||D&&D.key===de.key?"":(""+de.key).replace(oe,"$&/")+"/")+Ee)),Z.push(de)),1;Ee=0;var Rt=le===""?".":le+":";if(L(D))for(var tt=0;tt>>1,ae=H[re];if(0>>1;rei(W,B))lei(de,W)?(H[re]=de,H[le]=B,re=le):(H[re]=W,H[Z]=B,re=Z);else if(lei(de,B))H[re]=de,H[le]=B,re=le;else break e}}return j}function i(H,j){var B=H.sortIndex-j.sortIndex;return B!==0?B:H.id-j.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var l=Date,c=l.now();t.unstable_now=function(){return l.now()-c}}var d=[],f=[],h=1,m=null,g=3,y=!1,C=!1,w=!1,x=!1,k=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;function R(H){for(var j=n(f);j!==null;){if(j.callback===null)r(f);else if(j.startTime<=H)r(f),j.sortIndex=j.expirationTime,e(d,j);else break;j=n(f)}}function L(H){if(w=!1,R(H),!C)if(n(d)!==null)C=!0,z||(z=!0,se());else{var j=n(f);j!==null&&P(L,j.startTime-H)}}var z=!1,_=-1,$=5,J=-1;function U(){return x?!0:!(t.unstable_now()-J<$)}function ne(){if(x=!1,z){var H=t.unstable_now();J=H;var j=!0;try{e:{C=!1,w&&(w=!1,A(_),_=-1),y=!0;var B=g;try{t:{for(R(H),m=n(d);m!==null&&!(m.expirationTime>H&&U());){var re=m.callback;if(typeof re=="function"){m.callback=null,g=m.priorityLevel;var ae=re(m.expirationTime<=H);if(H=t.unstable_now(),typeof ae=="function"){m.callback=ae,R(H),j=!0;break t}m===n(d)&&r(d),R(H)}else r(d);m=n(d)}if(m!==null)j=!0;else{var D=n(f);D!==null&&P(L,D.startTime-H),j=!1}}break e}finally{m=null,g=B,y=!1}j=void 0}}finally{j?se():z=!1}}}var se;if(typeof N=="function")se=function(){N(ne)};else if(typeof MessageChannel<"u"){var oe=new MessageChannel,G=oe.port2;oe.port1.onmessage=ne,se=function(){G.postMessage(null)}}else se=function(){k(ne,0)};function P(H,j){_=k(function(){H(t.unstable_now())},j)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(H){H.callback=null},t.unstable_forceFrameRate=function(H){0>H||125re?(H.sortIndex=B,e(f,H),n(d)===null&&H===n(f)&&(w?(A(_),_=-1):w=!0,P(L,B-re))):(H.sortIndex=ae,e(d,H),C||y||(C=!0,z||(z=!0,se()))),H},t.unstable_shouldYield=U,t.unstable_wrapCallback=function(H){var j=g;return function(){var B=g;g=j;try{return H.apply(this,arguments)}finally{g=B}}}})(Fg)),Fg}var b7;function bN(){return b7||(b7=1,Pg.exports=vN()),Pg.exports}var $g={exports:{}},vn={};var C7;function CN(){if(C7)return vn;C7=1;var t=Ou();function e(d){var f="https://react.dev/errors/"+d;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),$g.exports=CN(),$g.exports}var x7;function wN(){if(x7)return Dc;x7=1;var t=bN(),e=Ou(),n=r9();function r(s){var a="https://react.dev/errors/"+s;if(1ae||(s.current=re[ae],re[ae]=null,ae--)}function W(s,a){ae++,re[ae]=s.current,s.current=a}var le=D(null),de=D(null),ye=D(null),Ee=D(null);function Rt(s,a){switch(W(ye,a),W(de,s),W(le,null),a.nodeType){case 9:case 11:s=(s=a.documentElement)&&(s=s.namespaceURI)?zC(s):0;break;default:if(s=a.tagName,a=a.namespaceURI)a=zC(a),s=BC(a,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}Z(le),W(le,s)}function tt(){Z(le),Z(de),Z(ye)}function Nn(s){s.memoizedState!==null&&W(Ee,s);var a=le.current,u=BC(a,s.type);a!==u&&(W(de,s),W(le,u))}function Or(s){de.current===s&&(Z(le),Z(de)),Ee.current===s&&(Z(Ee),Mc._currentValue=B)}var Me,He;function Te(s){if(Me===void 0)try{throw Error()}catch(u){var a=u.stack.trim().match(/\n( *(at )?)/);Me=a&&a[1]||"",He=-1)":-1v||O[p]!==$[v]){var X=` +`),q=M.split(` +`);for(v=p=0;pv||O[p]!==q[v]){var X=` `+O[p].replace(" at new "," at ");return s.displayName&&X.includes("")&&(X=X.replace("",s.displayName)),X}while(1<=p&&0<=v);break}}}finally{nt=!1,Error.prepareStackTrace=u}return(u=s?s.displayName||s.name:"")?Te(u):""}function Be(s,a){switch(s.tag){case 26:case 27:case 5:return Te(s.type);case 16:return Te("Lazy");case 13:return s.child!==a&&a!==null?Te("Suspense Fallback"):Te("Suspense");case 19:return Te("SuspenseList");case 0:case 15:return ht(s.type,!1);case 11:return ht(s.type.render,!1);case 1:return ht(s.type,!0);case 31:return Te("Activity");default:return""}}function Gt(s){try{var a="",u=null;do a+=Be(s,u),u=s,s=s.return;while(s);return a}catch(p){return` Error generating stack: `+p.message+` -`+p.stack}}var Ot=Object.prototype.hasOwnProperty,zt=t.unstable_scheduleCallback,Hn=t.unstable_cancelCallback,ve=t.unstable_shouldYield,Re=t.unstable_requestPaint,fe=t.unstable_now,Ye=t.unstable_getCurrentPriorityLevel,lt=t.unstable_ImmediatePriority,wt=t.unstable_UserBlockingPriority,Jr=t.unstable_NormalPriority,al=t.unstable_LowPriority,ro=t.unstable_IdlePriority,In=t.log,mi=t.unstable_setDisableYieldValue,Xr=null,yn=null;function Dr(s){if(typeof In=="function"&&mi(s),yn&&typeof yn.setStrictMode=="function")try{yn.setStrictMode(Xr,s)}catch{}}var Yt=Math.clz32?Math.clz32:E1,Qr=Math.log,cl=Math.LN2;function E1(s){return s>>>=0,s===0?32:31-(Qr(s)/cl|0)|0}var ls=256,as=262144,Wu=4194304;function cs(s){var a=s&42;if(a!==0)return a;switch(s&-s){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return s&261888;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function Ju(s,a,u){var p=s.pendingLanes;if(p===0)return 0;var v=0,b=s.suspendedLanes,T=s.pingedLanes;s=s.warmLanes;var M=p&134217727;return M!==0?(p=M&~b,p!==0?v=cs(p):(T&=M,T!==0?v=cs(T):u||(u=M&~s,u!==0&&(v=cs(u))))):(M=p&~b,M!==0?v=cs(M):T!==0?v=cs(T):u||(u=p&~s,u!==0&&(v=cs(u)))),v===0?0:a!==0&&a!==v&&(a&b)===0&&(b=v&-v,u=a&-a,b>=u||b===32&&(u&4194048)!==0)?a:v}function Va(s,a){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&a)===0}function QE(s,a){switch(s){case 1:case 2:case 4:case 8:case 64:return a+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function vv(){var s=Wu;return Wu<<=1,(Wu&62914560)===0&&(Wu=4194304),s}function M1(s){for(var a=[],u=0;31>u;u++)a.push(s);return a}function Ua(s,a){s.pendingLanes|=a,a!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function eM(s,a,u,p,v,b){var T=s.pendingLanes;s.pendingLanes=u,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=u,s.entangledLanes&=u,s.errorRecoveryDisabledLanes&=u,s.shellSuspendCounter=0;var M=s.entanglements,O=s.expirationTimes,$=s.hiddenUpdates;for(u=T&~u;0"u")return null;try{return s.activeElement||s.body}catch{return s.body}}var sM=/[\n"\\]/g;function dr(s){return s.replace(sM,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function L1(s,a,u,p,v,b,T,M){s.name="",T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?s.type=T:s.removeAttribute("type"),a!=null?T==="number"?(a===0&&s.value===""||s.value!=a)&&(s.value=""+ur(a)):s.value!==""+ur(a)&&(s.value=""+ur(a)):T!=="submit"&&T!=="reset"||s.removeAttribute("value"),a!=null?_1(s,T,ur(a)):u!=null?_1(s,T,ur(u)):p!=null&&s.removeAttribute("value"),v==null&&b!=null&&(s.defaultChecked=!!b),v!=null&&(s.checked=v&&typeof v!="function"&&typeof v!="symbol"),M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"?s.name=""+ur(M):s.removeAttribute("name")}function Ov(s,a,u,p,v,b,T,M){if(b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(s.type=b),a!=null||u!=null){if(!(b!=="submit"&&b!=="reset"||a!=null)){D1(s);return}u=u!=null?""+ur(u):"",a=a!=null?""+ur(a):u,M||a===s.value||(s.value=a),s.defaultValue=a}p=p??v,p=typeof p!="function"&&typeof p!="symbol"&&!!p,s.checked=M?s.checked:!!p,s.defaultChecked=!!p,T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"&&(s.name=T),D1(s)}function _1(s,a,u){a==="number"&&ed(s.ownerDocument)===s||s.defaultValue===""+u||(s.defaultValue=""+u)}function ml(s,a,u,p){if(s=s.options,a){a={};for(var v=0;v"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),j1=!1;if(vi)try{var qa={};Object.defineProperty(qa,"passive",{get:function(){j1=!0}}),window.addEventListener("test",qa,qa),window.removeEventListener("test",qa,qa)}catch{j1=!1}var oo=null,V1=null,nd=null;function Bv(){if(nd)return nd;var s,a=V1,u=a.length,p,v="value"in oo?oo.value:oo.textContent,b=v.length;for(s=0;s=Ga),$v=" ",qv=!1;function Zv(s,a){switch(s){case"keyup":return _M.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Kv(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var bl=!1;function IM(s,a){switch(s){case"compositionend":return Kv(a);case"keypress":return a.which!==32?null:(qv=!0,$v);case"textInput":return s=a.data,s===$v&&qv?null:s;default:return null}}function zM(s,a){if(bl)return s==="compositionend"||!q1&&Zv(s,a)?(s=Bv(),nd=V1=oo=null,bl=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1=a)return{node:u,offset:a-s};s=p}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=tb(u)}}function rb(s,a){return s&&a?s===a?!0:s&&s.nodeType===3?!1:a&&a.nodeType===3?rb(s,a.parentNode):"contains"in s?s.contains(a):s.compareDocumentPosition?!!(s.compareDocumentPosition(a)&16):!1:!1}function ib(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var a=ed(s.document);a instanceof s.HTMLIFrameElement;){try{var u=typeof a.contentWindow.location.href=="string"}catch{u=!1}if(u)s=a.contentWindow;else break;a=ed(s.document)}return a}function G1(s){var a=s&&s.nodeName&&s.nodeName.toLowerCase();return a&&(a==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||a==="textarea"||s.contentEditable==="true")}var qM=vi&&"documentMode"in document&&11>=document.documentMode,Cl=null,Y1=null,Xa=null,W1=!1;function ob(s,a,u){var p=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;W1||Cl==null||Cl!==ed(p)||(p=Cl,"selectionStart"in p&&G1(p)?p={start:p.selectionStart,end:p.selectionEnd}:(p=(p.ownerDocument&&p.ownerDocument.defaultView||window).getSelection(),p={anchorNode:p.anchorNode,anchorOffset:p.anchorOffset,focusNode:p.focusNode,focusOffset:p.focusOffset}),Xa&&Ja(Xa,p)||(Xa=p,p=Yd(Y1,"onSelect"),0>=T,v-=T,ei=1<<32-Yt(a)+v|u<Ne?(ze=ge,ge=null):ze=ge.sibling;var $e=K(V,ge,F[Ne],Q);if($e===null){ge===null&&(ge=ze);break}s&&ge&&$e.alternate===null&&a(V,ge),I=b($e,I,Ne),Fe===null?Ce=$e:Fe.sibling=$e,Fe=$e,ge=ze}if(Ne===F.length)return u(V,ge),je&&Ci(V,Ne),Ce;if(ge===null){for(;NeNe?(ze=ge,ge=null):ze=ge.sibling;var Ao=K(V,ge,$e.value,Q);if(Ao===null){ge===null&&(ge=ze);break}s&&ge&&Ao.alternate===null&&a(V,ge),I=b(Ao,I,Ne),Fe===null?Ce=Ao:Fe.sibling=Ao,Fe=Ao,ge=ze}if($e.done)return u(V,ge),je&&Ci(V,Ne),Ce;if(ge===null){for(;!$e.done;Ne++,$e=F.next())$e=ee(V,$e.value,Q),$e!==null&&(I=b($e,I,Ne),Fe===null?Ce=$e:Fe.sibling=$e,Fe=$e);return je&&Ci(V,Ne),Ce}for(ge=p(ge);!$e.done;Ne++,$e=F.next())$e=Y(ge,V,Ne,$e.value,Q),$e!==null&&(s&&$e.alternate!==null&&ge.delete($e.key===null?Ne:$e.key),I=b($e,I,Ne),Fe===null?Ce=$e:Fe.sibling=$e,Fe=$e);return s&&ge.forEach(function(dN){return a(V,dN)}),je&&Ci(V,Ne),Ce}function ot(V,I,F,Q){if(typeof F=="object"&&F!==null&&F.type===w&&F.key===null&&(F=F.props.children),typeof F=="object"&&F!==null){switch(F.$$typeof){case y:e:{for(var Ce=F.key;I!==null;){if(I.key===Ce){if(Ce=F.type,Ce===w){if(I.tag===7){u(V,I.sibling),Q=v(I,F.props.children),Q.return=V,V=Q;break e}}else if(I.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===q&&Cs(Ce)===I.type){u(V,I.sibling),Q=v(I,F.props),ic(Q,F),Q.return=V,V=Q;break e}u(V,I);break}else a(V,I);I=I.sibling}F.type===w?(Q=ms(F.props.children,V.mode,Q,F.key),Q.return=V,V=Q):(Q=fd(F.type,F.key,F.props,null,V.mode,Q),ic(Q,F),Q.return=V,V=Q)}return T(V);case C:e:{for(Ce=F.key;I!==null;){if(I.key===Ce)if(I.tag===4&&I.stateNode.containerInfo===F.containerInfo&&I.stateNode.implementation===F.implementation){u(V,I.sibling),Q=v(I,F.children||[]),Q.return=V,V=Q;break e}else{u(V,I);break}else a(V,I);I=I.sibling}Q=rm(F,V.mode,Q),Q.return=V,V=Q}return T(V);case q:return F=Cs(F),ot(V,I,F,Q)}if(P(F))return he(V,I,F,Q);if(le(F)){if(Ce=le(F),typeof Ce!="function")throw Error(r(150));return F=Ce.call(F),xe(V,I,F,Q)}if(typeof F.then=="function")return ot(V,I,bd(F),Q);if(F.$$typeof===N)return ot(V,I,md(V,F),Q);Cd(V,F)}return typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint"?(F=""+F,I!==null&&I.tag===6?(u(V,I.sibling),Q=v(I,F),Q.return=V,V=Q):(u(V,I),Q=nm(F,V.mode,Q),Q.return=V,V=Q),T(V)):u(V,I)}return function(V,I,F,Q){try{rc=0;var Ce=ot(V,I,F,Q);return Ol=null,Ce}catch(ge){if(ge===Rl||ge===yd)throw ge;var Fe=er(29,ge,null,V.mode);return Fe.lanes=Q,Fe.return=V,Fe}}}var xs=Ab(!0),Nb=Ab(!1),uo=!1;function mm(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function gm(s,a){s=s.updateQueue,a.updateQueue===s&&(a.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,callbacks:null})}function fo(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function ho(s,a,u){var p=s.updateQueue;if(p===null)return null;if(p=p.shared,(Ke&2)!==0){var v=p.pending;return v===null?a.next=a:(a.next=v.next,v.next=a),p.pending=a,a=dd(s),fb(s,null,u),a}return ud(s,p,a,u),dd(s)}function oc(s,a,u){if(a=a.updateQueue,a!==null&&(a=a.shared,(u&4194048)!==0)){var p=a.lanes;p&=s.pendingLanes,u|=p,a.lanes=u,Cv(s,u)}}function ym(s,a){var u=s.updateQueue,p=s.alternate;if(p!==null&&(p=p.updateQueue,u===p)){var v=null,b=null;if(u=u.firstBaseUpdate,u!==null){do{var T={lane:u.lane,tag:u.tag,payload:u.payload,callback:null,next:null};b===null?v=b=T:b=b.next=T,u=u.next}while(u!==null);b===null?v=b=a:b=b.next=a}else v=b=a;u={baseState:p.baseState,firstBaseUpdate:v,lastBaseUpdate:b,shared:p.shared,callbacks:p.callbacks},s.updateQueue=u;return}s=u.lastBaseUpdate,s===null?u.firstBaseUpdate=a:s.next=a,u.lastBaseUpdate=a}var vm=!1;function sc(){if(vm){var s=Nl;if(s!==null)throw s}}function lc(s,a,u,p){vm=!1;var v=s.updateQueue;uo=!1;var b=v.firstBaseUpdate,T=v.lastBaseUpdate,M=v.shared.pending;if(M!==null){v.shared.pending=null;var O=M,$=O.next;O.next=null,T===null?b=$:T.next=$,T=O;var X=s.alternate;X!==null&&(X=X.updateQueue,M=X.lastBaseUpdate,M!==T&&(M===null?X.firstBaseUpdate=$:M.next=$,X.lastBaseUpdate=O))}if(b!==null){var ee=v.baseState;T=0,X=$=O=null,M=b;do{var K=M.lane&-536870913,Y=K!==M.lane;if(Y?(Ie&K)===K:(p&K)===K){K!==0&&K===Al&&(vm=!0),X!==null&&(X=X.next={lane:0,tag:M.tag,payload:M.payload,callback:null,next:null});e:{var he=s,xe=M;K=a;var ot=u;switch(xe.tag){case 1:if(he=xe.payload,typeof he=="function"){ee=he.call(ot,ee,K);break e}ee=he;break e;case 3:he.flags=he.flags&-65537|128;case 0:if(he=xe.payload,K=typeof he=="function"?he.call(ot,ee,K):he,K==null)break e;ee=m({},ee,K);break e;case 2:uo=!0}}K=M.callback,K!==null&&(s.flags|=64,Y&&(s.flags|=8192),Y=v.callbacks,Y===null?v.callbacks=[K]:Y.push(K))}else Y={lane:K,tag:M.tag,payload:M.payload,callback:M.callback,next:null},X===null?($=X=Y,O=ee):X=X.next=Y,T|=K;if(M=M.next,M===null){if(M=v.shared.pending,M===null)break;Y=M,M=Y.next,Y.next=null,v.lastBaseUpdate=Y,v.shared.pending=null}}while(!0);X===null&&(O=ee),v.baseState=O,v.firstBaseUpdate=$,v.lastBaseUpdate=X,b===null&&(v.shared.lanes=0),vo|=T,s.lanes=T,s.memoizedState=ee}}function Rb(s,a){if(typeof s!="function")throw Error(r(191,s));s.call(a)}function Ob(s,a){var u=s.callbacks;if(u!==null)for(s.callbacks=null,s=0;sb?b:8;var T=H.T,M={};H.T=M,zm(s,!1,a,u);try{var O=v(),$=H.S;if($!==null&&$(M,O),O!==null&&typeof O=="object"&&typeof O.then=="function"){var X=eA(O,p);uc(s,a,X,or(s))}else uc(s,a,p,or(s))}catch(ee){uc(s,a,{then:function(){},status:"rejected",reason:ee},or())}finally{j.p=b,T!==null&&M.types!==null&&(T.types=M.types),H.T=T}}function sA(){}function Hm(s,a,u,p){if(s.tag!==5)throw Error(r(476));var v=c4(s).queue;a4(s,v,a,B,u===null?sA:function(){return u4(s),u(p)})}function c4(s){var a=s.memoizedState;if(a!==null)return a;a={memoizedState:B,baseState:B,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ti,lastRenderedState:B},next:null};var u={};return a.next={memoizedState:u,baseState:u,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ti,lastRenderedState:u},next:null},s.memoizedState=a,s=s.alternate,s!==null&&(s.memoizedState=a),a}function u4(s){var a=c4(s);a.next===null&&(a=s.alternate.memoizedState),uc(s,a.next.queue,{},or())}function Im(){return an(Mc)}function d4(){return Lt().memoizedState}function f4(){return Lt().memoizedState}function lA(s){for(var a=s.return;a!==null;){switch(a.tag){case 24:case 3:var u=or();s=fo(u);var p=ho(a,s,u);p!==null&&(Fn(p,a,u),oc(p,a,u)),a={cache:dm()},s.payload=a;return}a=a.return}}function aA(s,a,u){var p=or();u={lane:p,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Rd(s)?p4(a,u):(u=em(s,a,u,p),u!==null&&(Fn(u,s,p),m4(u,a,p)))}function h4(s,a,u){var p=or();uc(s,a,u,p)}function uc(s,a,u,p){var v={lane:p,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null};if(Rd(s))p4(a,v);else{var b=s.alternate;if(s.lanes===0&&(b===null||b.lanes===0)&&(b=a.lastRenderedReducer,b!==null))try{var T=a.lastRenderedState,M=b(T,u);if(v.hasEagerState=!0,v.eagerState=M,Qn(M,T))return ud(s,a,v,0),at===null&&cd(),!1}catch{}if(u=em(s,a,v,p),u!==null)return Fn(u,s,p),m4(u,a,p),!0}return!1}function zm(s,a,u,p){if(p={lane:2,revertLane:mg(),gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},Rd(s)){if(a)throw Error(r(479))}else a=em(s,u,p,2),a!==null&&Fn(a,s,2)}function Rd(s){var a=s.alternate;return s===Ae||a!==null&&a===Ae}function p4(s,a){Ll=Sd=!0;var u=s.pending;u===null?a.next=a:(a.next=u.next,u.next=a),s.pending=a}function m4(s,a,u){if((u&4194048)!==0){var p=a.lanes;p&=s.pendingLanes,u|=p,a.lanes=u,Cv(s,u)}}var dc={readContext:an,use:Ed,useCallback:St,useContext:St,useEffect:St,useImperativeHandle:St,useLayoutEffect:St,useInsertionEffect:St,useMemo:St,useReducer:St,useRef:St,useState:St,useDebugValue:St,useDeferredValue:St,useTransition:St,useSyncExternalStore:St,useId:St,useHostTransitionStatus:St,useFormState:St,useActionState:St,useOptimistic:St,useMemoCache:St,useCacheRefresh:St};dc.useEffectEvent=St;var g4={readContext:an,use:Ed,useCallback:function(s,a){return Rn().memoizedState=[s,a===void 0?null:a],s},useContext:an,useEffect:Qb,useImperativeHandle:function(s,a,u){u=u!=null?u.concat([s]):null,Ad(4194308,4,r4.bind(null,a,s),u)},useLayoutEffect:function(s,a){return Ad(4194308,4,s,a)},useInsertionEffect:function(s,a){Ad(4,2,s,a)},useMemo:function(s,a){var u=Rn();a=a===void 0?null:a;var p=s();if(Ss){Dr(!0);try{s()}finally{Dr(!1)}}return u.memoizedState=[p,a],p},useReducer:function(s,a,u){var p=Rn();if(u!==void 0){var v=u(a);if(Ss){Dr(!0);try{u(a)}finally{Dr(!1)}}}else v=a;return p.memoizedState=p.baseState=v,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:v},p.queue=s,s=s.dispatch=aA.bind(null,Ae,s),[p.memoizedState,s]},useRef:function(s){var a=Rn();return s={current:s},a.memoizedState=s},useState:function(s){s=Rm(s);var a=s.queue,u=h4.bind(null,Ae,a);return a.dispatch=u,[s.memoizedState,u]},useDebugValue:Lm,useDeferredValue:function(s,a){var u=Rn();return _m(u,s,a)},useTransition:function(){var s=Rm(!1);return s=a4.bind(null,Ae,s.queue,!0,!1),Rn().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,a,u){var p=Ae,v=Rn();if(je){if(u===void 0)throw Error(r(407));u=u()}else{if(u=a(),at===null)throw Error(r(349));(Ie&127)!==0||zb(p,a,u)}v.memoizedState=u;var b={value:u,getSnapshot:a};return v.queue=b,Qb(jb.bind(null,p,b,s),[s]),p.flags|=2048,Hl(9,{destroy:void 0},Bb.bind(null,p,b,u,a),null),u},useId:function(){var s=Rn(),a=at.identifierPrefix;if(je){var u=ti,p=ei;u=(p&~(1<<32-Yt(p)-1)).toString(32)+u,a="_"+a+"R_"+u,u=Td++,0<\/script>",b=b.removeChild(b.firstChild);break;case"select":b=typeof p.is=="string"?T.createElement("select",{is:p.is}):T.createElement("select"),p.multiple?b.multiple=!0:p.size&&(b.size=p.size);break;default:b=typeof p.is=="string"?T.createElement(v,{is:p.is}):T.createElement(v)}}b[sn]=a,b[zn]=p;e:for(T=a.child;T!==null;){if(T.tag===5||T.tag===6)b.appendChild(T.stateNode);else if(T.tag!==4&&T.tag!==27&&T.child!==null){T.child.return=T,T=T.child;continue}if(T===a)break e;for(;T.sibling===null;){if(T.return===null||T.return===a)break e;T=T.return}T.sibling.return=T.return,T=T.sibling}a.stateNode=b;e:switch(un(b,v,p),v){case"button":case"input":case"select":case"textarea":p=!!p.autoFocus;break e;case"img":p=!0;break e;default:p=!1}p&&Ei(a)}}return mt(a),Jm(a,a.type,s===null?null:s.memoizedProps,a.pendingProps,u),null;case 6:if(s&&a.stateNode!=null)s.memoizedProps!==p&&Ei(a);else{if(typeof p!="string"&&a.stateNode===null)throw Error(r(166));if(s=ye.current,El(a)){if(s=a.stateNode,u=a.memoizedProps,p=null,v=ln,v!==null)switch(v.tag){case 27:case 5:p=v.memoizedProps}s[sn]=a,s=!!(s.nodeValue===u||p!==null&&p.suppressHydrationWarning===!0||HC(s.nodeValue,u)),s||ao(a,!0)}else s=Wd(s).createTextNode(p),s[sn]=a,a.stateNode=s}return mt(a),null;case 31:if(u=a.memoizedState,s===null||s.memoizedState!==null){if(p=El(a),u!==null){if(s===null){if(!p)throw Error(r(318));if(s=a.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(557));s[sn]=a}else gs(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;mt(a),s=!1}else u=lm(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=u),s=!0;if(!s)return a.flags&256?(nr(a),a):(nr(a),null);if((a.flags&128)!==0)throw Error(r(558))}return mt(a),null;case 13:if(p=a.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(v=El(a),p!==null&&p.dehydrated!==null){if(s===null){if(!v)throw Error(r(318));if(v=a.memoizedState,v=v!==null?v.dehydrated:null,!v)throw Error(r(317));v[sn]=a}else gs(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;mt(a),v=!1}else v=lm(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=v),v=!0;if(!v)return a.flags&256?(nr(a),a):(nr(a),null)}return nr(a),(a.flags&128)!==0?(a.lanes=u,a):(u=p!==null,s=s!==null&&s.memoizedState!==null,u&&(p=a.child,v=null,p.alternate!==null&&p.alternate.memoizedState!==null&&p.alternate.memoizedState.cachePool!==null&&(v=p.alternate.memoizedState.cachePool.pool),b=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(b=p.memoizedState.cachePool.pool),b!==v&&(p.flags|=2048)),u!==s&&u&&(a.child.flags|=8192),Hd(a,a.updateQueue),mt(a),null);case 4:return tt(),s===null&&bg(a.stateNode.containerInfo),mt(a),null;case 10:return xi(a.type),mt(a),null;case 19:if(Z(Dt),p=a.memoizedState,p===null)return mt(a),null;if(v=(a.flags&128)!==0,b=p.rendering,b===null)if(v)hc(p,!1);else{if(Tt!==0||s!==null&&(s.flags&128)!==0)for(s=a.child;s!==null;){if(b=xd(s),b!==null){for(a.flags|=128,hc(p,!1),s=b.updateQueue,a.updateQueue=s,Hd(a,s),a.subtreeFlags=0,s=u,u=a.child;u!==null;)hb(u,s),u=u.sibling;return W(Dt,Dt.current&1|2),je&&Ci(a,p.treeForkCount),a.child}s=s.sibling}p.tail!==null&&fe()>Vd&&(a.flags|=128,v=!0,hc(p,!1),a.lanes=4194304)}else{if(!v)if(s=xd(b),s!==null){if(a.flags|=128,v=!0,s=s.updateQueue,a.updateQueue=s,Hd(a,s),hc(p,!0),p.tail===null&&p.tailMode==="hidden"&&!b.alternate&&!je)return mt(a),null}else 2*fe()-p.renderingStartTime>Vd&&u!==536870912&&(a.flags|=128,v=!0,hc(p,!1),a.lanes=4194304);p.isBackwards?(b.sibling=a.child,a.child=b):(s=p.last,s!==null?s.sibling=b:a.child=b,p.last=b)}return p.tail!==null?(s=p.tail,p.rendering=s,p.tail=s.sibling,p.renderingStartTime=fe(),s.sibling=null,u=Dt.current,W(Dt,v?u&1|2:u&1),je&&Ci(a,p.treeForkCount),s):(mt(a),null);case 22:case 23:return nr(a),Cm(),p=a.memoizedState!==null,s!==null?s.memoizedState!==null!==p&&(a.flags|=8192):p&&(a.flags|=8192),p?(u&536870912)!==0&&(a.flags&128)===0&&(mt(a),a.subtreeFlags&6&&(a.flags|=8192)):mt(a),u=a.updateQueue,u!==null&&Hd(a,u.retryQueue),u=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(u=s.memoizedState.cachePool.pool),p=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(p=a.memoizedState.cachePool.pool),p!==u&&(a.flags|=2048),s!==null&&Z(bs),null;case 24:return u=null,s!==null&&(u=s.memoizedState.cache),a.memoizedState.cache!==u&&(a.flags|=2048),xi(Bt),mt(a),null;case 25:return null;case 30:return null}throw Error(r(156,a.tag))}function hA(s,a){switch(om(a),a.tag){case 1:return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 3:return xi(Bt),tt(),s=a.flags,(s&65536)!==0&&(s&128)===0?(a.flags=s&-65537|128,a):null;case 26:case 27:case 5:return Or(a),null;case 31:if(a.memoizedState!==null){if(nr(a),a.alternate===null)throw Error(r(340));gs()}return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 13:if(nr(a),s=a.memoizedState,s!==null&&s.dehydrated!==null){if(a.alternate===null)throw Error(r(340));gs()}return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 19:return Z(Dt),null;case 4:return tt(),null;case 10:return xi(a.type),null;case 22:case 23:return nr(a),Cm(),s!==null&&Z(bs),s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 24:return xi(Bt),null;case 25:return null;default:return null}}function V4(s,a){switch(om(a),a.tag){case 3:xi(Bt),tt();break;case 26:case 27:case 5:Or(a);break;case 4:tt();break;case 31:a.memoizedState!==null&&nr(a);break;case 13:nr(a);break;case 19:Z(Dt);break;case 10:xi(a.type);break;case 22:case 23:nr(a),Cm(),s!==null&&Z(bs);break;case 24:xi(Bt)}}function pc(s,a){try{var u=a.updateQueue,p=u!==null?u.lastEffect:null;if(p!==null){var v=p.next;u=v;do{if((u.tag&s)===s){p=void 0;var b=u.create,T=u.inst;p=b(),T.destroy=p}u=u.next}while(u!==v)}}catch(M){Je(a,a.return,M)}}function go(s,a,u){try{var p=a.updateQueue,v=p!==null?p.lastEffect:null;if(v!==null){var b=v.next;p=b;do{if((p.tag&s)===s){var T=p.inst,M=T.destroy;if(M!==void 0){T.destroy=void 0,v=a;var O=u,$=M;try{$()}catch(X){Je(v,O,X)}}}p=p.next}while(p!==b)}}catch(X){Je(a,a.return,X)}}function U4(s){var a=s.updateQueue;if(a!==null){var u=s.stateNode;try{Ob(a,u)}catch(p){Je(s,s.return,p)}}}function P4(s,a,u){u.props=Ts(s.type,s.memoizedProps),u.state=s.memoizedState;try{u.componentWillUnmount()}catch(p){Je(s,a,p)}}function mc(s,a){try{var u=s.ref;if(u!==null){switch(s.tag){case 26:case 27:case 5:var p=s.stateNode;break;case 30:p=s.stateNode;break;default:p=s.stateNode}typeof u=="function"?s.refCleanup=u(p):u.current=p}}catch(v){Je(s,a,v)}}function ni(s,a){var u=s.ref,p=s.refCleanup;if(u!==null)if(typeof p=="function")try{p()}catch(v){Je(s,a,v)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof u=="function")try{u(null)}catch(v){Je(s,a,v)}else u.current=null}function F4(s){var a=s.type,u=s.memoizedProps,p=s.stateNode;try{e:switch(a){case"button":case"input":case"select":case"textarea":u.autoFocus&&p.focus();break e;case"img":u.src?p.src=u.src:u.srcSet&&(p.srcset=u.srcSet)}}catch(v){Je(s,s.return,v)}}function Xm(s,a,u){try{var p=s.stateNode;HA(p,s.type,u,a),p[zn]=a}catch(v){Je(s,s.return,v)}}function $4(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&So(s.type)||s.tag===4}function Qm(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||$4(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.tag===27&&So(s.type)||s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function eg(s,a,u){var p=s.tag;if(p===5||p===6)s=s.stateNode,a?(u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u).insertBefore(s,a):(a=u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u,a.appendChild(s),u=u._reactRootContainer,u!=null||a.onclick!==null||(a.onclick=yi));else if(p!==4&&(p===27&&So(s.type)&&(u=s.stateNode,a=null),s=s.child,s!==null))for(eg(s,a,u),s=s.sibling;s!==null;)eg(s,a,u),s=s.sibling}function Id(s,a,u){var p=s.tag;if(p===5||p===6)s=s.stateNode,a?u.insertBefore(s,a):u.appendChild(s);else if(p!==4&&(p===27&&So(s.type)&&(u=s.stateNode),s=s.child,s!==null))for(Id(s,a,u),s=s.sibling;s!==null;)Id(s,a,u),s=s.sibling}function q4(s){var a=s.stateNode,u=s.memoizedProps;try{for(var p=s.type,v=a.attributes;v.length;)a.removeAttributeNode(v[0]);un(a,p,u),a[sn]=s,a[zn]=u}catch(b){Je(s,s.return,b)}}var Mi=!1,Ut=!1,tg=!1,Z4=typeof WeakSet=="function"?WeakSet:Set,Jt=null;function pA(s,a){if(s=s.containerInfo,xg=rf,s=ib(s),G1(s)){if("selectionStart"in s)var u={start:s.selectionStart,end:s.selectionEnd};else e:{u=(u=s.ownerDocument)&&u.defaultView||window;var p=u.getSelection&&u.getSelection();if(p&&p.rangeCount!==0){u=p.anchorNode;var v=p.anchorOffset,b=p.focusNode;p=p.focusOffset;try{u.nodeType,b.nodeType}catch{u=null;break e}var T=0,M=-1,O=-1,$=0,X=0,ee=s,K=null;t:for(;;){for(var Y;ee!==u||v!==0&&ee.nodeType!==3||(M=T+v),ee!==b||p!==0&&ee.nodeType!==3||(O=T+p),ee.nodeType===3&&(T+=ee.nodeValue.length),(Y=ee.firstChild)!==null;)K=ee,ee=Y;for(;;){if(ee===s)break t;if(K===u&&++$===v&&(M=T),K===b&&++X===p&&(O=T),(Y=ee.nextSibling)!==null)break;ee=K,K=ee.parentNode}ee=Y}u=M===-1||O===-1?null:{start:M,end:O}}else u=null}u=u||{start:0,end:0}}else u=null;for(Sg={focusedElem:s,selectionRange:u},rf=!1,Jt=a;Jt!==null;)if(a=Jt,s=a.child,(a.subtreeFlags&1028)!==0&&s!==null)s.return=a,Jt=s;else for(;Jt!==null;){switch(a=Jt,b=a.alternate,s=a.flags,a.tag){case 0:if((s&4)!==0&&(s=a.updateQueue,s=s!==null?s.events:null,s!==null))for(u=0;u title"))),un(b,p,u),b[sn]=s,Wt(b),p=b;break e;case"link":var T=XC("link","href",v).get(p+(u.href||""));if(T){for(var M=0;Mot&&(T=ot,ot=xe,xe=T);var V=nb(M,xe),I=nb(M,ot);if(V&&I&&(Y.rangeCount!==1||Y.anchorNode!==V.node||Y.anchorOffset!==V.offset||Y.focusNode!==I.node||Y.focusOffset!==I.offset)){var F=ee.createRange();F.setStart(V.node,V.offset),Y.removeAllRanges(),xe>ot?(Y.addRange(F),Y.extend(I.node,I.offset)):(F.setEnd(I.node,I.offset),Y.addRange(F))}}}}for(ee=[],Y=M;Y=Y.parentNode;)Y.nodeType===1&&ee.push({element:Y,left:Y.scrollLeft,top:Y.scrollTop});for(typeof M.focus=="function"&&M.focus(),M=0;Mu?32:u,H.T=null,u=ag,ag=null;var b=Co,T=Di;if(Kt=0,Vl=Co=null,Di=0,(Ke&6)!==0)throw Error(r(331));var M=Ke;if(Ke|=4,rC(b.current),eC(b,b.current,T,u),Ke=M,wc(0,!1),yn&&typeof yn.onPostCommitFiberRoot=="function")try{yn.onPostCommitFiberRoot(Xr,b)}catch{}return!0}finally{j.p=v,H.T=p,wC(s,a)}}function SC(s,a,u){a=hr(u,a),a=Um(s.stateNode,a,2),s=ho(s,a,2),s!==null&&(Ua(s,2),ri(s))}function Je(s,a,u){if(s.tag===3)SC(s,s,u);else for(;a!==null;){if(a.tag===3){SC(a,s,u);break}else if(a.tag===1){var p=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof p.componentDidCatch=="function"&&(bo===null||!bo.has(p))){s=hr(u,s),u=T4(2),p=ho(a,u,2),p!==null&&(k4(u,p,a,s),Ua(p,2),ri(p));break}}a=a.return}}function fg(s,a,u){var p=s.pingCache;if(p===null){p=s.pingCache=new yA;var v=new Set;p.set(a,v)}else v=p.get(a),v===void 0&&(v=new Set,p.set(a,v));v.has(u)||(ig=!0,v.add(u),s=xA.bind(null,s,a,u),a.then(s,s))}function xA(s,a,u){var p=s.pingCache;p!==null&&p.delete(a),s.pingedLanes|=s.suspendedLanes&u,s.warmLanes&=~u,at===s&&(Ie&u)===u&&(Tt===4||Tt===3&&(Ie&62914560)===Ie&&300>fe()-jd?(Ke&2)===0&&Ul(s,0):og|=u,jl===Ie&&(jl=0)),ri(s)}function TC(s,a){a===0&&(a=vv()),s=ps(s,a),s!==null&&(Ua(s,a),ri(s))}function SA(s){var a=s.memoizedState,u=0;a!==null&&(u=a.retryLane),TC(s,u)}function TA(s,a){var u=0;switch(s.tag){case 31:case 13:var p=s.stateNode,v=s.memoizedState;v!==null&&(u=v.retryLane);break;case 19:p=s.stateNode;break;case 22:p=s.stateNode._retryCache;break;default:throw Error(r(314))}p!==null&&p.delete(a),TC(s,u)}function kA(s,a){return zt(s,a)}var Zd=null,Fl=null,hg=!1,Kd=!1,pg=!1,xo=0;function ri(s){s!==Fl&&s.next===null&&(Fl===null?Zd=Fl=s:Fl=Fl.next=s),Kd=!0,hg||(hg=!0,MA())}function wc(s,a){if(!pg&&Kd){pg=!0;do for(var u=!1,p=Zd;p!==null;){if(s!==0){var v=p.pendingLanes;if(v===0)var b=0;else{var T=p.suspendedLanes,M=p.pingedLanes;b=(1<<31-Yt(42|s)+1)-1,b&=v&~(T&~M),b=b&201326741?b&201326741|1:b?b|2:0}b!==0&&(u=!0,AC(p,b))}else b=Ie,b=Ju(p,p===at?b:0,p.cancelPendingCommit!==null||p.timeoutHandle!==-1),(b&3)===0||Va(p,b)||(u=!0,AC(p,b));p=p.next}while(u);pg=!1}}function EA(){kC()}function kC(){Kd=hg=!1;var s=0;xo!==0&&zA()&&(s=xo);for(var a=fe(),u=null,p=Zd;p!==null;){var v=p.next,b=EC(p,a);b===0?(p.next=null,u===null?Zd=v:u.next=v,v===null&&(Fl=u)):(u=p,(s!==0||(b&3)!==0)&&(Kd=!0)),p=v}Kt!==0&&Kt!==5||wc(s),xo!==0&&(xo=0)}function EC(s,a){for(var u=s.suspendedLanes,p=s.pingedLanes,v=s.expirationTimes,b=s.pendingLanes&-62914561;0M)break;var X=O.transferSize,ee=O.initiatorType;X&&IC(ee)&&(O=O.responseEnd,T+=X*(O"u"?null:document;function GC(s,a,u){var p=$l;if(p&&typeof a=="string"&&a){var v=dr(a);v='link[rel="'+s+'"][href="'+v+'"]',typeof u=="string"&&(v+='[crossorigin="'+u+'"]'),KC.has(v)||(KC.add(v),s={rel:s,crossOrigin:u,href:a},p.querySelector(v)===null&&(a=p.createElement("link"),un(a,"link",s),Wt(a),p.head.appendChild(a)))}}function ZA(s){Li.D(s),GC("dns-prefetch",s,null)}function KA(s,a){Li.C(s,a),GC("preconnect",s,a)}function GA(s,a,u){Li.L(s,a,u);var p=$l;if(p&&s&&a){var v='link[rel="preload"][as="'+dr(a)+'"]';a==="image"&&u&&u.imageSrcSet?(v+='[imagesrcset="'+dr(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(v+='[imagesizes="'+dr(u.imageSizes)+'"]')):v+='[href="'+dr(s)+'"]';var b=v;switch(a){case"style":b=ql(s);break;case"script":b=Zl(s)}br.has(b)||(s=m({rel:"preload",href:a==="image"&&u&&u.imageSrcSet?void 0:s,as:a},u),br.set(b,s),p.querySelector(v)!==null||a==="style"&&p.querySelector(kc(b))||a==="script"&&p.querySelector(Ec(b))||(a=p.createElement("link"),un(a,"link",s),Wt(a),p.head.appendChild(a)))}}function YA(s,a){Li.m(s,a);var u=$l;if(u&&s){var p=a&&typeof a.as=="string"?a.as:"script",v='link[rel="modulepreload"][as="'+dr(p)+'"][href="'+dr(s)+'"]',b=v;switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":b=Zl(s)}if(!br.has(b)&&(s=m({rel:"modulepreload",href:s},a),br.set(b,s),u.querySelector(v)===null)){switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector(Ec(b)))return}p=u.createElement("link"),un(p,"link",s),Wt(p),u.head.appendChild(p)}}}function WA(s,a,u){Li.S(s,a,u);var p=$l;if(p&&s){var v=hl(p).hoistableStyles,b=ql(s);a=a||"default";var T=v.get(b);if(!T){var M={loading:0,preload:null};if(T=p.querySelector(kc(b)))M.loading=5;else{s=m({rel:"stylesheet",href:s,"data-precedence":a},u),(u=br.get(b))&&Rg(s,u);var O=T=p.createElement("link");Wt(O),un(O,"link",s),O._p=new Promise(function($,X){O.onload=$,O.onerror=X}),O.addEventListener("load",function(){M.loading|=1}),O.addEventListener("error",function(){M.loading|=2}),M.loading|=4,Xd(T,a,p)}T={type:"stylesheet",instance:T,count:1,state:M},v.set(b,T)}}}function JA(s,a){Li.X(s,a);var u=$l;if(u&&s){var p=hl(u).hoistableScripts,v=Zl(s),b=p.get(v);b||(b=u.querySelector(Ec(v)),b||(s=m({src:s,async:!0},a),(a=br.get(v))&&Og(s,a),b=u.createElement("script"),Wt(b),un(b,"link",s),u.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},p.set(v,b))}}function XA(s,a){Li.M(s,a);var u=$l;if(u&&s){var p=hl(u).hoistableScripts,v=Zl(s),b=p.get(v);b||(b=u.querySelector(Ec(v)),b||(s=m({src:s,async:!0,type:"module"},a),(a=br.get(v))&&Og(s,a),b=u.createElement("script"),Wt(b),un(b,"link",s),u.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},p.set(v,b))}}function YC(s,a,u,p){var v=(v=ye.current)?Jd(v):null;if(!v)throw Error(r(446));switch(s){case"meta":case"title":return null;case"style":return typeof u.precedence=="string"&&typeof u.href=="string"?(a=ql(u.href),u=hl(v).hoistableStyles,p=u.get(a),p||(p={type:"style",instance:null,count:0,state:null},u.set(a,p)),p):{type:"void",instance:null,count:0,state:null};case"link":if(u.rel==="stylesheet"&&typeof u.href=="string"&&typeof u.precedence=="string"){s=ql(u.href);var b=hl(v).hoistableStyles,T=b.get(s);if(T||(v=v.ownerDocument||v,T={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},b.set(s,T),(b=v.querySelector(kc(s)))&&!b._p&&(T.instance=b,T.state.loading=5),br.has(s)||(u={rel:"preload",as:"style",href:u.href,crossOrigin:u.crossOrigin,integrity:u.integrity,media:u.media,hrefLang:u.hrefLang,referrerPolicy:u.referrerPolicy},br.set(s,u),b||QA(v,s,u,T.state))),a&&p===null)throw Error(r(528,""));return T}if(a&&p!==null)throw Error(r(529,""));return null;case"script":return a=u.async,u=u.src,typeof u=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=Zl(u),u=hl(v).hoistableScripts,p=u.get(a),p||(p={type:"script",instance:null,count:0,state:null},u.set(a,p)),p):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,s))}}function ql(s){return'href="'+dr(s)+'"'}function kc(s){return'link[rel="stylesheet"]['+s+"]"}function WC(s){return m({},s,{"data-precedence":s.precedence,precedence:null})}function QA(s,a,u,p){s.querySelector('link[rel="preload"][as="style"]['+a+"]")?p.loading=1:(a=s.createElement("link"),p.preload=a,a.addEventListener("load",function(){return p.loading|=1}),a.addEventListener("error",function(){return p.loading|=2}),un(a,"link",u),Wt(a),s.head.appendChild(a))}function Zl(s){return'[src="'+dr(s)+'"]'}function Ec(s){return"script[async]"+s}function JC(s,a,u){if(a.count++,a.instance===null)switch(a.type){case"style":var p=s.querySelector('style[data-href~="'+dr(u.href)+'"]');if(p)return a.instance=p,Wt(p),p;var v=m({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return p=(s.ownerDocument||s).createElement("style"),Wt(p),un(p,"style",v),Xd(p,u.precedence,s),a.instance=p;case"stylesheet":v=ql(u.href);var b=s.querySelector(kc(v));if(b)return a.state.loading|=4,a.instance=b,Wt(b),b;p=WC(u),(v=br.get(v))&&Rg(p,v),b=(s.ownerDocument||s).createElement("link"),Wt(b);var T=b;return T._p=new Promise(function(M,O){T.onload=M,T.onerror=O}),un(b,"link",p),a.state.loading|=4,Xd(b,u.precedence,s),a.instance=b;case"script":return b=Zl(u.src),(v=s.querySelector(Ec(b)))?(a.instance=v,Wt(v),v):(p=u,(v=br.get(b))&&(p=m({},u),Og(p,v)),s=s.ownerDocument||s,v=s.createElement("script"),Wt(v),un(v,"link",p),s.head.appendChild(v),a.instance=v);case"void":return null;default:throw Error(r(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(p=a.instance,a.state.loading|=4,Xd(p,u.precedence,s));return a.instance}function Xd(s,a,u){for(var p=u.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),v=p.length?p[p.length-1]:null,b=v,T=0;T title"):null)}function eN(s,a,u){if(u===1||a.itemProp!=null)return!1;switch(s){case"meta":case"title":return!0;case"style":if(typeof a.precedence!="string"||typeof a.href!="string"||a.href==="")break;return!0;case"link":if(typeof a.rel!="string"||typeof a.href!="string"||a.href===""||a.onLoad||a.onError)break;return a.rel==="stylesheet"?(s=a.disabled,typeof a.precedence=="string"&&s==null):!0;case"script":if(a.async&&typeof a.async!="function"&&typeof a.async!="symbol"&&!a.onLoad&&!a.onError&&a.src&&typeof a.src=="string")return!0}return!1}function e7(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function tN(s,a,u,p){if(u.type==="stylesheet"&&(typeof p.media!="string"||matchMedia(p.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var v=ql(p.href),b=a.querySelector(kc(v));if(b){a=b._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(s.count++,s=ef.bind(s),a.then(s,s)),u.state.loading|=4,u.instance=b,Wt(b);return}b=a.ownerDocument||a,p=WC(p),(v=br.get(v))&&Rg(p,v),b=b.createElement("link"),Wt(b);var T=b;T._p=new Promise(function(M,O){T.onload=M,T.onerror=O}),un(b,"link",p),u.instance=b}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(u,a),(a=u.state.preload)&&(u.state.loading&3)===0&&(s.count++,u=ef.bind(s),a.addEventListener("load",u),a.addEventListener("error",u))}}var Dg=0;function nN(s,a){return s.stylesheets&&s.count===0&&nf(s,s.stylesheets),0Dg?50:800)+a);return s.unsuspend=u,function(){s.unsuspend=null,clearTimeout(p),clearTimeout(v)}}:null}function ef(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)nf(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var tf=null;function nf(s,a){s.stylesheets=null,s.unsuspend!==null&&(s.count++,tf=new Map,a.forEach(rN,s),tf=null,ef.call(s))}function rN(s,a){if(!(a.state.loading&4)){var u=tf.get(s);if(u)var p=u.get(null);else{u=new Map,tf.set(s,u);for(var v=s.querySelectorAll("link[data-precedence],style[data-precedence]"),b=0;b"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Ug.exports=wN(),Ug.exports}var SN=xN(),Oa=r9();const TN=t9(Oa);var qg={exports:{}},Zg={};var T7;function kN(){if(T7)return Zg;T7=1;var t=Ou();function e(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,o=t.useLayoutEffect,l=t.useDebugValue;function c(m,g){var y=g(),C=r({inst:{value:y,getSnapshot:g}}),w=C[0].inst,x=C[1];return o(function(){w.value=y,w.getSnapshot=g,d(w)&&x({inst:w})},[m,y,g]),i(function(){return d(w)&&x({inst:w}),m(function(){d(w)&&x({inst:w})})},[m]),l(y),y}function d(m){var g=m.getSnapshot;m=m.value;try{var y=g();return!n(m,y)}catch{return!0}}function f(m,g){return g()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return Zg.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:h,Zg}var k7;function i9(){return k7||(k7=1,qg.exports=kN()),qg.exports}var o9=i9();function dn(t){this.content=t}dn.prototype={constructor:dn,find:function(t){for(var e=0;e>1}};dn.from=function(t){if(t instanceof dn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new dn(e)};function s9(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),o=e.child(r);if(i==o){n+=i.nodeSize;continue}if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){for(let l=0;i.text[l]==o.text[l];l++)n++;return n}if(i.content.size||o.content.size){let l=s9(i.content,o.content,n+1);if(l!=null)return l}n+=i.nodeSize}}function l9(t,e,n,r){for(let i=t.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:n,b:r};let l=t.child(--i),c=e.child(--o),d=l.nodeSize;if(l==c){n-=d,r-=d;continue}if(!l.sameMarkup(c))return{a:n,b:r};if(l.isText&&l.text!=c.text){let f=0,h=Math.min(l.text.length,c.text.length);for(;fe&&r(d,i+c,o||null,l)!==!1&&d.content.size){let h=c+1;d.nodesBetween(Math.max(0,e-h),Math.min(d.content.size,n-h),r,i+h)}c=f}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let o="",l=!0;return this.nodesBetween(e,n,(c,d)=>{let f=c.isText?c.text.slice(Math.max(e,d)-d,n-d):c.isLeaf?i?typeof i=="function"?i(c):i:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&f||c.isTextblock)&&r&&(l?l=!1:o+=r),o+=f},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),o=1);oe)for(let o=0,l=0;le&&((ln)&&(c.isText?c=c.cut(Math.max(0,e-l),Math.min(c.text.length,n-l)):c=c.cut(Math.max(0,e-l-1),Math.min(c.content.size,n-l-1))),r.push(c),i+=c.nodeSize),l=d}return new te(r,i)}cutByIndex(e,n){return e==n?te.empty:e==0&&n==this.content.length?this:new te(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new te(i,o)}addToStart(e){return new te([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new te(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),o=r+i.nodeSize;if(o>=e)return o==e?ff(n+1,o):ff(n,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return te.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new te(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return te.empty;let n,r=0;for(let i=0;ithis.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;nr.type.rank-i.type.rank),n}};ut.none=[];class oh extends Error{}class ce{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=c9(this.content,e+this.openStart,n);return r&&new ce(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ce(a9(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return ce.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ce(te.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)i++;return new ce(e,r,i)}}ce.empty=new ce(te.empty,0,0);function a9(t,e,n){let{index:r,offset:i}=t.findIndex(e),o=t.maybeChild(r),{index:l,offset:c}=t.findIndex(n);if(i==e||o.isText){if(c!=n&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(a9(o.content,e-i-1,n-i-1)))}function c9(t,e,n,r){let{index:i,offset:o}=t.findIndex(e),l=t.maybeChild(i);if(o==e||l.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=c9(l.content,e-o-1,n,l);return c&&t.replaceChild(i,l.copy(c))}function EN(t,e,n){if(n.openStart>t.depth)throw new oh("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new oh("Inconsistent open depths");return u9(t,e,n,0)}function u9(t,e,n,r){let i=t.index(r),o=t.node(r);if(i==e.index(r)&&r=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function $c(t,e,n,r){let i=(e||t).node(n),o=0,l=e?e.index(n):i.childCount;t&&(o=t.index(n),t.depth>n?o++:t.textOffset&&(Is(t.nodeAfter,r),o++));for(let c=o;ci&&t2(t,e,i+1),l=r.depth>i&&t2(n,r,i+1),c=[];return $c(null,t,i,c),o&&l&&e.index(i)==n.index(i)?(d9(o,l),Is(zs(o,f9(t,e,n,r,i+1)),c)):(o&&Is(zs(o,sh(t,e,i+1)),c),$c(e,n,i,c),l&&Is(zs(l,sh(n,r,i+1)),c)),$c(r,null,i,c),new te(c)}function sh(t,e,n){let r=[];if($c(null,t,n,r),t.depth>n){let i=t2(t,e,n+1);Is(zs(i,sh(t,e,n+1)),r)}return $c(e,null,n,r),new te(r)}function MN(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let o=n-1;o>=0;o--)i=e.node(o).copy(te.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class ou{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let o=0;o0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new su(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,o=n;for(let l=e;;){let{index:c,offset:d}=l.content.findIndex(o),f=o-d;if(r.push(l,c,i+d),!f||(l=l.child(c),l.isText))break;o=f-1,i+=d+1}return new ou(n,r,o)}static resolveCached(e,n){let r=E7.get(e);if(r)for(let o=0;oe&&this.nodesBetween(e,n,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),h9(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=te.empty,i=0,o=r.childCount){let l=this.contentMatchAt(e).matchFragment(r,i,o),c=l&&l.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let d=i;dn.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=te.fromJSON(e,n.content),o=e.nodeType(n.type).create(n.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};Gn.prototype.text=void 0;class lh extends Gn{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):h9(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new lh(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new lh(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function h9(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Fs{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new ON(e,n);if(r.next==null)return Fs.empty;let i=p9(r);r.next&&r.err("Unexpected trailing text");let o=BN(zN(i));return jN(o,r),o}matchType(e){for(let n=0;nf.createAndFill()));for(let f=0;f=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i{let o=i+(r.validEnd?"*":" ")+" ";for(let l=0;l"+e.indexOf(r.next[l].next);return o}).join(` +`+p.stack}}var Ot=Object.prototype.hasOwnProperty,zt=t.unstable_scheduleCallback,Hn=t.unstable_cancelCallback,ve=t.unstable_shouldYield,Re=t.unstable_requestPaint,fe=t.unstable_now,We=t.unstable_getCurrentPriorityLevel,lt=t.unstable_ImmediatePriority,wt=t.unstable_UserBlockingPriority,Jr=t.unstable_NormalPriority,al=t.unstable_LowPriority,ro=t.unstable_IdlePriority,In=t.log,mi=t.unstable_setDisableYieldValue,Xr=null,yn=null;function Dr(s){if(typeof In=="function"&&mi(s),yn&&typeof yn.setStrictMode=="function")try{yn.setStrictMode(Xr,s)}catch{}}var Yt=Math.clz32?Math.clz32:E1,Qr=Math.log,cl=Math.LN2;function E1(s){return s>>>=0,s===0?32:31-(Qr(s)/cl|0)|0}var ls=256,as=262144,Wu=4194304;function cs(s){var a=s&42;if(a!==0)return a;switch(s&-s){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return s&261888;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function Ju(s,a,u){var p=s.pendingLanes;if(p===0)return 0;var v=0,b=s.suspendedLanes,T=s.pingedLanes;s=s.warmLanes;var M=p&134217727;return M!==0?(p=M&~b,p!==0?v=cs(p):(T&=M,T!==0?v=cs(T):u||(u=M&~s,u!==0&&(v=cs(u))))):(M=p&~b,M!==0?v=cs(M):T!==0?v=cs(T):u||(u=p&~s,u!==0&&(v=cs(u)))),v===0?0:a!==0&&a!==v&&(a&b)===0&&(b=v&-v,u=a&-a,b>=u||b===32&&(u&4194048)!==0)?a:v}function Va(s,a){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&a)===0}function QE(s,a){switch(s){case 1:case 2:case 4:case 8:case 64:return a+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function vv(){var s=Wu;return Wu<<=1,(Wu&62914560)===0&&(Wu=4194304),s}function M1(s){for(var a=[],u=0;31>u;u++)a.push(s);return a}function Ua(s,a){s.pendingLanes|=a,a!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function eM(s,a,u,p,v,b){var T=s.pendingLanes;s.pendingLanes=u,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=u,s.entangledLanes&=u,s.errorRecoveryDisabledLanes&=u,s.shellSuspendCounter=0;var M=s.entanglements,O=s.expirationTimes,q=s.hiddenUpdates;for(u=T&~u;0"u")return null;try{return s.activeElement||s.body}catch{return s.body}}var sM=/[\n"\\]/g;function dr(s){return s.replace(sM,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function L1(s,a,u,p,v,b,T,M){s.name="",T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?s.type=T:s.removeAttribute("type"),a!=null?T==="number"?(a===0&&s.value===""||s.value!=a)&&(s.value=""+ur(a)):s.value!==""+ur(a)&&(s.value=""+ur(a)):T!=="submit"&&T!=="reset"||s.removeAttribute("value"),a!=null?_1(s,T,ur(a)):u!=null?_1(s,T,ur(u)):p!=null&&s.removeAttribute("value"),v==null&&b!=null&&(s.defaultChecked=!!b),v!=null&&(s.checked=v&&typeof v!="function"&&typeof v!="symbol"),M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"?s.name=""+ur(M):s.removeAttribute("name")}function Ov(s,a,u,p,v,b,T,M){if(b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(s.type=b),a!=null||u!=null){if(!(b!=="submit"&&b!=="reset"||a!=null)){D1(s);return}u=u!=null?""+ur(u):"",a=a!=null?""+ur(a):u,M||a===s.value||(s.value=a),s.defaultValue=a}p=p??v,p=typeof p!="function"&&typeof p!="symbol"&&!!p,s.checked=M?s.checked:!!p,s.defaultChecked=!!p,T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"&&(s.name=T),D1(s)}function _1(s,a,u){a==="number"&&ed(s.ownerDocument)===s||s.defaultValue===""+u||(s.defaultValue=""+u)}function ml(s,a,u,p){if(s=s.options,a){a={};for(var v=0;v"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),j1=!1;if(vi)try{var qa={};Object.defineProperty(qa,"passive",{get:function(){j1=!0}}),window.addEventListener("test",qa,qa),window.removeEventListener("test",qa,qa)}catch{j1=!1}var oo=null,V1=null,nd=null;function Bv(){if(nd)return nd;var s,a=V1,u=a.length,p,v="value"in oo?oo.value:oo.textContent,b=v.length;for(s=0;s=Ga),$v=" ",qv=!1;function Zv(s,a){switch(s){case"keyup":return _M.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Kv(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var bl=!1;function IM(s,a){switch(s){case"compositionend":return Kv(a);case"keypress":return a.which!==32?null:(qv=!0,$v);case"textInput":return s=a.data,s===$v&&qv?null:s;default:return null}}function zM(s,a){if(bl)return s==="compositionend"||!q1&&Zv(s,a)?(s=Bv(),nd=V1=oo=null,bl=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1=a)return{node:u,offset:a-s};s=p}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=tb(u)}}function rb(s,a){return s&&a?s===a?!0:s&&s.nodeType===3?!1:a&&a.nodeType===3?rb(s,a.parentNode):"contains"in s?s.contains(a):s.compareDocumentPosition?!!(s.compareDocumentPosition(a)&16):!1:!1}function ib(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var a=ed(s.document);a instanceof s.HTMLIFrameElement;){try{var u=typeof a.contentWindow.location.href=="string"}catch{u=!1}if(u)s=a.contentWindow;else break;a=ed(s.document)}return a}function G1(s){var a=s&&s.nodeName&&s.nodeName.toLowerCase();return a&&(a==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||a==="textarea"||s.contentEditable==="true")}var qM=vi&&"documentMode"in document&&11>=document.documentMode,Cl=null,Y1=null,Xa=null,W1=!1;function ob(s,a,u){var p=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;W1||Cl==null||Cl!==ed(p)||(p=Cl,"selectionStart"in p&&G1(p)?p={start:p.selectionStart,end:p.selectionEnd}:(p=(p.ownerDocument&&p.ownerDocument.defaultView||window).getSelection(),p={anchorNode:p.anchorNode,anchorOffset:p.anchorOffset,focusNode:p.focusNode,focusOffset:p.focusOffset}),Xa&&Ja(Xa,p)||(Xa=p,p=Yd(Y1,"onSelect"),0>=T,v-=T,ei=1<<32-Yt(a)+v|u<Ne?(ze=ge,ge=null):ze=ge.sibling;var qe=K(V,ge,F[Ne],Q);if(qe===null){ge===null&&(ge=ze);break}s&&ge&&qe.alternate===null&&a(V,ge),I=b(qe,I,Ne),$e===null?Ce=qe:$e.sibling=qe,$e=qe,ge=ze}if(Ne===F.length)return u(V,ge),je&&Ci(V,Ne),Ce;if(ge===null){for(;NeNe?(ze=ge,ge=null):ze=ge.sibling;var Ao=K(V,ge,qe.value,Q);if(Ao===null){ge===null&&(ge=ze);break}s&&ge&&Ao.alternate===null&&a(V,ge),I=b(Ao,I,Ne),$e===null?Ce=Ao:$e.sibling=Ao,$e=Ao,ge=ze}if(qe.done)return u(V,ge),je&&Ci(V,Ne),Ce;if(ge===null){for(;!qe.done;Ne++,qe=F.next())qe=ee(V,qe.value,Q),qe!==null&&(I=b(qe,I,Ne),$e===null?Ce=qe:$e.sibling=qe,$e=qe);return je&&Ci(V,Ne),Ce}for(ge=p(ge);!qe.done;Ne++,qe=F.next())qe=Y(ge,V,Ne,qe.value,Q),qe!==null&&(s&&qe.alternate!==null&&ge.delete(qe.key===null?Ne:qe.key),I=b(qe,I,Ne),$e===null?Ce=qe:$e.sibling=qe,$e=qe);return s&&ge.forEach(function(dN){return a(V,dN)}),je&&Ci(V,Ne),Ce}function ot(V,I,F,Q){if(typeof F=="object"&&F!==null&&F.type===w&&F.key===null&&(F=F.props.children),typeof F=="object"&&F!==null){switch(F.$$typeof){case y:e:{for(var Ce=F.key;I!==null;){if(I.key===Ce){if(Ce=F.type,Ce===w){if(I.tag===7){u(V,I.sibling),Q=v(I,F.props.children),Q.return=V,V=Q;break e}}else if(I.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===$&&Cs(Ce)===I.type){u(V,I.sibling),Q=v(I,F.props),ic(Q,F),Q.return=V,V=Q;break e}u(V,I);break}else a(V,I);I=I.sibling}F.type===w?(Q=ms(F.props.children,V.mode,Q,F.key),Q.return=V,V=Q):(Q=fd(F.type,F.key,F.props,null,V.mode,Q),ic(Q,F),Q.return=V,V=Q)}return T(V);case C:e:{for(Ce=F.key;I!==null;){if(I.key===Ce)if(I.tag===4&&I.stateNode.containerInfo===F.containerInfo&&I.stateNode.implementation===F.implementation){u(V,I.sibling),Q=v(I,F.children||[]),Q.return=V,V=Q;break e}else{u(V,I);break}else a(V,I);I=I.sibling}Q=rm(F,V.mode,Q),Q.return=V,V=Q}return T(V);case $:return F=Cs(F),ot(V,I,F,Q)}if(P(F))return he(V,I,F,Q);if(se(F)){if(Ce=se(F),typeof Ce!="function")throw Error(r(150));return F=Ce.call(F),xe(V,I,F,Q)}if(typeof F.then=="function")return ot(V,I,bd(F),Q);if(F.$$typeof===N)return ot(V,I,md(V,F),Q);Cd(V,F)}return typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint"?(F=""+F,I!==null&&I.tag===6?(u(V,I.sibling),Q=v(I,F),Q.return=V,V=Q):(u(V,I),Q=nm(F,V.mode,Q),Q.return=V,V=Q),T(V)):u(V,I)}return function(V,I,F,Q){try{rc=0;var Ce=ot(V,I,F,Q);return Ol=null,Ce}catch(ge){if(ge===Rl||ge===yd)throw ge;var $e=er(29,ge,null,V.mode);return $e.lanes=Q,$e.return=V,$e}}}var xs=Ab(!0),Nb=Ab(!1),uo=!1;function mm(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function gm(s,a){s=s.updateQueue,a.updateQueue===s&&(a.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,callbacks:null})}function fo(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function ho(s,a,u){var p=s.updateQueue;if(p===null)return null;if(p=p.shared,(Ge&2)!==0){var v=p.pending;return v===null?a.next=a:(a.next=v.next,v.next=a),p.pending=a,a=dd(s),fb(s,null,u),a}return ud(s,p,a,u),dd(s)}function oc(s,a,u){if(a=a.updateQueue,a!==null&&(a=a.shared,(u&4194048)!==0)){var p=a.lanes;p&=s.pendingLanes,u|=p,a.lanes=u,Cv(s,u)}}function ym(s,a){var u=s.updateQueue,p=s.alternate;if(p!==null&&(p=p.updateQueue,u===p)){var v=null,b=null;if(u=u.firstBaseUpdate,u!==null){do{var T={lane:u.lane,tag:u.tag,payload:u.payload,callback:null,next:null};b===null?v=b=T:b=b.next=T,u=u.next}while(u!==null);b===null?v=b=a:b=b.next=a}else v=b=a;u={baseState:p.baseState,firstBaseUpdate:v,lastBaseUpdate:b,shared:p.shared,callbacks:p.callbacks},s.updateQueue=u;return}s=u.lastBaseUpdate,s===null?u.firstBaseUpdate=a:s.next=a,u.lastBaseUpdate=a}var vm=!1;function sc(){if(vm){var s=Nl;if(s!==null)throw s}}function lc(s,a,u,p){vm=!1;var v=s.updateQueue;uo=!1;var b=v.firstBaseUpdate,T=v.lastBaseUpdate,M=v.shared.pending;if(M!==null){v.shared.pending=null;var O=M,q=O.next;O.next=null,T===null?b=q:T.next=q,T=O;var X=s.alternate;X!==null&&(X=X.updateQueue,M=X.lastBaseUpdate,M!==T&&(M===null?X.firstBaseUpdate=q:M.next=q,X.lastBaseUpdate=O))}if(b!==null){var ee=v.baseState;T=0,X=q=O=null,M=b;do{var K=M.lane&-536870913,Y=K!==M.lane;if(Y?(Ie&K)===K:(p&K)===K){K!==0&&K===Al&&(vm=!0),X!==null&&(X=X.next={lane:0,tag:M.tag,payload:M.payload,callback:null,next:null});e:{var he=s,xe=M;K=a;var ot=u;switch(xe.tag){case 1:if(he=xe.payload,typeof he=="function"){ee=he.call(ot,ee,K);break e}ee=he;break e;case 3:he.flags=he.flags&-65537|128;case 0:if(he=xe.payload,K=typeof he=="function"?he.call(ot,ee,K):he,K==null)break e;ee=m({},ee,K);break e;case 2:uo=!0}}K=M.callback,K!==null&&(s.flags|=64,Y&&(s.flags|=8192),Y=v.callbacks,Y===null?v.callbacks=[K]:Y.push(K))}else Y={lane:K,tag:M.tag,payload:M.payload,callback:M.callback,next:null},X===null?(q=X=Y,O=ee):X=X.next=Y,T|=K;if(M=M.next,M===null){if(M=v.shared.pending,M===null)break;Y=M,M=Y.next,Y.next=null,v.lastBaseUpdate=Y,v.shared.pending=null}}while(!0);X===null&&(O=ee),v.baseState=O,v.firstBaseUpdate=q,v.lastBaseUpdate=X,b===null&&(v.shared.lanes=0),vo|=T,s.lanes=T,s.memoizedState=ee}}function Rb(s,a){if(typeof s!="function")throw Error(r(191,s));s.call(a)}function Ob(s,a){var u=s.callbacks;if(u!==null)for(s.callbacks=null,s=0;sb?b:8;var T=H.T,M={};H.T=M,zm(s,!1,a,u);try{var O=v(),q=H.S;if(q!==null&&q(M,O),O!==null&&typeof O=="object"&&typeof O.then=="function"){var X=eA(O,p);uc(s,a,X,or(s))}else uc(s,a,p,or(s))}catch(ee){uc(s,a,{then:function(){},status:"rejected",reason:ee},or())}finally{j.p=b,T!==null&&M.types!==null&&(T.types=M.types),H.T=T}}function sA(){}function Hm(s,a,u,p){if(s.tag!==5)throw Error(r(476));var v=c4(s).queue;a4(s,v,a,B,u===null?sA:function(){return u4(s),u(p)})}function c4(s){var a=s.memoizedState;if(a!==null)return a;a={memoizedState:B,baseState:B,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ti,lastRenderedState:B},next:null};var u={};return a.next={memoizedState:u,baseState:u,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ti,lastRenderedState:u},next:null},s.memoizedState=a,s=s.alternate,s!==null&&(s.memoizedState=a),a}function u4(s){var a=c4(s);a.next===null&&(a=s.alternate.memoizedState),uc(s,a.next.queue,{},or())}function Im(){return an(Mc)}function d4(){return Lt().memoizedState}function f4(){return Lt().memoizedState}function lA(s){for(var a=s.return;a!==null;){switch(a.tag){case 24:case 3:var u=or();s=fo(u);var p=ho(a,s,u);p!==null&&(Fn(p,a,u),oc(p,a,u)),a={cache:dm()},s.payload=a;return}a=a.return}}function aA(s,a,u){var p=or();u={lane:p,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Rd(s)?p4(a,u):(u=em(s,a,u,p),u!==null&&(Fn(u,s,p),m4(u,a,p)))}function h4(s,a,u){var p=or();uc(s,a,u,p)}function uc(s,a,u,p){var v={lane:p,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null};if(Rd(s))p4(a,v);else{var b=s.alternate;if(s.lanes===0&&(b===null||b.lanes===0)&&(b=a.lastRenderedReducer,b!==null))try{var T=a.lastRenderedState,M=b(T,u);if(v.hasEagerState=!0,v.eagerState=M,Qn(M,T))return ud(s,a,v,0),at===null&&cd(),!1}catch{}if(u=em(s,a,v,p),u!==null)return Fn(u,s,p),m4(u,a,p),!0}return!1}function zm(s,a,u,p){if(p={lane:2,revertLane:mg(),gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},Rd(s)){if(a)throw Error(r(479))}else a=em(s,u,p,2),a!==null&&Fn(a,s,2)}function Rd(s){var a=s.alternate;return s===Ae||a!==null&&a===Ae}function p4(s,a){Ll=Sd=!0;var u=s.pending;u===null?a.next=a:(a.next=u.next,u.next=a),s.pending=a}function m4(s,a,u){if((u&4194048)!==0){var p=a.lanes;p&=s.pendingLanes,u|=p,a.lanes=u,Cv(s,u)}}var dc={readContext:an,use:Ed,useCallback:St,useContext:St,useEffect:St,useImperativeHandle:St,useLayoutEffect:St,useInsertionEffect:St,useMemo:St,useReducer:St,useRef:St,useState:St,useDebugValue:St,useDeferredValue:St,useTransition:St,useSyncExternalStore:St,useId:St,useHostTransitionStatus:St,useFormState:St,useActionState:St,useOptimistic:St,useMemoCache:St,useCacheRefresh:St};dc.useEffectEvent=St;var g4={readContext:an,use:Ed,useCallback:function(s,a){return Rn().memoizedState=[s,a===void 0?null:a],s},useContext:an,useEffect:Qb,useImperativeHandle:function(s,a,u){u=u!=null?u.concat([s]):null,Ad(4194308,4,r4.bind(null,a,s),u)},useLayoutEffect:function(s,a){return Ad(4194308,4,s,a)},useInsertionEffect:function(s,a){Ad(4,2,s,a)},useMemo:function(s,a){var u=Rn();a=a===void 0?null:a;var p=s();if(Ss){Dr(!0);try{s()}finally{Dr(!1)}}return u.memoizedState=[p,a],p},useReducer:function(s,a,u){var p=Rn();if(u!==void 0){var v=u(a);if(Ss){Dr(!0);try{u(a)}finally{Dr(!1)}}}else v=a;return p.memoizedState=p.baseState=v,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:v},p.queue=s,s=s.dispatch=aA.bind(null,Ae,s),[p.memoizedState,s]},useRef:function(s){var a=Rn();return s={current:s},a.memoizedState=s},useState:function(s){s=Rm(s);var a=s.queue,u=h4.bind(null,Ae,a);return a.dispatch=u,[s.memoizedState,u]},useDebugValue:Lm,useDeferredValue:function(s,a){var u=Rn();return _m(u,s,a)},useTransition:function(){var s=Rm(!1);return s=a4.bind(null,Ae,s.queue,!0,!1),Rn().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,a,u){var p=Ae,v=Rn();if(je){if(u===void 0)throw Error(r(407));u=u()}else{if(u=a(),at===null)throw Error(r(349));(Ie&127)!==0||zb(p,a,u)}v.memoizedState=u;var b={value:u,getSnapshot:a};return v.queue=b,Qb(jb.bind(null,p,b,s),[s]),p.flags|=2048,Hl(9,{destroy:void 0},Bb.bind(null,p,b,u,a),null),u},useId:function(){var s=Rn(),a=at.identifierPrefix;if(je){var u=ti,p=ei;u=(p&~(1<<32-Yt(p)-1)).toString(32)+u,a="_"+a+"R_"+u,u=Td++,0<\/script>",b=b.removeChild(b.firstChild);break;case"select":b=typeof p.is=="string"?T.createElement("select",{is:p.is}):T.createElement("select"),p.multiple?b.multiple=!0:p.size&&(b.size=p.size);break;default:b=typeof p.is=="string"?T.createElement(v,{is:p.is}):T.createElement(v)}}b[sn]=a,b[zn]=p;e:for(T=a.child;T!==null;){if(T.tag===5||T.tag===6)b.appendChild(T.stateNode);else if(T.tag!==4&&T.tag!==27&&T.child!==null){T.child.return=T,T=T.child;continue}if(T===a)break e;for(;T.sibling===null;){if(T.return===null||T.return===a)break e;T=T.return}T.sibling.return=T.return,T=T.sibling}a.stateNode=b;e:switch(un(b,v,p),v){case"button":case"input":case"select":case"textarea":p=!!p.autoFocus;break e;case"img":p=!0;break e;default:p=!1}p&&Ei(a)}}return mt(a),Jm(a,a.type,s===null?null:s.memoizedProps,a.pendingProps,u),null;case 6:if(s&&a.stateNode!=null)s.memoizedProps!==p&&Ei(a);else{if(typeof p!="string"&&a.stateNode===null)throw Error(r(166));if(s=ye.current,El(a)){if(s=a.stateNode,u=a.memoizedProps,p=null,v=ln,v!==null)switch(v.tag){case 27:case 5:p=v.memoizedProps}s[sn]=a,s=!!(s.nodeValue===u||p!==null&&p.suppressHydrationWarning===!0||HC(s.nodeValue,u)),s||ao(a,!0)}else s=Wd(s).createTextNode(p),s[sn]=a,a.stateNode=s}return mt(a),null;case 31:if(u=a.memoizedState,s===null||s.memoizedState!==null){if(p=El(a),u!==null){if(s===null){if(!p)throw Error(r(318));if(s=a.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(r(557));s[sn]=a}else gs(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;mt(a),s=!1}else u=lm(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=u),s=!0;if(!s)return a.flags&256?(nr(a),a):(nr(a),null);if((a.flags&128)!==0)throw Error(r(558))}return mt(a),null;case 13:if(p=a.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(v=El(a),p!==null&&p.dehydrated!==null){if(s===null){if(!v)throw Error(r(318));if(v=a.memoizedState,v=v!==null?v.dehydrated:null,!v)throw Error(r(317));v[sn]=a}else gs(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;mt(a),v=!1}else v=lm(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=v),v=!0;if(!v)return a.flags&256?(nr(a),a):(nr(a),null)}return nr(a),(a.flags&128)!==0?(a.lanes=u,a):(u=p!==null,s=s!==null&&s.memoizedState!==null,u&&(p=a.child,v=null,p.alternate!==null&&p.alternate.memoizedState!==null&&p.alternate.memoizedState.cachePool!==null&&(v=p.alternate.memoizedState.cachePool.pool),b=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(b=p.memoizedState.cachePool.pool),b!==v&&(p.flags|=2048)),u!==s&&u&&(a.child.flags|=8192),Hd(a,a.updateQueue),mt(a),null);case 4:return tt(),s===null&&bg(a.stateNode.containerInfo),mt(a),null;case 10:return xi(a.type),mt(a),null;case 19:if(Z(Dt),p=a.memoizedState,p===null)return mt(a),null;if(v=(a.flags&128)!==0,b=p.rendering,b===null)if(v)hc(p,!1);else{if(Tt!==0||s!==null&&(s.flags&128)!==0)for(s=a.child;s!==null;){if(b=xd(s),b!==null){for(a.flags|=128,hc(p,!1),s=b.updateQueue,a.updateQueue=s,Hd(a,s),a.subtreeFlags=0,s=u,u=a.child;u!==null;)hb(u,s),u=u.sibling;return W(Dt,Dt.current&1|2),je&&Ci(a,p.treeForkCount),a.child}s=s.sibling}p.tail!==null&&fe()>Vd&&(a.flags|=128,v=!0,hc(p,!1),a.lanes=4194304)}else{if(!v)if(s=xd(b),s!==null){if(a.flags|=128,v=!0,s=s.updateQueue,a.updateQueue=s,Hd(a,s),hc(p,!0),p.tail===null&&p.tailMode==="hidden"&&!b.alternate&&!je)return mt(a),null}else 2*fe()-p.renderingStartTime>Vd&&u!==536870912&&(a.flags|=128,v=!0,hc(p,!1),a.lanes=4194304);p.isBackwards?(b.sibling=a.child,a.child=b):(s=p.last,s!==null?s.sibling=b:a.child=b,p.last=b)}return p.tail!==null?(s=p.tail,p.rendering=s,p.tail=s.sibling,p.renderingStartTime=fe(),s.sibling=null,u=Dt.current,W(Dt,v?u&1|2:u&1),je&&Ci(a,p.treeForkCount),s):(mt(a),null);case 22:case 23:return nr(a),Cm(),p=a.memoizedState!==null,s!==null?s.memoizedState!==null!==p&&(a.flags|=8192):p&&(a.flags|=8192),p?(u&536870912)!==0&&(a.flags&128)===0&&(mt(a),a.subtreeFlags&6&&(a.flags|=8192)):mt(a),u=a.updateQueue,u!==null&&Hd(a,u.retryQueue),u=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(u=s.memoizedState.cachePool.pool),p=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(p=a.memoizedState.cachePool.pool),p!==u&&(a.flags|=2048),s!==null&&Z(bs),null;case 24:return u=null,s!==null&&(u=s.memoizedState.cache),a.memoizedState.cache!==u&&(a.flags|=2048),xi(Bt),mt(a),null;case 25:return null;case 30:return null}throw Error(r(156,a.tag))}function hA(s,a){switch(om(a),a.tag){case 1:return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 3:return xi(Bt),tt(),s=a.flags,(s&65536)!==0&&(s&128)===0?(a.flags=s&-65537|128,a):null;case 26:case 27:case 5:return Or(a),null;case 31:if(a.memoizedState!==null){if(nr(a),a.alternate===null)throw Error(r(340));gs()}return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 13:if(nr(a),s=a.memoizedState,s!==null&&s.dehydrated!==null){if(a.alternate===null)throw Error(r(340));gs()}return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 19:return Z(Dt),null;case 4:return tt(),null;case 10:return xi(a.type),null;case 22:case 23:return nr(a),Cm(),s!==null&&Z(bs),s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 24:return xi(Bt),null;case 25:return null;default:return null}}function V4(s,a){switch(om(a),a.tag){case 3:xi(Bt),tt();break;case 26:case 27:case 5:Or(a);break;case 4:tt();break;case 31:a.memoizedState!==null&&nr(a);break;case 13:nr(a);break;case 19:Z(Dt);break;case 10:xi(a.type);break;case 22:case 23:nr(a),Cm(),s!==null&&Z(bs);break;case 24:xi(Bt)}}function pc(s,a){try{var u=a.updateQueue,p=u!==null?u.lastEffect:null;if(p!==null){var v=p.next;u=v;do{if((u.tag&s)===s){p=void 0;var b=u.create,T=u.inst;p=b(),T.destroy=p}u=u.next}while(u!==v)}}catch(M){Xe(a,a.return,M)}}function go(s,a,u){try{var p=a.updateQueue,v=p!==null?p.lastEffect:null;if(v!==null){var b=v.next;p=b;do{if((p.tag&s)===s){var T=p.inst,M=T.destroy;if(M!==void 0){T.destroy=void 0,v=a;var O=u,q=M;try{q()}catch(X){Xe(v,O,X)}}}p=p.next}while(p!==b)}}catch(X){Xe(a,a.return,X)}}function U4(s){var a=s.updateQueue;if(a!==null){var u=s.stateNode;try{Ob(a,u)}catch(p){Xe(s,s.return,p)}}}function P4(s,a,u){u.props=Ts(s.type,s.memoizedProps),u.state=s.memoizedState;try{u.componentWillUnmount()}catch(p){Xe(s,a,p)}}function mc(s,a){try{var u=s.ref;if(u!==null){switch(s.tag){case 26:case 27:case 5:var p=s.stateNode;break;case 30:p=s.stateNode;break;default:p=s.stateNode}typeof u=="function"?s.refCleanup=u(p):u.current=p}}catch(v){Xe(s,a,v)}}function ni(s,a){var u=s.ref,p=s.refCleanup;if(u!==null)if(typeof p=="function")try{p()}catch(v){Xe(s,a,v)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof u=="function")try{u(null)}catch(v){Xe(s,a,v)}else u.current=null}function F4(s){var a=s.type,u=s.memoizedProps,p=s.stateNode;try{e:switch(a){case"button":case"input":case"select":case"textarea":u.autoFocus&&p.focus();break e;case"img":u.src?p.src=u.src:u.srcSet&&(p.srcset=u.srcSet)}}catch(v){Xe(s,s.return,v)}}function Xm(s,a,u){try{var p=s.stateNode;HA(p,s.type,u,a),p[zn]=a}catch(v){Xe(s,s.return,v)}}function $4(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&So(s.type)||s.tag===4}function Qm(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||$4(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.tag===27&&So(s.type)||s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function eg(s,a,u){var p=s.tag;if(p===5||p===6)s=s.stateNode,a?(u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u).insertBefore(s,a):(a=u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u,a.appendChild(s),u=u._reactRootContainer,u!=null||a.onclick!==null||(a.onclick=yi));else if(p!==4&&(p===27&&So(s.type)&&(u=s.stateNode,a=null),s=s.child,s!==null))for(eg(s,a,u),s=s.sibling;s!==null;)eg(s,a,u),s=s.sibling}function Id(s,a,u){var p=s.tag;if(p===5||p===6)s=s.stateNode,a?u.insertBefore(s,a):u.appendChild(s);else if(p!==4&&(p===27&&So(s.type)&&(u=s.stateNode),s=s.child,s!==null))for(Id(s,a,u),s=s.sibling;s!==null;)Id(s,a,u),s=s.sibling}function q4(s){var a=s.stateNode,u=s.memoizedProps;try{for(var p=s.type,v=a.attributes;v.length;)a.removeAttributeNode(v[0]);un(a,p,u),a[sn]=s,a[zn]=u}catch(b){Xe(s,s.return,b)}}var Mi=!1,Ut=!1,tg=!1,Z4=typeof WeakSet=="function"?WeakSet:Set,Jt=null;function pA(s,a){if(s=s.containerInfo,xg=rf,s=ib(s),G1(s)){if("selectionStart"in s)var u={start:s.selectionStart,end:s.selectionEnd};else e:{u=(u=s.ownerDocument)&&u.defaultView||window;var p=u.getSelection&&u.getSelection();if(p&&p.rangeCount!==0){u=p.anchorNode;var v=p.anchorOffset,b=p.focusNode;p=p.focusOffset;try{u.nodeType,b.nodeType}catch{u=null;break e}var T=0,M=-1,O=-1,q=0,X=0,ee=s,K=null;t:for(;;){for(var Y;ee!==u||v!==0&&ee.nodeType!==3||(M=T+v),ee!==b||p!==0&&ee.nodeType!==3||(O=T+p),ee.nodeType===3&&(T+=ee.nodeValue.length),(Y=ee.firstChild)!==null;)K=ee,ee=Y;for(;;){if(ee===s)break t;if(K===u&&++q===v&&(M=T),K===b&&++X===p&&(O=T),(Y=ee.nextSibling)!==null)break;ee=K,K=ee.parentNode}ee=Y}u=M===-1||O===-1?null:{start:M,end:O}}else u=null}u=u||{start:0,end:0}}else u=null;for(Sg={focusedElem:s,selectionRange:u},rf=!1,Jt=a;Jt!==null;)if(a=Jt,s=a.child,(a.subtreeFlags&1028)!==0&&s!==null)s.return=a,Jt=s;else for(;Jt!==null;){switch(a=Jt,b=a.alternate,s=a.flags,a.tag){case 0:if((s&4)!==0&&(s=a.updateQueue,s=s!==null?s.events:null,s!==null))for(u=0;u title"))),un(b,p,u),b[sn]=s,Wt(b),p=b;break e;case"link":var T=XC("link","href",v).get(p+(u.href||""));if(T){for(var M=0;Mot&&(T=ot,ot=xe,xe=T);var V=nb(M,xe),I=nb(M,ot);if(V&&I&&(Y.rangeCount!==1||Y.anchorNode!==V.node||Y.anchorOffset!==V.offset||Y.focusNode!==I.node||Y.focusOffset!==I.offset)){var F=ee.createRange();F.setStart(V.node,V.offset),Y.removeAllRanges(),xe>ot?(Y.addRange(F),Y.extend(I.node,I.offset)):(F.setEnd(I.node,I.offset),Y.addRange(F))}}}}for(ee=[],Y=M;Y=Y.parentNode;)Y.nodeType===1&&ee.push({element:Y,left:Y.scrollLeft,top:Y.scrollTop});for(typeof M.focus=="function"&&M.focus(),M=0;Mu?32:u,H.T=null,u=ag,ag=null;var b=Co,T=Di;if(Kt=0,Vl=Co=null,Di=0,(Ge&6)!==0)throw Error(r(331));var M=Ge;if(Ge|=4,rC(b.current),eC(b,b.current,T,u),Ge=M,wc(0,!1),yn&&typeof yn.onPostCommitFiberRoot=="function")try{yn.onPostCommitFiberRoot(Xr,b)}catch{}return!0}finally{j.p=v,H.T=p,wC(s,a)}}function SC(s,a,u){a=hr(u,a),a=Um(s.stateNode,a,2),s=ho(s,a,2),s!==null&&(Ua(s,2),ri(s))}function Xe(s,a,u){if(s.tag===3)SC(s,s,u);else for(;a!==null;){if(a.tag===3){SC(a,s,u);break}else if(a.tag===1){var p=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof p.componentDidCatch=="function"&&(bo===null||!bo.has(p))){s=hr(u,s),u=T4(2),p=ho(a,u,2),p!==null&&(k4(u,p,a,s),Ua(p,2),ri(p));break}}a=a.return}}function fg(s,a,u){var p=s.pingCache;if(p===null){p=s.pingCache=new yA;var v=new Set;p.set(a,v)}else v=p.get(a),v===void 0&&(v=new Set,p.set(a,v));v.has(u)||(ig=!0,v.add(u),s=xA.bind(null,s,a,u),a.then(s,s))}function xA(s,a,u){var p=s.pingCache;p!==null&&p.delete(a),s.pingedLanes|=s.suspendedLanes&u,s.warmLanes&=~u,at===s&&(Ie&u)===u&&(Tt===4||Tt===3&&(Ie&62914560)===Ie&&300>fe()-jd?(Ge&2)===0&&Ul(s,0):og|=u,jl===Ie&&(jl=0)),ri(s)}function TC(s,a){a===0&&(a=vv()),s=ps(s,a),s!==null&&(Ua(s,a),ri(s))}function SA(s){var a=s.memoizedState,u=0;a!==null&&(u=a.retryLane),TC(s,u)}function TA(s,a){var u=0;switch(s.tag){case 31:case 13:var p=s.stateNode,v=s.memoizedState;v!==null&&(u=v.retryLane);break;case 19:p=s.stateNode;break;case 22:p=s.stateNode._retryCache;break;default:throw Error(r(314))}p!==null&&p.delete(a),TC(s,u)}function kA(s,a){return zt(s,a)}var Zd=null,Fl=null,hg=!1,Kd=!1,pg=!1,xo=0;function ri(s){s!==Fl&&s.next===null&&(Fl===null?Zd=Fl=s:Fl=Fl.next=s),Kd=!0,hg||(hg=!0,MA())}function wc(s,a){if(!pg&&Kd){pg=!0;do for(var u=!1,p=Zd;p!==null;){if(s!==0){var v=p.pendingLanes;if(v===0)var b=0;else{var T=p.suspendedLanes,M=p.pingedLanes;b=(1<<31-Yt(42|s)+1)-1,b&=v&~(T&~M),b=b&201326741?b&201326741|1:b?b|2:0}b!==0&&(u=!0,AC(p,b))}else b=Ie,b=Ju(p,p===at?b:0,p.cancelPendingCommit!==null||p.timeoutHandle!==-1),(b&3)===0||Va(p,b)||(u=!0,AC(p,b));p=p.next}while(u);pg=!1}}function EA(){kC()}function kC(){Kd=hg=!1;var s=0;xo!==0&&zA()&&(s=xo);for(var a=fe(),u=null,p=Zd;p!==null;){var v=p.next,b=EC(p,a);b===0?(p.next=null,u===null?Zd=v:u.next=v,v===null&&(Fl=u)):(u=p,(s!==0||(b&3)!==0)&&(Kd=!0)),p=v}Kt!==0&&Kt!==5||wc(s),xo!==0&&(xo=0)}function EC(s,a){for(var u=s.suspendedLanes,p=s.pingedLanes,v=s.expirationTimes,b=s.pendingLanes&-62914561;0M)break;var X=O.transferSize,ee=O.initiatorType;X&&IC(ee)&&(O=O.responseEnd,T+=X*(O"u"?null:document;function GC(s,a,u){var p=$l;if(p&&typeof a=="string"&&a){var v=dr(a);v='link[rel="'+s+'"][href="'+v+'"]',typeof u=="string"&&(v+='[crossorigin="'+u+'"]'),KC.has(v)||(KC.add(v),s={rel:s,crossOrigin:u,href:a},p.querySelector(v)===null&&(a=p.createElement("link"),un(a,"link",s),Wt(a),p.head.appendChild(a)))}}function ZA(s){Li.D(s),GC("dns-prefetch",s,null)}function KA(s,a){Li.C(s,a),GC("preconnect",s,a)}function GA(s,a,u){Li.L(s,a,u);var p=$l;if(p&&s&&a){var v='link[rel="preload"][as="'+dr(a)+'"]';a==="image"&&u&&u.imageSrcSet?(v+='[imagesrcset="'+dr(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(v+='[imagesizes="'+dr(u.imageSizes)+'"]')):v+='[href="'+dr(s)+'"]';var b=v;switch(a){case"style":b=ql(s);break;case"script":b=Zl(s)}br.has(b)||(s=m({rel:"preload",href:a==="image"&&u&&u.imageSrcSet?void 0:s,as:a},u),br.set(b,s),p.querySelector(v)!==null||a==="style"&&p.querySelector(kc(b))||a==="script"&&p.querySelector(Ec(b))||(a=p.createElement("link"),un(a,"link",s),Wt(a),p.head.appendChild(a)))}}function YA(s,a){Li.m(s,a);var u=$l;if(u&&s){var p=a&&typeof a.as=="string"?a.as:"script",v='link[rel="modulepreload"][as="'+dr(p)+'"][href="'+dr(s)+'"]',b=v;switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":b=Zl(s)}if(!br.has(b)&&(s=m({rel:"modulepreload",href:s},a),br.set(b,s),u.querySelector(v)===null)){switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector(Ec(b)))return}p=u.createElement("link"),un(p,"link",s),Wt(p),u.head.appendChild(p)}}}function WA(s,a,u){Li.S(s,a,u);var p=$l;if(p&&s){var v=hl(p).hoistableStyles,b=ql(s);a=a||"default";var T=v.get(b);if(!T){var M={loading:0,preload:null};if(T=p.querySelector(kc(b)))M.loading=5;else{s=m({rel:"stylesheet",href:s,"data-precedence":a},u),(u=br.get(b))&&Rg(s,u);var O=T=p.createElement("link");Wt(O),un(O,"link",s),O._p=new Promise(function(q,X){O.onload=q,O.onerror=X}),O.addEventListener("load",function(){M.loading|=1}),O.addEventListener("error",function(){M.loading|=2}),M.loading|=4,Xd(T,a,p)}T={type:"stylesheet",instance:T,count:1,state:M},v.set(b,T)}}}function JA(s,a){Li.X(s,a);var u=$l;if(u&&s){var p=hl(u).hoistableScripts,v=Zl(s),b=p.get(v);b||(b=u.querySelector(Ec(v)),b||(s=m({src:s,async:!0},a),(a=br.get(v))&&Og(s,a),b=u.createElement("script"),Wt(b),un(b,"link",s),u.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},p.set(v,b))}}function XA(s,a){Li.M(s,a);var u=$l;if(u&&s){var p=hl(u).hoistableScripts,v=Zl(s),b=p.get(v);b||(b=u.querySelector(Ec(v)),b||(s=m({src:s,async:!0,type:"module"},a),(a=br.get(v))&&Og(s,a),b=u.createElement("script"),Wt(b),un(b,"link",s),u.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},p.set(v,b))}}function YC(s,a,u,p){var v=(v=ye.current)?Jd(v):null;if(!v)throw Error(r(446));switch(s){case"meta":case"title":return null;case"style":return typeof u.precedence=="string"&&typeof u.href=="string"?(a=ql(u.href),u=hl(v).hoistableStyles,p=u.get(a),p||(p={type:"style",instance:null,count:0,state:null},u.set(a,p)),p):{type:"void",instance:null,count:0,state:null};case"link":if(u.rel==="stylesheet"&&typeof u.href=="string"&&typeof u.precedence=="string"){s=ql(u.href);var b=hl(v).hoistableStyles,T=b.get(s);if(T||(v=v.ownerDocument||v,T={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},b.set(s,T),(b=v.querySelector(kc(s)))&&!b._p&&(T.instance=b,T.state.loading=5),br.has(s)||(u={rel:"preload",as:"style",href:u.href,crossOrigin:u.crossOrigin,integrity:u.integrity,media:u.media,hrefLang:u.hrefLang,referrerPolicy:u.referrerPolicy},br.set(s,u),b||QA(v,s,u,T.state))),a&&p===null)throw Error(r(528,""));return T}if(a&&p!==null)throw Error(r(529,""));return null;case"script":return a=u.async,u=u.src,typeof u=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=Zl(u),u=hl(v).hoistableScripts,p=u.get(a),p||(p={type:"script",instance:null,count:0,state:null},u.set(a,p)),p):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,s))}}function ql(s){return'href="'+dr(s)+'"'}function kc(s){return'link[rel="stylesheet"]['+s+"]"}function WC(s){return m({},s,{"data-precedence":s.precedence,precedence:null})}function QA(s,a,u,p){s.querySelector('link[rel="preload"][as="style"]['+a+"]")?p.loading=1:(a=s.createElement("link"),p.preload=a,a.addEventListener("load",function(){return p.loading|=1}),a.addEventListener("error",function(){return p.loading|=2}),un(a,"link",u),Wt(a),s.head.appendChild(a))}function Zl(s){return'[src="'+dr(s)+'"]'}function Ec(s){return"script[async]"+s}function JC(s,a,u){if(a.count++,a.instance===null)switch(a.type){case"style":var p=s.querySelector('style[data-href~="'+dr(u.href)+'"]');if(p)return a.instance=p,Wt(p),p;var v=m({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return p=(s.ownerDocument||s).createElement("style"),Wt(p),un(p,"style",v),Xd(p,u.precedence,s),a.instance=p;case"stylesheet":v=ql(u.href);var b=s.querySelector(kc(v));if(b)return a.state.loading|=4,a.instance=b,Wt(b),b;p=WC(u),(v=br.get(v))&&Rg(p,v),b=(s.ownerDocument||s).createElement("link"),Wt(b);var T=b;return T._p=new Promise(function(M,O){T.onload=M,T.onerror=O}),un(b,"link",p),a.state.loading|=4,Xd(b,u.precedence,s),a.instance=b;case"script":return b=Zl(u.src),(v=s.querySelector(Ec(b)))?(a.instance=v,Wt(v),v):(p=u,(v=br.get(b))&&(p=m({},u),Og(p,v)),s=s.ownerDocument||s,v=s.createElement("script"),Wt(v),un(v,"link",p),s.head.appendChild(v),a.instance=v);case"void":return null;default:throw Error(r(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(p=a.instance,a.state.loading|=4,Xd(p,u.precedence,s));return a.instance}function Xd(s,a,u){for(var p=u.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),v=p.length?p[p.length-1]:null,b=v,T=0;T title"):null)}function eN(s,a,u){if(u===1||a.itemProp!=null)return!1;switch(s){case"meta":case"title":return!0;case"style":if(typeof a.precedence!="string"||typeof a.href!="string"||a.href==="")break;return!0;case"link":if(typeof a.rel!="string"||typeof a.href!="string"||a.href===""||a.onLoad||a.onError)break;return a.rel==="stylesheet"?(s=a.disabled,typeof a.precedence=="string"&&s==null):!0;case"script":if(a.async&&typeof a.async!="function"&&typeof a.async!="symbol"&&!a.onLoad&&!a.onError&&a.src&&typeof a.src=="string")return!0}return!1}function e7(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function tN(s,a,u,p){if(u.type==="stylesheet"&&(typeof p.media!="string"||matchMedia(p.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var v=ql(p.href),b=a.querySelector(kc(v));if(b){a=b._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(s.count++,s=ef.bind(s),a.then(s,s)),u.state.loading|=4,u.instance=b,Wt(b);return}b=a.ownerDocument||a,p=WC(p),(v=br.get(v))&&Rg(p,v),b=b.createElement("link"),Wt(b);var T=b;T._p=new Promise(function(M,O){T.onload=M,T.onerror=O}),un(b,"link",p),u.instance=b}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(u,a),(a=u.state.preload)&&(u.state.loading&3)===0&&(s.count++,u=ef.bind(s),a.addEventListener("load",u),a.addEventListener("error",u))}}var Dg=0;function nN(s,a){return s.stylesheets&&s.count===0&&nf(s,s.stylesheets),0Dg?50:800)+a);return s.unsuspend=u,function(){s.unsuspend=null,clearTimeout(p),clearTimeout(v)}}:null}function ef(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)nf(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var tf=null;function nf(s,a){s.stylesheets=null,s.unsuspend!==null&&(s.count++,tf=new Map,a.forEach(rN,s),tf=null,ef.call(s))}function rN(s,a){if(!(a.state.loading&4)){var u=tf.get(s);if(u)var p=u.get(null);else{u=new Map,tf.set(s,u);for(var v=s.querySelectorAll("link[data-precedence],style[data-precedence]"),b=0;b"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Ug.exports=wN(),Ug.exports}var SN=xN(),Oa=r9();const TN=t9(Oa);var qg={exports:{}},Zg={};var T7;function kN(){if(T7)return Zg;T7=1;var t=Ou();function e(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,o=t.useLayoutEffect,l=t.useDebugValue;function c(m,g){var y=g(),C=r({inst:{value:y,getSnapshot:g}}),w=C[0].inst,x=C[1];return o(function(){w.value=y,w.getSnapshot=g,d(w)&&x({inst:w})},[m,y,g]),i(function(){return d(w)&&x({inst:w}),m(function(){d(w)&&x({inst:w})})},[m]),l(y),y}function d(m){var g=m.getSnapshot;m=m.value;try{var y=g();return!n(m,y)}catch{return!0}}function f(m,g){return g()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return Zg.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:h,Zg}var k7;function i9(){return k7||(k7=1,qg.exports=kN()),qg.exports}var o9=i9();function dn(t){this.content=t}dn.prototype={constructor:dn,find:function(t){for(var e=0;e>1}};dn.from=function(t){if(t instanceof dn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new dn(e)};function s9(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),o=e.child(r);if(i==o){n+=i.nodeSize;continue}if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){for(let l=0;i.text[l]==o.text[l];l++)n++;return n}if(i.content.size||o.content.size){let l=s9(i.content,o.content,n+1);if(l!=null)return l}n+=i.nodeSize}}function l9(t,e,n,r){for(let i=t.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:n,b:r};let l=t.child(--i),c=e.child(--o),d=l.nodeSize;if(l==c){n-=d,r-=d;continue}if(!l.sameMarkup(c))return{a:n,b:r};if(l.isText&&l.text!=c.text){let f=0,h=Math.min(l.text.length,c.text.length);for(;fe&&r(d,i+c,o||null,l)!==!1&&d.content.size){let h=c+1;d.nodesBetween(Math.max(0,e-h),Math.min(d.content.size,n-h),r,i+h)}c=f}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let o="",l=!0;return this.nodesBetween(e,n,(c,d)=>{let f=c.isText?c.text.slice(Math.max(e,d)-d,n-d):c.isLeaf?i?typeof i=="function"?i(c):i:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&f||c.isTextblock)&&r&&(l?l=!1:o+=r),o+=f},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),o=1);oe)for(let o=0,l=0;le&&((ln)&&(c.isText?c=c.cut(Math.max(0,e-l),Math.min(c.text.length,n-l)):c=c.cut(Math.max(0,e-l-1),Math.min(c.content.size,n-l-1))),r.push(c),i+=c.nodeSize),l=d}return new te(r,i)}cutByIndex(e,n){return e==n?te.empty:e==0&&n==this.content.length?this:new te(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new te(i,o)}addToStart(e){return new te([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new te(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),o=r+i.nodeSize;if(o>=e)return o==e?ff(n+1,o):ff(n,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return te.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new te(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return te.empty;let n,r=0;for(let i=0;ithis.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;nr.type.rank-i.type.rank),n}};ut.none=[];class oh extends Error{}class ce{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=c9(this.content,e+this.openStart,n);return r&&new ce(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ce(a9(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return ce.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ce(te.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)i++;return new ce(e,r,i)}}ce.empty=new ce(te.empty,0,0);function a9(t,e,n){let{index:r,offset:i}=t.findIndex(e),o=t.maybeChild(r),{index:l,offset:c}=t.findIndex(n);if(i==e||o.isText){if(c!=n&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(a9(o.content,e-i-1,n-i-1)))}function c9(t,e,n,r){let{index:i,offset:o}=t.findIndex(e),l=t.maybeChild(i);if(o==e||l.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=c9(l.content,e-o-1,n,l);return c&&t.replaceChild(i,l.copy(c))}function EN(t,e,n){if(n.openStart>t.depth)throw new oh("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new oh("Inconsistent open depths");return u9(t,e,n,0)}function u9(t,e,n,r){let i=t.index(r),o=t.node(r);if(i==e.index(r)&&r=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function $c(t,e,n,r){let i=(e||t).node(n),o=0,l=e?e.index(n):i.childCount;t&&(o=t.index(n),t.depth>n?o++:t.textOffset&&(Is(t.nodeAfter,r),o++));for(let c=o;ci&&t2(t,e,i+1),l=r.depth>i&&t2(n,r,i+1),c=[];return $c(null,t,i,c),o&&l&&e.index(i)==n.index(i)?(d9(o,l),Is(zs(o,f9(t,e,n,r,i+1)),c)):(o&&Is(zs(o,sh(t,e,i+1)),c),$c(e,n,i,c),l&&Is(zs(l,sh(n,r,i+1)),c)),$c(r,null,i,c),new te(c)}function sh(t,e,n){let r=[];if($c(null,t,n,r),t.depth>n){let i=t2(t,e,n+1);Is(zs(i,sh(t,e,n+1)),r)}return $c(e,null,n,r),new te(r)}function MN(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let o=n-1;o>=0;o--)i=e.node(o).copy(te.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class ou{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let o=0;o0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new su(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,o=n;for(let l=e;;){let{index:c,offset:d}=l.content.findIndex(o),f=o-d;if(r.push(l,c,i+d),!f||(l=l.child(c),l.isText))break;o=f-1,i+=d+1}return new ou(n,r,o)}static resolveCached(e,n){let r=E7.get(e);if(r)for(let o=0;oe&&this.nodesBetween(e,n,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),h9(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=te.empty,i=0,o=r.childCount){let l=this.contentMatchAt(e).matchFragment(r,i,o),c=l&&l.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let d=i;dn.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=te.fromJSON(e,n.content),o=e.nodeType(n.type).create(n.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};Gn.prototype.text=void 0;class lh extends Gn{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):h9(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new lh(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new lh(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function h9(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Fs{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new ON(e,n);if(r.next==null)return Fs.empty;let i=p9(r);r.next&&r.err("Unexpected trailing text");let o=BN(zN(i));return jN(o,r),o}matchType(e){for(let n=0;nf.createAndFill()));for(let f=0;f=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i{let o=i+(r.validEnd?"*":" ")+" ";for(let l=0;l"+e.indexOf(r.next[l].next);return o}).join(` `)}}Fs.empty=new Fs(!0);class ON{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function p9(t){let e=[];do e.push(DN(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function DN(t){let e=[];do e.push(LN(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function LN(t){let e=IN(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=_N(t,e);else break;return e}function M7(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function _N(t,e){let n=M7(t),r=n;return t.eat(",")&&(t.next!="}"?r=M7(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function HN(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let o in n){let l=n[o];l.isInGroup(e)&&i.push(l)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function IN(t){if(t.eat("(")){let e=p9(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=HN(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function zN(t){let e=[[]];return i(o(t,0),n()),e;function n(){return e.push([])-1}function r(l,c,d){let f={term:d,to:c};return e[l].push(f),f}function i(l,c){l.forEach(d=>d.to=c)}function o(l,c){if(l.type=="choice")return l.exprs.reduce((d,f)=>d.concat(o(f,c)),[]);if(l.type=="seq")for(let d=0;;d++){let f=o(l.exprs[d],c);if(d==l.exprs.length-1)return f;i(f,c=n())}else if(l.type=="star"){let d=n();return r(c,d),i(o(l.expr,d),d),[r(d)]}else if(l.type=="plus"){let d=n();return i(o(l.expr,c),d),i(o(l.expr,d),d),[r(d)]}else{if(l.type=="opt")return[r(c)].concat(o(l.expr,c));if(l.type=="range"){let d=c;for(let f=0;f{t[l].forEach(({term:c,to:d})=>{if(!c)return;let f;for(let h=0;h{f||i.push([c,f=[]]),f.indexOf(h)==-1&&f.push(h)})})});let o=e[r.join(",")]=new Fs(r.indexOf(t.length-1)>-1);for(let l=0;l-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:y9(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Gn(this,this.computeAttrs(e),te.from(n),ut.setFrom(r))}createChecked(e=null,n,r){return n=te.from(n),this.checkContent(n),new Gn(this,this.computeAttrs(e),n,ut.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=te.from(n),n.size){let l=this.contentMatch.fillBefore(n);if(!l)return null;n=l.append(n)}let i=this.contentMatch.matchFragment(n),o=i&&i.fillBefore(te.empty,!0);return o?new Gn(this,e,n.append(o),ut.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[o]=new C9(o,n,l));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function VN(t,e,n){let r=n.split("|");return i=>{let o=i===null?"null":typeof i;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${o}`)}}class UN{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?VN(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class xp{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=b9(e,i.attrs),this.excluded=null;let o=g9(this.attrs);this.instance=o?new ut(this,o):null}create(e=null){return!e&&this.instance?this.instance:new ut(this,y9(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((o,l)=>r[o]=new xp(o,i++,n,l)),r}removeFromSet(e){for(var n=0;n-1}}let w9=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=dn.from(e.nodes),n.marks=dn.from(e.marks||{}),this.nodes=N7.compile(this.spec.nodes,this),this.marks=xp.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],l=o.spec.content||"",c=o.spec.marks;if(o.contentMatch=r[l]||(r[l]=Fs.parse(l,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=c=="_"?null:c?R7(this,c.split(" ")):c==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],l=o.spec.excludes;o.excluded=l==null?[o]:l==""?[]:R7(this,l.split(" "))}this.nodeFromJSON=i=>Gn.fromJSON(this,i),this.markFromJSON=i=>ut.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof N7){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new lh(r,r.defaultAttrs,e,ut.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function R7(t,e){let n=[];for(let r=0;r-1)&&n.push(l=d)}if(!l)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function PN(t){return t.tag!=null}function FN(t){return t.style!=null}let qc=class r2{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(PN(i))this.tags.push(i);else if(FN(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,n={}){let r=new D7(this,n,!1);return r.addAll(e,ut.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new D7(this,n,!0);return r.addAll(e,ut.none,n.from,n.to),ce.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.length&&(c.charCodeAt(e.length)!=61||c.slice(e.length+1)!=n))){if(l.getAttrs){let d=l.getAttrs(n);if(d===!1)continue;l.attrs=d||void 0}return l}}}static schemaRules(e){let n=[];function r(i){let o=i.priority==null?50:i.priority,l=0;for(;l{r(l=L7(l)),l.mark||l.ignore||l.clearMark||(l.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(l=>{r(l=L7(l)),l.node||l.ignore||l.mark||(l.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new r2(e,r2.schemaRules(e)))}};const x9={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},$N={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},S9={ol:!0,ul:!0},lu=1,i2=2,Zc=4;function O7(t,e,n){return e!=null?(e?lu:0)|(e==="full"?i2:0):t&&t.whitespace=="pre"?lu|i2:n&~Zc}class hf{constructor(e,n,r,i,o,l){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=l,this.content=[],this.activeMarks=ut.none,this.match=o||(l&Zc?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(te.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&lu)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let n=te.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(te.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!x9.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class D7{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,o,l=O7(null,n.preserveWhitespace,0)|(r?Zc:0);i?o=new hf(i.type,i.attrs,ut.none,!0,n.topMatch||i.type.contentMatch,l):r?o=new hf(null,null,ut.none,!0,null,l):o=new hf(e.schema.topNodeType,null,ut.none,!0,null,l),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,o=i.options&i2?"full":this.localPreserveWS||(i.options&lu)>0,{schema:l}=this.parser;if(o==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,` `);else if(l.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(l.linebreakReplacement.create())){let c=r.split(/\r?\n|\r/);for(let d=0;d!d.clearMark(f)):n=n.concat(this.parser.schema.marks[d.mark].create(d.attrs)),d.consuming===!1)c=d;else break}}return n}addElementByRule(e,n,r,i){let o,l;if(n.node)if(l=this.parser.schema.nodes[n.node],l.isLeaf)this.insertNode(l.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let d=this.enter(l,n.attrs||null,r,n.preserveWhitespace);d&&(o=!0,r=d)}else{let d=this.parser.schema.marks[n.mark];r=r.concat(d.create(n.attrs))}let c=this.top;if(l&&l.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(d=>this.insertNode(d,r,!1));else{let d=e;typeof n.contentElement=="string"?d=e.querySelector(n.contentElement):typeof n.contentElement=="function"?d=n.contentElement(e):n.contentElement&&(d=n.contentElement),this.findAround(e,d,!0),this.addAll(d,r),this.findAround(e,d,!1)}o&&this.sync(c)&&this.open--}addAll(e,n,r,i){let o=r||0;for(let l=r?e.childNodes[r]:e.firstChild,c=i==null?null:e.childNodes[i];l!=c;l=l.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(l,n);this.findAtPoint(e,o)}findPlace(e,n,r){let i,o;for(let l=this.open,c=0;l>=0;l--){let d=this.nodes[l],f=d.findWrapping(e);if(f&&(!i||i.length>f.length+c)&&(i=f,o=d,!f.length))break;if(d.solid){if(r)break;c+=2}}if(!i)return null;this.sync(o);for(let l=0;l(l.type?l.type.allowsMarkType(f.type):_7(f.type,e))?(d=f.addToSet(d),!1):!0),this.nodes.push(new hf(e,n,d,i,null,c)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=lu)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),l=(c,d)=>{for(;c>=0;c--){let f=n[c];if(f==""){if(c==n.length-1||c==0)continue;for(;d>=o;d--)if(l(c-1,d))return!0;return!1}else{let h=d>0||d==0&&i?this.nodes[d].type:r&&d>=o?r.node(d-o).type:null;if(!h||h.name!=f&&!h.isInGroup(f))return!1;d--}}return!0};return l(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function qN(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&S9.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function ZN(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function L7(t){let e={};for(let n in t)e[n]=t[n];return e}function _7(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let o=[],l=c=>{o.push(c);for(let d=0;d{if(o.length||l.marks.length){let c=0,d=0;for(;c=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,n);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Uf(Gg(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return Uf(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new rl(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=H7(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return H7(e.marks)}}function H7(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Gg(t){return t.document||window.document}const I7=new WeakMap;function KN(t){let e=I7.get(t);return e===void 0&&I7.set(t,e=GN(t)),e}function GN(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let l=i.indexOf(" ");l>0&&(n=i.slice(0,l),i=i.slice(l+1));let c,d=n?t.createElementNS(n,i):t.createElement(i),f=e[1],h=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){h=2;for(let m in f)if(f[m]!=null){let g=m.indexOf(" ");g>0?d.setAttributeNS(m.slice(0,g),m.slice(g+1),f[m]):m=="style"&&d.style?d.style.cssText=f[m]:d.setAttribute(m,f[m])}}for(let m=h;mh)throw new RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}else{let{dom:y,contentDOM:C}=Uf(t,g,n,r);if(d.appendChild(y),C){if(c)throw new RangeError("Multiple content holes");c=C}}}return{dom:d,contentDOM:c}}const T9=65535,k9=Math.pow(2,16);function YN(t,e){return t+e*k9}function z7(t){return t&T9}function WN(t){return(t-(t&T9))/k9}const E9=1,M9=2,Pf=4,A9=8;class o2{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&A9)>0}get deletedBefore(){return(this.delInfo&(E9|Pf))>0}get deletedAfter(){return(this.delInfo&(M9|Pf))>0}get deletedAcross(){return(this.delInfo&Pf)>0}}class lr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&lr.empty)return lr.empty}recover(e){let n=0,r=z7(e);if(!this.inverted)for(let i=0;ie)break;let f=this.ranges[c+o],h=this.ranges[c+l],m=d+f;if(e<=m){let g=f?e==d?-1:e==m?1:n:n,y=d+i+(g<0?0:h);if(r)return y;let C=e==(n<0?d:m)?null:YN(c/3,e-d),w=e==d?M9:e==m?E9:Pf;return(n<0?e!=d:e!=m)&&(w|=A9),new o2(y,w,C)}i+=h-f}return r?e+i:new o2(e+i,0,null)}touches(e,n){let r=0,i=z7(n),o=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;ce)break;let f=this.ranges[c+o],h=d+f;if(e<=h&&c==i*3)return!0;r+=this.ranges[c+l]-f}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new au;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ro&&d!l.isAtom||!c.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),i),n.openStart,n.openEnd);return Pt.fromReplace(e,this.from,this.to,o)}invert(){return new jr(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Vo(n.pos,r.pos,this.mark)}merge(e){return e instanceof Vo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Vo(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Vo(n.from,n.to,e.markFromJSON(n.mark))}}Mn.jsonID("addMark",Vo);class jr extends Mn{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new ce(yy(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Pt.fromReplace(e,this.from,this.to,r)}invert(){return new Vo(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new jr(n.pos,r.pos,this.mark)}merge(e){return e instanceof jr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new jr(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new jr(n.from,n.to,e.markFromJSON(n.mark))}}Mn.jsonID("removeMark",jr);class Uo extends Mn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Pt.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Pt.fromReplace(e,this.pos,this.pos+1,new ce(te.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;ir.pos?null:new tn(n.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new tn(n.from,n.to,n.gapFrom,n.gapTo,ce.fromJSON(e,n.slice),n.insert,!!n.structure)}}Mn.jsonID("replaceAround",tn);function s2(t,e,n){let r=t.resolve(e),i=n-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let l=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,i--}}return!1}function JN(t,e,n,r){let i=[],o=[],l,c;t.doc.nodesBetween(e,n,(d,f,h)=>{if(!d.isInline)return;let m=d.marks;if(!r.isInSet(m)&&h.type.allowsMarkType(r.type)){let g=Math.max(f,e),y=Math.min(f+d.nodeSize,n),C=r.addToSet(m);for(let w=0;wt.step(d)),o.forEach(d=>t.step(d))}function XN(t,e,n,r){let i=[],o=0;t.doc.nodesBetween(e,n,(l,c)=>{if(!l.isInline)return;o++;let d=null;if(r instanceof xp){let f=l.marks,h;for(;h=r.isInSet(f);)(d||(d=[])).push(h),f=h.removeFromSet(f)}else r?r.isInSet(l.marks)&&(d=[r]):d=l.marks;if(d&&d.length){let f=Math.min(c+l.nodeSize,n);for(let h=0;ht.step(new jr(l.from,l.to,l.style)))}function vy(t,e,n,r=n.contentMatch,i=!0){let o=t.doc.nodeAt(e),l=[],c=e+1;for(let d=0;d=0;d--)t.step(l[d])}function QN(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Da(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,o=0;;--r){let l=t.$from.node(r),c=t.$from.index(r)+i,d=t.$to.indexAfter(r)-o;if(rn;C--)w||r.index(C)>0?(w=!0,h=te.from(r.node(C).copy(h)),m++):d--;let g=te.empty,y=0;for(let C=o,w=!1;C>n;C--)w||i.after(C+1)=0;l--){if(r.size){let c=n[l].type.contentMatch.matchFragment(r);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=te.from(n[l].type.create(n[l].attrs,r))}let i=e.start,o=e.end;t.step(new tn(i,o,i,o,new ce(r,0,0),n.length,!0))}function iR(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(e,n,(l,c)=>{let d=typeof i=="function"?i(l):i;if(l.isTextblock&&!l.hasMarkup(r,d)&&oR(t.doc,t.mapping.slice(o).map(c),r)){let f=null;if(r.schema.linebreakReplacement){let y=r.whitespace=="pre",C=!!r.contentMatch.matchType(r.schema.linebreakReplacement);y&&!C?f=!1:!y&&C&&(f=!0)}f===!1&&R9(t,l,c,o),vy(t,t.mapping.slice(o).map(c,1),r,void 0,f===null);let h=t.mapping.slice(o),m=h.map(c,1),g=h.map(c+l.nodeSize,1);return t.step(new tn(m,g,m+1,g-1,new ce(te.from(r.create(d,null,l.marks)),0,0),1,!0)),f===!0&&N9(t,l,c,o),!1}})}function N9(t,e,n,r){e.forEach((i,o)=>{if(i.isText){let l,c=/\r?\n|\r/g;for(;l=c.exec(i.text);){let d=t.mapping.slice(r).map(n+1+o+l.index);t.replaceWith(d,d+1,e.type.schema.linebreakReplacement.create())}}})}function R9(t,e,n,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let l=t.mapping.slice(r).map(n+1+o);t.replaceWith(l,l+1,e.type.schema.text(` -`))}})}function oR(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function sR(t,e,n,r,i){let o=t.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let l=n.create(r,null,i||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,l);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new tn(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new ce(te.from(l),0,0),1,!0))}function qi(t,e,n=1,r){let i=t.resolve(e),o=i.depth-n,l=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!l.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let f=i.depth-1,h=n-2;f>o;f--,h--){let m=i.node(f),g=i.index(f);if(m.type.spec.isolating)return!1;let y=m.content.cutByIndex(g,m.childCount),C=r&&r[h+1];C&&(y=y.replaceChild(0,C.type.create(C.attrs)));let w=r&&r[h]||m;if(!m.canReplace(g+1,m.childCount)||!w.type.validContent(y))return!1}let c=i.indexAfter(o),d=r&&r[0];return i.node(o).canReplaceWith(c,c,d?d.type:i.node(o+1).type)}function lR(t,e,n=1,r){let i=t.doc.resolve(e),o=te.empty,l=te.empty;for(let c=i.depth,d=i.depth-n,f=n-1;c>d;c--,f--){o=te.from(i.node(c).copy(o));let h=r&&r[f];l=te.from(h?h.type.create(h.attrs,l):i.node(c).copy(l))}t.step(new Qt(e,e,new ce(o.append(l),n,n),!0))}function ns(t,e){let n=t.resolve(e),r=n.index();return O9(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function aR(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i0?(o=r.node(i+1),c++,l=r.node(i).maybeChild(c)):(o=r.node(i).maybeChild(c-1),l=r.node(i+1)),o&&!o.isTextblock&&O9(o,l)&&r.node(i).canReplace(c,c+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function cR(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,o=t.doc.resolve(e-n),l=o.node().type;if(i&&l.inlineContent){let h=l.whitespace=="pre",m=!!l.contentMatch.matchType(i);h&&!m?r=!1:!h&&m&&(r=!0)}let c=t.steps.length;if(r===!1){let h=t.doc.resolve(e+n);R9(t,h.node(),h.before(),c)}l.inlineContent&&vy(t,e+n-1,l,o.node().contentMatchAt(o.index()),r==null);let d=t.mapping.slice(c),f=d.map(e-n);if(t.step(new Qt(f,d.map(e+n,-1),ce.empty,!0)),r===!0){let h=t.doc.resolve(f);N9(t,h.node(),h.before(),t.steps.length)}return t}function uR(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,n))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,n))return r.after(i+1);if(o=0;l--){let c=l==r.depth?0:r.pos<=(r.start(l+1)+r.end(l+1))/2?-1:1,d=r.index(l)+(c>0?1:0),f=r.node(l),h=!1;if(o==1)h=f.canReplace(d,d,i);else{let m=f.contentMatchAt(d).findWrapping(i.firstChild.type);h=m&&f.canReplaceWith(d,d,m[0])}if(h)return c==0?r.pos:c<0?r.before(l+1):r.after(l+1)}return null}function Tp(t,e,n=e,r=ce.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),o=t.resolve(n);return L9(i,o,r)?new Qt(e,n,r):new dR(i,o,r).fit()}function L9(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class dR{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=te.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=te.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let f=this.findFittable();f?this.placeNodes(f):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,l=r.depth,c=i.depth;for(;l&&c&&o.childCount==1;)o=o.firstChild.content,l--,c--;let d=new ce(o,l,c);return e>-1?new tn(r.pos,e,this.$to.pos,this.$to.end(),d,n):d.size||r.pos!=this.$to.pos?new Qt(r.pos,i.pos,d):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Wg(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let l=i.firstChild;for(let c=this.depth;c>=0;c--){let{type:d,match:f}=this.frontier[c],h,m=null;if(n==1&&(l?f.matchType(l.type)||(m=f.fillBefore(te.from(l),!1)):o&&d.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:c,parent:o,inject:m};if(n==2&&l&&(h=f.findWrapping(l.type)))return{sliceDepth:r,frontierDepth:c,parent:o,wrap:h};if(o&&f.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Wg(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new ce(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Wg(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new ce(Vc(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new ce(Vc(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let w=0;w1||d==0||w.content.size)&&(m=x,h.push(_9(w.mark(g.allowedMarks(w.marks)),f==1?d:0,f==c.childCount?y:-1)))}let C=f==c.childCount;C||(y=-1),this.placed=Uc(this.placed,n,te.from(h)),this.frontier[n].match=m,C&&y<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,x=c;w1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],o=n=0;c--){let{match:d,type:f}=this.frontier[c],h=Jg(e,c,f,d,!0);if(!h||h.childCount)continue e}return{depth:n,fit:l,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Uc(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Uc(this.placed,this.depth,te.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(te.empty,!0);n.childCount&&(this.placed=Uc(this.placed,this.frontier.length,n))}}function Vc(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Vc(t.firstChild.content,e-1,n)))}function Uc(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Uc(t.lastChild.content,e-1,n)))}function Wg(t,e){for(let n=0;n1&&(r=r.replaceChild(0,_9(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(te.empty,!0)))),t.copy(r)}function Jg(t,e,n,r,i){let o=t.node(e),l=i?t.indexAfter(e):t.index(e);if(l==o.childCount&&!n.compatibleContent(o.type))return null;let c=r.fillBefore(o.content,!0,l);return c&&!fR(n,o.content,l)?c:null}function fR(t,e,n){for(let r=n;r0;g--,y--){let C=i.node(g).type.spec;if(C.defining||C.definingAsContext||C.isolating)break;l.indexOf(g)>-1?c=g:i.before(g)==y&&l.splice(1,0,-g)}let d=l.indexOf(c),f=[],h=r.openStart;for(let g=r.content,y=0;;y++){let C=g.firstChild;if(f.push(C),y==r.openStart)break;g=C.content}for(let g=h-1;g>=0;g--){let y=f[g],C=hR(y.type);if(C&&!y.sameMarkup(i.node(Math.abs(c)-1)))h=g;else if(C||!y.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let y=(g+h+1)%(r.openStart+1),C=f[y];if(C)for(let w=0;w=0&&(t.replace(e,n,r),!(t.steps.length>m));g--){let y=l[g];y<0||(e=i.before(y),n=o.after(y))}}function H9(t,e,n,r,i){if(er){let o=i.contentMatchAt(0),l=o.fillBefore(t).append(t);t=l.append(o.matchFragment(l).fillBefore(te.empty,!0))}return t}function mR(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=uR(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new ce(te.from(r),0,0))}function gR(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),o=I9(r,i);for(let l=0;l0&&(d||r.node(c-1).canReplace(r.index(c-1),i.indexAfter(c-1))))return t.delete(r.before(c),i.after(c))}for(let l=1;l<=r.depth&&l<=i.depth;l++)if(e-r.start(l)==r.depth-l&&n>r.end(l)&&i.end(l)-n!=i.depth-l&&r.start(l-1)==i.start(l-1)&&r.node(l-1).canReplace(r.index(l-1),i.index(l-1)))return t.delete(r.before(l),n);t.delete(e,n)}function I9(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let o=t.start(i);if(oe.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&n.push(i)}return n}class oa extends Mn{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Pt.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return Pt.fromReplace(e,this.pos,this.pos+1,new ce(te.from(i),0,n.isLeaf?0:1))}getMap(){return lr.empty}invert(e){return new oa(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new oa(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new oa(n.pos,n.attr,n.value)}}Mn.jsonID("attr",oa);class cu extends Mn{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Pt.ok(r)}getMap(){return lr.empty}invert(e){return new cu(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new cu(n.attr,n.value)}}Mn.jsonID("docAttr",cu);let pa=class extends Error{};pa=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};pa.prototype=Object.create(Error.prototype);pa.prototype.constructor=pa;pa.prototype.name="TransformError";class Cy{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new au}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new pa(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=ce.empty){let i=Tp(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new ce(te.from(r),0,0))}delete(e,n){return this.replace(e,n,ce.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return pR(this,e,n,r),this}replaceRangeWith(e,n,r){return mR(this,e,n,r),this}deleteRange(e,n){return gR(this,e,n),this}lift(e,n){return eR(this,e,n),this}join(e,n=1){return cR(this,e,n),this}wrap(e,n){return rR(this,e,n),this}setBlockType(e,n=e,r,i=null){return iR(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return sR(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new oa(e,n,r)),this}setDocAttribute(e,n){return this.step(new cu(e,n)),this}addNodeMark(e,n){return this.step(new Uo(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof ut)n.isInSet(r.marks)&&this.step(new $s(e,n));else{let i=r.marks,o,l=[];for(;o=n.isInSet(i);)l.push(new $s(e,o)),i=o.removeFromSet(i);for(let c=l.length-1;c>=0;c--)this.step(l[c])}return this}split(e,n=1,r){return lR(this,e,n,r),this}addMark(e,n,r){return JN(this,e,n,r),this}removeMark(e,n,r){return XN(this,e,n,r),this}clearIncompatible(e,n,r){return vy(this,e,n,r),this}}const Xg=Object.create(null);class Se{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new wy(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n=0;o--){let l=n<0?Ql(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):Ql(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(l)return l}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Yn(e.node(0))}static atStart(e){return Ql(e,e,0,0,1)||new Yn(e)}static atEnd(e){return Ql(e,e,e.content.size,e.childCount,-1)||new Yn(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Xg[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Xg)throw new RangeError("Duplicate use of selection JSON ID "+e);return Xg[e]=n,n.prototype.jsonID=e,n}getBookmark(){return ue.between(this.$anchor,this.$head).getBookmark()}}Se.prototype.visible=!0;class wy{constructor(e,n){this.$from=e,this.$to=n}}let j7=!1;function V7(t){!j7&&!t.parent.inlineContent&&(j7=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ue extends Se{constructor(e,n=e){V7(e),V7(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Se.near(r);let i=e.resolve(n.map(this.anchor));return new ue(i.parent.inlineContent?i:r,r)}replace(e,n=ce.empty){if(super.replace(e,n),n==ce.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof ue&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new kp(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ue(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let o=Se.findFrom(n,r,!0)||Se.findFrom(n,-r,!0);if(o)n=o.$head;else return Se.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(Se.findFrom(e,-r,!0)||Se.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?l=0;l+=i){let c=e.child(l);if(c.isAtom){if(!o&&me.isSelectable(c))return me.create(t,n-(i<0?c.nodeSize:0))}else{let d=Ql(t,c,n+i,i<0?c.childCount:0,i,o);if(d)return d}n+=c.nodeSize*i}return null}function U7(t,e,n){let r=t.steps.length-1;if(r{l==null&&(l=h)}),t.setSelection(Se.near(t.doc.resolve(l),n))}const P7=1,pf=2,F7=4;let vR=class extends Cy{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=pf,this}ensureMarks(e){return ut.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&pf)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~pf,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ut.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let o=this.storedMarks;if(!o){let l=this.doc.resolve(n);o=r==n?l.marks():l.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,o)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Se.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=F7,this}get scrolledIntoView(){return(this.updated&F7)>0}};function $7(t,e){return!e||!t?t:t.bind(e)}class Pc{constructor(e,n,r){this.name=e,this.init=$7(n.init,r),this.apply=$7(n.apply,r)}}const bR=[new Pc("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Pc("selection",{init(t,e){return t.selection||Se.atStart(e.doc)},apply(t){return t.selection}}),new Pc("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Pc("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Qg{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=bR.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Pc(r.key,r.spec.state,r))})}}class ra{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(n[r]=o.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Qg(e.schema,e.plugins),o=new ra(i);return i.fields.forEach(l=>{if(l.name=="doc")o.doc=Gn.fromJSON(e.schema,n.doc);else if(l.name=="selection")o.selection=Se.fromJSON(o.doc,n.selection);else if(l.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let c in r){let d=r[c],f=d.spec.state;if(d.key==l.name&&f&&f.fromJSON&&Object.prototype.hasOwnProperty.call(n,c)){o[l.name]=f.fromJSON.call(d,e,n[c],o);return}}o[l.name]=l.init(e,o)}}),o}}function z9(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=z9(i,e,{})),n[r]=i}return n}class Ve{constructor(e){this.spec=e,this.props={},e.props&&z9(e.props,this,this.props),this.key=e.key?e.key.key:B9("plugin")}getState(e){return e[this.key]}}const e0=Object.create(null);function B9(t){return t in e0?t+"$"+ ++e0[t]:(e0[t]=0,t+"$")}class qe{constructor(e="key"){this.key=B9(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Sy=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function j9(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const V9=(t,e,n)=>{let r=j9(t,n);if(!r)return!1;let i=Ty(r);if(!i){let l=r.blockRange(),c=l&&Da(l);return c==null?!1:(e&&e(t.tr.lift(l,c).scrollIntoView()),!0)}let o=i.nodeBefore;if(Y9(t,i,e,-1))return!0;if(r.parent.content.size==0&&(ma(o,"end")||me.isSelectable(o)))for(let l=r.depth;;l--){let c=Tp(t.doc,r.before(l),r.after(l),ce.empty);if(c&&c.slice.size1)break}return o.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},CR=(t,e,n)=>{let r=j9(t,n);if(!r)return!1;let i=Ty(r);return i?U9(t,i,e):!1},wR=(t,e,n)=>{let r=F9(t,n);if(!r)return!1;let i=ky(r);return i?U9(t,i,e):!1};function U9(t,e,n){let r=e.nodeBefore,i=r,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let h=i.lastChild;if(!h)return!1;i=h}let l=e.nodeAfter,c=l,d=e.pos+1;for(;!c.isTextblock;d++){if(c.type.spec.isolating)return!1;let h=c.firstChild;if(!h)return!1;c=h}let f=Tp(t.doc,o,d,ce.empty);if(!f||f.from!=o||f instanceof Qt&&f.slice.size>=d-o)return!1;if(n){let h=t.tr.step(f);h.setSelection(ue.create(h.doc,o)),n(h.scrollIntoView())}return!0}function ma(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const P9=(t,e,n)=>{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;o=Ty(r)}let l=o&&o.nodeBefore;return!l||!me.isSelectable(l)?!1:(e&&e(t.tr.setSelection(me.create(t.doc,o.pos-l.nodeSize)).scrollIntoView()),!0)};function Ty(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function F9(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=F9(t,n);if(!r)return!1;let i=ky(r);if(!i)return!1;let o=i.nodeAfter;if(Y9(t,i,e,1))return!0;if(r.parent.content.size==0&&(ma(o,"start")||me.isSelectable(o))){let l=Tp(t.doc,r.before(),r.after(),ce.empty);if(l&&l.slice.size{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,r=n instanceof me,i;if(r){if(n.node.isTextblock||!ns(t.doc,n.from))return!1;i=n.from}else if(i=Sp(t.doc,n.from,-1),i==null)return!1;if(e){let o=t.tr.join(i);r&&o.setSelection(me.create(o.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},SR=(t,e)=>{let n=t.selection,r;if(n instanceof me){if(n.node.isTextblock||!ns(t.doc,n.to))return!1;r=n.to}else if(r=Sp(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},TR=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),o=i&&Da(i);return o==null?!1:(e&&e(t.tr.lift(i,o).scrollIntoView()),!0)},Z9=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(` +`))}})}function oR(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function sR(t,e,n,r,i){let o=t.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let l=n.create(r,null,i||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,l);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new tn(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new ce(te.from(l),0,0),1,!0))}function qi(t,e,n=1,r){let i=t.resolve(e),o=i.depth-n,l=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!l.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let f=i.depth-1,h=n-2;f>o;f--,h--){let m=i.node(f),g=i.index(f);if(m.type.spec.isolating)return!1;let y=m.content.cutByIndex(g,m.childCount),C=r&&r[h+1];C&&(y=y.replaceChild(0,C.type.create(C.attrs)));let w=r&&r[h]||m;if(!m.canReplace(g+1,m.childCount)||!w.type.validContent(y))return!1}let c=i.indexAfter(o),d=r&&r[0];return i.node(o).canReplaceWith(c,c,d?d.type:i.node(o+1).type)}function lR(t,e,n=1,r){let i=t.doc.resolve(e),o=te.empty,l=te.empty;for(let c=i.depth,d=i.depth-n,f=n-1;c>d;c--,f--){o=te.from(i.node(c).copy(o));let h=r&&r[f];l=te.from(h?h.type.create(h.attrs,l):i.node(c).copy(l))}t.step(new Qt(e,e,new ce(o.append(l),n,n),!0))}function ns(t,e){let n=t.resolve(e),r=n.index();return O9(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function aR(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i0?(o=r.node(i+1),c++,l=r.node(i).maybeChild(c)):(o=r.node(i).maybeChild(c-1),l=r.node(i+1)),o&&!o.isTextblock&&O9(o,l)&&r.node(i).canReplace(c,c+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function cR(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,o=t.doc.resolve(e-n),l=o.node().type;if(i&&l.inlineContent){let h=l.whitespace=="pre",m=!!l.contentMatch.matchType(i);h&&!m?r=!1:!h&&m&&(r=!0)}let c=t.steps.length;if(r===!1){let h=t.doc.resolve(e+n);R9(t,h.node(),h.before(),c)}l.inlineContent&&vy(t,e+n-1,l,o.node().contentMatchAt(o.index()),r==null);let d=t.mapping.slice(c),f=d.map(e-n);if(t.step(new Qt(f,d.map(e+n,-1),ce.empty,!0)),r===!0){let h=t.doc.resolve(f);N9(t,h.node(),h.before(),t.steps.length)}return t}function uR(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,n))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,n))return r.after(i+1);if(o=0;l--){let c=l==r.depth?0:r.pos<=(r.start(l+1)+r.end(l+1))/2?-1:1,d=r.index(l)+(c>0?1:0),f=r.node(l),h=!1;if(o==1)h=f.canReplace(d,d,i);else{let m=f.contentMatchAt(d).findWrapping(i.firstChild.type);h=m&&f.canReplaceWith(d,d,m[0])}if(h)return c==0?r.pos:c<0?r.before(l+1):r.after(l+1)}return null}function Tp(t,e,n=e,r=ce.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),o=t.resolve(n);return L9(i,o,r)?new Qt(e,n,r):new dR(i,o,r).fit()}function L9(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class dR{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=te.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=te.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let f=this.findFittable();f?this.placeNodes(f):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,l=r.depth,c=i.depth;for(;l&&c&&o.childCount==1;)o=o.firstChild.content,l--,c--;let d=new ce(o,l,c);return e>-1?new tn(r.pos,e,this.$to.pos,this.$to.end(),d,n):d.size||r.pos!=this.$to.pos?new Qt(r.pos,i.pos,d):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Wg(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let l=i.firstChild;for(let c=this.depth;c>=0;c--){let{type:d,match:f}=this.frontier[c],h,m=null;if(n==1&&(l?f.matchType(l.type)||(m=f.fillBefore(te.from(l),!1)):o&&d.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:c,parent:o,inject:m};if(n==2&&l&&(h=f.findWrapping(l.type)))return{sliceDepth:r,frontierDepth:c,parent:o,wrap:h};if(o&&f.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Wg(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new ce(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Wg(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new ce(Vc(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new ce(Vc(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let w=0;w1||d==0||w.content.size)&&(m=x,h.push(_9(w.mark(g.allowedMarks(w.marks)),f==1?d:0,f==c.childCount?y:-1)))}let C=f==c.childCount;C||(y=-1),this.placed=Uc(this.placed,n,te.from(h)),this.frontier[n].match=m,C&&y<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,x=c;w1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],o=n=0;c--){let{match:d,type:f}=this.frontier[c],h=Jg(e,c,f,d,!0);if(!h||h.childCount)continue e}return{depth:n,fit:l,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Uc(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Uc(this.placed,this.depth,te.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(te.empty,!0);n.childCount&&(this.placed=Uc(this.placed,this.frontier.length,n))}}function Vc(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Vc(t.firstChild.content,e-1,n)))}function Uc(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Uc(t.lastChild.content,e-1,n)))}function Wg(t,e){for(let n=0;n1&&(r=r.replaceChild(0,_9(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(te.empty,!0)))),t.copy(r)}function Jg(t,e,n,r,i){let o=t.node(e),l=i?t.indexAfter(e):t.index(e);if(l==o.childCount&&!n.compatibleContent(o.type))return null;let c=r.fillBefore(o.content,!0,l);return c&&!fR(n,o.content,l)?c:null}function fR(t,e,n){for(let r=n;r0;g--,y--){let C=i.node(g).type.spec;if(C.defining||C.definingAsContext||C.isolating)break;l.indexOf(g)>-1?c=g:i.before(g)==y&&l.splice(1,0,-g)}let d=l.indexOf(c),f=[],h=r.openStart;for(let g=r.content,y=0;;y++){let C=g.firstChild;if(f.push(C),y==r.openStart)break;g=C.content}for(let g=h-1;g>=0;g--){let y=f[g],C=hR(y.type);if(C&&!y.sameMarkup(i.node(Math.abs(c)-1)))h=g;else if(C||!y.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let y=(g+h+1)%(r.openStart+1),C=f[y];if(C)for(let w=0;w=0&&(t.replace(e,n,r),!(t.steps.length>m));g--){let y=l[g];y<0||(e=i.before(y),n=o.after(y))}}function H9(t,e,n,r,i){if(er){let o=i.contentMatchAt(0),l=o.fillBefore(t).append(t);t=l.append(o.matchFragment(l).fillBefore(te.empty,!0))}return t}function mR(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=uR(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new ce(te.from(r),0,0))}function gR(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),o=I9(r,i);for(let l=0;l0&&(d||r.node(c-1).canReplace(r.index(c-1),i.indexAfter(c-1))))return t.delete(r.before(c),i.after(c))}for(let l=1;l<=r.depth&&l<=i.depth;l++)if(e-r.start(l)==r.depth-l&&n>r.end(l)&&i.end(l)-n!=i.depth-l&&r.start(l-1)==i.start(l-1)&&r.node(l-1).canReplace(r.index(l-1),i.index(l-1)))return t.delete(r.before(l),n);t.delete(e,n)}function I9(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let o=t.start(i);if(oe.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&n.push(i)}return n}class oa extends Mn{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Pt.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return Pt.fromReplace(e,this.pos,this.pos+1,new ce(te.from(i),0,n.isLeaf?0:1))}getMap(){return lr.empty}invert(e){return new oa(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new oa(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new oa(n.pos,n.attr,n.value)}}Mn.jsonID("attr",oa);class cu extends Mn{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Pt.ok(r)}getMap(){return lr.empty}invert(e){return new cu(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new cu(n.attr,n.value)}}Mn.jsonID("docAttr",cu);let pa=class extends Error{};pa=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};pa.prototype=Object.create(Error.prototype);pa.prototype.constructor=pa;pa.prototype.name="TransformError";class Cy{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new au}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new pa(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=ce.empty){let i=Tp(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new ce(te.from(r),0,0))}delete(e,n){return this.replace(e,n,ce.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return pR(this,e,n,r),this}replaceRangeWith(e,n,r){return mR(this,e,n,r),this}deleteRange(e,n){return gR(this,e,n),this}lift(e,n){return eR(this,e,n),this}join(e,n=1){return cR(this,e,n),this}wrap(e,n){return rR(this,e,n),this}setBlockType(e,n=e,r,i=null){return iR(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return sR(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new oa(e,n,r)),this}setDocAttribute(e,n){return this.step(new cu(e,n)),this}addNodeMark(e,n){return this.step(new Uo(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof ut)n.isInSet(r.marks)&&this.step(new $s(e,n));else{let i=r.marks,o,l=[];for(;o=n.isInSet(i);)l.push(new $s(e,o)),i=o.removeFromSet(i);for(let c=l.length-1;c>=0;c--)this.step(l[c])}return this}split(e,n=1,r){return lR(this,e,n,r),this}addMark(e,n,r){return JN(this,e,n,r),this}removeMark(e,n,r){return XN(this,e,n,r),this}clearIncompatible(e,n,r){return vy(this,e,n,r),this}}const Xg=Object.create(null);class Se{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new wy(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n=0;o--){let l=n<0?Ql(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):Ql(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(l)return l}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Yn(e.node(0))}static atStart(e){return Ql(e,e,0,0,1)||new Yn(e)}static atEnd(e){return Ql(e,e,e.content.size,e.childCount,-1)||new Yn(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Xg[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Xg)throw new RangeError("Duplicate use of selection JSON ID "+e);return Xg[e]=n,n.prototype.jsonID=e,n}getBookmark(){return ue.between(this.$anchor,this.$head).getBookmark()}}Se.prototype.visible=!0;class wy{constructor(e,n){this.$from=e,this.$to=n}}let j7=!1;function V7(t){!j7&&!t.parent.inlineContent&&(j7=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ue extends Se{constructor(e,n=e){V7(e),V7(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Se.near(r);let i=e.resolve(n.map(this.anchor));return new ue(i.parent.inlineContent?i:r,r)}replace(e,n=ce.empty){if(super.replace(e,n),n==ce.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof ue&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new kp(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ue(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let o=Se.findFrom(n,r,!0)||Se.findFrom(n,-r,!0);if(o)n=o.$head;else return Se.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(Se.findFrom(e,-r,!0)||Se.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?l=0;l+=i){let c=e.child(l);if(c.isAtom){if(!o&&me.isSelectable(c))return me.create(t,n-(i<0?c.nodeSize:0))}else{let d=Ql(t,c,n+i,i<0?c.childCount:0,i,o);if(d)return d}n+=c.nodeSize*i}return null}function U7(t,e,n){let r=t.steps.length-1;if(r{l==null&&(l=h)}),t.setSelection(Se.near(t.doc.resolve(l),n))}const P7=1,pf=2,F7=4;let vR=class extends Cy{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=pf,this}ensureMarks(e){return ut.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&pf)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~pf,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ut.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let o=this.storedMarks;if(!o){let l=this.doc.resolve(n);o=r==n?l.marks():l.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,o)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Se.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=F7,this}get scrolledIntoView(){return(this.updated&F7)>0}};function $7(t,e){return!e||!t?t:t.bind(e)}class Pc{constructor(e,n,r){this.name=e,this.init=$7(n.init,r),this.apply=$7(n.apply,r)}}const bR=[new Pc("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Pc("selection",{init(t,e){return t.selection||Se.atStart(e.doc)},apply(t){return t.selection}}),new Pc("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Pc("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Qg{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=bR.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Pc(r.key,r.spec.state,r))})}}class ra{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(n[r]=o.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Qg(e.schema,e.plugins),o=new ra(i);return i.fields.forEach(l=>{if(l.name=="doc")o.doc=Gn.fromJSON(e.schema,n.doc);else if(l.name=="selection")o.selection=Se.fromJSON(o.doc,n.selection);else if(l.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let c in r){let d=r[c],f=d.spec.state;if(d.key==l.name&&f&&f.fromJSON&&Object.prototype.hasOwnProperty.call(n,c)){o[l.name]=f.fromJSON.call(d,e,n[c],o);return}}o[l.name]=l.init(e,o)}}),o}}function z9(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=z9(i,e,{})),n[r]=i}return n}class Ue{constructor(e){this.spec=e,this.props={},e.props&&z9(e.props,this,this.props),this.key=e.key?e.key.key:B9("plugin")}getState(e){return e[this.key]}}const e0=Object.create(null);function B9(t){return t in e0?t+"$"+ ++e0[t]:(e0[t]=0,t+"$")}class Ze{constructor(e="key"){this.key=B9(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Sy=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function j9(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const V9=(t,e,n)=>{let r=j9(t,n);if(!r)return!1;let i=Ty(r);if(!i){let l=r.blockRange(),c=l&&Da(l);return c==null?!1:(e&&e(t.tr.lift(l,c).scrollIntoView()),!0)}let o=i.nodeBefore;if(Y9(t,i,e,-1))return!0;if(r.parent.content.size==0&&(ma(o,"end")||me.isSelectable(o)))for(let l=r.depth;;l--){let c=Tp(t.doc,r.before(l),r.after(l),ce.empty);if(c&&c.slice.size1)break}return o.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},CR=(t,e,n)=>{let r=j9(t,n);if(!r)return!1;let i=Ty(r);return i?U9(t,i,e):!1},wR=(t,e,n)=>{let r=F9(t,n);if(!r)return!1;let i=ky(r);return i?U9(t,i,e):!1};function U9(t,e,n){let r=e.nodeBefore,i=r,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let h=i.lastChild;if(!h)return!1;i=h}let l=e.nodeAfter,c=l,d=e.pos+1;for(;!c.isTextblock;d++){if(c.type.spec.isolating)return!1;let h=c.firstChild;if(!h)return!1;c=h}let f=Tp(t.doc,o,d,ce.empty);if(!f||f.from!=o||f instanceof Qt&&f.slice.size>=d-o)return!1;if(n){let h=t.tr.step(f);h.setSelection(ue.create(h.doc,o)),n(h.scrollIntoView())}return!0}function ma(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const P9=(t,e,n)=>{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;o=Ty(r)}let l=o&&o.nodeBefore;return!l||!me.isSelectable(l)?!1:(e&&e(t.tr.setSelection(me.create(t.doc,o.pos-l.nodeSize)).scrollIntoView()),!0)};function Ty(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function F9(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=F9(t,n);if(!r)return!1;let i=ky(r);if(!i)return!1;let o=i.nodeAfter;if(Y9(t,i,e,1))return!0;if(r.parent.content.size==0&&(ma(o,"start")||me.isSelectable(o))){let l=Tp(t.doc,r.before(),r.after(),ce.empty);if(l&&l.slice.size{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,r=n instanceof me,i;if(r){if(n.node.isTextblock||!ns(t.doc,n.from))return!1;i=n.from}else if(i=Sp(t.doc,n.from,-1),i==null)return!1;if(e){let o=t.tr.join(i);r&&o.setSelection(me.create(o.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},SR=(t,e)=>{let n=t.selection,r;if(n instanceof me){if(n.node.isTextblock||!ns(t.doc,n.to))return!1;r=n.to}else if(r=Sp(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},TR=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),o=i&&Da(i);return o==null?!1:(e&&e(t.tr.lift(i,o).scrollIntoView()),!0)},Z9=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(` `).scrollIntoView()),!0)};function Ey(t){for(let e=0;e{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),o=n.indexAfter(-1),l=Ey(i.contentMatchAt(o));if(!l||!i.canReplaceWith(o,o,l))return!1;if(e){let c=n.after(),d=t.tr.replaceWith(c,c,l.createAndFill());d.setSelection(Se.near(d.doc.resolve(c),1)),e(d.scrollIntoView())}return!0},K9=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Yn||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=Ey(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let l=(!r.parentOffset&&i.index(){let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(qi(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Da(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function ER(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof me&&e.selection.node.isBlock)return!r.parentOffset||!qi(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],l,c,d=!1,f=!1;for(let y=r.depth;;y--)if(r.node(y).isBlock){d=r.end(y)==r.pos+(r.depth-y),f=r.start(y)==r.pos-(r.depth-y),c=Ey(r.node(y-1).contentMatchAt(r.indexAfter(y-1))),o.unshift(d&&c?{type:c}:null),l=y;break}else{if(y==1)return!1;o.unshift(null)}let h=e.tr;(e.selection instanceof ue||e.selection instanceof Yn)&&h.deleteSelection();let m=h.mapping.map(r.pos),g=qi(h.doc,m,o.length,o);if(g||(o[0]=c?{type:c}:null,g=qi(h.doc,m,o.length,o)),!g)return!1;if(h.split(m,o.length,o),!d&&f&&r.node(l).type!=c){let y=h.mapping.map(r.before(l)),C=h.doc.resolve(y);c&&r.node(l-1).canReplaceWith(C.index(),C.index()+1,c)&&h.setNodeMarkup(h.mapping.map(r.before(l)),c)}return n&&n(h.scrollIntoView()),!0}}const MR=ER(),AR=(t,e)=>{let{$from:n,to:r}=t.selection,i,o=n.sharedDepth(r);return o==0?!1:(i=n.before(o),e&&e(t.tr.setSelection(me.create(t.doc,i))),!0)};function NR(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||ns(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Y9(t,e,n,r){let i=e.nodeBefore,o=e.nodeAfter,l,c,d=i.type.spec.isolating||o.type.spec.isolating;if(!d&&NR(t,e,n))return!0;let f=!d&&e.parent.canReplace(e.index(),e.index()+1);if(f&&(l=(c=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&c.matchType(l[0]||o.type).validEnd){if(n){let y=e.pos+o.nodeSize,C=te.empty;for(let k=l.length-1;k>=0;k--)C=te.from(l[k].create(null,C));C=te.from(i.copy(C));let w=t.tr.step(new tn(e.pos-1,y,e.pos,y,new ce(C,1,0),l.length,!0)),x=w.doc.resolve(y+2*l.length);x.nodeAfter&&x.nodeAfter.type==i.type&&ns(w.doc,x.pos)&&w.join(x.pos),n(w.scrollIntoView())}return!0}let h=o.type.spec.isolating||r>0&&d?null:Se.findFrom(e,1),m=h&&h.$from.blockRange(h.$to),g=m&&Da(m);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(m,g).scrollIntoView()),!0;if(f&&ma(o,"start",!0)&&ma(i,"end")){let y=i,C=[];for(;C.push(y),!y.isTextblock;)y=y.lastChild;let w=o,x=1;for(;!w.isTextblock;w=w.firstChild)x++;if(y.canReplace(y.childCount,y.childCount,w.content)){if(n){let k=te.empty;for(let N=C.length-1;N>=0;N--)k=te.from(C[N].copy(k));let A=t.tr.step(new tn(e.pos-C.length,e.pos+o.nodeSize,e.pos+x,e.pos+o.nodeSize-x,new ce(k,C.length,0),0,!0));n(A.scrollIntoView())}return!0}}return!1}function W9(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(n&&n(e.tr.setSelection(ue.create(e.doc,t<0?i.start(o):i.end(o)))),!0):!1}}const RR=W9(-1),OR=W9(1);function DR(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,l=i.blockRange(o),c=l&&by(l,t,e);return c?(r&&r(n.tr.wrap(l,c).scrollIntoView()),!0):!1}}function q7(t,e=null){return function(n,r){let i=!1;for(let o=0;o{if(i)return!1;if(!(!d.isTextblock||d.hasMarkup(t,e)))if(d.type==t)i=!0;else{let h=n.doc.resolve(f),m=h.index();i=h.parent.canReplaceWith(m,m+1,t)}})}if(!i)return!1;if(r){let o=n.tr;for(let l=0;l=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let d=l.resolve(e.start-2);o=new su(d,d,e.depth),e.endIndex=0;h--)o=te.from(n[h].type.create(n[h].attrs,o));t.step(new tn(e.start-(r?2:0),e.end,e.start,e.end,new ce(o,0,0),n.length,!0));let l=0;for(let h=0;hl.childCount>0&&l.firstChild.type==t);return o?n?r.node(o.depth-1).type==t?zR(e,n,t,o):BR(e,n,o):!0:!1}}function zR(t,e,n,r){let i=t.tr,o=r.end,l=r.$to.end(r.depth);ow;C--)y-=i.child(C).nodeSize,r.delete(y-1,y+1);let o=r.doc.resolve(n.start),l=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let c=n.startIndex==0,d=n.endIndex==i.childCount,f=o.node(-1),h=o.index(-1);if(!f.canReplace(h+(c?0:1),h+1,l.content.append(d?te.empty:te.from(i))))return!1;let m=o.pos,g=m+l.nodeSize;return r.step(new tn(m-(c?1:0),g+(d?1:0),m+1,g-1,new ce((c?te.empty:te.from(i.copy(te.empty))).append(d?te.empty:te.from(i.copy(te.empty))),c?0:1,d?0:1),c?0:1)),e(r.scrollIntoView()),!0}function jR(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,f=>f.childCount>0&&f.firstChild.type==t);if(!o)return!1;let l=o.startIndex;if(l==0)return!1;let c=o.parent,d=c.child(l-1);if(d.type!=t)return!1;if(n){let f=d.lastChild&&d.lastChild.type==c.type,h=te.from(f?t.create():null),m=new ce(te.from(t.create(null,te.from(c.type.create(null,h)))),f?3:1,0),g=o.start,y=o.end;n(e.tr.step(new tn(g-(f?3:1),y,g,y,m,1,!0)).scrollIntoView())}return!0}}const pn=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},ga=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let l2=null;const Vi=function(t,e,n){let r=l2||(l2=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},VR=function(){l2=null},qs=function(t,e,n,r){return n&&(Z7(t,e,n,r,-1)||Z7(t,e,n,r,1))},UR=/^(img|br|input|textarea|hr)$/i;function Z7(t,e,n,r,i){for(var o;;){if(t==n&&e==r)return!0;if(e==(i<0?0:kr(t))){let l=t.parentNode;if(!l||l.nodeType!=1||Du(t)||UR.test(t.nodeName)||t.contentEditable=="false")return!1;e=pn(t)+(i<0?0:1),t=l}else if(t.nodeType==1){let l=t.childNodes[e+(i<0?-1:0)];if(l.nodeType==1&&l.contentEditable=="false")if(!((o=l.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else t=l,e=i<0?kr(t):0}else return!1}}function kr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function PR(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=kr(t)}else if(t.parentNode&&!Du(t))e=pn(t),t=t.parentNode;else return null}}function FR(t,e){for(;;){if(t.nodeType==3&&e2),Tr=ya||(ui?/Mac/.test(ui.platform):!1),Q9=ui?/Win/.test(ui.platform):!1,Fi=/Android \d/.test(rs),Lu=!!K7&&"webkitFontSmoothing"in K7.documentElement.style,KR=Lu?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function GR(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function _i(t,e){return typeof t=="number"?t:t[e]}function YR(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function G7(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let l=n||t.dom;l;){if(l.nodeType!=1){l=ga(l);continue}let c=l,d=c==o.body,f=d?GR(o):YR(c),h=0,m=0;if(e.topf.bottom-_i(r,"bottom")&&(m=e.bottom-e.top>f.bottom-f.top?e.top+_i(i,"top")-f.top:e.bottom-f.bottom+_i(i,"bottom")),e.leftf.right-_i(r,"right")&&(h=e.right-f.right+_i(i,"right")),h||m)if(d)o.defaultView.scrollBy(h,m);else{let y=c.scrollLeft,C=c.scrollTop;m&&(c.scrollTop+=m),h&&(c.scrollLeft+=h);let w=c.scrollLeft-y,x=c.scrollTop-C;e={left:e.left-w,top:e.top-x,right:e.right-w,bottom:e.bottom-x}}let g=d?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(g))break;l=g=="absolute"?l.offsetParent:ga(l)}}function WR(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,l=n+1;l=n-20){r=c,i=d.top;break}}return{refDOM:r,refTop:i,stack:ex(t.dom)}}function ex(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=ga(r));return e}function JR({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;tx(n,r==0?0:r-e)}function tx(t,e){for(let n=0;n=c){l=Math.max(C.bottom,l),c=Math.min(C.top,c);let w=C.left>e.left?C.left-e.left:C.right=(C.left+C.right)/2?1:0));continue}}else C.top>e.top&&!d&&C.left<=e.left&&C.right>=e.left&&(d=h,f={left:Math.max(C.left,Math.min(C.right,e.left)),top:C.top});!n&&(e.left>=C.right&&e.top>=C.top||e.left>=C.left&&e.top>=C.bottom)&&(o=m+1)}}return!n&&d&&(n=d,i=f,r=0),n&&n.nodeType==3?QR(n,i):!n||r&&n.nodeType==1?{node:t,offset:o}:nx(n,i)}function QR(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let o=0;o=(l.left+l.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function Ay(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function eO(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(l.left+l.right)/2?1:-1}return t.docView.posFromDOM(r,i,o)}function nO(t,e,n,r){let i=-1;for(let o=e,l=!1;o!=t.dom;){let c=t.docView.nearestDesc(o,!0),d;if(!c)return null;if(c.dom.nodeType==1&&(c.node.isBlock&&c.parent||!c.contentDOM)&&((d=c.dom.getBoundingClientRect()).width||d.height)&&(c.node.isBlock&&c.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(c.dom.nodeName)&&(!l&&d.left>r.left||d.top>r.top?i=c.posBefore:(!l&&d.right-1?i:t.docView.posFromDOM(e,n,-1)}function rx(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&i++}let f;Lu&&i&&r.nodeType==1&&(f=r.childNodes[i-1]).nodeType==1&&f.contentEditable=="false"&&f.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?c=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(c=nO(t,r,i,e))}c==null&&(c=tO(t,l,e));let d=t.docView.nearestDesc(l,!0);return{pos:c,inside:d?d.posAtStart-d.border:-1}}function Y7(t){return t.top=0&&i==r.nodeValue.length?(d--,h=1):n<0?d--:f++,Lc(Oo(Vi(r,d,f),h),h<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(n<0||i==kr(r))){let d=r.childNodes[i-1];if(d.nodeType==1)return t0(d.getBoundingClientRect(),!1)}if(o==null&&i=0)}if(o==null&&i&&(n<0||i==kr(r))){let d=r.childNodes[i-1],f=d.nodeType==3?Vi(d,kr(d)-(l?0:1)):d.nodeType==1&&(d.nodeName!="BR"||!d.nextSibling)?d:null;if(f)return Lc(Oo(f,1),!1)}if(o==null&&i=0)}function Lc(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function t0(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function ox(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function oO(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return ox(t,e,()=>{let{node:o}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let c=t.docView.nearestDesc(o,!0);if(!c)break;if(c.node.isBlock){o=c.contentDOM||c.dom;break}o=c.dom.parentNode}let l=ix(t,i.pos,1);for(let c=o.firstChild;c;c=c.nextSibling){let d;if(c.nodeType==1)d=c.getClientRects();else if(c.nodeType==3)d=Vi(c,0,c.nodeValue.length).getClientRects();else continue;for(let f=0;fh.top+1&&(n=="up"?l.top-h.top>(h.bottom-l.top)*2:h.bottom-l.bottom>(l.bottom-h.top)*2))return!1}}return!0})}const sO=/[\u0590-\u08ac]/;function lO(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,l=i==r.parent.content.size,c=t.domSelection();return c?!sO.test(r.parent.textContent)||!c.modify?n=="left"||n=="backward"?o:l:ox(t,e,()=>{let{focusNode:d,focusOffset:f,anchorNode:h,anchorOffset:m}=t.domSelectionRange(),g=c.caretBidiLevel;c.modify("move",n,"character");let y=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:C,focusOffset:w}=t.domSelectionRange(),x=C&&!y.contains(C.nodeType==1?C:C.parentNode)||d==C&&f==w;try{c.collapse(h,m),d&&(d!=h||f!=m)&&c.extend&&c.extend(d,f)}catch{}return g!=null&&(c.caretBidiLevel=g),x}):r.pos==r.start()||r.pos==r.end()}let W7=null,J7=null,X7=!1;function aO(t,e,n){return W7==e&&J7==n?X7:(W7=e,J7=n,X7=n=="up"||n=="down"?oO(t,e,n):lO(t,e,n))}const Ar=0,Q7=1,Ls=2,di=3;class _u{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Ar,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;npn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),l;if(o&&(!n||o.node))if(r&&(l=o.nodeDOM)&&!(l.nodeType==1?l.contains(e.nodeType==1?e:e.parentNode):l==e))r=!1;else return o}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||l instanceof lx){i=e-o;break}o=c}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof sx&&o.side>=0;r--);if(n<=0){let o,l=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,l=!1);return o&&n&&l&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?pn(o.dom)+1:0}}else{let o,l=!0;for(;o=r=h&&n<=f-d.border&&d.node&&d.contentDOM&&this.contentDOM.contains(d.contentDOM))return d.parseRange(e,n,h);e=l;for(let m=c;m>0;m--){let g=this.children[m-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){i=pn(g.dom)+1;break}e-=g.size}i==-1&&(i=0)}if(i>-1&&(f>n||c==this.children.length-1)){n=f;for(let h=c+1;hC&&ln){let C=c;c=d,d=C}let y=document.createRange();y.setEnd(d.node,d.offset),y.setStart(c.node,c.offset),f.removeAllRanges(),f.addRange(y)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i=r:er){let c=r+o.border,d=l-o.border;if(e>=c&&n<=d){this.dirty=e==r||n==l?Ls:Q7,e==c&&n==d&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=di:o.markDirty(e-c,n-c);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Ls:di}r=l}this.dirty=Ls}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Ls:Q7;n.dirty{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!n.type.spec.raw){if(l.nodeType!=1){let c=document.createElement("span");c.appendChild(l),l=c}l.contentEditable="false",l.classList.add("ProseMirror-widget")}super(e,[],l,null),this.widget=n,this.widget=n,o=this}matchesWidget(e){return this.dirty==Ar&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class cO extends _u{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Zs extends _u{constructor(e,n,r,i,o){super(e,[],r,i),this.mark=n,this.spec=o}static create(e,n,r,i){let o=i.nodeViews[n.type.name],l=o&&o(n,i,r);return(!l||!l.dom)&&(l=rl.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Zs(e,n,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&di||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=di&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Ar){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(o=f2(o,0,e,r));for(let c=0;c{if(!d)return l;if(d.parent)return d.parent.posBeforeChild(d)},r,i),h=f&&f.dom,m=f&&f.contentDOM;if(n.isText){if(!h)h=document.createTextNode(n.text);else if(h.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else h||({dom:h,contentDOM:m}=rl.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!m&&!n.isText&&h.nodeName!="BR"&&(h.hasAttribute("contenteditable")||(h.contentEditable="false"),n.type.spec.draggable&&(h.draggable=!0));let g=h;return h=ux(h,r,n),f?d=new uO(e,n,r,i,h,m||null,g,f,o,l+1):n.isText?new Mp(e,n,r,i,h,g,o):new Ko(e,n,r,i,h,m||null,g,o,l+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>te.empty)}return e}matchesNode(e,n,r){return this.dirty==Ar&&e.eq(this.node)&&ah(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,o=e.composing?this.localCompositionInfo(e,n):null,l=o&&o.pos>-1?o:null,c=o&&o.pos<0,d=new fO(this,l&&l.node,e);mO(this.node,this.innerDeco,(f,h,m)=>{f.spec.marks?d.syncToMarks(f.spec.marks,r,e):f.type.side>=0&&!m&&d.syncToMarks(h==this.node.childCount?ut.none:this.node.child(h).marks,r,e),d.placeWidget(f,e,i)},(f,h,m,g)=>{d.syncToMarks(f.marks,r,e);let y;d.findNodeMatch(f,h,m,g)||c&&e.state.selection.from>i&&e.state.selection.to-1&&d.updateNodeAt(f,h,m,y,e)||d.updateNextNode(f,h,m,e,g,i)||d.addNode(f,h,m,e,i),i+=f.nodeSize}),d.syncToMarks([],r,e),this.node.isTextblock&&d.addTextblockHacks(),d.destroyRest(),(d.changed||this.dirty==Ls)&&(l&&this.protectLocalComposition(e,l),ax(this.contentDOM,this.children,e),ya&&gO(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof ue)||rn+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let l=o.nodeValue,c=yO(this.node.content,l,r-n,i-n);return c<0?null:{node:o,pos:c,text:l}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let o=n;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let l=new cO(this,o,n,i);e.input.compositionNodes.push(l),this.children=f2(this.children,r,r+i.length,e,l)}update(e,n,r,i){return this.dirty==di||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Ar}updateOuterDeco(e){if(ah(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=cx(this.dom,this.nodeDOM,d2(this.outerDeco,this.node,n),d2(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function ew(t,e,n,r,i){ux(r,e,t);let o=new Ko(void 0,t,e,n,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}class Mp extends Ko{constructor(e,n,r,i,o,l,c){super(e,n,r,i,o,null,l,c,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==di||this.dirty!=Ar&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Ar||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Ar,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),o=document.createTextNode(i.text);return new Mp(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=di)}get domAtom(){return!1}isText(e){return this.node.text==e}}class lx extends _u{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ar&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class uO extends Ko{constructor(e,n,r,i,o,l,c,d,f,h){super(e,n,r,i,o,l,c,f,h),this.spec=d}update(e,n,r,i){if(this.dirty==di)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,n,r);return o&&this.updateInner(e,n,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function ax(t,e,n){let r=t.firstChild,i=!1;for(let o=0;o>1,l=Math.min(o,e.length);for(;i-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let d=Zs.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,i){let o=-1,l;if(i>=this.preMatch.index&&(l=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&l.matchesNode(e,n,r))o=this.top.children.indexOf(l,this.index);else for(let c=this.index,d=Math.min(this.top.children.length,c+5);c0;){let c;for(;;)if(r){let f=n.children[r-1];if(f instanceof Zs)n=f,r=f.children.length;else{c=f,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let d=c.node;if(d){if(d!=t.child(i-1))break;--i,o.set(c,i),l.push(c)}}return{index:i,matched:o,matches:l.reverse()}}function pO(t,e){return t.type.side-e.type.side}function mO(t,e,n,r){let i=e.locals(t),o=0;if(i.length==0){for(let f=0;fo;)c.push(i[l++]);let C=o+g.nodeSize;if(g.isText){let x=C;l!x.inline):c.slice();r(g,w,e.forChild(o,g),y),o=C}}function gO(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function yO(t,e,n,r){for(let i=0,o=0;i=n){if(o>=r&&d.slice(r-e.length-c,r-c)==e)return r-e.length;let f=c=0&&f+e.length+c>=n)return c+f;if(n==r&&d.length>=r+e.length-c&&d.slice(r-c,r-c+e.length)==e)return r}}return-1}function f2(t,e,n,r,i){let o=[];for(let l=0,c=0;l=n||h<=e?o.push(d):(fn&&o.push(d.slice(n-f,d.size,r)))}return o}function Ny(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),o=i&&i.size==0,l=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(l<0)return null;let c=r.resolve(l),d,f;if(Ep(n)){for(d=l;i&&!i.node;)i=i.parent;let m=i.node;if(i&&m.isAtom&&me.isSelectable(m)&&i.parent&&!(m.isInline&&$R(n.focusNode,n.focusOffset,i.dom))){let g=i.posBefore;f=new me(l==g?c:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let m=l,g=l;for(let y=0;y{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!dx(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function bO(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,pn(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Wn&&Zo<=11&&(n.disabled=!0,n.disabled=!1)}function fx(t,e){if(e instanceof me){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(ow(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else ow(t)}function ow(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ry(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||ue.between(e,n,r)}function sw(t){return t.editable&&!t.hasFocus()?!1:hx(t)}function hx(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function CO(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return qs(e.node,e.offset,n.anchorNode,n.anchorOffset)}function h2(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),o=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return o&&Se.findFrom(o,e)}function _o(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function lw(t,e,n){let r=t.state.selection;if(r instanceof ue)if(n.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let l=t.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return _o(t,new ue(r.$anchor,l))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=h2(t.state,e);return i&&i instanceof me?_o(t,i):!1}else if(!(Tr&&n.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,l;if(!o||o.isText)return!1;let c=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(l=t.docView.descAt(c))&&!l.contentDOM?me.isSelectable(o)?_o(t,new me(e<0?t.state.doc.resolve(i.pos-o.nodeSize):i)):Lu?_o(t,new ue(t.state.doc.resolve(e<0?c:c+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof me&&r.node.isInline)return _o(t,new ue(e>0?r.$to:r.$from));{let i=h2(t.state,e);return i?_o(t,i):!1}}}function ch(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Gc(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Yl(t,e){return e<0?wO(t):xO(t)}function wO(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,o,l=!1;for(Mr&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let c=n.childNodes[r-1];if(Gc(c,-1))i=n,o=--r;else if(c.nodeType==3)n=c,r=n.nodeValue.length;else break}}else{if(px(n))break;{let c=n.previousSibling;for(;c&&Gc(c,-1);)i=n.parentNode,o=pn(c),c=c.previousSibling;if(c)n=c,r=ch(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}l?p2(t,n,r):i&&p2(t,i,o)}function xO(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=ch(n),o,l;for(;;)if(r{t.state==i&&Zi(t)},50)}function aw(t,e){let n=t.state.doc.resolve(e);if(!(en||Q9)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),l=(o.top+o.bottom)/2;if(l>i.top&&l1)return o.lefti.top&&l1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function cw(t,e,n){let r=t.state.selection;if(r instanceof ue&&!r.empty||n.indexOf("s")>-1||Tr&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let l=h2(t.state,e);if(l&&l instanceof me)return _o(t,l)}if(!i.parent.inlineContent){let l=e<0?i:o,c=r instanceof Yn?Se.near(l,e):Se.findFrom(l,e);return c?_o(t,c):!1}return!1}function uw(t,e){if(!(t.state.selection instanceof ue))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let l=t.state.tr;return e<0?l.delete(n.pos-o.nodeSize,n.pos):l.delete(n.pos,n.pos+o.nodeSize),t.dispatch(l),!0}return!1}function dw(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function kO(t){if(!Tn||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;dw(t,r,"true"),setTimeout(()=>dw(t,r,"false"),20)}return!1}function EO(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function MO(t,e){let n=e.keyCode,r=EO(e);if(n==8||Tr&&n==72&&r=="c")return uw(t,-1)||Yl(t,-1);if(n==46&&!e.shiftKey||Tr&&n==68&&r=="c")return uw(t,1)||Yl(t,1);if(n==13||n==27)return!0;if(n==37||Tr&&n==66&&r=="c"){let i=n==37?aw(t,t.state.selection.from)=="ltr"?-1:1:-1;return lw(t,i,r)||Yl(t,i)}else if(n==39||Tr&&n==70&&r=="c"){let i=n==39?aw(t,t.state.selection.from)=="ltr"?1:-1:1;return lw(t,i,r)||Yl(t,i)}else{if(n==38||Tr&&n==80&&r=="c")return cw(t,-1,r)||Yl(t,-1);if(n==40||Tr&&n==78&&r=="c")return kO(t)||cw(t,1,r)||Yl(t,1);if(r==(Tr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Oy(t,e){t.someProp("transformCopied",y=>{e=y(e,t)});let n=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let y=r.firstChild;n.push(y.type.name,y.attrs!=y.type.defaultAttrs?y.attrs:null),r=y.content}let l=t.someProp("clipboardSerializer")||rl.fromSchema(t.state.schema),c=Cx(),d=c.createElement("div");d.appendChild(l.serializeFragment(r,{document:c}));let f=d.firstChild,h,m=0;for(;f&&f.nodeType==1&&(h=bx[f.nodeName.toLowerCase()]);){for(let y=h.length-1;y>=0;y--){let C=c.createElement(h[y]);for(;d.firstChild;)C.appendChild(d.firstChild);d.appendChild(C),m++}f=d.firstChild}f&&f.nodeType==1&&f.setAttribute("data-pm-slice",`${i} ${o}${m?` -${m}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",y=>y(e,t))||e.content.textBetween(0,e.content.size,` `);return{dom:d,text:g,slice:e}}function mx(t,e,n,r,i){let o=i.parent.type.spec.code,l,c;if(!n&&!e)return null;let d=!!e&&(r||o||!n);if(d){if(t.someProp("transformPastedText",g=>{e=g(e,o||r,t)}),o)return c=new ce(te.from(t.state.schema.text(e.replace(/\r\n?/g,` -`))),0,0),t.someProp("transformPasted",g=>{c=g(c,t,!0)}),c;let m=t.someProp("clipboardTextParser",g=>g(e,i,r,t));if(m)c=m;else{let g=i.marks(),{schema:y}=t.state,C=rl.fromSchema(y);l=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(w=>{let x=l.appendChild(document.createElement("p"));w&&x.appendChild(C.serializeNode(y.text(w,g)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),l=OO(n),Lu&&DO(l);let f=l&&l.querySelector("[data-pm-slice]"),h=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let m=+h[3];m>0;m--){let g=l.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;l=g}if(c||(c=(t.someProp("clipboardParser")||t.someProp("domParser")||qc.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(d||h),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!AO.test(g.parentNode.nodeName)?{ignore:!0}:null}})),h)c=LO(fw(c,+h[1],+h[2]),h[4]);else if(c=ce.maxOpen(NO(c.content,i),!0),c.openStart||c.openEnd){let m=0,g=0;for(let y=c.content.firstChild;m{c=m(c,t,d)}),c}const AO=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function NO(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),o,l=[];if(t.forEach(c=>{if(!l)return;let d=i.findWrapping(c.type),f;if(!d)return l=null;if(f=l.length&&o.length&&yx(d,o,c,l[l.length-1],0))l[l.length-1]=f;else{l.length&&(l[l.length-1]=vx(l[l.length-1],o.length));let h=gx(c,d);l.push(h),i=i.matchType(h.type),o=d}}),l)return te.from(l)}return t}function gx(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,te.from(t));return t}function yx(t,e,n,r,i){if(i1&&(o=0),i=n&&(c=e<0?l.contentMatchAt(0).fillBefore(c,o<=i).append(c):c.append(l.contentMatchAt(l.childCount).fillBefore(te.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,l.copy(c))}function fw(t,e,n){return en})),r0.createHTML(t)):t}function OO(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Cx().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&bx[r[1].toLowerCase()])&&(t=i.map(o=>"<"+o+">").join("")+t+i.map(o=>"").reverse().join("")),n.innerHTML=RO(t),i)for(let o=0;o=0;c-=2){let d=n.nodes[r[c]];if(!d||d.hasRequiredAttrs())break;i=te.from(d.create(r[c+1],i)),o++,l++}return new ce(i,o,l)}const Ln={},_n={},_O={touchstart:!0,touchmove:!0};class HO{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function IO(t){for(let e in Ln){let n=Ln[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{BO(t,r)&&!Dy(t,r)&&(t.editable||!(r.type in _n))&&n(t,r)},_O[e]?{passive:!0}:void 0)}Tn&&t.dom.addEventListener("input",()=>null),g2(t)}function Po(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function zO(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function g2(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Dy(t,r))})}function Dy(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function BO(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function jO(t,e){!Dy(t,e)&&Ln[e.type]&&(t.editable||!(e.type in _n))&&Ln[e.type](t,e)}_n.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!xx(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Fi&&en&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),ya&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,Os(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||MO(t,n)?n.preventDefault():Po(t,"key")};_n.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};_n.keypress=(t,e)=>{let n=e;if(xx(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Tr&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof ue)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),o=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",l=>l(t,r.$from.pos,r.$to.pos,i,o))&&t.dispatch(o()),n.preventDefault()}};function Ap(t){return{left:t.clientX,top:t.clientY}}function VO(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Ly(t,e,n,r,i){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let l=o.depth+1;l>0;l--)if(t.someProp(e,c=>l>o.depth?c(t,n,o.nodeAfter,o.before(l),i,!0):c(t,n,o.node(l),o.before(l),i,!1)))return!0;return!1}function sa(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function UO(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&me.isSelectable(r)?(sa(t,new me(n)),!0):!1}function PO(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof me&&(r=n.node);let o=t.state.doc.resolve(e);for(let l=o.depth+1;l>0;l--){let c=l>o.depth?o.nodeAfter:o.node(l);if(me.isSelectable(c)){r&&n.$from.depth>0&&l>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?i=o.before(n.$from.depth):i=o.before(l);break}}return i!=null?(sa(t,me.create(t.state.doc,i)),!0):!1}function FO(t,e,n,r,i){return Ly(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?PO(t,n):UO(t,n))}function $O(t,e,n,r){return Ly(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function qO(t,e,n,r){return Ly(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||ZO(t,n,r)}function ZO(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(sa(t,ue.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o),c=i.before(o);if(l.inlineContent)sa(t,ue.create(r,c+1,c+1+l.content.size));else if(me.isSelectable(l))sa(t,me.create(r,c));else continue;return!0}}function _y(t){return uh(t)}const wx=Tr?"metaKey":"ctrlKey";Ln.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=_y(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&VO(n,t.input.lastClick)&&!n[wx]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:o,button:n.button};let l=t.posAtCoords(Ap(n));l&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new KO(t,l,n,!!r)):(o=="doubleClick"?$O:qO)(t,l.pos,l.inside,n)?n.preventDefault():Po(t,"pointer"))};class KO{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[wx],this.allowDefault=r.shiftKey;let o,l;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),l=n.inside;else{let h=e.state.doc.resolve(n.pos);o=h.parent,l=h.depth?h.before():0}const c=i?null:r.target,d=c?e.docView.nearestDesc(c,!0):null;this.target=d&&d.nodeDOM.nodeType==1?d.nodeDOM:null;let{selection:f}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||f instanceof me&&f.from<=l&&f.to>l)&&(this.mightDrag={node:o,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Mr&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Po(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Zi(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Ap(e))),this.updateAllowDefault(e),this.allowDefault||!n?Po(this.view,"pointer"):FO(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Tn&&this.mightDrag&&!this.mightDrag.node.isAtom||en&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(sa(this.view,Se.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Po(this.view,"pointer")}move(e){this.updateAllowDefault(e),Po(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Ln.touchstart=t=>{t.input.lastTouch=Date.now(),_y(t),Po(t,"pointer")};Ln.touchmove=t=>{t.input.lastTouch=Date.now(),Po(t,"pointer")};Ln.contextmenu=t=>_y(t);function xx(t,e){return t.composing?!0:Tn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const GO=Fi?5e3:-1;_n.compositionstart=_n.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof ue&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||en&&Q9&&YO(t)))t.markCursor=t.state.storedMarks||n.marks(),uh(t,!0),t.markCursor=null;else if(uh(t,!e.selection.empty),Mr&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let l=o<0?i.lastChild:i.childNodes[o-1];if(!l)break;if(l.nodeType==3){let c=t.domSelection();c&&c.collapse(l,l.nodeValue.length);break}else i=l,o=-1}}t.input.composing=!0}Sx(t,GO)};function YO(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}_n.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Sx(t,20))};function Sx(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>uh(t),e))}function Tx(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=JO());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function WO(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=PR(e.focusNode,e.focusOffset),r=FR(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let l=n.pmViewDesc;if(!(!l||!l.isText(n.nodeValue)))return r}}return n||r}function JO(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function uh(t,e=!1){if(!(Fi&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Tx(t),e||t.docView&&t.docView.dirty){let n=Ny(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function XO(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const uu=Wn&&Zo<15||ya&&KR<604;Ln.copy=_n.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=uu?null:n.clipboardData,l=r.content(),{dom:c,text:d}=Oy(t,l);o?(n.preventDefault(),o.clearData(),o.setData("text/html",c.innerHTML),o.setData("text/plain",d)):XO(t,c),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function QO(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function eD(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?du(t,r.value,null,i,e):du(t,r.textContent,r.innerHTML,i,e)},50)}function du(t,e,n,r,i){let o=mx(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",d=>d(t,i,o||ce.empty)))return!0;if(!o)return!1;let l=QO(o),c=l?t.state.tr.replaceSelectionWith(l,r):t.state.tr.replaceSelection(o);return t.dispatch(c.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function kx(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}_n.paste=(t,e)=>{let n=e;if(t.composing&&!Fi)return;let r=uu?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&du(t,kx(r),r.getData("text/html"),i,n)?n.preventDefault():eD(t,n)};class Ex{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const tD=Tr?"altKey":"ctrlKey";function Mx(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[tD]}Ln.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,o=i.empty?null:t.posAtCoords(Ap(n)),l;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof me?i.to-1:i.to))){if(r&&r.mightDrag)l=me.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let m=t.docView.nearestDesc(n.target,!0);m&&m.node.type.spec.draggable&&m!=t.docView&&(l=me.create(t.state.doc,m.posBefore))}}let c=(l||t.state.selection).content(),{dom:d,text:f,slice:h}=Oy(t,c);(!n.dataTransfer.files.length||!en||X9>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(uu?"Text":"text/html",d.innerHTML),n.dataTransfer.effectAllowed="copyMove",uu||n.dataTransfer.setData("text/plain",f),t.dragging=new Ex(h,Mx(t,n),l)};Ln.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};_n.dragover=_n.dragenter=(t,e)=>e.preventDefault();_n.drop=(t,e)=>{try{nD(t,e,t.dragging)}finally{t.dragging=null}};function nD(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Ap(e));if(!r)return;let i=t.state.doc.resolve(r.pos),o=n&&n.slice;o?t.someProp("transformPasted",y=>{o=y(o,t,!1)}):o=mx(t,kx(e.dataTransfer),uu?null:e.dataTransfer.getData("text/html"),!1,i);let l=!!(n&&Mx(t,e));if(t.someProp("handleDrop",y=>y(t,e,o||ce.empty,l))){e.preventDefault();return}if(!o)return;e.preventDefault();let c=o?D9(t.state.doc,i.pos,o):i.pos;c==null&&(c=i.pos);let d=t.state.tr;if(l){let{node:y}=n;y?y.replace(d):d.deleteSelection()}let f=d.mapping.map(c),h=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,m=d.doc;if(h?d.replaceRangeWith(f,f,o.content.firstChild):d.replaceRange(f,f,o),d.doc.eq(m))return;let g=d.doc.resolve(f);if(h&&me.isSelectable(o.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(o.content.firstChild))d.setSelection(new me(g));else{let y=d.mapping.map(c);d.mapping.maps[d.mapping.maps.length-1].forEach((C,w,x,k)=>y=k),d.setSelection(Ry(t,g,d.doc.resolve(y)))}t.focus(),t.dispatch(d.setMeta("uiEvent","drop"))}Ln.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Zi(t)},20))};Ln.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Ln.beforeinput=(t,e)=>{if(en&&Fi&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,Os(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in _n)Ln[t]=_n[t];function fu(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class dh{constructor(e,n){this.toDOM=e,this.spec=n||Bs,this.side=this.spec.side||0}map(e,n,r,i){let{pos:o,deleted:l}=e.mapResult(n.from+i,this.side<0?-1:1);return l?null:new Ft(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof dh&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&fu(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Go{constructor(e,n){this.attrs=e,this.spec=n||Bs}map(e,n,r,i){let o=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,l=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=l?null:new Ft(o,l,this)}valid(e,n){return n.from=e&&(!o||o(c.spec))&&r.push(c.copy(c.from+i,c.to+i))}for(let l=0;le){let c=this.children[l]+1;this.children[l+2].findInner(e-c,n-c,r,i+c,o)}}map(e,n,r){return this==bn||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Bs)}mapInner(e,n,r,i,o){let l;for(let c=0;c{let f=d+r,h;if(h=Nx(n,c,f)){for(i||(i=this.children.slice());oc&&m.to=e){this.children[c]==e&&(r=this.children[c+2]);break}let o=e+1,l=o+n.content.size;for(let c=0;co&&d.type instanceof Go){let f=Math.max(o,d.from)-o,h=Math.min(l,d.to)-o;fi.map(e,n,Bs));return zo.from(r)}forChild(e,n){if(n.isLeaf)return Xe.empty;let r=[];for(let i=0;in instanceof Xe)?e:e.reduce((n,r)=>n.concat(r instanceof Xe?r:r.members),[]))}}forEachSet(e){for(let n=0;n{let x=w-C-(y-g);for(let k=0;kA+h-m)continue;let N=c[k]+h-m;y>=N?c[k+1]=g<=N?-2:-1:g>=h&&x&&(c[k]+=x,c[k+1]+=x)}m+=x}),h=n.maps[f].map(h,-1)}let d=!1;for(let f=0;f=r.content.size){d=!0;continue}let g=n.map(t[f+1]+o,-1),y=g-i,{index:C,offset:w}=r.content.findIndex(m),x=r.maybeChild(C);if(x&&w==m&&w+x.nodeSize==y){let k=c[f+2].mapInner(n,x,h+1,t[f]+o+1,l);k!=bn?(c[f]=m,c[f+1]=y,c[f+2]=k):(c[f+1]=-2,d=!0)}else d=!0}if(d){let f=iD(c,t,e,n,i,o,l),h=fh(f,r,0,l);e=h.local;for(let m=0;mn&&l.to{let f=Nx(t,c,d+n);if(f){o=!0;let h=fh(f,c,n+d+1,r);h!=bn&&i.push(d,d+c.nodeSize,h)}});let l=Ax(o?Rx(t):t,-n).sort(js);for(let c=0;c0;)e++;t.splice(e,0,n)}function i0(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=bn&&e.push(r)}),t.cursorWrapper&&e.push(Xe.create(t.state.doc,[t.cursorWrapper.deco])),zo.from(e)}const oD={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},sD=Wn&&Zo<=11;class lD{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class aD{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new lD,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),sD&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,oD)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;nthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(sw(this.view)){if(this.suppressingSelectionUpdates)return Zi(this.view);if(Wn&&Zo<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&qs(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let o=e.focusNode;o;o=ga(o))n.add(o);for(let o=e.anchorNode;o;o=ga(o))if(n.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&sw(e)&&!this.ignoreSelectionChange(r),o=-1,l=-1,c=!1,d=[];if(e.editable)for(let h=0;hm.nodeName=="BR");if(h.length==2){let[m,g]=h;m.parentNode&&m.parentNode.parentNode==g.parentNode?g.remove():m.remove()}else{let{focusNode:m}=this.currentSelection;for(let g of h){let y=g.parentNode;y&&y.nodeName=="LI"&&(!m||dD(e,m)!=y)&&g.remove()}}}else if((en||Tn)&&d.some(h=>h.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let h of d)if(h.nodeName=="BR"&&h.parentNode){let m=h.nextSibling;m&&m.nodeType==1&&m.contentEditable=="false"&&h.parentNode.removeChild(h)}}let f=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(o>-1&&(e.docView.markDirty(o,l),cD(e)),this.handleDOMChange(o,l,c,d),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Zi(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let h=0;hi;x--){let k=r.childNodes[x-1],A=k.pmViewDesc;if(k.nodeName=="BR"&&!A){o=x;break}if(!A||A.size)break}let m=t.state.doc,g=t.someProp("domParser")||qc.fromSchema(t.state.schema),y=m.resolve(l),C=null,w=g.parse(r,{topNode:y.parent,topMatch:y.parent.contentMatchAt(y.index()),topOpen:!0,from:i,to:o,preserveWhitespace:y.parent.type.whitespace=="pre"?"full":!0,findPositions:f,ruleFromNode:hD,context:y});if(f&&f[0].pos!=null){let x=f[0].pos,k=f[1]&&f[1].pos;k==null&&(k=x),C={anchor:x+l,head:k+l}}return{doc:w,sel:C,from:l,to:c}}function hD(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Tn&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||Tn&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const pD=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function mD(t,e,n,r,i){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let _=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,q=Ny(t,_);if(q&&!t.state.selection.eq(q)){if(en&&Fi&&t.input.lastKeyCode===13&&Date.now()-100U(t,Os(13,"Enter"))))return;let J=t.state.tr.setSelection(q);_=="pointer"?J.setMeta("pointer",!0):_=="key"&&J.scrollIntoView(),o&&J.setMeta("composition",o),t.dispatch(J)}return}let l=t.state.doc.resolve(e),c=l.sharedDepth(n);e=l.before(c+1),n=t.state.doc.resolve(n).after(c+1);let d=t.state.selection,f=fD(t,e,n),h=t.state.doc,m=h.slice(f.from,f.to),g,y;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||Fi)&&i.some(_=>_.nodeType==1&&!pD.test(_.nodeName))&&(!C||C.endA>=C.endB)&&t.someProp("handleKeyDown",_=>_(t,Os(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!C)if(r&&d instanceof ue&&!d.empty&&d.$head.sameParent(d.$anchor)&&!t.composing&&!(f.sel&&f.sel.anchor!=f.sel.head))C={start:d.from,endA:d.to,endB:d.to};else{if(f.sel){let _=vw(t,t.state.doc,f.sel);if(_&&!_.eq(t.state.selection)){let q=t.state.tr.setSelection(_);o&&q.setMeta("composition",o),t.dispatch(q)}}return}t.state.selection.fromt.state.selection.from&&C.start<=t.state.selection.from+2&&t.state.selection.from>=f.from?C.start=t.state.selection.from:C.endA=t.state.selection.to-2&&t.state.selection.to<=f.to&&(C.endB+=t.state.selection.to-C.endA,C.endA=t.state.selection.to)),Wn&&Zo<=11&&C.endB==C.start+1&&C.endA==C.start&&C.start>f.from&&f.doc.textBetween(C.start-f.from-1,C.start-f.from+1)=="  "&&(C.start--,C.endA--,C.endB--);let w=f.doc.resolveNoCache(C.start-f.from),x=f.doc.resolveNoCache(C.endB-f.from),k=h.resolve(C.start),A=w.sameParent(x)&&w.parent.inlineContent&&k.end()>=C.endA;if((ya&&t.input.lastIOSEnter>Date.now()-225&&(!A||i.some(_=>_.nodeName=="DIV"||_.nodeName=="P"))||!A&&w.pos_(t,Os(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>C.start&&yD(h,C.start,C.endA,w,x)&&t.someProp("handleKeyDown",_=>_(t,Os(8,"Backspace")))){Fi&&en&&t.domObserver.suppressSelectionUpdates();return}en&&C.endB==C.start&&(t.input.lastChromeDelete=Date.now()),Fi&&!A&&w.start()!=x.start()&&x.parentOffset==0&&w.depth==x.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==C.endA&&(C.endB-=2,x=f.doc.resolveNoCache(C.endB-f.from),setTimeout(()=>{t.someProp("handleKeyDown",function(_){return _(t,Os(13,"Enter"))})},20));let N=C.start,R=C.endA,L=_=>{let q=_||t.state.tr.replace(N,R,f.doc.slice(C.start-f.from,C.endB-f.from));if(f.sel){let J=vw(t,q.doc,f.sel);J&&!(en&&t.composing&&J.empty&&(C.start!=C.endB||t.input.lastChromeDeleteZi(t),20));let _=L(t.state.tr.delete(N,R)),q=h.resolve(C.start).marksAcross(h.resolve(C.endA));q&&_.ensureMarks(q),t.dispatch(_)}else if(C.endA==C.endB&&(z=gD(w.parent.content.cut(w.parentOffset,x.parentOffset),k.parent.content.cut(k.parentOffset,C.endA-k.start())))){let _=L(t.state.tr);z.type=="add"?_.addMark(N,R,z.mark):_.removeMark(N,R,z.mark),t.dispatch(_)}else if(w.parent.child(w.index()).isText&&w.index()==x.index()-(x.textOffset?0:1)){let _=w.parent.textBetween(w.parentOffset,x.parentOffset),q=()=>L(t.state.tr.insertText(_,N,R));t.someProp("handleTextInput",J=>J(t,N,R,_,q))||t.dispatch(q())}else t.dispatch(L());else t.dispatch(L())}function vw(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Ry(t,e.resolve(n.anchor),e.resolve(n.head))}function gD(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,o=r,l,c,d;for(let h=0;hh.mark(c.addToSet(h.marks));else if(i.length==0&&o.length==1)c=o[0],l="remove",d=h=>h.mark(c.removeFromSet(h.marks));else return null;let f=[];for(let h=0;hn||o0(l,!0,!1)0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let o=t.node(r).maybeChild(t.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function vD(t,e,n,r,i){let o=t.findDiffStart(e,n);if(o==null)return null;let{a:l,b:c}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let d=Math.max(0,o-Math.min(l,c));r-=l+d-o}if(l=l?o-r:0;o-=d,o&&o=c?o-r:0;o-=d,o&&o=56320&&e<=57343&&n>=55296&&n<=56319}class Ox{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new HO,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Tw),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=xw(this),ww(this),this.nodeViews=Sw(this),this.docView=ew(this.state.doc,Cw(this),i0(this),this.dom,this),this.domObserver=new aD(this,(r,i,o,l)=>mD(this,r,i,o,l)),this.domObserver.start(),IO(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&g2(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Tw),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,o=!1,l=!1;e.storedMarks&&this.composing&&(Tx(this),l=!0),this.state=e;let c=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(c||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let y=Sw(this);CD(y,this.nodeViews)&&(this.nodeViews=y,o=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&g2(this),this.editable=xw(this),ww(this);let d=i0(this),f=Cw(this),h=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",m=o||!this.docView.matchesNode(e.doc,f,d);(m||!e.selection.eq(i.selection))&&(l=!0);let g=h=="preserve"&&l&&this.dom.style.overflowAnchor==null&&WR(this);if(l){this.domObserver.stop();let y=m&&(Wn||en)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&bD(i.selection,e.selection);if(m){let C=en?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=WO(this)),(o||!this.docView.update(e.doc,f,d,this))&&(this.docView.updateOuterDeco(f),this.docView.destroy(),this.docView=ew(e.doc,f,d,this.dom,this)),C&&!this.trackWrites&&(y=!0)}y||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&CO(this))?Zi(this,y):(fx(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),h=="reset"?this.dom.scrollTop=0:h=="to selection"?this.scrollToSelection():g&&JR(g)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof me){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&G7(this,n.getBoundingClientRect(),e)}else G7(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n0&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new Ex(e.slice,e.move,i<0?void 0:me.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let l=0;ln.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return rO(this,e)}coordsAtPos(e,n=1){return ix(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return aO(this,n||this.state,e)}pasteHTML(e,n){return du(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return du(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Oy(this,e)}destroy(){this.docView&&(zO(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],i0(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,VR())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return jO(this,e)}domSelectionRange(){let e=this.domSelection();return e?Tn&&this.root.nodeType===11&&qR(this.dom.ownerDocument)==this.dom&&uD(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Ox.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Cw(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Ft.node(0,t.state.doc.content.size,e)]}function ww(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Ft.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function xw(t){return!t.someProp("editable",e=>e(t.state)===!1)}function bD(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Sw(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function CD(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function Tw(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Wo={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},hh={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},wD=typeof navigator<"u"&&/Mac/.test(navigator.platform),xD=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var mn=0;mn<10;mn++)Wo[48+mn]=Wo[96+mn]=String(mn);for(var mn=1;mn<=24;mn++)Wo[mn+111]="F"+mn;for(var mn=65;mn<=90;mn++)Wo[mn]=String.fromCharCode(mn+32),hh[mn]=String.fromCharCode(mn);for(var s0 in Wo)hh.hasOwnProperty(s0)||(hh[s0]=Wo[s0]);function SD(t){var e=wD&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||xD&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?hh:Wo)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const TD=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),kD=typeof navigator<"u"&&/Win/.test(navigator.platform);function ED(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,o,l;for(let c=0;c{for(var n in e)ND(t,n,{get:e[n],enumerable:!0})};function Np(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:o}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,o=n.storedMarks,n}}}var Rp=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,o=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([l,c])=>[l,(...f)=>{const h=c(...f)(o);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),h}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:o}=r,l=[],c=!!t,d=t||i.tr,f=()=>(!c&&e&&!d.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(d),l.every(m=>m===!0)),h={...Object.fromEntries(Object.entries(n).map(([m,g])=>[m,(...C)=>{const w=this.buildProps(d,e),x=g(...C)(w);return l.push(x),h}])),run:f};return h}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,o=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([c,d])=>[c,(...f)=>d(...f)({...o,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:o}=r,l={tr:t,editor:r,view:o,state:Np({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([c,d])=>[c,(...f)=>d(...f)(l)]))}};return l}},Dx={};By(Dx,{blur:()=>RD,clearContent:()=>OD,clearNodes:()=>DD,command:()=>LD,createParagraphNear:()=>_D,cut:()=>HD,deleteCurrentNode:()=>ID,deleteNode:()=>zD,deleteRange:()=>BD,deleteSelection:()=>jD,enter:()=>VD,exitCode:()=>UD,extendMarkRange:()=>PD,first:()=>FD,focus:()=>$D,forEach:()=>qD,insertContent:()=>ZD,insertContentAt:()=>YD,joinBackward:()=>XD,joinDown:()=>JD,joinForward:()=>QD,joinItemBackward:()=>eL,joinItemForward:()=>tL,joinTextblockBackward:()=>nL,joinTextblockForward:()=>rL,joinUp:()=>WD,keyboardShortcut:()=>oL,lift:()=>sL,liftEmptyBlock:()=>lL,liftListItem:()=>aL,newlineInCode:()=>cL,resetAttributes:()=>uL,scrollIntoView:()=>dL,selectAll:()=>fL,selectNodeBackward:()=>hL,selectNodeForward:()=>pL,selectParentNode:()=>mL,selectTextblockEnd:()=>gL,selectTextblockStart:()=>yL,setContent:()=>vL,setMark:()=>HL,setMeta:()=>IL,setNode:()=>zL,setNodeSelection:()=>BL,setTextDirection:()=>jL,setTextSelection:()=>VL,sinkListItem:()=>UL,splitBlock:()=>PL,splitListItem:()=>FL,toggleList:()=>$L,toggleMark:()=>qL,toggleNode:()=>ZL,toggleWrap:()=>KL,undoInputRule:()=>GL,unsetAllMarks:()=>YL,unsetMark:()=>WL,unsetTextDirection:()=>JL,updateAttributes:()=>XL,wrapIn:()=>QL,wrapInList:()=>e_});var RD=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),OD=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),DD=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:o,$to:l})=>{t.doc.nodesBetween(o.pos,l.pos,(c,d)=>{if(c.type.isText)return;const{doc:f,mapping:h}=e,m=f.resolve(h.map(d)),g=f.resolve(h.map(d+c.nodeSize)),y=m.blockRange(g);if(!y)return;const C=Da(y);if(c.type.isTextblock){const{defaultType:w}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(y.start,w)}(C||C===0)&&e.lift(y,C)})}),!0},LD=t=>e=>t(e),_D=()=>({state:t,dispatch:e})=>K9(t,e),HD=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,o=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const l=r.mapping.map(e);return r.insert(l,o.content),r.setSelection(new ue(r.doc.resolve(Math.max(l-1,0)))),!0},ID=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===r.type){if(e){const c=i.before(o),d=i.after(o);t.delete(c,d).scrollIntoView()}return!0}return!1};function $t(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var zD=t=>({tr:e,state:n,dispatch:r})=>{const i=$t(t,n.schema),o=e.selection.$anchor;for(let l=o.depth;l>0;l-=1)if(o.node(l).type===i){if(r){const d=o.before(l),f=o.after(l);e.delete(d,f).scrollIntoView()}return!0}return!1},BD=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},jD=()=>({state:t,dispatch:e})=>Sy(t,e),VD=()=>({commands:t})=>t.keyboardShortcut("Enter"),UD=()=>({state:t,dispatch:e})=>kR(t,e);function jy(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function ph(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:jy(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Lx(t,e,n={}){return t.find(r=>r.type===e&&ph(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function kw(t,e,n={}){return!!Lx(t,e,n)}function Vy(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(h=>h.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(h=>h.type===e)||(n=n||((r=i.node.marks[0])==null?void 0:r.attrs),!Lx([...i.node.marks],e,n)))return;let l=i.index,c=t.start()+i.offset,d=l+1,f=c+i.node.nodeSize;for(;l>0&&kw([...t.parent.child(l-1).marks],e,n);)l-=1,c-=t.parent.child(l).nodeSize;for(;d({tr:n,state:r,dispatch:i})=>{const o=Ji(t,r.schema),{doc:l,selection:c}=n,{$from:d,from:f,to:h}=c;if(i){const m=Vy(d,o,e);if(m&&m.from<=f&&m.to>=h){const g=ue.create(l,m.from,m.to);n.setSelection(g)}}return!0},FD=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r({editor:n,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};const l=()=>{(Op()||Hx())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!Uy(n.state.selection))return l(),!0;const c=_x(i.doc,t)||n.state.selection,d=n.state.selection.eq(c);return o&&(d||i.setSelection(c),d&&i.storedMarks&&i.setStoredMarks(i.storedMarks),l()),!0},qD=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),ZD=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Ix=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Ix(r)}return t};function mf(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`${t}`,n=new window.DOMParser().parseFromString(e,"text/html").body;return Ix(n)}function hu(t,e,n){if(t instanceof Gn||t instanceof te)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return te.fromArray(t.map(c=>e.nodeFromJSON(c)));const l=e.nodeFromJSON(t);return n.errorOnInvalidContent&&l.check(),l}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),hu("",e,n)}if(i){if(n.errorOnInvalidContent){let l=!1,c="";const d=new w9({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:f=>(l=!0,c=typeof f=="string"?f:f.outerHTML,null)}]}})});if(n.slice?qc.fromSchema(d).parseSlice(mf(t),n.parseOptions):qc.fromSchema(d).parse(mf(t),n.parseOptions),n.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const o=qc.fromSchema(e);return n.slice?o.parseSlice(mf(t),n.parseOptions).content:o.parse(mf(t),n.parseOptions)}return hu("",e,n)}function KD(t,e,n){const r=t.steps.length-1;if(r{l===0&&(l=h)}),t.setSelection(Se.near(t.doc.resolve(l),n))}var GD=t=>!("type"in t),YD=(t,e,n)=>({tr:r,dispatch:i,editor:o})=>{var l;if(i){n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let c;const d=x=>{o.emit("contentError",{editor:o,error:x,disableCollaboration:()=>{"collaboration"in o.storage&&typeof o.storage.collaboration=="object"&&o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},f={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{hu(e,o.schema,{parseOptions:f,errorOnInvalidContent:!0})}catch(x){d(x)}try{c=hu(e,o.schema,{parseOptions:f,errorOnInvalidContent:(l=n.errorOnInvalidContent)!=null?l:o.options.enableContentCheck})}catch(x){return d(x),!1}let{from:h,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,y=!0;if((GD(c)?c:[c]).forEach(x=>{x.check(),g=g?x.isText&&x.marks.length===0:!1,y=y?x.isBlock:!1}),h===m&&y){const{parent:x}=r.doc.resolve(h);x.isTextblock&&!x.type.spec.code&&!x.childCount&&(h-=1,m+=1)}let w;if(g){if(Array.isArray(e))w=e.map(x=>x.text||"").join("");else if(e instanceof te){let x="";e.forEach(k=>{k.text&&(x+=k.text)}),w=x}else typeof e=="object"&&e&&e.text?w=e.text:w=e;r.insertText(w,h,m)}else{w=c;const x=r.doc.resolve(h),k=x.node(),A=x.parentOffset===0,N=k.isText||k.isTextblock,R=k.content.size>0;A&&N&&R&&(h=Math.max(0,h-1)),r.replaceWith(h,m,w)}n.updateSelection&&KD(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:h,text:w}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:h,text:w})}return!0},WD=()=>({state:t,dispatch:e})=>xR(t,e),JD=()=>({state:t,dispatch:e})=>SR(t,e),XD=()=>({state:t,dispatch:e})=>V9(t,e),QD=()=>({state:t,dispatch:e})=>$9(t,e),eL=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Sp(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},tL=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Sp(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},nL=()=>({state:t,dispatch:e})=>CR(t,e),rL=()=>({state:t,dispatch:e})=>wR(t,e);function zx(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function iL(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,o,l;for(let c=0;c({editor:e,view:n,tr:r,dispatch:i})=>{const o=iL(t).split(/-(?!$)/),l=o.find(f=>!["Alt","Ctrl","Meta","Shift"].includes(f)),c=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),d=e.captureTransaction(()=>{n.someProp("handleKeyDown",f=>f(n,c))});return d?.steps.forEach(f=>{const h=f.map(r.mapping);h&&i&&r.maybeStep(h)}),!0};function Jo(t,e,n={}){const{from:r,to:i,empty:o}=t.selection,l=e?$t(e,t.schema):null,c=[];t.doc.nodesBetween(r,i,(m,g)=>{if(m.isText)return;const y=Math.max(r,g),C=Math.min(i,g+m.nodeSize);c.push({node:m,from:y,to:C})});const d=i-r,f=c.filter(m=>l?l.name===m.node.type.name:!0).filter(m=>ph(m.node.attrs,n,{strict:!1}));return o?!!f.length:f.reduce((m,g)=>m+g.to-g.from,0)>=d}var sL=(t,e={})=>({state:n,dispatch:r})=>{const i=$t(t,n.schema);return Jo(n,i,e)?TR(n,r):!1},lL=()=>({state:t,dispatch:e})=>G9(t,e),aL=t=>({state:e,dispatch:n})=>{const r=$t(t,e.schema);return IR(r)(e,n)},cL=()=>({state:t,dispatch:e})=>Z9(t,e);function Dp(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Ew(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}var uL=(t,e)=>({tr:n,state:r,dispatch:i})=>{let o=null,l=null;const c=Dp(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(o=$t(t,r.schema)),c==="mark"&&(l=Ji(t,r.schema));let d=!1;return n.selection.ranges.forEach(f=>{r.doc.nodesBetween(f.$from.pos,f.$to.pos,(h,m)=>{o&&o===h.type&&(d=!0,i&&n.setNodeMarkup(m,void 0,Ew(h.attrs,e))),l&&h.marks.length&&h.marks.forEach(g=>{l===g.type&&(d=!0,i&&n.addMark(m,m+h.nodeSize,l.create(Ew(g.attrs,e))))})})}),d},dL=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),fL=()=>({tr:t,dispatch:e})=>{if(e){const n=new Yn(t.doc);t.setSelection(n)}return!0},hL=()=>({state:t,dispatch:e})=>P9(t,e),pL=()=>({state:t,dispatch:e})=>q9(t,e),mL=()=>({state:t,dispatch:e})=>AR(t,e),gL=()=>({state:t,dispatch:e})=>OR(t,e),yL=()=>({state:t,dispatch:e})=>RR(t,e);function y2(t,e,n={},r={}){return hu(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var vL=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:o,dispatch:l,commands:c})=>{const{doc:d}=o;if(r.preserveWhitespace!=="full"){const f=y2(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return l&&o.replaceWith(0,d.content.size,f).setMeta("preventUpdate",!n),!0}return l&&o.setMeta("preventUpdate",!n),c.insertContentAt({from:0,to:d.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function Bx(t,e){const n=Ji(e,t.schema),{from:r,to:i,empty:o}=t.selection,l=[];o?(t.storedMarks&&l.push(...t.storedMarks),l.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,d=>{l.push(...d.marks)});const c=l.find(d=>d.type.name===n.name);return c?{...c.attrs}:{}}function jx(t,e){const n=new Cy(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function bL(t){for(let e=0;e{e(r)&&n.push({node:r,pos:i})}),n}function CL(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,o)=>{n(i)&&r.push({node:i,pos:o})}),r}function Ux(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function At(t){return e=>Ux(e.$from,t)}function be(t,e,n){return t.config[e]===void 0&&t.parent?be(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?be(t.parent,e,n):null}):t.config[e]}function Py(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=be(e,"addExtensions",n);return r?[e,...Py(r())]:e}).flat(10)}function Fy(t,e){const n=rl.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function Px(t){return typeof t=="function"}function Ge(t,e=void 0,...n){return Px(t)?e?t.bind(e)(...n):t(...n):t}function wL(t={}){return Object.keys(t).length===0&&t.constructor===Object}function va(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Fx(t){const e=[],{nodeExtensions:n,markExtensions:r}=va(t),i=[...n,...r],o={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(l=>{const c={name:l.name,options:l.options,storage:l.storage,extensions:i},d=be(l,"addGlobalAttributes",c);if(!d)return;d().forEach(h=>{h.types.forEach(m=>{Object.entries(h.attributes).forEach(([g,y])=>{e.push({type:m,name:g,attribute:{...o,...y}})})})})}),i.forEach(l=>{const c={name:l.name,options:l.options,storage:l.storage},d=be(l,"addAttributes",c);if(!d)return;const f=d();Object.entries(f).forEach(([h,m])=>{const g={...o,...m};typeof g?.default=="function"&&(g.default=g.default()),g?.isRequired&&g?.default===void 0&&delete g.default,e.push({type:l.name,name:h,attribute:g})})}),e}function Pe(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,o])=>{if(!r[i]){r[i]=o;return}if(i==="class"){const c=o?String(o).split(" "):[],d=r[i]?r[i].split(" "):[],f=c.filter(h=>!d.includes(h));r[i]=[...d,...f].join(" ")}else if(i==="style"){const c=o?o.split(";").map(h=>h.trim()).filter(Boolean):[],d=r[i]?r[i].split(";").map(h=>h.trim()).filter(Boolean):[],f=new Map;d.forEach(h=>{const[m,g]=h.split(":").map(y=>y.trim());f.set(m,g)}),c.forEach(h=>{const[m,g]=h.split(":").map(y=>y.trim());f.set(m,g)}),r[i]=Array.from(f.entries()).map(([h,m])=>`${h}: ${m}`).join("; ")}else r[i]=o}),r},{})}function pu(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>Pe(n,r),{})}function xL(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Mw(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((o,l)=>{const c=l.attribute.parseHTML?l.attribute.parseHTML(n):xL(n.getAttribute(l.name));return c==null?o:{...o,[l.name]:c}},{});return{...r,...i}}}}function Aw(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&wL(n)?!1:n!=null))}function Nw(t){var e,n;const r={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function SL(t,e){var n;const r=Fx(t),{nodeExtensions:i,markExtensions:o}=va(t),l=(n=i.find(f=>be(f,"topNode")))==null?void 0:n.name,c=Object.fromEntries(i.map(f=>{const h=r.filter(k=>k.type===f.name),m={name:f.name,options:f.options,storage:f.storage,editor:e},g=t.reduce((k,A)=>{const N=be(A,"extendNodeSchema",m);return{...k,...N?N(f):{}}},{}),y=Aw({...g,content:Ge(be(f,"content",m)),marks:Ge(be(f,"marks",m)),group:Ge(be(f,"group",m)),inline:Ge(be(f,"inline",m)),atom:Ge(be(f,"atom",m)),selectable:Ge(be(f,"selectable",m)),draggable:Ge(be(f,"draggable",m)),code:Ge(be(f,"code",m)),whitespace:Ge(be(f,"whitespace",m)),linebreakReplacement:Ge(be(f,"linebreakReplacement",m)),defining:Ge(be(f,"defining",m)),isolating:Ge(be(f,"isolating",m)),attrs:Object.fromEntries(h.map(Nw))}),C=Ge(be(f,"parseHTML",m));C&&(y.parseDOM=C.map(k=>Mw(k,h)));const w=be(f,"renderHTML",m);w&&(y.toDOM=k=>w({node:k,HTMLAttributes:pu(k,h)}));const x=be(f,"renderText",m);return x&&(y.toText=x),[f.name,y]})),d=Object.fromEntries(o.map(f=>{const h=r.filter(x=>x.type===f.name),m={name:f.name,options:f.options,storage:f.storage,editor:e},g=t.reduce((x,k)=>{const A=be(k,"extendMarkSchema",m);return{...x,...A?A(f):{}}},{}),y=Aw({...g,inclusive:Ge(be(f,"inclusive",m)),excludes:Ge(be(f,"excludes",m)),group:Ge(be(f,"group",m)),spanning:Ge(be(f,"spanning",m)),code:Ge(be(f,"code",m)),attrs:Object.fromEntries(h.map(Nw))}),C=Ge(be(f,"parseHTML",m));C&&(y.parseDOM=C.map(x=>Mw(x,h)));const w=be(f,"renderHTML",m);return w&&(y.toDOM=x=>w({mark:x,HTMLAttributes:pu(x,h)})),[f.name,y]}));return new w9({topNode:l,nodes:c,marks:d})}function TL(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function $y(t){return t.sort((n,r)=>{const i=be(n,"priority")||100,o=be(r,"priority")||100;return i>o?-1:ir.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function qx(t,e,n){const{from:r,to:i}=e,{blockSeparator:o=` +`))),0,0),t.someProp("transformPasted",g=>{c=g(c,t,!0)}),c;let m=t.someProp("clipboardTextParser",g=>g(e,i,r,t));if(m)c=m;else{let g=i.marks(),{schema:y}=t.state,C=rl.fromSchema(y);l=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(w=>{let x=l.appendChild(document.createElement("p"));w&&x.appendChild(C.serializeNode(y.text(w,g)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),l=OO(n),Lu&&DO(l);let f=l&&l.querySelector("[data-pm-slice]"),h=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let m=+h[3];m>0;m--){let g=l.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;l=g}if(c||(c=(t.someProp("clipboardParser")||t.someProp("domParser")||qc.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(d||h),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!AO.test(g.parentNode.nodeName)?{ignore:!0}:null}})),h)c=LO(fw(c,+h[1],+h[2]),h[4]);else if(c=ce.maxOpen(NO(c.content,i),!0),c.openStart||c.openEnd){let m=0,g=0;for(let y=c.content.firstChild;m{c=m(c,t,d)}),c}const AO=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function NO(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),o,l=[];if(t.forEach(c=>{if(!l)return;let d=i.findWrapping(c.type),f;if(!d)return l=null;if(f=l.length&&o.length&&yx(d,o,c,l[l.length-1],0))l[l.length-1]=f;else{l.length&&(l[l.length-1]=vx(l[l.length-1],o.length));let h=gx(c,d);l.push(h),i=i.matchType(h.type),o=d}}),l)return te.from(l)}return t}function gx(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,te.from(t));return t}function yx(t,e,n,r,i){if(i1&&(o=0),i=n&&(c=e<0?l.contentMatchAt(0).fillBefore(c,o<=i).append(c):c.append(l.contentMatchAt(l.childCount).fillBefore(te.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,l.copy(c))}function fw(t,e,n){return en})),r0.createHTML(t)):t}function OO(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Cx().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&bx[r[1].toLowerCase()])&&(t=i.map(o=>"<"+o+">").join("")+t+i.map(o=>"").reverse().join("")),n.innerHTML=RO(t),i)for(let o=0;o=0;c-=2){let d=n.nodes[r[c]];if(!d||d.hasRequiredAttrs())break;i=te.from(d.create(r[c+1],i)),o++,l++}return new ce(i,o,l)}const Ln={},_n={},_O={touchstart:!0,touchmove:!0};class HO{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function IO(t){for(let e in Ln){let n=Ln[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{BO(t,r)&&!Dy(t,r)&&(t.editable||!(r.type in _n))&&n(t,r)},_O[e]?{passive:!0}:void 0)}Tn&&t.dom.addEventListener("input",()=>null),g2(t)}function Po(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function zO(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function g2(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Dy(t,r))})}function Dy(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function BO(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function jO(t,e){!Dy(t,e)&&Ln[e.type]&&(t.editable||!(e.type in _n))&&Ln[e.type](t,e)}_n.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!xx(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Fi&&en&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),ya&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,Os(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||MO(t,n)?n.preventDefault():Po(t,"key")};_n.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};_n.keypress=(t,e)=>{let n=e;if(xx(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Tr&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof ue)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),o=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",l=>l(t,r.$from.pos,r.$to.pos,i,o))&&t.dispatch(o()),n.preventDefault()}};function Ap(t){return{left:t.clientX,top:t.clientY}}function VO(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Ly(t,e,n,r,i){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let l=o.depth+1;l>0;l--)if(t.someProp(e,c=>l>o.depth?c(t,n,o.nodeAfter,o.before(l),i,!0):c(t,n,o.node(l),o.before(l),i,!1)))return!0;return!1}function sa(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function UO(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&me.isSelectable(r)?(sa(t,new me(n)),!0):!1}function PO(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof me&&(r=n.node);let o=t.state.doc.resolve(e);for(let l=o.depth+1;l>0;l--){let c=l>o.depth?o.nodeAfter:o.node(l);if(me.isSelectable(c)){r&&n.$from.depth>0&&l>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?i=o.before(n.$from.depth):i=o.before(l);break}}return i!=null?(sa(t,me.create(t.state.doc,i)),!0):!1}function FO(t,e,n,r,i){return Ly(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?PO(t,n):UO(t,n))}function $O(t,e,n,r){return Ly(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function qO(t,e,n,r){return Ly(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||ZO(t,n,r)}function ZO(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(sa(t,ue.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o),c=i.before(o);if(l.inlineContent)sa(t,ue.create(r,c+1,c+1+l.content.size));else if(me.isSelectable(l))sa(t,me.create(r,c));else continue;return!0}}function _y(t){return uh(t)}const wx=Tr?"metaKey":"ctrlKey";Ln.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=_y(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&VO(n,t.input.lastClick)&&!n[wx]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:o,button:n.button};let l=t.posAtCoords(Ap(n));l&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new KO(t,l,n,!!r)):(o=="doubleClick"?$O:qO)(t,l.pos,l.inside,n)?n.preventDefault():Po(t,"pointer"))};class KO{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[wx],this.allowDefault=r.shiftKey;let o,l;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),l=n.inside;else{let h=e.state.doc.resolve(n.pos);o=h.parent,l=h.depth?h.before():0}const c=i?null:r.target,d=c?e.docView.nearestDesc(c,!0):null;this.target=d&&d.nodeDOM.nodeType==1?d.nodeDOM:null;let{selection:f}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||f instanceof me&&f.from<=l&&f.to>l)&&(this.mightDrag={node:o,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Mr&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Po(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Zi(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Ap(e))),this.updateAllowDefault(e),this.allowDefault||!n?Po(this.view,"pointer"):FO(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Tn&&this.mightDrag&&!this.mightDrag.node.isAtom||en&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(sa(this.view,Se.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Po(this.view,"pointer")}move(e){this.updateAllowDefault(e),Po(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Ln.touchstart=t=>{t.input.lastTouch=Date.now(),_y(t),Po(t,"pointer")};Ln.touchmove=t=>{t.input.lastTouch=Date.now(),Po(t,"pointer")};Ln.contextmenu=t=>_y(t);function xx(t,e){return t.composing?!0:Tn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const GO=Fi?5e3:-1;_n.compositionstart=_n.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof ue&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||en&&Q9&&YO(t)))t.markCursor=t.state.storedMarks||n.marks(),uh(t,!0),t.markCursor=null;else if(uh(t,!e.selection.empty),Mr&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let l=o<0?i.lastChild:i.childNodes[o-1];if(!l)break;if(l.nodeType==3){let c=t.domSelection();c&&c.collapse(l,l.nodeValue.length);break}else i=l,o=-1}}t.input.composing=!0}Sx(t,GO)};function YO(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}_n.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Sx(t,20))};function Sx(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>uh(t),e))}function Tx(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=JO());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function WO(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=PR(e.focusNode,e.focusOffset),r=FR(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let l=n.pmViewDesc;if(!(!l||!l.isText(n.nodeValue)))return r}}return n||r}function JO(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function uh(t,e=!1){if(!(Fi&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Tx(t),e||t.docView&&t.docView.dirty){let n=Ny(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function XO(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const uu=Wn&&Zo<15||ya&&KR<604;Ln.copy=_n.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=uu?null:n.clipboardData,l=r.content(),{dom:c,text:d}=Oy(t,l);o?(n.preventDefault(),o.clearData(),o.setData("text/html",c.innerHTML),o.setData("text/plain",d)):XO(t,c),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function QO(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function eD(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?du(t,r.value,null,i,e):du(t,r.textContent,r.innerHTML,i,e)},50)}function du(t,e,n,r,i){let o=mx(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",d=>d(t,i,o||ce.empty)))return!0;if(!o)return!1;let l=QO(o),c=l?t.state.tr.replaceSelectionWith(l,r):t.state.tr.replaceSelection(o);return t.dispatch(c.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function kx(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}_n.paste=(t,e)=>{let n=e;if(t.composing&&!Fi)return;let r=uu?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&du(t,kx(r),r.getData("text/html"),i,n)?n.preventDefault():eD(t,n)};class Ex{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const tD=Tr?"altKey":"ctrlKey";function Mx(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[tD]}Ln.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,o=i.empty?null:t.posAtCoords(Ap(n)),l;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof me?i.to-1:i.to))){if(r&&r.mightDrag)l=me.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let m=t.docView.nearestDesc(n.target,!0);m&&m.node.type.spec.draggable&&m!=t.docView&&(l=me.create(t.state.doc,m.posBefore))}}let c=(l||t.state.selection).content(),{dom:d,text:f,slice:h}=Oy(t,c);(!n.dataTransfer.files.length||!en||X9>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(uu?"Text":"text/html",d.innerHTML),n.dataTransfer.effectAllowed="copyMove",uu||n.dataTransfer.setData("text/plain",f),t.dragging=new Ex(h,Mx(t,n),l)};Ln.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};_n.dragover=_n.dragenter=(t,e)=>e.preventDefault();_n.drop=(t,e)=>{try{nD(t,e,t.dragging)}finally{t.dragging=null}};function nD(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Ap(e));if(!r)return;let i=t.state.doc.resolve(r.pos),o=n&&n.slice;o?t.someProp("transformPasted",y=>{o=y(o,t,!1)}):o=mx(t,kx(e.dataTransfer),uu?null:e.dataTransfer.getData("text/html"),!1,i);let l=!!(n&&Mx(t,e));if(t.someProp("handleDrop",y=>y(t,e,o||ce.empty,l))){e.preventDefault();return}if(!o)return;e.preventDefault();let c=o?D9(t.state.doc,i.pos,o):i.pos;c==null&&(c=i.pos);let d=t.state.tr;if(l){let{node:y}=n;y?y.replace(d):d.deleteSelection()}let f=d.mapping.map(c),h=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,m=d.doc;if(h?d.replaceRangeWith(f,f,o.content.firstChild):d.replaceRange(f,f,o),d.doc.eq(m))return;let g=d.doc.resolve(f);if(h&&me.isSelectable(o.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(o.content.firstChild))d.setSelection(new me(g));else{let y=d.mapping.map(c);d.mapping.maps[d.mapping.maps.length-1].forEach((C,w,x,k)=>y=k),d.setSelection(Ry(t,g,d.doc.resolve(y)))}t.focus(),t.dispatch(d.setMeta("uiEvent","drop"))}Ln.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Zi(t)},20))};Ln.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Ln.beforeinput=(t,e)=>{if(en&&Fi&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,Os(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in _n)Ln[t]=_n[t];function fu(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class dh{constructor(e,n){this.toDOM=e,this.spec=n||Bs,this.side=this.spec.side||0}map(e,n,r,i){let{pos:o,deleted:l}=e.mapResult(n.from+i,this.side<0?-1:1);return l?null:new Ft(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof dh&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&fu(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Go{constructor(e,n){this.attrs=e,this.spec=n||Bs}map(e,n,r,i){let o=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,l=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=l?null:new Ft(o,l,this)}valid(e,n){return n.from=e&&(!o||o(c.spec))&&r.push(c.copy(c.from+i,c.to+i))}for(let l=0;le){let c=this.children[l]+1;this.children[l+2].findInner(e-c,n-c,r,i+c,o)}}map(e,n,r){return this==bn||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Bs)}mapInner(e,n,r,i,o){let l;for(let c=0;c{let f=d+r,h;if(h=Nx(n,c,f)){for(i||(i=this.children.slice());oc&&m.to=e){this.children[c]==e&&(r=this.children[c+2]);break}let o=e+1,l=o+n.content.size;for(let c=0;co&&d.type instanceof Go){let f=Math.max(o,d.from)-o,h=Math.min(l,d.to)-o;fi.map(e,n,Bs));return zo.from(r)}forChild(e,n){if(n.isLeaf)return Qe.empty;let r=[];for(let i=0;in instanceof Qe)?e:e.reduce((n,r)=>n.concat(r instanceof Qe?r:r.members),[]))}}forEachSet(e){for(let n=0;n{let x=w-C-(y-g);for(let k=0;kA+h-m)continue;let N=c[k]+h-m;y>=N?c[k+1]=g<=N?-2:-1:g>=h&&x&&(c[k]+=x,c[k+1]+=x)}m+=x}),h=n.maps[f].map(h,-1)}let d=!1;for(let f=0;f=r.content.size){d=!0;continue}let g=n.map(t[f+1]+o,-1),y=g-i,{index:C,offset:w}=r.content.findIndex(m),x=r.maybeChild(C);if(x&&w==m&&w+x.nodeSize==y){let k=c[f+2].mapInner(n,x,h+1,t[f]+o+1,l);k!=bn?(c[f]=m,c[f+1]=y,c[f+2]=k):(c[f+1]=-2,d=!0)}else d=!0}if(d){let f=iD(c,t,e,n,i,o,l),h=fh(f,r,0,l);e=h.local;for(let m=0;mn&&l.to{let f=Nx(t,c,d+n);if(f){o=!0;let h=fh(f,c,n+d+1,r);h!=bn&&i.push(d,d+c.nodeSize,h)}});let l=Ax(o?Rx(t):t,-n).sort(js);for(let c=0;c0;)e++;t.splice(e,0,n)}function i0(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=bn&&e.push(r)}),t.cursorWrapper&&e.push(Qe.create(t.state.doc,[t.cursorWrapper.deco])),zo.from(e)}const oD={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},sD=Wn&&Zo<=11;class lD{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class aD{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new lD,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),sD&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,oD)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;nthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(sw(this.view)){if(this.suppressingSelectionUpdates)return Zi(this.view);if(Wn&&Zo<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&qs(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let o=e.focusNode;o;o=ga(o))n.add(o);for(let o=e.anchorNode;o;o=ga(o))if(n.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&sw(e)&&!this.ignoreSelectionChange(r),o=-1,l=-1,c=!1,d=[];if(e.editable)for(let h=0;hm.nodeName=="BR");if(h.length==2){let[m,g]=h;m.parentNode&&m.parentNode.parentNode==g.parentNode?g.remove():m.remove()}else{let{focusNode:m}=this.currentSelection;for(let g of h){let y=g.parentNode;y&&y.nodeName=="LI"&&(!m||dD(e,m)!=y)&&g.remove()}}}else if((en||Tn)&&d.some(h=>h.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let h of d)if(h.nodeName=="BR"&&h.parentNode){let m=h.nextSibling;m&&m.nodeType==1&&m.contentEditable=="false"&&h.parentNode.removeChild(h)}}let f=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(o>-1&&(e.docView.markDirty(o,l),cD(e)),this.handleDOMChange(o,l,c,d),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Zi(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let h=0;hi;x--){let k=r.childNodes[x-1],A=k.pmViewDesc;if(k.nodeName=="BR"&&!A){o=x;break}if(!A||A.size)break}let m=t.state.doc,g=t.someProp("domParser")||qc.fromSchema(t.state.schema),y=m.resolve(l),C=null,w=g.parse(r,{topNode:y.parent,topMatch:y.parent.contentMatchAt(y.index()),topOpen:!0,from:i,to:o,preserveWhitespace:y.parent.type.whitespace=="pre"?"full":!0,findPositions:f,ruleFromNode:hD,context:y});if(f&&f[0].pos!=null){let x=f[0].pos,k=f[1]&&f[1].pos;k==null&&(k=x),C={anchor:x+l,head:k+l}}return{doc:w,sel:C,from:l,to:c}}function hD(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Tn&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||Tn&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const pD=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function mD(t,e,n,r,i){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let _=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,$=Ny(t,_);if($&&!t.state.selection.eq($)){if(en&&Fi&&t.input.lastKeyCode===13&&Date.now()-100U(t,Os(13,"Enter"))))return;let J=t.state.tr.setSelection($);_=="pointer"?J.setMeta("pointer",!0):_=="key"&&J.scrollIntoView(),o&&J.setMeta("composition",o),t.dispatch(J)}return}let l=t.state.doc.resolve(e),c=l.sharedDepth(n);e=l.before(c+1),n=t.state.doc.resolve(n).after(c+1);let d=t.state.selection,f=fD(t,e,n),h=t.state.doc,m=h.slice(f.from,f.to),g,y;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||Fi)&&i.some(_=>_.nodeType==1&&!pD.test(_.nodeName))&&(!C||C.endA>=C.endB)&&t.someProp("handleKeyDown",_=>_(t,Os(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!C)if(r&&d instanceof ue&&!d.empty&&d.$head.sameParent(d.$anchor)&&!t.composing&&!(f.sel&&f.sel.anchor!=f.sel.head))C={start:d.from,endA:d.to,endB:d.to};else{if(f.sel){let _=vw(t,t.state.doc,f.sel);if(_&&!_.eq(t.state.selection)){let $=t.state.tr.setSelection(_);o&&$.setMeta("composition",o),t.dispatch($)}}return}t.state.selection.fromt.state.selection.from&&C.start<=t.state.selection.from+2&&t.state.selection.from>=f.from?C.start=t.state.selection.from:C.endA=t.state.selection.to-2&&t.state.selection.to<=f.to&&(C.endB+=t.state.selection.to-C.endA,C.endA=t.state.selection.to)),Wn&&Zo<=11&&C.endB==C.start+1&&C.endA==C.start&&C.start>f.from&&f.doc.textBetween(C.start-f.from-1,C.start-f.from+1)=="  "&&(C.start--,C.endA--,C.endB--);let w=f.doc.resolveNoCache(C.start-f.from),x=f.doc.resolveNoCache(C.endB-f.from),k=h.resolve(C.start),A=w.sameParent(x)&&w.parent.inlineContent&&k.end()>=C.endA;if((ya&&t.input.lastIOSEnter>Date.now()-225&&(!A||i.some(_=>_.nodeName=="DIV"||_.nodeName=="P"))||!A&&w.pos_(t,Os(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>C.start&&yD(h,C.start,C.endA,w,x)&&t.someProp("handleKeyDown",_=>_(t,Os(8,"Backspace")))){Fi&&en&&t.domObserver.suppressSelectionUpdates();return}en&&C.endB==C.start&&(t.input.lastChromeDelete=Date.now()),Fi&&!A&&w.start()!=x.start()&&x.parentOffset==0&&w.depth==x.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==C.endA&&(C.endB-=2,x=f.doc.resolveNoCache(C.endB-f.from),setTimeout(()=>{t.someProp("handleKeyDown",function(_){return _(t,Os(13,"Enter"))})},20));let N=C.start,R=C.endA,L=_=>{let $=_||t.state.tr.replace(N,R,f.doc.slice(C.start-f.from,C.endB-f.from));if(f.sel){let J=vw(t,$.doc,f.sel);J&&!(en&&t.composing&&J.empty&&(C.start!=C.endB||t.input.lastChromeDeleteZi(t),20));let _=L(t.state.tr.delete(N,R)),$=h.resolve(C.start).marksAcross(h.resolve(C.endA));$&&_.ensureMarks($),t.dispatch(_)}else if(C.endA==C.endB&&(z=gD(w.parent.content.cut(w.parentOffset,x.parentOffset),k.parent.content.cut(k.parentOffset,C.endA-k.start())))){let _=L(t.state.tr);z.type=="add"?_.addMark(N,R,z.mark):_.removeMark(N,R,z.mark),t.dispatch(_)}else if(w.parent.child(w.index()).isText&&w.index()==x.index()-(x.textOffset?0:1)){let _=w.parent.textBetween(w.parentOffset,x.parentOffset),$=()=>L(t.state.tr.insertText(_,N,R));t.someProp("handleTextInput",J=>J(t,N,R,_,$))||t.dispatch($())}else t.dispatch(L());else t.dispatch(L())}function vw(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Ry(t,e.resolve(n.anchor),e.resolve(n.head))}function gD(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,o=r,l,c,d;for(let h=0;hh.mark(c.addToSet(h.marks));else if(i.length==0&&o.length==1)c=o[0],l="remove",d=h=>h.mark(c.removeFromSet(h.marks));else return null;let f=[];for(let h=0;hn||o0(l,!0,!1)0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let o=t.node(r).maybeChild(t.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function vD(t,e,n,r,i){let o=t.findDiffStart(e,n);if(o==null)return null;let{a:l,b:c}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let d=Math.max(0,o-Math.min(l,c));r-=l+d-o}if(l=l?o-r:0;o-=d,o&&o=c?o-r:0;o-=d,o&&o=56320&&e<=57343&&n>=55296&&n<=56319}class Ox{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new HO,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Tw),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=xw(this),ww(this),this.nodeViews=Sw(this),this.docView=ew(this.state.doc,Cw(this),i0(this),this.dom,this),this.domObserver=new aD(this,(r,i,o,l)=>mD(this,r,i,o,l)),this.domObserver.start(),IO(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&g2(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Tw),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,o=!1,l=!1;e.storedMarks&&this.composing&&(Tx(this),l=!0),this.state=e;let c=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(c||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let y=Sw(this);CD(y,this.nodeViews)&&(this.nodeViews=y,o=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&g2(this),this.editable=xw(this),ww(this);let d=i0(this),f=Cw(this),h=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",m=o||!this.docView.matchesNode(e.doc,f,d);(m||!e.selection.eq(i.selection))&&(l=!0);let g=h=="preserve"&&l&&this.dom.style.overflowAnchor==null&&WR(this);if(l){this.domObserver.stop();let y=m&&(Wn||en)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&bD(i.selection,e.selection);if(m){let C=en?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=WO(this)),(o||!this.docView.update(e.doc,f,d,this))&&(this.docView.updateOuterDeco(f),this.docView.destroy(),this.docView=ew(e.doc,f,d,this.dom,this)),C&&!this.trackWrites&&(y=!0)}y||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&CO(this))?Zi(this,y):(fx(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),h=="reset"?this.dom.scrollTop=0:h=="to selection"?this.scrollToSelection():g&&JR(g)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof me){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&G7(this,n.getBoundingClientRect(),e)}else G7(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n0&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new Ex(e.slice,e.move,i<0?void 0:me.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let l=0;ln.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return rO(this,e)}coordsAtPos(e,n=1){return ix(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return aO(this,n||this.state,e)}pasteHTML(e,n){return du(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return du(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Oy(this,e)}destroy(){this.docView&&(zO(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],i0(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,VR())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return jO(this,e)}domSelectionRange(){let e=this.domSelection();return e?Tn&&this.root.nodeType===11&&qR(this.dom.ownerDocument)==this.dom&&uD(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Ox.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Cw(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Ft.node(0,t.state.doc.content.size,e)]}function ww(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Ft.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function xw(t){return!t.someProp("editable",e=>e(t.state)===!1)}function bD(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Sw(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function CD(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function Tw(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Wo={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},hh={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},wD=typeof navigator<"u"&&/Mac/.test(navigator.platform),xD=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var mn=0;mn<10;mn++)Wo[48+mn]=Wo[96+mn]=String(mn);for(var mn=1;mn<=24;mn++)Wo[mn+111]="F"+mn;for(var mn=65;mn<=90;mn++)Wo[mn]=String.fromCharCode(mn+32),hh[mn]=String.fromCharCode(mn);for(var s0 in Wo)hh.hasOwnProperty(s0)||(hh[s0]=Wo[s0]);function SD(t){var e=wD&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||xD&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?hh:Wo)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const TD=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),kD=typeof navigator<"u"&&/Win/.test(navigator.platform);function ED(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,o,l;for(let c=0;c{for(var n in e)ND(t,n,{get:e[n],enumerable:!0})};function Np(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:o}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,o=n.storedMarks,n}}}var Rp=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,o=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([l,c])=>[l,(...f)=>{const h=c(...f)(o);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),h}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:o}=r,l=[],c=!!t,d=t||i.tr,f=()=>(!c&&e&&!d.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(d),l.every(m=>m===!0)),h={...Object.fromEntries(Object.entries(n).map(([m,g])=>[m,(...C)=>{const w=this.buildProps(d,e),x=g(...C)(w);return l.push(x),h}])),run:f};return h}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,o=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([c,d])=>[c,(...f)=>d(...f)({...o,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:o}=r,l={tr:t,editor:r,view:o,state:Np({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([c,d])=>[c,(...f)=>d(...f)(l)]))}};return l}},Dx={};By(Dx,{blur:()=>RD,clearContent:()=>OD,clearNodes:()=>DD,command:()=>LD,createParagraphNear:()=>_D,cut:()=>HD,deleteCurrentNode:()=>ID,deleteNode:()=>zD,deleteRange:()=>BD,deleteSelection:()=>jD,enter:()=>VD,exitCode:()=>UD,extendMarkRange:()=>PD,first:()=>FD,focus:()=>$D,forEach:()=>qD,insertContent:()=>ZD,insertContentAt:()=>YD,joinBackward:()=>XD,joinDown:()=>JD,joinForward:()=>QD,joinItemBackward:()=>eL,joinItemForward:()=>tL,joinTextblockBackward:()=>nL,joinTextblockForward:()=>rL,joinUp:()=>WD,keyboardShortcut:()=>oL,lift:()=>sL,liftEmptyBlock:()=>lL,liftListItem:()=>aL,newlineInCode:()=>cL,resetAttributes:()=>uL,scrollIntoView:()=>dL,selectAll:()=>fL,selectNodeBackward:()=>hL,selectNodeForward:()=>pL,selectParentNode:()=>mL,selectTextblockEnd:()=>gL,selectTextblockStart:()=>yL,setContent:()=>vL,setMark:()=>HL,setMeta:()=>IL,setNode:()=>zL,setNodeSelection:()=>BL,setTextDirection:()=>jL,setTextSelection:()=>VL,sinkListItem:()=>UL,splitBlock:()=>PL,splitListItem:()=>FL,toggleList:()=>$L,toggleMark:()=>qL,toggleNode:()=>ZL,toggleWrap:()=>KL,undoInputRule:()=>GL,unsetAllMarks:()=>YL,unsetMark:()=>WL,unsetTextDirection:()=>JL,updateAttributes:()=>XL,wrapIn:()=>QL,wrapInList:()=>e_});var RD=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),OD=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),DD=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:o,$to:l})=>{t.doc.nodesBetween(o.pos,l.pos,(c,d)=>{if(c.type.isText)return;const{doc:f,mapping:h}=e,m=f.resolve(h.map(d)),g=f.resolve(h.map(d+c.nodeSize)),y=m.blockRange(g);if(!y)return;const C=Da(y);if(c.type.isTextblock){const{defaultType:w}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(y.start,w)}(C||C===0)&&e.lift(y,C)})}),!0},LD=t=>e=>t(e),_D=()=>({state:t,dispatch:e})=>K9(t,e),HD=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,o=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const l=r.mapping.map(e);return r.insert(l,o.content),r.setSelection(new ue(r.doc.resolve(Math.max(l-1,0)))),!0},ID=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===r.type){if(e){const c=i.before(o),d=i.after(o);t.delete(c,d).scrollIntoView()}return!0}return!1};function $t(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var zD=t=>({tr:e,state:n,dispatch:r})=>{const i=$t(t,n.schema),o=e.selection.$anchor;for(let l=o.depth;l>0;l-=1)if(o.node(l).type===i){if(r){const d=o.before(l),f=o.after(l);e.delete(d,f).scrollIntoView()}return!0}return!1},BD=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},jD=()=>({state:t,dispatch:e})=>Sy(t,e),VD=()=>({commands:t})=>t.keyboardShortcut("Enter"),UD=()=>({state:t,dispatch:e})=>kR(t,e);function jy(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function ph(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:jy(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Lx(t,e,n={}){return t.find(r=>r.type===e&&ph(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function kw(t,e,n={}){return!!Lx(t,e,n)}function Vy(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(h=>h.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(h=>h.type===e)||(n=n||((r=i.node.marks[0])==null?void 0:r.attrs),!Lx([...i.node.marks],e,n)))return;let l=i.index,c=t.start()+i.offset,d=l+1,f=c+i.node.nodeSize;for(;l>0&&kw([...t.parent.child(l-1).marks],e,n);)l-=1,c-=t.parent.child(l).nodeSize;for(;d({tr:n,state:r,dispatch:i})=>{const o=Ji(t,r.schema),{doc:l,selection:c}=n,{$from:d,from:f,to:h}=c;if(i){const m=Vy(d,o,e);if(m&&m.from<=f&&m.to>=h){const g=ue.create(l,m.from,m.to);n.setSelection(g)}}return!0},FD=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r({editor:n,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};const l=()=>{(Op()||Hx())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!Uy(n.state.selection))return l(),!0;const c=_x(i.doc,t)||n.state.selection,d=n.state.selection.eq(c);return o&&(d||i.setSelection(c),d&&i.storedMarks&&i.setStoredMarks(i.storedMarks),l()),!0},qD=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),ZD=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Ix=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Ix(r)}return t};function mf(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`${t}`,n=new window.DOMParser().parseFromString(e,"text/html").body;return Ix(n)}function hu(t,e,n){if(t instanceof Gn||t instanceof te)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return te.fromArray(t.map(c=>e.nodeFromJSON(c)));const l=e.nodeFromJSON(t);return n.errorOnInvalidContent&&l.check(),l}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),hu("",e,n)}if(i){if(n.errorOnInvalidContent){let l=!1,c="";const d=new w9({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:f=>(l=!0,c=typeof f=="string"?f:f.outerHTML,null)}]}})});if(n.slice?qc.fromSchema(d).parseSlice(mf(t),n.parseOptions):qc.fromSchema(d).parse(mf(t),n.parseOptions),n.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const o=qc.fromSchema(e);return n.slice?o.parseSlice(mf(t),n.parseOptions).content:o.parse(mf(t),n.parseOptions)}return hu("",e,n)}function KD(t,e,n){const r=t.steps.length-1;if(r{l===0&&(l=h)}),t.setSelection(Se.near(t.doc.resolve(l),n))}var GD=t=>!("type"in t),YD=(t,e,n)=>({tr:r,dispatch:i,editor:o})=>{var l;if(i){n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let c;const d=x=>{o.emit("contentError",{editor:o,error:x,disableCollaboration:()=>{"collaboration"in o.storage&&typeof o.storage.collaboration=="object"&&o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},f={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{hu(e,o.schema,{parseOptions:f,errorOnInvalidContent:!0})}catch(x){d(x)}try{c=hu(e,o.schema,{parseOptions:f,errorOnInvalidContent:(l=n.errorOnInvalidContent)!=null?l:o.options.enableContentCheck})}catch(x){return d(x),!1}let{from:h,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,y=!0;if((GD(c)?c:[c]).forEach(x=>{x.check(),g=g?x.isText&&x.marks.length===0:!1,y=y?x.isBlock:!1}),h===m&&y){const{parent:x}=r.doc.resolve(h);x.isTextblock&&!x.type.spec.code&&!x.childCount&&(h-=1,m+=1)}let w;if(g){if(Array.isArray(e))w=e.map(x=>x.text||"").join("");else if(e instanceof te){let x="";e.forEach(k=>{k.text&&(x+=k.text)}),w=x}else typeof e=="object"&&e&&e.text?w=e.text:w=e;r.insertText(w,h,m)}else{w=c;const x=r.doc.resolve(h),k=x.node(),A=x.parentOffset===0,N=k.isText||k.isTextblock,R=k.content.size>0;A&&N&&R&&(h=Math.max(0,h-1)),r.replaceWith(h,m,w)}n.updateSelection&&KD(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:h,text:w}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:h,text:w})}return!0},WD=()=>({state:t,dispatch:e})=>xR(t,e),JD=()=>({state:t,dispatch:e})=>SR(t,e),XD=()=>({state:t,dispatch:e})=>V9(t,e),QD=()=>({state:t,dispatch:e})=>$9(t,e),eL=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Sp(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},tL=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Sp(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},nL=()=>({state:t,dispatch:e})=>CR(t,e),rL=()=>({state:t,dispatch:e})=>wR(t,e);function zx(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function iL(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,o,l;for(let c=0;c({editor:e,view:n,tr:r,dispatch:i})=>{const o=iL(t).split(/-(?!$)/),l=o.find(f=>!["Alt","Ctrl","Meta","Shift"].includes(f)),c=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),d=e.captureTransaction(()=>{n.someProp("handleKeyDown",f=>f(n,c))});return d?.steps.forEach(f=>{const h=f.map(r.mapping);h&&i&&r.maybeStep(h)}),!0};function Jo(t,e,n={}){const{from:r,to:i,empty:o}=t.selection,l=e?$t(e,t.schema):null,c=[];t.doc.nodesBetween(r,i,(m,g)=>{if(m.isText)return;const y=Math.max(r,g),C=Math.min(i,g+m.nodeSize);c.push({node:m,from:y,to:C})});const d=i-r,f=c.filter(m=>l?l.name===m.node.type.name:!0).filter(m=>ph(m.node.attrs,n,{strict:!1}));return o?!!f.length:f.reduce((m,g)=>m+g.to-g.from,0)>=d}var sL=(t,e={})=>({state:n,dispatch:r})=>{const i=$t(t,n.schema);return Jo(n,i,e)?TR(n,r):!1},lL=()=>({state:t,dispatch:e})=>G9(t,e),aL=t=>({state:e,dispatch:n})=>{const r=$t(t,e.schema);return IR(r)(e,n)},cL=()=>({state:t,dispatch:e})=>Z9(t,e);function Dp(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Ew(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}var uL=(t,e)=>({tr:n,state:r,dispatch:i})=>{let o=null,l=null;const c=Dp(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(o=$t(t,r.schema)),c==="mark"&&(l=Ji(t,r.schema));let d=!1;return n.selection.ranges.forEach(f=>{r.doc.nodesBetween(f.$from.pos,f.$to.pos,(h,m)=>{o&&o===h.type&&(d=!0,i&&n.setNodeMarkup(m,void 0,Ew(h.attrs,e))),l&&h.marks.length&&h.marks.forEach(g=>{l===g.type&&(d=!0,i&&n.addMark(m,m+h.nodeSize,l.create(Ew(g.attrs,e))))})})}),d},dL=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),fL=()=>({tr:t,dispatch:e})=>{if(e){const n=new Yn(t.doc);t.setSelection(n)}return!0},hL=()=>({state:t,dispatch:e})=>P9(t,e),pL=()=>({state:t,dispatch:e})=>q9(t,e),mL=()=>({state:t,dispatch:e})=>AR(t,e),gL=()=>({state:t,dispatch:e})=>OR(t,e),yL=()=>({state:t,dispatch:e})=>RR(t,e);function y2(t,e,n={},r={}){return hu(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var vL=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:o,dispatch:l,commands:c})=>{const{doc:d}=o;if(r.preserveWhitespace!=="full"){const f=y2(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return l&&o.replaceWith(0,d.content.size,f).setMeta("preventUpdate",!n),!0}return l&&o.setMeta("preventUpdate",!n),c.insertContentAt({from:0,to:d.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function Bx(t,e){const n=Ji(e,t.schema),{from:r,to:i,empty:o}=t.selection,l=[];o?(t.storedMarks&&l.push(...t.storedMarks),l.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,d=>{l.push(...d.marks)});const c=l.find(d=>d.type.name===n.name);return c?{...c.attrs}:{}}function jx(t,e){const n=new Cy(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function bL(t){for(let e=0;e{e(r)&&n.push({node:r,pos:i})}),n}function CL(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,o)=>{n(i)&&r.push({node:i,pos:o})}),r}function Ux(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function At(t){return e=>Ux(e.$from,t)}function be(t,e,n){return t.config[e]===void 0&&t.parent?be(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?be(t.parent,e,n):null}):t.config[e]}function Py(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=be(e,"addExtensions",n);return r?[e,...Py(r())]:e}).flat(10)}function Fy(t,e){const n=rl.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function Px(t){return typeof t=="function"}function Ye(t,e=void 0,...n){return Px(t)?e?t.bind(e)(...n):t(...n):t}function wL(t={}){return Object.keys(t).length===0&&t.constructor===Object}function va(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Fx(t){const e=[],{nodeExtensions:n,markExtensions:r}=va(t),i=[...n,...r],o={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(l=>{const c={name:l.name,options:l.options,storage:l.storage,extensions:i},d=be(l,"addGlobalAttributes",c);if(!d)return;d().forEach(h=>{h.types.forEach(m=>{Object.entries(h.attributes).forEach(([g,y])=>{e.push({type:m,name:g,attribute:{...o,...y}})})})})}),i.forEach(l=>{const c={name:l.name,options:l.options,storage:l.storage},d=be(l,"addAttributes",c);if(!d)return;const f=d();Object.entries(f).forEach(([h,m])=>{const g={...o,...m};typeof g?.default=="function"&&(g.default=g.default()),g?.isRequired&&g?.default===void 0&&delete g.default,e.push({type:l.name,name:h,attribute:g})})}),e}function Fe(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,o])=>{if(!r[i]){r[i]=o;return}if(i==="class"){const c=o?String(o).split(" "):[],d=r[i]?r[i].split(" "):[],f=c.filter(h=>!d.includes(h));r[i]=[...d,...f].join(" ")}else if(i==="style"){const c=o?o.split(";").map(h=>h.trim()).filter(Boolean):[],d=r[i]?r[i].split(";").map(h=>h.trim()).filter(Boolean):[],f=new Map;d.forEach(h=>{const[m,g]=h.split(":").map(y=>y.trim());f.set(m,g)}),c.forEach(h=>{const[m,g]=h.split(":").map(y=>y.trim());f.set(m,g)}),r[i]=Array.from(f.entries()).map(([h,m])=>`${h}: ${m}`).join("; ")}else r[i]=o}),r},{})}function pu(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>Fe(n,r),{})}function xL(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Mw(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((o,l)=>{const c=l.attribute.parseHTML?l.attribute.parseHTML(n):xL(n.getAttribute(l.name));return c==null?o:{...o,[l.name]:c}},{});return{...r,...i}}}}function Aw(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&wL(n)?!1:n!=null))}function Nw(t){var e,n;const r={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function SL(t,e){var n;const r=Fx(t),{nodeExtensions:i,markExtensions:o}=va(t),l=(n=i.find(f=>be(f,"topNode")))==null?void 0:n.name,c=Object.fromEntries(i.map(f=>{const h=r.filter(k=>k.type===f.name),m={name:f.name,options:f.options,storage:f.storage,editor:e},g=t.reduce((k,A)=>{const N=be(A,"extendNodeSchema",m);return{...k,...N?N(f):{}}},{}),y=Aw({...g,content:Ye(be(f,"content",m)),marks:Ye(be(f,"marks",m)),group:Ye(be(f,"group",m)),inline:Ye(be(f,"inline",m)),atom:Ye(be(f,"atom",m)),selectable:Ye(be(f,"selectable",m)),draggable:Ye(be(f,"draggable",m)),code:Ye(be(f,"code",m)),whitespace:Ye(be(f,"whitespace",m)),linebreakReplacement:Ye(be(f,"linebreakReplacement",m)),defining:Ye(be(f,"defining",m)),isolating:Ye(be(f,"isolating",m)),attrs:Object.fromEntries(h.map(Nw))}),C=Ye(be(f,"parseHTML",m));C&&(y.parseDOM=C.map(k=>Mw(k,h)));const w=be(f,"renderHTML",m);w&&(y.toDOM=k=>w({node:k,HTMLAttributes:pu(k,h)}));const x=be(f,"renderText",m);return x&&(y.toText=x),[f.name,y]})),d=Object.fromEntries(o.map(f=>{const h=r.filter(x=>x.type===f.name),m={name:f.name,options:f.options,storage:f.storage,editor:e},g=t.reduce((x,k)=>{const A=be(k,"extendMarkSchema",m);return{...x,...A?A(f):{}}},{}),y=Aw({...g,inclusive:Ye(be(f,"inclusive",m)),excludes:Ye(be(f,"excludes",m)),group:Ye(be(f,"group",m)),spanning:Ye(be(f,"spanning",m)),code:Ye(be(f,"code",m)),attrs:Object.fromEntries(h.map(Nw))}),C=Ye(be(f,"parseHTML",m));C&&(y.parseDOM=C.map(x=>Mw(x,h)));const w=be(f,"renderHTML",m);return w&&(y.toDOM=x=>w({mark:x,HTMLAttributes:pu(x,h)})),[f.name,y]}));return new w9({topNode:l,nodes:c,marks:d})}function TL(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function $y(t){return t.sort((n,r)=>{const i=be(n,"priority")||100,o=be(r,"priority")||100;return i>o?-1:ir.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function qx(t,e,n){const{from:r,to:i}=e,{blockSeparator:o=` -`,textSerializers:l={}}=n||{};let c="";return t.nodesBetween(r,i,(d,f,h,m)=>{var g;d.isBlock&&f>r&&(c+=o);const y=l?.[d.type.name];if(y)return h&&(c+=y({node:d,pos:f,parent:h,index:m,range:e})),!1;d.isText&&(c+=(g=d?.text)==null?void 0:g.slice(Math.max(r,f)-f,i-f))}),c}function Zx(t,e){const n={from:0,to:t.content.size};return qx(t,n,e)}function qy(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function kL(t,e){const n=$t(e,t.schema),{from:r,to:i}=t.selection,o=[];t.doc.nodesBetween(r,i,c=>{o.push(c)});const l=o.reverse().find(c=>c.type.name===n.name);return l?{...l.attrs}:{}}function Kx(t,e){const n=Dp(typeof e=="string"?e:e.name,t.schema);return n==="node"?kL(t,e):n==="mark"?Bx(t,e):{}}function EL(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function ML(t){const e=EL(t);return e.length===1?e:e.filter((n,r)=>!e.filter((o,l)=>l!==r).some(o=>n.oldRange.from>=o.oldRange.from&&n.oldRange.to<=o.oldRange.to&&n.newRange.from>=o.newRange.from&&n.newRange.to<=o.newRange.to))}function Gx(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,o)=>{const l=[];if(i.ranges.length)i.forEach((c,d)=>{l.push({from:c,to:d})});else{const{from:c,to:d}=n[o];if(c===void 0||d===void 0)return;l.push({from:c,to:d})}l.forEach(({from:c,to:d})=>{const f=e.slice(o).map(c,-1),h=e.slice(o).map(d),m=e.invert().map(f,-1),g=e.invert().map(h);r.push({oldRange:{from:m,to:g},newRange:{from:f,to:h}})})}),ML(r)}function Zy(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const o=n.resolve(t),l=Vy(o,i.type);l&&r.push({mark:i,...l})}):n.nodesBetween(t,e,(i,o)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(l=>({from:o,to:o+i.nodeSize,mark:l})))}),r}var AL=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let o=r,l=null;for(;o>0&&l===null;){const c=i.node(o);c?.type.name===e?l=c:o-=1}return[l,o]};function a0(t,e){return e.nodes[t]||e.marks[t]||null}function Ff(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(o=>o.type===e&&o.name===r);return i?i.attribute.keepOnSplit:!1}))}var NL=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,o,l,c)=>{var d,f;const h=((f=(d=i.type.spec).toText)==null?void 0:f.call(d,{node:i,pos:o,parent:l,index:c}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?h:h.slice(0,Math.max(0,r-o))}),n};function v2(t,e,n={}){const{empty:r,ranges:i}=t.selection,o=e?Ji(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>o?o.name===m.type.name:!0).find(m=>ph(m.attrs,n,{strict:!1}));let l=0;const c=[];if(i.forEach(({$from:m,$to:g})=>{const y=m.pos,C=g.pos;t.doc.nodesBetween(y,C,(w,x)=>{if(!w.isText&&!w.marks.length)return;const k=Math.max(y,x),A=Math.min(C,x+w.nodeSize),N=A-k;l+=N,c.push(...w.marks.map(R=>({mark:R,from:k,to:A})))})}),l===0)return!1;const d=c.filter(m=>o?o.name===m.mark.type.name:!0).filter(m=>ph(m.mark.attrs,n,{strict:!1})).reduce((m,g)=>m+g.to-g.from,0),f=c.filter(m=>o?m.mark.type!==o&&m.mark.type.excludes(o):!0).reduce((m,g)=>m+g.to-g.from,0);return(d>0?d+f:d)>=l}function RL(t,e,n={}){if(!e)return Jo(t,null,n)||v2(t,null,n);const r=Dp(e,t.schema);return r==="node"?Jo(t,e,n):r==="mark"?v2(t,e,n):!1}var OL=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const o=At(c=>c.type.name===e)(t.selection);if(!o)return!1;const l=t.doc.resolve(o.pos+1);return i.pos+1===l.end()}return!(r.parentOffset{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function Rw(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Ow(t,e){const{nodeExtensions:n}=va(e),r=n.find(l=>l.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},o=Ge(be(r,"group",i));return typeof o!="string"?!1:o.split(" ").includes("list")}function Lp(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(o=>{i!==!1&&(Lp(o,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function Ky(t){return t instanceof me}var Gy=class Yx{constructor(e){this.position=e}static fromJSON(e){return new Yx(e.position)}toJSON(){return{position:this.position}}};function Wx(t,e){const n=e.mapping.mapResult(t.position);return{position:new Gy(n.pos),mapResult:n}}function LL(t){return new Gy(t)}function Jx(t,e,n){const i=t.state.doc.content.size,o=$i(e,0,i),l=$i(n,0,i),c=t.coordsAtPos(o),d=t.coordsAtPos(l,-1),f=Math.min(c.top,d.top),h=Math.max(c.bottom,d.bottom),m=Math.min(c.left,d.left),g=Math.max(c.right,d.right),y=g-m,C=h-f,k={top:f,bottom:h,left:m,right:g,width:y,height:C,x:m,y:f};return{...k,toJSON:()=>k}}function _L(t,e,n){var r;const{selection:i}=e;let o=null;if(Uy(i)&&(o=i.$cursor),o){const c=(r=t.storedMarks)!=null?r:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(c)||!c.some(f=>f.type.excludes(n)))}const{ranges:l}=i;return l.some(({$from:c,$to:d})=>{let f=c.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(c.pos,d.pos,(h,m,g)=>{if(f)return!1;if(h.isInline){const y=!g||g.type.allowsMarkType(n),C=!!n.isInSet(h.marks)||!h.marks.some(w=>w.type.excludes(n));f=y&&C}return!f}),f})}var HL=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=n,{empty:l,ranges:c}=o,d=Ji(t,r.schema);if(i)if(l){const f=Bx(r,d);n.addStoredMark(d.create({...f,...e}))}else c.forEach(f=>{const h=f.$from.pos,m=f.$to.pos;r.doc.nodesBetween(h,m,(g,y)=>{const C=Math.max(y,h),w=Math.min(y+g.nodeSize,m);g.marks.find(k=>k.type===d)?g.marks.forEach(k=>{d===k.type&&n.addMark(C,w,d.create({...k.attrs,...e}))}):n.addMark(C,w,d.create(e))})});return _L(r,n,d)},IL=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),zL=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const o=$t(t,n.schema);let l;return n.selection.$anchor.sameParent(n.selection.$head)&&(l=n.selection.$anchor.parent.attrs),o.isTextblock?i().command(({commands:c})=>q7(o,{...l,...e})(n)?!0:c.clearNodes()).command(({state:c})=>q7(o,{...l,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},BL=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=$i(t,0,r.content.size),o=me.create(r,i);e.setSelection(o)}return!0},jL=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=r;let l,c;return typeof e=="number"?(l=e,c=e):e&&"from"in e&&"to"in e?(l=e.from,c=e.to):(l=o.from,c=o.to),i&&n.doc.nodesBetween(l,c,(d,f)=>{d.isText||n.setNodeMarkup(f,void 0,{...d.attrs,dir:t})}),!0},VL=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:o}=typeof t=="number"?{from:t,to:t}:t,l=ue.atStart(r).from,c=ue.atEnd(r).to,d=$i(i,l,c),f=$i(o,l,c),h=ue.create(r,d,f);e.setSelection(h)}return!0},UL=t=>({state:e,dispatch:n})=>{const r=$t(t,e.schema);return jR(r)(e,n)};function Dw(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e?.includes(i.type.name));t.tr.ensureMarks(r)}}var PL=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:o,doc:l}=e,{$from:c,$to:d}=o,f=i.extensionManager.attributes,h=Ff(f,c.node().type.name,c.node().attrs);if(o instanceof me&&o.node.isBlock)return!c.parentOffset||!qi(l,c.pos)?!1:(r&&(t&&Dw(n,i.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;const m=d.parentOffset===d.parent.content.size,g=c.depth===0?void 0:bL(c.node(-1).contentMatchAt(c.indexAfter(-1)));let y=m&&g?[{type:g,attrs:h}]:void 0,C=qi(e.doc,e.mapping.map(c.pos),1,y);if(!y&&!C&&qi(e.doc,e.mapping.map(c.pos),1,g?[{type:g}]:void 0)&&(C=!0,y=g?[{type:g,attrs:h}]:void 0),r){if(C&&(o instanceof ue&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,y),g&&!m&&!c.parentOffset&&c.parent.type!==g)){const w=e.mapping.map(c.before()),x=e.doc.resolve(w);c.node(-1).canReplaceWith(x.index(),x.index()+1,g)&&e.setNodeMarkup(e.mapping.map(c.before()),g)}t&&Dw(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return C},FL=(t,e={})=>({tr:n,state:r,dispatch:i,editor:o})=>{var l;const c=$t(t,r.schema),{$from:d,$to:f}=r.selection,h=r.selection.node;if(h&&h.isBlock||d.depth<2||!d.sameParent(f))return!1;const m=d.node(-1);if(m.type!==c)return!1;const g=o.extensionManager.attributes;if(d.parent.content.size===0&&d.node(-1).childCount===d.indexAfter(-1)){if(d.depth===2||d.node(-3).type!==c||d.index(-2)!==d.node(-2).childCount-1)return!1;if(i){let k=te.empty;const A=d.index(-1)?1:d.index(-2)?2:3;for(let q=d.depth-A;q>=d.depth-3;q-=1)k=te.from(d.node(q).copy(k));const N=d.indexAfter(-1){if(_>-1)return!1;q.isTextblock&&q.content.size===0&&(_=J+1)}),_>-1&&n.setSelection(ue.near(n.doc.resolve(_))),n.scrollIntoView()}return!0}const y=f.pos===d.end()?m.contentMatchAt(0).defaultType:null,C={...Ff(g,m.type.name,m.attrs),...e},w={...Ff(g,d.node().type.name,d.node().attrs),...e};n.delete(d.pos,f.pos);const x=y?[{type:c,attrs:C},{type:y,attrs:w}]:[{type:c,attrs:C}];if(!qi(n.doc,d.pos,2))return!1;if(i){const{selection:k,storedMarks:A}=r,{splittableMarks:N}=o.extensionManager,R=A||k.$to.parentOffset&&k.$from.marks();if(n.split(d.pos,2,x).scrollIntoView(),!R||!i)return!0;const L=R.filter(z=>N.includes(z.type.name));n.ensureMarks(L)}return!0},c0=(t,e)=>{const n=At(l=>l.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&ns(t.doc,n.pos)&&t.join(n.pos),!0},u0=(t,e)=>{const n=At(l=>l.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&ns(t.doc,r)&&t.join(r),!0},$L=(t,e,n,r={})=>({editor:i,tr:o,state:l,dispatch:c,chain:d,commands:f,can:h})=>{const{extensions:m,splittableMarks:g}=i.extensionManager,y=$t(t,l.schema),C=$t(e,l.schema),{selection:w,storedMarks:x}=l,{$from:k,$to:A}=w,N=k.blockRange(A),R=x||w.$to.parentOffset&&w.$from.marks();if(!N)return!1;const L=At(z=>Ow(z.type.name,m))(w);if(N.depth>=1&&L&&N.depth-L.depth<=1){if(L.node.type===y)return f.liftListItem(C);if(Ow(L.node.type.name,m)&&y.validContent(L.node.content)&&c)return d().command(()=>(o.setNodeMarkup(L.pos,y),!0)).command(()=>c0(o,y)).command(()=>u0(o,y)).run()}return!n||!R||!c?d().command(()=>h().wrapInList(y,r)?!0:f.clearNodes()).wrapInList(y,r).command(()=>c0(o,y)).command(()=>u0(o,y)).run():d().command(()=>{const z=h().wrapInList(y,r),_=R.filter(q=>g.includes(q.type.name));return o.ensureMarks(_),z?!0:f.clearNodes()}).wrapInList(y,r).command(()=>c0(o,y)).command(()=>u0(o,y)).run()},qL=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=n,l=Ji(t,r.schema);return v2(r,l,e)?i.unsetMark(l,{extendEmptyMarkRange:o}):i.setMark(l,e)},ZL=(t,e,n={})=>({state:r,commands:i})=>{const o=$t(t,r.schema),l=$t(e,r.schema),c=Jo(r,o,n);let d;return r.selection.$anchor.sameParent(r.selection.$head)&&(d=r.selection.$anchor.parent.attrs),c?i.setNode(l,d):i.setNode(o,{...d,...n})},KL=(t,e={})=>({state:n,commands:r})=>{const i=$t(t,n.schema);return Jo(n,i,e)?r.lift(i):r.wrapIn(i,e)},GL=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r=0;d-=1)l.step(c.steps[d].invert(c.docs[d]));if(o.text){const d=l.doc.resolve(o.from).marks();l.replaceWith(o.from,o.to,t.schema.text(o.text,d))}else l.delete(o.from,o.to)}return!0}}return!1},YL=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(o=>{t.removeMark(o.$from.pos,o.$to.pos)}),!0},WL=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var o;const{extendEmptyMarkRange:l=!1}=e,{selection:c}=n,d=Ji(t,r.schema),{$from:f,empty:h,ranges:m}=c;if(!i)return!0;if(h&&l){let{from:g,to:y}=c;const C=(o=f.marks().find(x=>x.type===d))==null?void 0:o.attrs,w=Vy(f,d,C);w&&(g=w.from,y=w.to),n.removeMark(g,y,d)}else m.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,d)});return n.removeStoredMark(d),!0},JL=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let o,l;return typeof t=="number"?(o=t,l=t):t&&"from"in t&&"to"in t?(o=t.from,l=t.to):(o=i.from,l=i.to),r&&e.doc.nodesBetween(o,l,(c,d)=>{if(c.isText)return;const f={...c.attrs};delete f.dir,e.setNodeMarkup(d,void 0,f)}),!0},XL=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let o=null,l=null;const c=Dp(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(o=$t(t,r.schema)),c==="mark"&&(l=Ji(t,r.schema));let d=!1;return n.selection.ranges.forEach(f=>{const h=f.$from.pos,m=f.$to.pos;let g,y,C,w;n.selection.empty?r.doc.nodesBetween(h,m,(x,k)=>{o&&o===x.type&&(d=!0,C=Math.max(k,h),w=Math.min(k+x.nodeSize,m),g=k,y=x)}):r.doc.nodesBetween(h,m,(x,k)=>{k=h&&k<=m&&(o&&o===x.type&&(d=!0,i&&n.setNodeMarkup(k,void 0,{...x.attrs,...e})),l&&x.marks.length&&x.marks.forEach(A=>{if(l===A.type&&(d=!0,i)){const N=Math.max(k,h),R=Math.min(k+x.nodeSize,m);n.addMark(N,R,l.create({...A.attrs,...e}))}}))}),y&&(g!==void 0&&i&&n.setNodeMarkup(g,void 0,{...y.attrs,...e}),l&&y.marks.length&&y.marks.forEach(x=>{l===x.type&&i&&n.addMark(C,w,l.create({...x.attrs,...e}))}))}),d},QL=(t,e={})=>({state:n,dispatch:r})=>{const i=$t(t,n.schema);return DR(i,e)(n,r)},e_=(t,e={})=>({state:n,dispatch:r})=>{const i=$t(t,n.schema);return LR(i,e)(n,r)},t_=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Hu=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},n_=(t,e)=>{if(jy(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function gf(t){var e;const{editor:n,from:r,to:i,text:o,rules:l,plugin:c}=t,{view:d}=n;if(d.composing)return!1;const f=d.state.doc.resolve(r);if(f.parent.type.spec.code||(e=f.nodeBefore||f.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let h=!1;const m=NL(f)+o;return l.forEach(g=>{if(h)return;const y=n_(m,g.find);if(!y)return;const C=d.state.tr,w=Np({state:d.state,transaction:C}),x={from:r-(y[0].length-o.length),to:i},{commands:k,chain:A,can:N}=new Rp({editor:n,state:w});g.handler({state:w,range:x,match:y,commands:k,chain:A,can:N})===null||!C.steps.length||(g.undoable&&C.setMeta(c,{transform:C,from:r,to:i,text:o}),d.dispatch(C),h=!0)}),h}function r_(t){const{editor:e,rules:n}=t,r=new Ve({state:{init(){return null},apply(i,o,l){const c=i.getMeta(r);if(c)return c;const d=i.getMeta("applyInputRules");return d&&setTimeout(()=>{let{text:h}=d;typeof h=="string"?h=h:h=Fy(te.from(h),l.schema);const{from:m}=d,g=m+h.length;gf({editor:e,from:m,to:g,text:h,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:o}},props:{handleTextInput(i,o,l,c){return gf({editor:e,from:o,to:l,text:c,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:o}=i.state.selection;o&&gf({editor:e,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,o){if(o.key!=="Enter")return!1;const{$cursor:l}=i.state.selection;return l?gf({editor:e,from:l.pos,to:l.pos,text:` -`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function i_(t){return Object.prototype.toString.call(t).slice(8,-1)}function yf(t){return i_(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Xx(t,e){const n={...t};return yf(t)&&yf(e)&&Object.keys(e).forEach(r=>{yf(e[r])&&yf(t[r])?n[r]=Xx(t[r],e[r]):n[r]=e[r]}),n}var Yy=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...Ge(be(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Ge(be(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Xx(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Xi=class Qx extends Yy{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Qx(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const l=i.marks();if(!!!l.find(f=>f?.type.name===n.name))return!1;const d=l.find(f=>f?.type.name===n.name);return d&&r.removeStoredMark(d),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function o_(t){return typeof t=="number"}var s_=class{constructor(t){this.find=t.find,this.handler=t.handler}},l_=(t,e,n)=>{if(jy(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const o=[i.text];return o.index=i.index,o.input=t,o.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(i.replaceWith)),o}):[]};function a_(t){const{editor:e,state:n,from:r,to:i,rule:o,pasteEvent:l,dropEvent:c}=t,{commands:d,chain:f,can:h}=new Rp({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,i,(y,C)=>{var w,x,k,A,N;if((x=(w=y.type)==null?void 0:w.spec)!=null&&x.code||!(y.isText||y.isTextblock||y.isInline))return;const R=(N=(A=(k=y.content)==null?void 0:k.size)!=null?A:y.nodeSize)!=null?N:0,L=Math.max(r,C),z=Math.min(i,C+R);if(L>=z)return;const _=y.isText?y.text||"":y.textBetween(L-C,z-C,void 0,"");l_(_,o.find,l).forEach(J=>{if(J.index===void 0)return;const U=L+J.index+1,ne=U+J[0].length,le={from:n.tr.mapping.map(U),to:n.tr.mapping.map(ne)},oe=o.handler({state:n,range:le,match:J,commands:d,chain:f,can:h,pasteEvent:l,dropEvent:c});m.push(oe)})}),m.every(y=>y!==null)}var vf=null,c_=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function u_(t){const{editor:e,rules:n}=t;let r=null,i=!1,o=!1,l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,c;try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}const d=({state:h,from:m,to:g,rule:y,pasteEvt:C})=>{const w=h.tr,x=Np({state:h,transaction:w});if(!(!a_({editor:e,state:x,from:Math.max(m-1,0),to:g.b-1,rule:y,pasteEvent:C,dropEvent:c})||!w.steps.length)){try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,w}};return n.map(h=>new Ve({view(m){const g=C=>{var w;r=(w=m.dom.parentElement)!=null&&w.contains(C.target)?m.dom.parentElement:null,r&&(vf=e)},y=()=>{vf&&(vf=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",y),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",y)}}},props:{handleDOMEvents:{drop:(m,g)=>{if(o=r===m.dom.parentElement,c=g,!o){const y=vf;y?.isEditable&&setTimeout(()=>{const C=y.state.selection;C&&y.commands.deleteRange({from:C.from,to:C.to})},10)}return!1},paste:(m,g)=>{var y;const C=(y=g.clipboardData)==null?void 0:y.getData("text/html");return l=g,i=!!C?.includes("data-pm-slice"),!1}}},appendTransaction:(m,g,y)=>{const C=m[0],w=C.getMeta("uiEvent")==="paste"&&!i,x=C.getMeta("uiEvent")==="drop"&&!o,k=C.getMeta("applyPasteRules"),A=!!k;if(!w&&!x&&!A)return;if(A){let{text:L}=k;typeof L=="string"?L=L:L=Fy(te.from(L),y.schema);const{from:z}=k,_=z+L.length,q=c_(L);return d({rule:h,state:y,from:z,to:{b:_},pasteEvt:q})}const N=g.doc.content.findDiffStart(y.doc.content),R=g.doc.content.findDiffEnd(y.doc.content);if(!(!o_(N)||!R||N===R.b))return d({rule:h,state:y,from:N,to:R,pasteEvt:l})}}))}var _p=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=$x(t),this.schema=SL(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:a0(e.name,this.schema)},r=be(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return $y([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:a0(r.name,this.schema)},o=[],l=be(r,"addKeyboardShortcuts",i);let c={};if(r.type==="mark"&&be(r,"exitable",i)&&(c.ArrowRight=()=>Xi.handleExit({editor:t,mark:r})),l){const g=Object.fromEntries(Object.entries(l()).map(([y,C])=>[y,()=>C({editor:t})]));c={...c,...g}}const d=AD(c);o.push(d);const f=be(r,"addInputRules",i);if(Rw(r,t.options.enableInputRules)&&f){const g=f();if(g&&g.length){const y=r_({editor:t,rules:g}),C=Array.isArray(y)?y:[y];o.push(...C)}}const h=be(r,"addPasteRules",i);if(Rw(r,t.options.enablePasteRules)&&h){const g=h();if(g&&g.length){const y=u_({editor:t,rules:g});o.push(...y)}}const m=be(r,"addProseMirrorPlugins",i);if(m){const g=m();o.push(...g)}return o})}get attributes(){return Fx(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=va(this.extensions);return Object.fromEntries(e.filter(n=>!!be(n,"addNodeView")).map(n=>{const r=this.attributes.filter(d=>d.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:$t(n.name,this.schema)},o=be(n,"addNodeView",i);if(!o)return[];const l=o();if(!l)return[];const c=(d,f,h,m,g)=>{const y=pu(d,r);return l({node:d,view:f,getPos:h,decorations:m,innerDecorations:g,editor:t,extension:n,HTMLAttributes:y})};return[n.name,c]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=va(this.extensions);return Object.fromEntries(e.filter(n=>!!be(n,"addMarkView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ji(n.name,this.schema)},o=be(n,"addMarkView",i);if(!o)return[];const l=(c,d,f)=>{const h=pu(c,r);return o()({mark:c,view:d,inline:f,editor:t,extension:n,HTMLAttributes:h,updateAttributes:m=>{k_(c,t,m)}})};return[n.name,l]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:a0(e.name,this.schema)};e.type==="mark"&&((n=Ge(be(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=be(e,"onBeforeCreate",r),o=be(e,"onCreate",r),l=be(e,"onUpdate",r),c=be(e,"onSelectionUpdate",r),d=be(e,"onTransaction",r),f=be(e,"onFocus",r),h=be(e,"onBlur",r),m=be(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),o&&this.editor.on("create",o),l&&this.editor.on("update",l),c&&this.editor.on("selectionUpdate",c),d&&this.editor.on("transaction",d),f&&this.editor.on("focus",f),h&&this.editor.on("blur",h),m&&this.editor.on("destroy",m)})}};_p.resolve=$x;_p.sort=$y;_p.flatten=Py;var d_={};By(d_,{ClipboardTextSerializer:()=>tS,Commands:()=>nS,Delete:()=>rS,Drop:()=>iS,Editable:()=>oS,FocusEvents:()=>lS,Keymap:()=>aS,Paste:()=>cS,Tabindex:()=>uS,TextDirection:()=>dS,focusEventsPluginKey:()=>sS});var Ze=class eS extends Yy{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new eS(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},tS=Ze.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Ve({key:new qe("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:o}=i,l=Math.min(...o.map(h=>h.$from.pos)),c=Math.max(...o.map(h=>h.$to.pos)),d=qy(n);return qx(r,{from:l,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:d})}}})]}}),nS=Ze.create({name:"commands",addCommands(){return{...Dx}}}),rS=Ze.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const o=()=>{var l,c,d,f;if((f=(d=(c=(l=this.editor.options.coreExtensionOptions)==null?void 0:l.delete)==null?void 0:c.filterTransaction)==null?void 0:d.call(c,t))!=null?f:t.getMeta("y-sync$"))return;const h=jx(t.before,[t,...e]);Gx(h).forEach(y=>{h.mapping.mapResult(y.oldRange.from).deletedAfter&&h.mapping.mapResult(y.oldRange.to).deletedBefore&&h.before.nodesBetween(y.oldRange.from,y.oldRange.to,(C,w)=>{const x=w+C.nodeSize-2,k=y.oldRange.from<=w&&x<=y.oldRange.to;this.editor.emit("delete",{type:"node",node:C,from:w,to:x,newFrom:h.mapping.map(w),newTo:h.mapping.map(x),deletedRange:y.oldRange,newRange:y.newRange,partial:!k,editor:this.editor,transaction:t,combinedTransform:h})})});const g=h.mapping;h.steps.forEach((y,C)=>{var w,x;if(y instanceof jr){const k=g.slice(C).map(y.from,-1),A=g.slice(C).map(y.to),N=g.invert().map(k,-1),R=g.invert().map(A),L=(w=h.doc.nodeAt(k-1))==null?void 0:w.marks.some(_=>_.eq(y.mark)),z=(x=h.doc.nodeAt(A))==null?void 0:x.marks.some(_=>_.eq(y.mark));this.editor.emit("delete",{type:"mark",mark:y.mark,from:y.from,to:y.to,deletedRange:{from:N,to:R},newRange:{from:k,to:A},partial:!!(z||L),editor:this.editor,transaction:t,combinedTransform:h})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(o,0):o()}}),iS=Ze.create({name:"drop",addProseMirrorPlugins(){return[new Ve({key:new qe("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),oS=Ze.create({name:"editable",addProseMirrorPlugins(){return[new Ve({key:new qe("editable"),props:{editable:()=>this.editor.options.editable}})]}}),sS=new qe("focusEvents"),lS=Ze.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Ve({key:sS,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),aS=Ze.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:c})=>{const{selection:d,doc:f}=c,{empty:h,$anchor:m}=d,{pos:g,parent:y}=m,C=m.parent.isTextblock&&g>0?c.doc.resolve(g-1):m,w=C.parent.type.spec.isolating,x=m.pos-m.parentOffset,k=w&&C.parent.childCount===1?x===m.pos:Se.atStart(f).from===g;return!h||!y.type.isTextblock||y.textContent.length||!k||k&&m.parent.type.name==="paragraph"?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},o={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Op()||zx()?o:i},addProseMirrorPlugins(){return[new Ve({key:new qe("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(w=>w.getMeta("composition")))return;const r=t.some(w=>w.docChanged)&&!e.doc.eq(n.doc),i=t.some(w=>w.getMeta("preventClearDocument"));if(!r||i)return;const{empty:o,from:l,to:c}=e.selection,d=Se.atStart(e.doc).from,f=Se.atEnd(e.doc).to;if(o||!(l===d&&c===f)||!Lp(n.doc))return;const g=n.tr,y=Np({state:n,transaction:g}),{commands:C}=new Rp({editor:this.editor,state:y});if(C.clearNodes(),!!g.steps.length)return g}})]}}),cS=Ze.create({name:"paste",addProseMirrorPlugins(){return[new Ve({key:new qe("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),uS=Ze.create({name:"tabindex",addProseMirrorPlugins(){return[new Ve({key:new qe("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),dS=Ze.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=va(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new Ve({key:new qe("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),f_=class ta{constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new ta(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new ta(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new ta(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,o=n.isAtom&&!n.isText,l=this.pos+r+(o?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const c=this.resolvedPos.doc.resolve(l);if(!i&&c.depth<=this.depth)return;const d=new ta(c,this.editor,i,i?n:null);i&&(d.actualDepth=this.depth+1),e.push(new ta(c,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const o=i.node.attrs,l=Object.keys(n);for(let c=0;c{r&&i.length>0||(l.node.type.name===e&&o.every(d=>n[d]===l.node.attrs[d])&&i.push(l),!(r&&i.length>0)&&(i=i.concat(l.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},h_=`.ProseMirror { +`,textSerializers:l={}}=n||{};let c="";return t.nodesBetween(r,i,(d,f,h,m)=>{var g;d.isBlock&&f>r&&(c+=o);const y=l?.[d.type.name];if(y)return h&&(c+=y({node:d,pos:f,parent:h,index:m,range:e})),!1;d.isText&&(c+=(g=d?.text)==null?void 0:g.slice(Math.max(r,f)-f,i-f))}),c}function Zx(t,e){const n={from:0,to:t.content.size};return qx(t,n,e)}function qy(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function kL(t,e){const n=$t(e,t.schema),{from:r,to:i}=t.selection,o=[];t.doc.nodesBetween(r,i,c=>{o.push(c)});const l=o.reverse().find(c=>c.type.name===n.name);return l?{...l.attrs}:{}}function Kx(t,e){const n=Dp(typeof e=="string"?e:e.name,t.schema);return n==="node"?kL(t,e):n==="mark"?Bx(t,e):{}}function EL(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function ML(t){const e=EL(t);return e.length===1?e:e.filter((n,r)=>!e.filter((o,l)=>l!==r).some(o=>n.oldRange.from>=o.oldRange.from&&n.oldRange.to<=o.oldRange.to&&n.newRange.from>=o.newRange.from&&n.newRange.to<=o.newRange.to))}function Gx(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,o)=>{const l=[];if(i.ranges.length)i.forEach((c,d)=>{l.push({from:c,to:d})});else{const{from:c,to:d}=n[o];if(c===void 0||d===void 0)return;l.push({from:c,to:d})}l.forEach(({from:c,to:d})=>{const f=e.slice(o).map(c,-1),h=e.slice(o).map(d),m=e.invert().map(f,-1),g=e.invert().map(h);r.push({oldRange:{from:m,to:g},newRange:{from:f,to:h}})})}),ML(r)}function Zy(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const o=n.resolve(t),l=Vy(o,i.type);l&&r.push({mark:i,...l})}):n.nodesBetween(t,e,(i,o)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(l=>({from:o,to:o+i.nodeSize,mark:l})))}),r}var AL=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let o=r,l=null;for(;o>0&&l===null;){const c=i.node(o);c?.type.name===e?l=c:o-=1}return[l,o]};function a0(t,e){return e.nodes[t]||e.marks[t]||null}function Ff(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(o=>o.type===e&&o.name===r);return i?i.attribute.keepOnSplit:!1}))}var NL=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,o,l,c)=>{var d,f;const h=((f=(d=i.type.spec).toText)==null?void 0:f.call(d,{node:i,pos:o,parent:l,index:c}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?h:h.slice(0,Math.max(0,r-o))}),n};function v2(t,e,n={}){const{empty:r,ranges:i}=t.selection,o=e?Ji(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>o?o.name===m.type.name:!0).find(m=>ph(m.attrs,n,{strict:!1}));let l=0;const c=[];if(i.forEach(({$from:m,$to:g})=>{const y=m.pos,C=g.pos;t.doc.nodesBetween(y,C,(w,x)=>{if(!w.isText&&!w.marks.length)return;const k=Math.max(y,x),A=Math.min(C,x+w.nodeSize),N=A-k;l+=N,c.push(...w.marks.map(R=>({mark:R,from:k,to:A})))})}),l===0)return!1;const d=c.filter(m=>o?o.name===m.mark.type.name:!0).filter(m=>ph(m.mark.attrs,n,{strict:!1})).reduce((m,g)=>m+g.to-g.from,0),f=c.filter(m=>o?m.mark.type!==o&&m.mark.type.excludes(o):!0).reduce((m,g)=>m+g.to-g.from,0);return(d>0?d+f:d)>=l}function RL(t,e,n={}){if(!e)return Jo(t,null,n)||v2(t,null,n);const r=Dp(e,t.schema);return r==="node"?Jo(t,e,n):r==="mark"?v2(t,e,n):!1}var OL=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const o=At(c=>c.type.name===e)(t.selection);if(!o)return!1;const l=t.doc.resolve(o.pos+1);return i.pos+1===l.end()}return!(r.parentOffset{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function Rw(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Ow(t,e){const{nodeExtensions:n}=va(e),r=n.find(l=>l.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},o=Ye(be(r,"group",i));return typeof o!="string"?!1:o.split(" ").includes("list")}function Lp(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(o=>{i!==!1&&(Lp(o,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function Ky(t){return t instanceof me}var Gy=class Yx{constructor(e){this.position=e}static fromJSON(e){return new Yx(e.position)}toJSON(){return{position:this.position}}};function Wx(t,e){const n=e.mapping.mapResult(t.position);return{position:new Gy(n.pos),mapResult:n}}function LL(t){return new Gy(t)}function Jx(t,e,n){const i=t.state.doc.content.size,o=$i(e,0,i),l=$i(n,0,i),c=t.coordsAtPos(o),d=t.coordsAtPos(l,-1),f=Math.min(c.top,d.top),h=Math.max(c.bottom,d.bottom),m=Math.min(c.left,d.left),g=Math.max(c.right,d.right),y=g-m,C=h-f,k={top:f,bottom:h,left:m,right:g,width:y,height:C,x:m,y:f};return{...k,toJSON:()=>k}}function _L(t,e,n){var r;const{selection:i}=e;let o=null;if(Uy(i)&&(o=i.$cursor),o){const c=(r=t.storedMarks)!=null?r:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(c)||!c.some(f=>f.type.excludes(n)))}const{ranges:l}=i;return l.some(({$from:c,$to:d})=>{let f=c.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(c.pos,d.pos,(h,m,g)=>{if(f)return!1;if(h.isInline){const y=!g||g.type.allowsMarkType(n),C=!!n.isInSet(h.marks)||!h.marks.some(w=>w.type.excludes(n));f=y&&C}return!f}),f})}var HL=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=n,{empty:l,ranges:c}=o,d=Ji(t,r.schema);if(i)if(l){const f=Bx(r,d);n.addStoredMark(d.create({...f,...e}))}else c.forEach(f=>{const h=f.$from.pos,m=f.$to.pos;r.doc.nodesBetween(h,m,(g,y)=>{const C=Math.max(y,h),w=Math.min(y+g.nodeSize,m);g.marks.find(k=>k.type===d)?g.marks.forEach(k=>{d===k.type&&n.addMark(C,w,d.create({...k.attrs,...e}))}):n.addMark(C,w,d.create(e))})});return _L(r,n,d)},IL=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),zL=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const o=$t(t,n.schema);let l;return n.selection.$anchor.sameParent(n.selection.$head)&&(l=n.selection.$anchor.parent.attrs),o.isTextblock?i().command(({commands:c})=>q7(o,{...l,...e})(n)?!0:c.clearNodes()).command(({state:c})=>q7(o,{...l,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},BL=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=$i(t,0,r.content.size),o=me.create(r,i);e.setSelection(o)}return!0},jL=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=r;let l,c;return typeof e=="number"?(l=e,c=e):e&&"from"in e&&"to"in e?(l=e.from,c=e.to):(l=o.from,c=o.to),i&&n.doc.nodesBetween(l,c,(d,f)=>{d.isText||n.setNodeMarkup(f,void 0,{...d.attrs,dir:t})}),!0},VL=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:o}=typeof t=="number"?{from:t,to:t}:t,l=ue.atStart(r).from,c=ue.atEnd(r).to,d=$i(i,l,c),f=$i(o,l,c),h=ue.create(r,d,f);e.setSelection(h)}return!0},UL=t=>({state:e,dispatch:n})=>{const r=$t(t,e.schema);return jR(r)(e,n)};function Dw(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e?.includes(i.type.name));t.tr.ensureMarks(r)}}var PL=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:o,doc:l}=e,{$from:c,$to:d}=o,f=i.extensionManager.attributes,h=Ff(f,c.node().type.name,c.node().attrs);if(o instanceof me&&o.node.isBlock)return!c.parentOffset||!qi(l,c.pos)?!1:(r&&(t&&Dw(n,i.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;const m=d.parentOffset===d.parent.content.size,g=c.depth===0?void 0:bL(c.node(-1).contentMatchAt(c.indexAfter(-1)));let y=m&&g?[{type:g,attrs:h}]:void 0,C=qi(e.doc,e.mapping.map(c.pos),1,y);if(!y&&!C&&qi(e.doc,e.mapping.map(c.pos),1,g?[{type:g}]:void 0)&&(C=!0,y=g?[{type:g,attrs:h}]:void 0),r){if(C&&(o instanceof ue&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,y),g&&!m&&!c.parentOffset&&c.parent.type!==g)){const w=e.mapping.map(c.before()),x=e.doc.resolve(w);c.node(-1).canReplaceWith(x.index(),x.index()+1,g)&&e.setNodeMarkup(e.mapping.map(c.before()),g)}t&&Dw(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return C},FL=(t,e={})=>({tr:n,state:r,dispatch:i,editor:o})=>{var l;const c=$t(t,r.schema),{$from:d,$to:f}=r.selection,h=r.selection.node;if(h&&h.isBlock||d.depth<2||!d.sameParent(f))return!1;const m=d.node(-1);if(m.type!==c)return!1;const g=o.extensionManager.attributes;if(d.parent.content.size===0&&d.node(-1).childCount===d.indexAfter(-1)){if(d.depth===2||d.node(-3).type!==c||d.index(-2)!==d.node(-2).childCount-1)return!1;if(i){let k=te.empty;const A=d.index(-1)?1:d.index(-2)?2:3;for(let $=d.depth-A;$>=d.depth-3;$-=1)k=te.from(d.node($).copy(k));const N=d.indexAfter(-1){if(_>-1)return!1;$.isTextblock&&$.content.size===0&&(_=J+1)}),_>-1&&n.setSelection(ue.near(n.doc.resolve(_))),n.scrollIntoView()}return!0}const y=f.pos===d.end()?m.contentMatchAt(0).defaultType:null,C={...Ff(g,m.type.name,m.attrs),...e},w={...Ff(g,d.node().type.name,d.node().attrs),...e};n.delete(d.pos,f.pos);const x=y?[{type:c,attrs:C},{type:y,attrs:w}]:[{type:c,attrs:C}];if(!qi(n.doc,d.pos,2))return!1;if(i){const{selection:k,storedMarks:A}=r,{splittableMarks:N}=o.extensionManager,R=A||k.$to.parentOffset&&k.$from.marks();if(n.split(d.pos,2,x).scrollIntoView(),!R||!i)return!0;const L=R.filter(z=>N.includes(z.type.name));n.ensureMarks(L)}return!0},c0=(t,e)=>{const n=At(l=>l.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&ns(t.doc,n.pos)&&t.join(n.pos),!0},u0=(t,e)=>{const n=At(l=>l.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&ns(t.doc,r)&&t.join(r),!0},$L=(t,e,n,r={})=>({editor:i,tr:o,state:l,dispatch:c,chain:d,commands:f,can:h})=>{const{extensions:m,splittableMarks:g}=i.extensionManager,y=$t(t,l.schema),C=$t(e,l.schema),{selection:w,storedMarks:x}=l,{$from:k,$to:A}=w,N=k.blockRange(A),R=x||w.$to.parentOffset&&w.$from.marks();if(!N)return!1;const L=At(z=>Ow(z.type.name,m))(w);if(N.depth>=1&&L&&N.depth-L.depth<=1){if(L.node.type===y)return f.liftListItem(C);if(Ow(L.node.type.name,m)&&y.validContent(L.node.content)&&c)return d().command(()=>(o.setNodeMarkup(L.pos,y),!0)).command(()=>c0(o,y)).command(()=>u0(o,y)).run()}return!n||!R||!c?d().command(()=>h().wrapInList(y,r)?!0:f.clearNodes()).wrapInList(y,r).command(()=>c0(o,y)).command(()=>u0(o,y)).run():d().command(()=>{const z=h().wrapInList(y,r),_=R.filter($=>g.includes($.type.name));return o.ensureMarks(_),z?!0:f.clearNodes()}).wrapInList(y,r).command(()=>c0(o,y)).command(()=>u0(o,y)).run()},qL=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=n,l=Ji(t,r.schema);return v2(r,l,e)?i.unsetMark(l,{extendEmptyMarkRange:o}):i.setMark(l,e)},ZL=(t,e,n={})=>({state:r,commands:i})=>{const o=$t(t,r.schema),l=$t(e,r.schema),c=Jo(r,o,n);let d;return r.selection.$anchor.sameParent(r.selection.$head)&&(d=r.selection.$anchor.parent.attrs),c?i.setNode(l,d):i.setNode(o,{...d,...n})},KL=(t,e={})=>({state:n,commands:r})=>{const i=$t(t,n.schema);return Jo(n,i,e)?r.lift(i):r.wrapIn(i,e)},GL=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r=0;d-=1)l.step(c.steps[d].invert(c.docs[d]));if(o.text){const d=l.doc.resolve(o.from).marks();l.replaceWith(o.from,o.to,t.schema.text(o.text,d))}else l.delete(o.from,o.to)}return!0}}return!1},YL=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(o=>{t.removeMark(o.$from.pos,o.$to.pos)}),!0},WL=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var o;const{extendEmptyMarkRange:l=!1}=e,{selection:c}=n,d=Ji(t,r.schema),{$from:f,empty:h,ranges:m}=c;if(!i)return!0;if(h&&l){let{from:g,to:y}=c;const C=(o=f.marks().find(x=>x.type===d))==null?void 0:o.attrs,w=Vy(f,d,C);w&&(g=w.from,y=w.to),n.removeMark(g,y,d)}else m.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,d)});return n.removeStoredMark(d),!0},JL=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let o,l;return typeof t=="number"?(o=t,l=t):t&&"from"in t&&"to"in t?(o=t.from,l=t.to):(o=i.from,l=i.to),r&&e.doc.nodesBetween(o,l,(c,d)=>{if(c.isText)return;const f={...c.attrs};delete f.dir,e.setNodeMarkup(d,void 0,f)}),!0},XL=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let o=null,l=null;const c=Dp(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(o=$t(t,r.schema)),c==="mark"&&(l=Ji(t,r.schema));let d=!1;return n.selection.ranges.forEach(f=>{const h=f.$from.pos,m=f.$to.pos;let g,y,C,w;n.selection.empty?r.doc.nodesBetween(h,m,(x,k)=>{o&&o===x.type&&(d=!0,C=Math.max(k,h),w=Math.min(k+x.nodeSize,m),g=k,y=x)}):r.doc.nodesBetween(h,m,(x,k)=>{k=h&&k<=m&&(o&&o===x.type&&(d=!0,i&&n.setNodeMarkup(k,void 0,{...x.attrs,...e})),l&&x.marks.length&&x.marks.forEach(A=>{if(l===A.type&&(d=!0,i)){const N=Math.max(k,h),R=Math.min(k+x.nodeSize,m);n.addMark(N,R,l.create({...A.attrs,...e}))}}))}),y&&(g!==void 0&&i&&n.setNodeMarkup(g,void 0,{...y.attrs,...e}),l&&y.marks.length&&y.marks.forEach(x=>{l===x.type&&i&&n.addMark(C,w,l.create({...x.attrs,...e}))}))}),d},QL=(t,e={})=>({state:n,dispatch:r})=>{const i=$t(t,n.schema);return DR(i,e)(n,r)},e_=(t,e={})=>({state:n,dispatch:r})=>{const i=$t(t,n.schema);return LR(i,e)(n,r)},t_=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Hu=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},n_=(t,e)=>{if(jy(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function gf(t){var e;const{editor:n,from:r,to:i,text:o,rules:l,plugin:c}=t,{view:d}=n;if(d.composing)return!1;const f=d.state.doc.resolve(r);if(f.parent.type.spec.code||(e=f.nodeBefore||f.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let h=!1;const m=NL(f)+o;return l.forEach(g=>{if(h)return;const y=n_(m,g.find);if(!y)return;const C=d.state.tr,w=Np({state:d.state,transaction:C}),x={from:r-(y[0].length-o.length),to:i},{commands:k,chain:A,can:N}=new Rp({editor:n,state:w});g.handler({state:w,range:x,match:y,commands:k,chain:A,can:N})===null||!C.steps.length||(g.undoable&&C.setMeta(c,{transform:C,from:r,to:i,text:o}),d.dispatch(C),h=!0)}),h}function r_(t){const{editor:e,rules:n}=t,r=new Ue({state:{init(){return null},apply(i,o,l){const c=i.getMeta(r);if(c)return c;const d=i.getMeta("applyInputRules");return d&&setTimeout(()=>{let{text:h}=d;typeof h=="string"?h=h:h=Fy(te.from(h),l.schema);const{from:m}=d,g=m+h.length;gf({editor:e,from:m,to:g,text:h,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:o}},props:{handleTextInput(i,o,l,c){return gf({editor:e,from:o,to:l,text:c,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:o}=i.state.selection;o&&gf({editor:e,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,o){if(o.key!=="Enter")return!1;const{$cursor:l}=i.state.selection;return l?gf({editor:e,from:l.pos,to:l.pos,text:` +`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function i_(t){return Object.prototype.toString.call(t).slice(8,-1)}function yf(t){return i_(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Xx(t,e){const n={...t};return yf(t)&&yf(e)&&Object.keys(e).forEach(r=>{yf(e[r])&&yf(t[r])?n[r]=Xx(t[r],e[r]):n[r]=e[r]}),n}var Yy=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...Ye(be(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Ye(be(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Xx(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Xi=class Qx extends Yy{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Qx(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const l=i.marks();if(!!!l.find(f=>f?.type.name===n.name))return!1;const d=l.find(f=>f?.type.name===n.name);return d&&r.removeStoredMark(d),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function o_(t){return typeof t=="number"}var s_=class{constructor(t){this.find=t.find,this.handler=t.handler}},l_=(t,e,n)=>{if(jy(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const o=[i.text];return o.index=i.index,o.input=t,o.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(i.replaceWith)),o}):[]};function a_(t){const{editor:e,state:n,from:r,to:i,rule:o,pasteEvent:l,dropEvent:c}=t,{commands:d,chain:f,can:h}=new Rp({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,i,(y,C)=>{var w,x,k,A,N;if((x=(w=y.type)==null?void 0:w.spec)!=null&&x.code||!(y.isText||y.isTextblock||y.isInline))return;const R=(N=(A=(k=y.content)==null?void 0:k.size)!=null?A:y.nodeSize)!=null?N:0,L=Math.max(r,C),z=Math.min(i,C+R);if(L>=z)return;const _=y.isText?y.text||"":y.textBetween(L-C,z-C,void 0,"");l_(_,o.find,l).forEach(J=>{if(J.index===void 0)return;const U=L+J.index+1,ne=U+J[0].length,se={from:n.tr.mapping.map(U),to:n.tr.mapping.map(ne)},oe=o.handler({state:n,range:se,match:J,commands:d,chain:f,can:h,pasteEvent:l,dropEvent:c});m.push(oe)})}),m.every(y=>y!==null)}var vf=null,c_=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function u_(t){const{editor:e,rules:n}=t;let r=null,i=!1,o=!1,l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,c;try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}const d=({state:h,from:m,to:g,rule:y,pasteEvt:C})=>{const w=h.tr,x=Np({state:h,transaction:w});if(!(!a_({editor:e,state:x,from:Math.max(m-1,0),to:g.b-1,rule:y,pasteEvent:C,dropEvent:c})||!w.steps.length)){try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,w}};return n.map(h=>new Ue({view(m){const g=C=>{var w;r=(w=m.dom.parentElement)!=null&&w.contains(C.target)?m.dom.parentElement:null,r&&(vf=e)},y=()=>{vf&&(vf=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",y),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",y)}}},props:{handleDOMEvents:{drop:(m,g)=>{if(o=r===m.dom.parentElement,c=g,!o){const y=vf;y?.isEditable&&setTimeout(()=>{const C=y.state.selection;C&&y.commands.deleteRange({from:C.from,to:C.to})},10)}return!1},paste:(m,g)=>{var y;const C=(y=g.clipboardData)==null?void 0:y.getData("text/html");return l=g,i=!!C?.includes("data-pm-slice"),!1}}},appendTransaction:(m,g,y)=>{const C=m[0],w=C.getMeta("uiEvent")==="paste"&&!i,x=C.getMeta("uiEvent")==="drop"&&!o,k=C.getMeta("applyPasteRules"),A=!!k;if(!w&&!x&&!A)return;if(A){let{text:L}=k;typeof L=="string"?L=L:L=Fy(te.from(L),y.schema);const{from:z}=k,_=z+L.length,$=c_(L);return d({rule:h,state:y,from:z,to:{b:_},pasteEvt:$})}const N=g.doc.content.findDiffStart(y.doc.content),R=g.doc.content.findDiffEnd(y.doc.content);if(!(!o_(N)||!R||N===R.b))return d({rule:h,state:y,from:N,to:R,pasteEvt:l})}}))}var _p=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=$x(t),this.schema=SL(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:a0(e.name,this.schema)},r=be(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return $y([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:a0(r.name,this.schema)},o=[],l=be(r,"addKeyboardShortcuts",i);let c={};if(r.type==="mark"&&be(r,"exitable",i)&&(c.ArrowRight=()=>Xi.handleExit({editor:t,mark:r})),l){const g=Object.fromEntries(Object.entries(l()).map(([y,C])=>[y,()=>C({editor:t})]));c={...c,...g}}const d=AD(c);o.push(d);const f=be(r,"addInputRules",i);if(Rw(r,t.options.enableInputRules)&&f){const g=f();if(g&&g.length){const y=r_({editor:t,rules:g}),C=Array.isArray(y)?y:[y];o.push(...C)}}const h=be(r,"addPasteRules",i);if(Rw(r,t.options.enablePasteRules)&&h){const g=h();if(g&&g.length){const y=u_({editor:t,rules:g});o.push(...y)}}const m=be(r,"addProseMirrorPlugins",i);if(m){const g=m();o.push(...g)}return o})}get attributes(){return Fx(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=va(this.extensions);return Object.fromEntries(e.filter(n=>!!be(n,"addNodeView")).map(n=>{const r=this.attributes.filter(d=>d.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:$t(n.name,this.schema)},o=be(n,"addNodeView",i);if(!o)return[];const l=o();if(!l)return[];const c=(d,f,h,m,g)=>{const y=pu(d,r);return l({node:d,view:f,getPos:h,decorations:m,innerDecorations:g,editor:t,extension:n,HTMLAttributes:y})};return[n.name,c]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=va(this.extensions);return Object.fromEntries(e.filter(n=>!!be(n,"addMarkView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ji(n.name,this.schema)},o=be(n,"addMarkView",i);if(!o)return[];const l=(c,d,f)=>{const h=pu(c,r);return o()({mark:c,view:d,inline:f,editor:t,extension:n,HTMLAttributes:h,updateAttributes:m=>{k_(c,t,m)}})};return[n.name,l]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:a0(e.name,this.schema)};e.type==="mark"&&((n=Ye(be(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=be(e,"onBeforeCreate",r),o=be(e,"onCreate",r),l=be(e,"onUpdate",r),c=be(e,"onSelectionUpdate",r),d=be(e,"onTransaction",r),f=be(e,"onFocus",r),h=be(e,"onBlur",r),m=be(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),o&&this.editor.on("create",o),l&&this.editor.on("update",l),c&&this.editor.on("selectionUpdate",c),d&&this.editor.on("transaction",d),f&&this.editor.on("focus",f),h&&this.editor.on("blur",h),m&&this.editor.on("destroy",m)})}};_p.resolve=$x;_p.sort=$y;_p.flatten=Py;var d_={};By(d_,{ClipboardTextSerializer:()=>tS,Commands:()=>nS,Delete:()=>rS,Drop:()=>iS,Editable:()=>oS,FocusEvents:()=>lS,Keymap:()=>aS,Paste:()=>cS,Tabindex:()=>uS,TextDirection:()=>dS,focusEventsPluginKey:()=>sS});var Ke=class eS extends Yy{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new eS(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},tS=Ke.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Ue({key:new Ze("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:o}=i,l=Math.min(...o.map(h=>h.$from.pos)),c=Math.max(...o.map(h=>h.$to.pos)),d=qy(n);return qx(r,{from:l,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:d})}}})]}}),nS=Ke.create({name:"commands",addCommands(){return{...Dx}}}),rS=Ke.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const o=()=>{var l,c,d,f;if((f=(d=(c=(l=this.editor.options.coreExtensionOptions)==null?void 0:l.delete)==null?void 0:c.filterTransaction)==null?void 0:d.call(c,t))!=null?f:t.getMeta("y-sync$"))return;const h=jx(t.before,[t,...e]);Gx(h).forEach(y=>{h.mapping.mapResult(y.oldRange.from).deletedAfter&&h.mapping.mapResult(y.oldRange.to).deletedBefore&&h.before.nodesBetween(y.oldRange.from,y.oldRange.to,(C,w)=>{const x=w+C.nodeSize-2,k=y.oldRange.from<=w&&x<=y.oldRange.to;this.editor.emit("delete",{type:"node",node:C,from:w,to:x,newFrom:h.mapping.map(w),newTo:h.mapping.map(x),deletedRange:y.oldRange,newRange:y.newRange,partial:!k,editor:this.editor,transaction:t,combinedTransform:h})})});const g=h.mapping;h.steps.forEach((y,C)=>{var w,x;if(y instanceof jr){const k=g.slice(C).map(y.from,-1),A=g.slice(C).map(y.to),N=g.invert().map(k,-1),R=g.invert().map(A),L=(w=h.doc.nodeAt(k-1))==null?void 0:w.marks.some(_=>_.eq(y.mark)),z=(x=h.doc.nodeAt(A))==null?void 0:x.marks.some(_=>_.eq(y.mark));this.editor.emit("delete",{type:"mark",mark:y.mark,from:y.from,to:y.to,deletedRange:{from:N,to:R},newRange:{from:k,to:A},partial:!!(z||L),editor:this.editor,transaction:t,combinedTransform:h})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(o,0):o()}}),iS=Ke.create({name:"drop",addProseMirrorPlugins(){return[new Ue({key:new Ze("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),oS=Ke.create({name:"editable",addProseMirrorPlugins(){return[new Ue({key:new Ze("editable"),props:{editable:()=>this.editor.options.editable}})]}}),sS=new Ze("focusEvents"),lS=Ke.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Ue({key:sS,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),aS=Ke.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:c})=>{const{selection:d,doc:f}=c,{empty:h,$anchor:m}=d,{pos:g,parent:y}=m,C=m.parent.isTextblock&&g>0?c.doc.resolve(g-1):m,w=C.parent.type.spec.isolating,x=m.pos-m.parentOffset,k=w&&C.parent.childCount===1?x===m.pos:Se.atStart(f).from===g;return!h||!y.type.isTextblock||y.textContent.length||!k||k&&m.parent.type.name==="paragraph"?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},o={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Op()||zx()?o:i},addProseMirrorPlugins(){return[new Ue({key:new Ze("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(w=>w.getMeta("composition")))return;const r=t.some(w=>w.docChanged)&&!e.doc.eq(n.doc),i=t.some(w=>w.getMeta("preventClearDocument"));if(!r||i)return;const{empty:o,from:l,to:c}=e.selection,d=Se.atStart(e.doc).from,f=Se.atEnd(e.doc).to;if(o||!(l===d&&c===f)||!Lp(n.doc))return;const g=n.tr,y=Np({state:n,transaction:g}),{commands:C}=new Rp({editor:this.editor,state:y});if(C.clearNodes(),!!g.steps.length)return g}})]}}),cS=Ke.create({name:"paste",addProseMirrorPlugins(){return[new Ue({key:new Ze("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),uS=Ke.create({name:"tabindex",addProseMirrorPlugins(){return[new Ue({key:new Ze("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),dS=Ke.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=va(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new Ue({key:new Ze("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),f_=class ta{constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new ta(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new ta(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new ta(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,o=n.isAtom&&!n.isText,l=this.pos+r+(o?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const c=this.resolvedPos.doc.resolve(l);if(!i&&c.depth<=this.depth)return;const d=new ta(c,this.editor,i,i?n:null);i&&(d.actualDepth=this.depth+1),e.push(new ta(c,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const o=i.node.attrs,l=Object.keys(n);for(let c=0;c{r&&i.length>0||(l.node.type.name===e&&o.every(d=>n[d]===l.node.attrs[d])&&i.push(l),!(r&&i.length>0)&&(i=i.concat(l.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},h_=`.ProseMirror { position: relative; } @@ -90,7 +90,7 @@ img.ProseMirror-separator { display: block; }`;function p_(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}var m_=class extends t_{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Wx,createMappablePosition:LL},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:i,moved:o})=>this.options.onDrop(r,i,o)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=_x(e,this.options.autofocus);this.editorState=ra.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=p_(h_,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=Px(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(i=>{const o=typeof i=="string"?`${i}$`:i.key;n=n.filter(l=>!l.key.startsWith(o))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[oS,tS.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),nS,lS,aS,uS,iS,cS,rS,dS.configure({direction:this.options.textDirection})].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i?.type));this.extensionManager=new _p(r,this)}createCommandManager(){this.commandManager=new Rp({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=y2(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=y2(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new Ox(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS();const r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(f=>{var h;return(h=this.capturedTransaction)==null?void 0:h.step(f)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const l=n.findLast(f=>f.getMeta("focus")||f.getMeta("blur")),c=l?.getMeta("focus"),d=l?.getMeta("blur");c&&this.emit("focus",{editor:this,event:c.event,transaction:l}),d&&this.emit("blur",{editor:this,event:d.event,transaction:l}),!(t.getMeta("preventUpdate")||!n.some(f=>f.docChanged)||o.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Kx(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return RL(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Fy(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=` -`,textSerializers:n={}}=t||{};return Zx(this.state.doc,{blockSeparator:e,textSerializers:{...qy(this.schema),...n}})}get isEmpty(){return Lp(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new f_(e,this)}get $doc(){return this.$pos(0)}};function ba(t){return new Hu({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Ge(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:o}=e,l=r[r.length-1],c=r[0];if(l){const d=c.search(/\S/),f=n.from+c.indexOf(l),h=f+l.length;if(Zy(n.from,n.to,e.doc).filter(y=>y.mark.type.excluded.find(w=>w===t.type&&w!==y.mark.type)).filter(y=>y.to>f).length)return null;hn.from&&o.delete(n.from+d,f);const g=n.from+d+l.length;o.addMark(n.from+d,g,t.type.create(i||{})),o.removeStoredMark(t.type)}},undoable:t.undoable})}function g_(t){return new Hu({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Ge(t.getAttributes,void 0,r)||{},{tr:o}=e,l=n.from;let c=n.to;const d=t.type.create(i);if(r[1]){const f=r[0].lastIndexOf(r[1]);let h=l+f;h>c?h=c:c=h+r[1].length;const m=r[0][r[0].length-1];o.insertText(m,l+r[0].length-1),o.replaceWith(h,c,d)}else if(r[0]){const f=t.type.isInline?l:l-1;o.insert(f,t.type.create(i)).delete(o.mapping.map(l),o.mapping.map(c))}o.scrollIntoView()},undoable:t.undoable})}function b2(t){return new Hu({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),o=Ge(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,o)},undoable:t.undoable})}function Nt(t){return new Hu({find:t.find,handler:({state:e,range:n,match:r})=>{let i=t.replace,o=n.from;const l=n.to;if(r[1]){const c=r[0].lastIndexOf(r[1]);i+=r[0].slice(c+r[1].length),o+=c;const d=o-l;d>0&&(i=r[0].slice(c-d,c)+i,o=l)}e.tr.insertText(i,o,l)},undoable:t.undoable})}function Ca(t){return new Hu({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const o=Ge(t.getAttributes,void 0,r)||{},l=e.tr.delete(n.from,n.to),d=l.doc.resolve(n.from).blockRange(),f=d&&by(d,t.type,o);if(!f)return null;if(l.wrap(d,f),t.keepMarks&&t.editor){const{selection:m,storedMarks:g}=e,{splittableMarks:y}=t.editor.extensionManager,C=g||m.$to.parentOffset&&m.$from.marks();if(C){const w=C.filter(x=>y.includes(x.type.name));l.ensureMarks(w)}}if(t.keepAttributes){const m=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(m,o).run()}const h=l.doc.resolve(n.from-1).nodeBefore;h&&h.type===t.type&&ns(l.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,h))&&l.join(n.from-1)},undoable:t.undoable})}function y_(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof me){const o=r.index();return r.parent.canReplaceWith(o,o+1,e)}let i=r.depth;for(;i>=0;){const o=r.index(i);if(r.node(i).contentMatchAt(o).matchType(e))return!0;i-=1}return!1}function v_(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var b_={};By(b_,{createAtomBlockMarkdownSpec:()=>C_,createBlockMarkdownSpec:()=>w_,createInlineMarkdownSpec:()=>T_,parseAttributes:()=>Wy,parseIndentedBlocks:()=>C2,renderNestedMarkdownContent:()=>Xy,serializeAttributes:()=>Jy});function Wy(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,f=>(n.push(f),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const f=i.map(h=>h.trim().slice(1));e.class=f.join(" ")}const o=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);o&&(e.id=o[1]);const l=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(l)).forEach(([,f,h])=>{var m;const g=parseInt(((m=h.match(/__QUOTED_(\d+)__/))==null?void 0:m[1])||"0",10),y=n[g];y&&(e[f]=y.slice(1,-1))});const d=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return d&&d.split(/\s+/).filter(Boolean).forEach(h=>{h.match(/^[a-zA-Z][\w-]*$/)&&(e[h]=!0)}),e}function Jy(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function C_(t){const{nodeName:e,name:n,parseAttributes:r=Wy,serializeAttributes:i=Jy,defaultAttributes:o={},requiredAttributes:l=[],allowedAttributes:c}=t,d=n||e,f=h=>{if(!c)return h;const m={};return c.forEach(g=>{g in h&&(m[g]=h[g])}),m};return{parseMarkdown:(h,m)=>{const g={...o,...h.attributes};return m.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(h){var m;const g=new RegExp(`^:::${d}(?:\\s|$)`,"m"),y=(m=h.match(g))==null?void 0:m.index;return y!==void 0?y:-1},tokenize(h,m,g){const y=new RegExp(`^:::${d}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),C=h.match(y);if(!C)return;const w=C[1]||"",x=r(w);if(!l.find(A=>!(A in x)))return{type:e,raw:C[0],attributes:x}}},renderMarkdown:h=>{const m=f(h.attrs||{}),g=i(m),y=g?` {${g}}`:"";return`:::${d}${y} :::`}}}function w_(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=Wy,serializeAttributes:o=Jy,defaultAttributes:l={},content:c="block",allowedAttributes:d}=t,f=n||e,h=m=>{if(!d)return m;const g={};return d.forEach(y=>{y in m&&(g[y]=m[y])}),g};return{parseMarkdown:(m,g)=>{let y;if(r){const w=r(m);y=typeof w=="string"?[{type:"text",text:w}]:w}else c==="block"?y=g.parseChildren(m.tokens||[]):y=g.parseInline(m.tokens||[]);const C={...l,...m.attributes};return g.createNode(e,C,y)},markdownTokenizer:{name:e,level:"block",start(m){var g;const y=new RegExp(`^:::${f}`,"m"),C=(g=m.match(y))==null?void 0:g.index;return C!==void 0?C:-1},tokenize(m,g,y){var C;const w=new RegExp(`^:::${f}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),x=m.match(w);if(!x)return;const[k,A=""]=x,N=i(A);let R=1;const L=k.length;let z="";const _=/^:::([\w-]*)(\s.*)?/gm,q=m.slice(L);for(_.lastIndex=0;;){const J=_.exec(q);if(J===null)break;const U=J.index,ne=J[1];if(!((C=J[2])!=null&&C.endsWith(":::"))){if(ne)R+=1;else if(R-=1,R===0){const le=q.slice(0,U);z=le.trim();const oe=m.slice(0,L+U+J[0].length);let G=[];if(z)if(c==="block")for(G=y.blockTokens(le),G.forEach(P=>{P.text&&(!P.tokens||P.tokens.length===0)&&(P.tokens=y.inlineTokens(P.text))});G.length>0;){const P=G[G.length-1];if(P.type==="paragraph"&&(!P.text||P.text.trim()===""))G.pop();else break}else G=y.inlineTokens(z);return{type:e,raw:oe,attributes:N,content:z,tokens:G}}}}}},renderMarkdown:(m,g)=>{const y=h(m.attrs||{}),C=o(y),w=C?` {${C}}`:"",x=g.renderChildren(m.content||[],` +`,textSerializers:n={}}=t||{};return Zx(this.state.doc,{blockSeparator:e,textSerializers:{...qy(this.schema),...n}})}get isEmpty(){return Lp(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new f_(e,this)}get $doc(){return this.$pos(0)}};function ba(t){return new Hu({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Ye(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:o}=e,l=r[r.length-1],c=r[0];if(l){const d=c.search(/\S/),f=n.from+c.indexOf(l),h=f+l.length;if(Zy(n.from,n.to,e.doc).filter(y=>y.mark.type.excluded.find(w=>w===t.type&&w!==y.mark.type)).filter(y=>y.to>f).length)return null;hn.from&&o.delete(n.from+d,f);const g=n.from+d+l.length;o.addMark(n.from+d,g,t.type.create(i||{})),o.removeStoredMark(t.type)}},undoable:t.undoable})}function g_(t){return new Hu({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Ye(t.getAttributes,void 0,r)||{},{tr:o}=e,l=n.from;let c=n.to;const d=t.type.create(i);if(r[1]){const f=r[0].lastIndexOf(r[1]);let h=l+f;h>c?h=c:c=h+r[1].length;const m=r[0][r[0].length-1];o.insertText(m,l+r[0].length-1),o.replaceWith(h,c,d)}else if(r[0]){const f=t.type.isInline?l:l-1;o.insert(f,t.type.create(i)).delete(o.mapping.map(l),o.mapping.map(c))}o.scrollIntoView()},undoable:t.undoable})}function b2(t){return new Hu({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),o=Ye(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,o)},undoable:t.undoable})}function Nt(t){return new Hu({find:t.find,handler:({state:e,range:n,match:r})=>{let i=t.replace,o=n.from;const l=n.to;if(r[1]){const c=r[0].lastIndexOf(r[1]);i+=r[0].slice(c+r[1].length),o+=c;const d=o-l;d>0&&(i=r[0].slice(c-d,c)+i,o=l)}e.tr.insertText(i,o,l)},undoable:t.undoable})}function Ca(t){return new Hu({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const o=Ye(t.getAttributes,void 0,r)||{},l=e.tr.delete(n.from,n.to),d=l.doc.resolve(n.from).blockRange(),f=d&&by(d,t.type,o);if(!f)return null;if(l.wrap(d,f),t.keepMarks&&t.editor){const{selection:m,storedMarks:g}=e,{splittableMarks:y}=t.editor.extensionManager,C=g||m.$to.parentOffset&&m.$from.marks();if(C){const w=C.filter(x=>y.includes(x.type.name));l.ensureMarks(w)}}if(t.keepAttributes){const m=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(m,o).run()}const h=l.doc.resolve(n.from-1).nodeBefore;h&&h.type===t.type&&ns(l.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,h))&&l.join(n.from-1)},undoable:t.undoable})}function y_(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof me){const o=r.index();return r.parent.canReplaceWith(o,o+1,e)}let i=r.depth;for(;i>=0;){const o=r.index(i);if(r.node(i).contentMatchAt(o).matchType(e))return!0;i-=1}return!1}function v_(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var b_={};By(b_,{createAtomBlockMarkdownSpec:()=>C_,createBlockMarkdownSpec:()=>w_,createInlineMarkdownSpec:()=>T_,parseAttributes:()=>Wy,parseIndentedBlocks:()=>C2,renderNestedMarkdownContent:()=>Xy,serializeAttributes:()=>Jy});function Wy(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,f=>(n.push(f),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const f=i.map(h=>h.trim().slice(1));e.class=f.join(" ")}const o=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);o&&(e.id=o[1]);const l=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(l)).forEach(([,f,h])=>{var m;const g=parseInt(((m=h.match(/__QUOTED_(\d+)__/))==null?void 0:m[1])||"0",10),y=n[g];y&&(e[f]=y.slice(1,-1))});const d=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return d&&d.split(/\s+/).filter(Boolean).forEach(h=>{h.match(/^[a-zA-Z][\w-]*$/)&&(e[h]=!0)}),e}function Jy(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function C_(t){const{nodeName:e,name:n,parseAttributes:r=Wy,serializeAttributes:i=Jy,defaultAttributes:o={},requiredAttributes:l=[],allowedAttributes:c}=t,d=n||e,f=h=>{if(!c)return h;const m={};return c.forEach(g=>{g in h&&(m[g]=h[g])}),m};return{parseMarkdown:(h,m)=>{const g={...o,...h.attributes};return m.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(h){var m;const g=new RegExp(`^:::${d}(?:\\s|$)`,"m"),y=(m=h.match(g))==null?void 0:m.index;return y!==void 0?y:-1},tokenize(h,m,g){const y=new RegExp(`^:::${d}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),C=h.match(y);if(!C)return;const w=C[1]||"",x=r(w);if(!l.find(A=>!(A in x)))return{type:e,raw:C[0],attributes:x}}},renderMarkdown:h=>{const m=f(h.attrs||{}),g=i(m),y=g?` {${g}}`:"";return`:::${d}${y} :::`}}}function w_(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=Wy,serializeAttributes:o=Jy,defaultAttributes:l={},content:c="block",allowedAttributes:d}=t,f=n||e,h=m=>{if(!d)return m;const g={};return d.forEach(y=>{y in m&&(g[y]=m[y])}),g};return{parseMarkdown:(m,g)=>{let y;if(r){const w=r(m);y=typeof w=="string"?[{type:"text",text:w}]:w}else c==="block"?y=g.parseChildren(m.tokens||[]):y=g.parseInline(m.tokens||[]);const C={...l,...m.attributes};return g.createNode(e,C,y)},markdownTokenizer:{name:e,level:"block",start(m){var g;const y=new RegExp(`^:::${f}`,"m"),C=(g=m.match(y))==null?void 0:g.index;return C!==void 0?C:-1},tokenize(m,g,y){var C;const w=new RegExp(`^:::${f}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),x=m.match(w);if(!x)return;const[k,A=""]=x,N=i(A);let R=1;const L=k.length;let z="";const _=/^:::([\w-]*)(\s.*)?/gm,$=m.slice(L);for(_.lastIndex=0;;){const J=_.exec($);if(J===null)break;const U=J.index,ne=J[1];if(!((C=J[2])!=null&&C.endsWith(":::"))){if(ne)R+=1;else if(R-=1,R===0){const se=$.slice(0,U);z=se.trim();const oe=m.slice(0,L+U+J[0].length);let G=[];if(z)if(c==="block")for(G=y.blockTokens(se),G.forEach(P=>{P.text&&(!P.tokens||P.tokens.length===0)&&(P.tokens=y.inlineTokens(P.text))});G.length>0;){const P=G[G.length-1];if(P.type==="paragraph"&&(!P.text||P.text.trim()===""))G.pop();else break}else G=y.inlineTokens(z);return{type:e,raw:oe,attributes:N,content:z,tokens:G}}}}}},renderMarkdown:(m,g)=>{const y=h(m.attrs||{}),C=o(y),w=C?` {${C}}`:"",x=g.renderChildren(m.content||[],` `);return`:::${f}${w} @@ -105,11 +105,11 @@ ${x} `);L.trim()&&(e.customNestedParser?A=e.customNestedParser(L):A=n.blockTokens(L))}const R=e.createToken(C,A);d.push(R)}if(d.length!==0)return{items:d,raw:f}}function Xy(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[o,...l]=t.content,c=e.renderChildren([o]),d=[`${i}${c}`];return l&&l.length>0&&l.forEach(f=>{const h=e.renderChildren([f]);if(h){const m=h.split(` `).map(g=>g?e.indent(g):"").join(` `);d.push(m)}}),d.join(` -`)}function k_(t,e,n={}){const{state:r}=e,{doc:i,tr:o}=r,l=t;i.descendants((c,d)=>{const f=o.mapping.map(d),h=o.mapping.map(d)+c.nodeSize;let m=null;if(c.marks.forEach(y=>{if(y!==l)return!1;m=y}),!m)return;let g=!1;if(Object.keys(n).forEach(y=>{n[y]!==m.attrs[y]&&(g=!0)}),g){const y=t.type.create({...t.attrs,...n});o.removeMark(f,h,t.type),o.addMark(f,h,y)}}),o.docChanged&&e.view.dispatch(o)}var st=class fS extends Yy{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new fS(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},E_=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n,r,i,o,l,c;const{view:d}=this.editor,f=t.target,h=f.nodeType===3?(e=f.parentElement)==null?void 0:e.closest("[data-drag-handle]"):f.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(f)||!h)return;let m=0,g=0;if(this.dom!==h){const A=this.dom.getBoundingClientRect(),N=h.getBoundingClientRect(),R=(i=t.offsetX)!=null?i:(r=t.nativeEvent)==null?void 0:r.offsetX,L=(l=t.offsetY)!=null?l:(o=t.nativeEvent)==null?void 0:o.offsetY;m=N.x-A.x+R,g=N.y-A.y+L}const y=this.dom.cloneNode(!0);try{const A=this.dom.getBoundingClientRect();y.style.width=`${Math.round(A.width)}px`,y.style.height=`${Math.round(A.height)}px`,y.style.boxSizing="border-box",y.style.pointerEvents="none"}catch{}let C=null;try{C=document.createElement("div"),C.style.position="absolute",C.style.top="-9999px",C.style.left="-9999px",C.style.pointerEvents="none",C.appendChild(y),document.body.appendChild(C),(c=t.dataTransfer)==null||c.setDragImage(y,m,g)}finally{C&&setTimeout(()=>{try{C?.remove()}catch{}},0)}const w=this.getPos();if(typeof w!="number")return;const x=me.create(d.state.doc,w),k=d.state.tr.setSelection(x);d.dispatch(k)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const i=t.type.startsWith("drag"),o=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!o&&!i)return!0;const{isEditable:c}=this.editor,{isDragging:d}=this,f=!!this.node.type.spec.draggable,h=me.isSelectable(this.node),m=t.type==="copy",g=t.type==="paste",y=t.type==="cut",C=t.type==="mousedown";if(!f&&h&&i&&t.target===this.dom&&t.preventDefault(),f&&i&&!d&&t.target===this.dom)return t.preventDefault(),!1;if(f&&c&&!d&&C){const w=n.closest("[data-drag-handle]");w&&(this.dom===w||this.dom.contains(w))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(d||o||m||g||y||C&&h)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(Op()||Hx())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function Ks(t){return new s_({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const o=Ge(t.getAttributes,void 0,r,i);if(o===!1||o===null)return null;const{tr:l}=e,c=r[r.length-1],d=r[0];let f=n.to;if(c){const h=d.search(/\S/),m=n.from+d.indexOf(c),g=m+c.length;if(Zy(n.from,n.to,e.doc).filter(C=>C.mark.type.excluded.find(x=>x===t.type&&x!==C.mark.type)).filter(C=>C.to>m).length)return null;gn.from&&l.delete(n.from+h,m),f=n.from+h+c.length,l.addMark(n.from+h,f,t.type.create(o||{})),l.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:M_,getOwnPropertySymbols:A_}=Object,{hasOwnProperty:N_}=Object.prototype;function d0(t,e){return function(r,i,o){return t(r,i,o)&&e(r,i,o)}}function bf(t){return function(n,r,i){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,i);const{cache:o}=i,l=o.get(n),c=o.get(r);if(l&&c)return l===r&&c===n;o.set(n,r),o.set(r,n);const d=t(n,r,i);return o.delete(n),o.delete(r),d}}function R_(t){return t?.[Symbol.toStringTag]}function Lw(t){return M_(t).concat(A_(t))}const O_=Object.hasOwn||((t,e)=>N_.call(t,e));function il(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const D_="__v",L_="__o",__="_owner",{getOwnPropertyDescriptor:_w,keys:Hw}=Object;function H_(t,e){return t.byteLength===e.byteLength&&mh(new Uint8Array(t),new Uint8Array(e))}function I_(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function z_(t,e){return t.byteLength===e.byteLength&&mh(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function B_(t,e){return il(t.getTime(),e.getTime())}function j_(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function V_(t,e){return t===e}function Iw(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),o=t.entries();let l,c,d=0;for(;(l=o.next())&&!l.done;){const f=e.entries();let h=!1,m=0;for(;(c=f.next())&&!c.done;){if(i[m]){m++;continue}const g=l.value,y=c.value;if(n.equals(g[0],y[0],d,m,t,e,n)&&n.equals(g[1],y[1],g[0],y[0],t,e,n)){h=i[m]=!0;break}m++}if(!h)return!1;d++}return!0}const U_=il;function P_(t,e,n){const r=Hw(t);let i=r.length;if(Hw(e).length!==i)return!1;for(;i-- >0;)if(!hS(t,e,n,r[i]))return!1;return!0}function _c(t,e,n){const r=Lw(t);let i=r.length;if(Lw(e).length!==i)return!1;let o,l,c;for(;i-- >0;)if(o=r[i],!hS(t,e,n,o)||(l=_w(t,o),c=_w(e,o),(l||c)&&(!l||!c||l.configurable!==c.configurable||l.enumerable!==c.enumerable||l.writable!==c.writable)))return!1;return!0}function F_(t,e){return il(t.valueOf(),e.valueOf())}function $_(t,e){return t.source===e.source&&t.flags===e.flags}function zw(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),o=t.values();let l,c;for(;(l=o.next())&&!l.done;){const d=e.values();let f=!1,h=0;for(;(c=d.next())&&!c.done;){if(!i[h]&&n.equals(l.value,c.value,l.value,c.value,t,e,n)){f=i[h]=!0;break}h++}if(!f)return!1}return!0}function mh(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function q_(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function hS(t,e,n,r){return(r===__||r===L_||r===D_)&&(t.$$typeof||e.$$typeof)?!0:O_(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const Z_="[object ArrayBuffer]",K_="[object Arguments]",G_="[object Boolean]",Y_="[object DataView]",W_="[object Date]",J_="[object Error]",X_="[object Map]",Q_="[object Number]",eH="[object Object]",tH="[object RegExp]",nH="[object Set]",rH="[object String]",iH={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},oH="[object URL]",sH=Object.prototype.toString;function lH({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:o,areMapsEqual:l,areNumbersEqual:c,areObjectsEqual:d,arePrimitiveWrappersEqual:f,areRegExpsEqual:h,areSetsEqual:m,areTypedArraysEqual:g,areUrlsEqual:y,unknownTagComparators:C}){return function(x,k,A){if(x===k)return!0;if(x==null||k==null)return!1;const N=typeof x;if(N!==typeof k)return!1;if(N!=="object")return N==="number"?c(x,k,A):N==="function"?o(x,k,A):!1;const R=x.constructor;if(R!==k.constructor)return!1;if(R===Object)return d(x,k,A);if(Array.isArray(x))return e(x,k,A);if(R===Date)return r(x,k,A);if(R===RegExp)return h(x,k,A);if(R===Map)return l(x,k,A);if(R===Set)return m(x,k,A);const L=sH.call(x);if(L===W_)return r(x,k,A);if(L===tH)return h(x,k,A);if(L===X_)return l(x,k,A);if(L===nH)return m(x,k,A);if(L===eH)return typeof x.then!="function"&&typeof k.then!="function"&&d(x,k,A);if(L===oH)return y(x,k,A);if(L===J_)return i(x,k,A);if(L===K_)return d(x,k,A);if(iH[L])return g(x,k,A);if(L===Z_)return t(x,k,A);if(L===Y_)return n(x,k,A);if(L===G_||L===Q_||L===rH)return f(x,k,A);if(C){let z=C[L];if(!z){const _=R_(x);_&&(z=C[_])}if(z)return z(x,k,A)}return!1}}function aH({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:H_,areArraysEqual:n?_c:I_,areDataViewsEqual:z_,areDatesEqual:B_,areErrorsEqual:j_,areFunctionsEqual:V_,areMapsEqual:n?d0(Iw,_c):Iw,areNumbersEqual:U_,areObjectsEqual:n?_c:P_,arePrimitiveWrappersEqual:F_,areRegExpsEqual:$_,areSetsEqual:n?d0(zw,_c):zw,areTypedArraysEqual:n?d0(mh,_c):mh,areUrlsEqual:q_,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const i=bf(r.areArraysEqual),o=bf(r.areMapsEqual),l=bf(r.areObjectsEqual),c=bf(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:i,areMapsEqual:o,areObjectsEqual:l,areSetsEqual:c})}return r}function cH(t){return function(e,n,r,i,o,l,c){return t(e,n,c)}}function uH({circular:t,comparator:e,createState:n,equals:r,strict:i}){if(n)return function(c,d){const{cache:f=t?new WeakMap:void 0,meta:h}=n();return e(c,d,{cache:f,equals:r,meta:h,strict:i})};if(t)return function(c,d){return e(c,d,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};const o={cache:void 0,equals:r,meta:void 0,strict:i};return function(c,d){return e(c,d,o)}}const dH=is();is({strict:!0});is({circular:!0});is({circular:!0,strict:!0});is({createInternalComparator:()=>il});is({strict:!0,createInternalComparator:()=>il});is({circular:!0,createInternalComparator:()=>il});is({circular:!0,createInternalComparator:()=>il,strict:!0});function is(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:i=!1}=t,o=aH(t),l=lH(o),c=n?n(l):cH(l);return uH({circular:e,comparator:l,createState:r,equals:c,strict:i})}var f0={exports:{}},h0={};var Bw;function fH(){if(Bw)return h0;Bw=1;var t=Ou(),e=i9();function n(f,h){return f===h&&(f!==0||1/f===1/h)||f!==f&&h!==h}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,o=t.useRef,l=t.useEffect,c=t.useMemo,d=t.useDebugValue;return h0.useSyncExternalStoreWithSelector=function(f,h,m,g,y){var C=o(null);if(C.current===null){var w={hasValue:!1,value:null};C.current=w}else w=C.current;C=c(function(){function k(z){if(!A){if(A=!0,N=z,z=g(z),y!==void 0&&w.hasValue){var _=w.value;if(y(_,z))return R=_}return R=z}if(_=R,r(N,z))return _;var q=g(z);return y!==void 0&&y(_,q)?(N=z,_):(N=z,R=q)}var A=!1,N,R,L=m===void 0?null:m;return[function(){return k(h())},L===null?void 0:function(){return k(L())}]},[h,m,g,y]);var x=i(f,C[0],C[1]);return l(function(){w.hasValue=!0,w.value=x},[x]),d(x),x},h0}var jw;function hH(){return jw||(jw=1,f0.exports=fH()),f0.exports}var pH=hH(),mH=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},gH=({contentComponent:t})=>{const e=o9.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return S.jsx(S.Fragment,{children:Object.values(e)})};function yH(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:TN.createPortal(r.reactElement,r.element,n)},t.forEach(i=>i())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(i=>i())}}}var vH=class extends Qe.Component{constructor(t){var e;super(t),this.editorContentRef=Qe.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=yH(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return S.jsxs(S.Fragment,{children:[S.jsx("div",{ref:mH(e,this.editorContentRef),...n}),t?.contentComponent&&S.jsx(gH,{contentComponent:t.contentComponent})]})}},bH=E.forwardRef((t,e)=>{const n=Qe.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Qe.createElement(vH,{key:n,innerRef:e,...t})}),CH=Qe.memo(bH),wH=typeof window<"u"?E.useLayoutEffect:E.useEffect,xH=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function pS(t){var e;const[n]=E.useState(()=>new xH(t.editor)),r=pH.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:dH);return wH(()=>n.watch(t.editor),[t.editor,n]),E.useDebugValue(r),r}var SH=!1,w2=typeof window>"u",TH=w2||!!(typeof window<"u"&&window.next),kH=class mS{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?w2||TH?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,o;return(o=(i=this.options.current).onBeforeCreate)==null?void 0:o.call(i,...r)},onBlur:(...r)=>{var i,o;return(o=(i=this.options.current).onBlur)==null?void 0:o.call(i,...r)},onCreate:(...r)=>{var i,o;return(o=(i=this.options.current).onCreate)==null?void 0:o.call(i,...r)},onDestroy:(...r)=>{var i,o;return(o=(i=this.options.current).onDestroy)==null?void 0:o.call(i,...r)},onFocus:(...r)=>{var i,o;return(o=(i=this.options.current).onFocus)==null?void 0:o.call(i,...r)},onSelectionUpdate:(...r)=>{var i,o;return(o=(i=this.options.current).onSelectionUpdate)==null?void 0:o.call(i,...r)},onTransaction:(...r)=>{var i,o;return(o=(i=this.options.current).onTransaction)==null?void 0:o.call(i,...r)},onUpdate:(...r)=>{var i,o;return(o=(i=this.options.current).onUpdate)==null?void 0:o.call(i,...r)},onContentError:(...r)=>{var i,o;return(o=(i=this.options.current).onContentError)==null?void 0:o.call(i,...r)},onDrop:(...r)=>{var i,o;return(o=(i=this.options.current).onDrop)==null?void 0:o.call(i,...r)},onPaste:(...r)=>{var i,o;return(o=(i=this.options.current).onPaste)==null?void 0:o.call(i,...r)},onDelete:(...r)=>{var i,o;return(o=(i=this.options.current).onDelete)==null?void 0:o.call(i,...r)}};return new m_(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,o)=>{var l;return i===((l=n.extensions)==null?void 0:l[o])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?mS.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,i)=>r===e[i]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function EH(t={},e=[]){const n=E.useRef(t);n.current=t;const[r]=E.useState(()=>new kH(n)),i=o9.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return E.useDebugValue(i),E.useEffect(r.onRender(e)),pS({editor:i,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&o===0?0:o+1}),i}var Qy=E.createContext({editor:null});Qy.Consumer;var e3=()=>E.useContext(Qy),gS=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),yS=()=>E.useContext(gS);function La({as:t="div",...e}){const{nodeViewContentRef:n,nodeViewContentChildren:r}=yS();return S.jsx(t,{...e,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...e.style},children:r})}var Qi=Qe.forwardRef((t,e)=>{const{onDragStart:n}=yS(),r=t.as||"div";return S.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function Vw(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function Uw(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function MH(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function AH(t){if(Vw(t)||Uw(t))return!0;if(MH(t)){const e=t.type;if(e)return Vw(e)||Uw(e)}return!1}function NH(){try{if(E.version)return parseInt(E.version.split(".")[0],10)>=19}catch{}return!1}var x2=class{constructor(t,{editor:e,props:n={},as:r="div",className:i=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isInitialized?Oa.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var t;const e=this.component,n=this.props,r=this.editor,i=NH(),o=AH(e),l={...n};l.ref&&!(i||o)&&delete l.ref,!l.ref&&(i||o)&&(l.ref=c=>{this.ref=c}),this.reactElement=S.jsx(e,{...l}),(t=r?.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){this.props={...this.props,...t},this.render()}destroy(){var t;const e=this.editor;(t=e?.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};Qe.createContext({markViewContentRef:()=>{}});var RH=class extends E_{constructor(t,e,n){if(super(t,e,n),this.selectionRafId=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}mount(){const t={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(d={})=>this.updateAttributes(d),deleteNode:()=>this.deleteNode(),ref:E.createRef()};if(!this.component.displayName){const d=f=>f.charAt(0).toUpperCase()+f.substring(1);this.component.displayName=d(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:d=>{d&&this.contentDOMElement&&d.firstChild!==this.contentDOMElement&&(d.hasAttribute("data-node-view-wrapper")&&d.removeAttribute("data-node-view-wrapper"),d.appendChild(this.contentDOMElement))}},i=this.component,o=E.memo(d=>S.jsx(gS.Provider,{value:r,children:E.createElement(i,d)}));o.displayName="ReactNodeView";let l=this.node.isInline?"span":"div";this.options.as&&(l=this.options.as);const{className:c=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new x2(o,{editor:this.editor,props:t,as:l,className:`node-${this.node.type.name} ${c}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const{from:t,to:e}=this.editor.state.selection,n=this.getPos();if(typeof n=="number")if(t<=n&&e>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(t,e,n){const r=i=>{this.renderer.updateProps(i),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const i=this.node,o=this.decorations,l=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.options.update({oldNode:i,oldDecorations:o,newNode:t,newDecorations:e,oldInnerDecorations:l,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n})})}return t===this.node&&this.decorations===e&&this.innerDecorations===n||(this.node=t,this.decorations=e,this.innerDecorations=n,r({node:t,decorations:e,innerDecorations:n})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=pu(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function eo(t,e){return n=>n.editor.contentComponent?new RH(t,n,e):{}}var gh=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},OH=/^\s*>\s$/,DH=st.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return gh("blockquote",{...Pe(this.options.HTMLAttributes,t),children:gh("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const c=e.renderChildren([i]).split(` +`)}function k_(t,e,n={}){const{state:r}=e,{doc:i,tr:o}=r,l=t;i.descendants((c,d)=>{const f=o.mapping.map(d),h=o.mapping.map(d)+c.nodeSize;let m=null;if(c.marks.forEach(y=>{if(y!==l)return!1;m=y}),!m)return;let g=!1;if(Object.keys(n).forEach(y=>{n[y]!==m.attrs[y]&&(g=!0)}),g){const y=t.type.create({...t.attrs,...n});o.removeMark(f,h,t.type),o.addMark(f,h,y)}}),o.docChanged&&e.view.dispatch(o)}var st=class fS extends Yy{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new fS(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},E_=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n,r,i,o,l,c;const{view:d}=this.editor,f=t.target,h=f.nodeType===3?(e=f.parentElement)==null?void 0:e.closest("[data-drag-handle]"):f.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(f)||!h)return;let m=0,g=0;if(this.dom!==h){const A=this.dom.getBoundingClientRect(),N=h.getBoundingClientRect(),R=(i=t.offsetX)!=null?i:(r=t.nativeEvent)==null?void 0:r.offsetX,L=(l=t.offsetY)!=null?l:(o=t.nativeEvent)==null?void 0:o.offsetY;m=N.x-A.x+R,g=N.y-A.y+L}const y=this.dom.cloneNode(!0);try{const A=this.dom.getBoundingClientRect();y.style.width=`${Math.round(A.width)}px`,y.style.height=`${Math.round(A.height)}px`,y.style.boxSizing="border-box",y.style.pointerEvents="none"}catch{}let C=null;try{C=document.createElement("div"),C.style.position="absolute",C.style.top="-9999px",C.style.left="-9999px",C.style.pointerEvents="none",C.appendChild(y),document.body.appendChild(C),(c=t.dataTransfer)==null||c.setDragImage(y,m,g)}finally{C&&setTimeout(()=>{try{C?.remove()}catch{}},0)}const w=this.getPos();if(typeof w!="number")return;const x=me.create(d.state.doc,w),k=d.state.tr.setSelection(x);d.dispatch(k)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const i=t.type.startsWith("drag"),o=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!o&&!i)return!0;const{isEditable:c}=this.editor,{isDragging:d}=this,f=!!this.node.type.spec.draggable,h=me.isSelectable(this.node),m=t.type==="copy",g=t.type==="paste",y=t.type==="cut",C=t.type==="mousedown";if(!f&&h&&i&&t.target===this.dom&&t.preventDefault(),f&&i&&!d&&t.target===this.dom)return t.preventDefault(),!1;if(f&&c&&!d&&C){const w=n.closest("[data-drag-handle]");w&&(this.dom===w||this.dom.contains(w))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(d||o||m||g||y||C&&h)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(Op()||Hx())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function Ks(t){return new s_({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const o=Ye(t.getAttributes,void 0,r,i);if(o===!1||o===null)return null;const{tr:l}=e,c=r[r.length-1],d=r[0];let f=n.to;if(c){const h=d.search(/\S/),m=n.from+d.indexOf(c),g=m+c.length;if(Zy(n.from,n.to,e.doc).filter(C=>C.mark.type.excluded.find(x=>x===t.type&&x!==C.mark.type)).filter(C=>C.to>m).length)return null;gn.from&&l.delete(n.from+h,m),f=n.from+h+c.length,l.addMark(n.from+h,f,t.type.create(o||{})),l.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:M_,getOwnPropertySymbols:A_}=Object,{hasOwnProperty:N_}=Object.prototype;function d0(t,e){return function(r,i,o){return t(r,i,o)&&e(r,i,o)}}function bf(t){return function(n,r,i){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,i);const{cache:o}=i,l=o.get(n),c=o.get(r);if(l&&c)return l===r&&c===n;o.set(n,r),o.set(r,n);const d=t(n,r,i);return o.delete(n),o.delete(r),d}}function R_(t){return t?.[Symbol.toStringTag]}function Lw(t){return M_(t).concat(A_(t))}const O_=Object.hasOwn||((t,e)=>N_.call(t,e));function il(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const D_="__v",L_="__o",__="_owner",{getOwnPropertyDescriptor:_w,keys:Hw}=Object;function H_(t,e){return t.byteLength===e.byteLength&&mh(new Uint8Array(t),new Uint8Array(e))}function I_(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function z_(t,e){return t.byteLength===e.byteLength&&mh(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function B_(t,e){return il(t.getTime(),e.getTime())}function j_(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function V_(t,e){return t===e}function Iw(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),o=t.entries();let l,c,d=0;for(;(l=o.next())&&!l.done;){const f=e.entries();let h=!1,m=0;for(;(c=f.next())&&!c.done;){if(i[m]){m++;continue}const g=l.value,y=c.value;if(n.equals(g[0],y[0],d,m,t,e,n)&&n.equals(g[1],y[1],g[0],y[0],t,e,n)){h=i[m]=!0;break}m++}if(!h)return!1;d++}return!0}const U_=il;function P_(t,e,n){const r=Hw(t);let i=r.length;if(Hw(e).length!==i)return!1;for(;i-- >0;)if(!hS(t,e,n,r[i]))return!1;return!0}function _c(t,e,n){const r=Lw(t);let i=r.length;if(Lw(e).length!==i)return!1;let o,l,c;for(;i-- >0;)if(o=r[i],!hS(t,e,n,o)||(l=_w(t,o),c=_w(e,o),(l||c)&&(!l||!c||l.configurable!==c.configurable||l.enumerable!==c.enumerable||l.writable!==c.writable)))return!1;return!0}function F_(t,e){return il(t.valueOf(),e.valueOf())}function $_(t,e){return t.source===e.source&&t.flags===e.flags}function zw(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),o=t.values();let l,c;for(;(l=o.next())&&!l.done;){const d=e.values();let f=!1,h=0;for(;(c=d.next())&&!c.done;){if(!i[h]&&n.equals(l.value,c.value,l.value,c.value,t,e,n)){f=i[h]=!0;break}h++}if(!f)return!1}return!0}function mh(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function q_(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function hS(t,e,n,r){return(r===__||r===L_||r===D_)&&(t.$$typeof||e.$$typeof)?!0:O_(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const Z_="[object ArrayBuffer]",K_="[object Arguments]",G_="[object Boolean]",Y_="[object DataView]",W_="[object Date]",J_="[object Error]",X_="[object Map]",Q_="[object Number]",eH="[object Object]",tH="[object RegExp]",nH="[object Set]",rH="[object String]",iH={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},oH="[object URL]",sH=Object.prototype.toString;function lH({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:o,areMapsEqual:l,areNumbersEqual:c,areObjectsEqual:d,arePrimitiveWrappersEqual:f,areRegExpsEqual:h,areSetsEqual:m,areTypedArraysEqual:g,areUrlsEqual:y,unknownTagComparators:C}){return function(x,k,A){if(x===k)return!0;if(x==null||k==null)return!1;const N=typeof x;if(N!==typeof k)return!1;if(N!=="object")return N==="number"?c(x,k,A):N==="function"?o(x,k,A):!1;const R=x.constructor;if(R!==k.constructor)return!1;if(R===Object)return d(x,k,A);if(Array.isArray(x))return e(x,k,A);if(R===Date)return r(x,k,A);if(R===RegExp)return h(x,k,A);if(R===Map)return l(x,k,A);if(R===Set)return m(x,k,A);const L=sH.call(x);if(L===W_)return r(x,k,A);if(L===tH)return h(x,k,A);if(L===X_)return l(x,k,A);if(L===nH)return m(x,k,A);if(L===eH)return typeof x.then!="function"&&typeof k.then!="function"&&d(x,k,A);if(L===oH)return y(x,k,A);if(L===J_)return i(x,k,A);if(L===K_)return d(x,k,A);if(iH[L])return g(x,k,A);if(L===Z_)return t(x,k,A);if(L===Y_)return n(x,k,A);if(L===G_||L===Q_||L===rH)return f(x,k,A);if(C){let z=C[L];if(!z){const _=R_(x);_&&(z=C[_])}if(z)return z(x,k,A)}return!1}}function aH({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:H_,areArraysEqual:n?_c:I_,areDataViewsEqual:z_,areDatesEqual:B_,areErrorsEqual:j_,areFunctionsEqual:V_,areMapsEqual:n?d0(Iw,_c):Iw,areNumbersEqual:U_,areObjectsEqual:n?_c:P_,arePrimitiveWrappersEqual:F_,areRegExpsEqual:$_,areSetsEqual:n?d0(zw,_c):zw,areTypedArraysEqual:n?d0(mh,_c):mh,areUrlsEqual:q_,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const i=bf(r.areArraysEqual),o=bf(r.areMapsEqual),l=bf(r.areObjectsEqual),c=bf(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:i,areMapsEqual:o,areObjectsEqual:l,areSetsEqual:c})}return r}function cH(t){return function(e,n,r,i,o,l,c){return t(e,n,c)}}function uH({circular:t,comparator:e,createState:n,equals:r,strict:i}){if(n)return function(c,d){const{cache:f=t?new WeakMap:void 0,meta:h}=n();return e(c,d,{cache:f,equals:r,meta:h,strict:i})};if(t)return function(c,d){return e(c,d,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};const o={cache:void 0,equals:r,meta:void 0,strict:i};return function(c,d){return e(c,d,o)}}const dH=is();is({strict:!0});is({circular:!0});is({circular:!0,strict:!0});is({createInternalComparator:()=>il});is({strict:!0,createInternalComparator:()=>il});is({circular:!0,createInternalComparator:()=>il});is({circular:!0,createInternalComparator:()=>il,strict:!0});function is(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:i=!1}=t,o=aH(t),l=lH(o),c=n?n(l):cH(l);return uH({circular:e,comparator:l,createState:r,equals:c,strict:i})}var f0={exports:{}},h0={};var Bw;function fH(){if(Bw)return h0;Bw=1;var t=Ou(),e=i9();function n(f,h){return f===h&&(f!==0||1/f===1/h)||f!==f&&h!==h}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,o=t.useRef,l=t.useEffect,c=t.useMemo,d=t.useDebugValue;return h0.useSyncExternalStoreWithSelector=function(f,h,m,g,y){var C=o(null);if(C.current===null){var w={hasValue:!1,value:null};C.current=w}else w=C.current;C=c(function(){function k(z){if(!A){if(A=!0,N=z,z=g(z),y!==void 0&&w.hasValue){var _=w.value;if(y(_,z))return R=_}return R=z}if(_=R,r(N,z))return _;var $=g(z);return y!==void 0&&y(_,$)?(N=z,_):(N=z,R=$)}var A=!1,N,R,L=m===void 0?null:m;return[function(){return k(h())},L===null?void 0:function(){return k(L())}]},[h,m,g,y]);var x=i(f,C[0],C[1]);return l(function(){w.hasValue=!0,w.value=x},[x]),d(x),x},h0}var jw;function hH(){return jw||(jw=1,f0.exports=fH()),f0.exports}var pH=hH(),mH=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},gH=({contentComponent:t})=>{const e=o9.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return S.jsx(S.Fragment,{children:Object.values(e)})};function yH(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:TN.createPortal(r.reactElement,r.element,n)},t.forEach(i=>i())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(i=>i())}}}var vH=class extends Ve.Component{constructor(t){var e;super(t),this.editorContentRef=Ve.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=yH(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return S.jsxs(S.Fragment,{children:[S.jsx("div",{ref:mH(e,this.editorContentRef),...n}),t?.contentComponent&&S.jsx(gH,{contentComponent:t.contentComponent})]})}},bH=E.forwardRef((t,e)=>{const n=Ve.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Ve.createElement(vH,{key:n,innerRef:e,...t})}),CH=Ve.memo(bH),wH=typeof window<"u"?E.useLayoutEffect:E.useEffect,xH=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function pS(t){var e;const[n]=E.useState(()=>new xH(t.editor)),r=pH.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:dH);return wH(()=>n.watch(t.editor),[t.editor,n]),E.useDebugValue(r),r}var SH=!1,w2=typeof window>"u",TH=w2||!!(typeof window<"u"&&window.next),kH=class mS{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?w2||TH?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,o;return(o=(i=this.options.current).onBeforeCreate)==null?void 0:o.call(i,...r)},onBlur:(...r)=>{var i,o;return(o=(i=this.options.current).onBlur)==null?void 0:o.call(i,...r)},onCreate:(...r)=>{var i,o;return(o=(i=this.options.current).onCreate)==null?void 0:o.call(i,...r)},onDestroy:(...r)=>{var i,o;return(o=(i=this.options.current).onDestroy)==null?void 0:o.call(i,...r)},onFocus:(...r)=>{var i,o;return(o=(i=this.options.current).onFocus)==null?void 0:o.call(i,...r)},onSelectionUpdate:(...r)=>{var i,o;return(o=(i=this.options.current).onSelectionUpdate)==null?void 0:o.call(i,...r)},onTransaction:(...r)=>{var i,o;return(o=(i=this.options.current).onTransaction)==null?void 0:o.call(i,...r)},onUpdate:(...r)=>{var i,o;return(o=(i=this.options.current).onUpdate)==null?void 0:o.call(i,...r)},onContentError:(...r)=>{var i,o;return(o=(i=this.options.current).onContentError)==null?void 0:o.call(i,...r)},onDrop:(...r)=>{var i,o;return(o=(i=this.options.current).onDrop)==null?void 0:o.call(i,...r)},onPaste:(...r)=>{var i,o;return(o=(i=this.options.current).onPaste)==null?void 0:o.call(i,...r)},onDelete:(...r)=>{var i,o;return(o=(i=this.options.current).onDelete)==null?void 0:o.call(i,...r)}};return new m_(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,o)=>{var l;return i===((l=n.extensions)==null?void 0:l[o])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?mS.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,i)=>r===e[i]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function EH(t={},e=[]){const n=E.useRef(t);n.current=t;const[r]=E.useState(()=>new kH(n)),i=o9.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return E.useDebugValue(i),E.useEffect(r.onRender(e)),pS({editor:i,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&o===0?0:o+1}),i}var Qy=E.createContext({editor:null});Qy.Consumer;var e3=()=>E.useContext(Qy),gS=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),yS=()=>E.useContext(gS);function La({as:t="div",...e}){const{nodeViewContentRef:n,nodeViewContentChildren:r}=yS();return S.jsx(t,{...e,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...e.style},children:r})}var Qi=Ve.forwardRef((t,e)=>{const{onDragStart:n}=yS(),r=t.as||"div";return S.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function Vw(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function Uw(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function MH(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function AH(t){if(Vw(t)||Uw(t))return!0;if(MH(t)){const e=t.type;if(e)return Vw(e)||Uw(e)}return!1}function NH(){try{if(E.version)return parseInt(E.version.split(".")[0],10)>=19}catch{}return!1}var x2=class{constructor(t,{editor:e,props:n={},as:r="div",className:i=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isInitialized?Oa.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var t;const e=this.component,n=this.props,r=this.editor,i=NH(),o=AH(e),l={...n};l.ref&&!(i||o)&&delete l.ref,!l.ref&&(i||o)&&(l.ref=c=>{this.ref=c}),this.reactElement=S.jsx(e,{...l}),(t=r?.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){this.props={...this.props,...t},this.render()}destroy(){var t;const e=this.editor;(t=e?.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};Ve.createContext({markViewContentRef:()=>{}});var RH=class extends E_{constructor(t,e,n){if(super(t,e,n),this.selectionRafId=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}mount(){const t={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(d={})=>this.updateAttributes(d),deleteNode:()=>this.deleteNode(),ref:E.createRef()};if(!this.component.displayName){const d=f=>f.charAt(0).toUpperCase()+f.substring(1);this.component.displayName=d(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:d=>{d&&this.contentDOMElement&&d.firstChild!==this.contentDOMElement&&(d.hasAttribute("data-node-view-wrapper")&&d.removeAttribute("data-node-view-wrapper"),d.appendChild(this.contentDOMElement))}},i=this.component,o=E.memo(d=>S.jsx(gS.Provider,{value:r,children:E.createElement(i,d)}));o.displayName="ReactNodeView";let l=this.node.isInline?"span":"div";this.options.as&&(l=this.options.as);const{className:c=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new x2(o,{editor:this.editor,props:t,as:l,className:`node-${this.node.type.name} ${c}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const{from:t,to:e}=this.editor.state.selection,n=this.getPos();if(typeof n=="number")if(t<=n&&e>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(t,e,n){const r=i=>{this.renderer.updateProps(i),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const i=this.node,o=this.decorations,l=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.options.update({oldNode:i,oldDecorations:o,newNode:t,newDecorations:e,oldInnerDecorations:l,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n})})}return t===this.node&&this.decorations===e&&this.innerDecorations===n||(this.node=t,this.decorations=e,this.innerDecorations=n,r({node:t,decorations:e,innerDecorations:n})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=pu(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function eo(t,e){return n=>n.editor.contentComponent?new RH(t,n,e):{}}var gh=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},OH=/^\s*>\s$/,DH=st.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return gh("blockquote",{...Fe(this.options.HTMLAttributes,t),children:gh("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const c=e.renderChildren([i]).split(` `).map(d=>d.trim()===""?n:`${n} ${d}`);r.push(c.join(` `))}),r.join(` ${n} -`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Ca({find:OH,type:this.type})]}}),LH=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,_H=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,HH=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,IH=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,zH=Xi.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return gh("strong",{...Pe(this.options.HTMLAttributes,t),children:gh("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ba({find:LH,type:this.type}),ba({find:HH,type:this.type})]},addPasteRules(){return[Ks({find:_H,type:this.type}),Ks({find:IH,type:this.type})]}}),BH=/(^|[^`])`([^`]+)`(?!`)$/,jH=/(^|[^`])`([^`]+)`(?!`)/g,VH=Xi.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Pe(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[ba({find:BH,type:this.type})]},addPasteRules(){return[Ks({find:jH,type:this.type})]}}),p0=4,UH=/^```([a-z]+)?[\s\n]$/,PH=/^~~~([a-z]+)?[\s\n]$/,FH=st.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:p0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const o=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(l=>l.startsWith(n)).map(l=>l.replace(n,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Pe(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(` +`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Ca({find:OH,type:this.type})]}}),LH=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,_H=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,HH=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,IH=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,zH=Xi.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return gh("strong",{...Fe(this.options.HTMLAttributes,t),children:gh("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ba({find:LH,type:this.type}),ba({find:HH,type:this.type})]},addPasteRules(){return[Ks({find:_H,type:this.type}),Ks({find:IH,type:this.type})]}}),BH=/(^|[^`])`([^`]+)`(?!`)$/,jH=/(^|[^`])`([^`]+)`(?!`)/g,VH=Xi.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Fe(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[ba({find:BH,type:this.type})]},addPasteRules(){return[Ks({find:jH,type:this.type})]}}),p0=4,UH=/^```([a-z]+)?[\s\n]$/,PH=/^~~~([a-z]+)?[\s\n]$/,FH=st.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:p0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const o=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(l=>l.startsWith(n)).map(l=>l.replace(n,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Fe(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(` `):r=`\`\`\`${i} \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:p0,{state:r}=t,{selection:i}=r,{$from:o,empty:l}=i;if(o.parent.type!==this.type)return!1;const c=" ".repeat(n);return l?t.commands.insertContent(c):t.commands.command(({tr:d})=>{const{from:f,to:h}=i,y=r.doc.textBetween(f,h,` @@ -125,33 +125,33 @@ ${n} `).map(y=>{var C;const w=((C=y.match(/^ */))==null?void 0:C[0])||"",x=Math.min(w.length,n);return y.slice(x)}).join(` `);return c.replaceWith(d,f,r.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,l=r.parent.textContent.endsWith(` -`);return!o||!l?!1:t.chain().command(({tr:c})=>(c.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:o}=n;if(!o||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const c=i.after();return c===void 0?!1:r.nodeAt(c)?t.commands.command(({tr:f})=>(f.setSelection(Se.near(r.resolve(c))),!0)):t.commands.exitCode()}}},addInputRules(){return[b2({find:UH,type:this.type,getAttributes:t=>({language:t[1]})}),b2({find:PH,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Ve({key:new qe("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,o=i?.mode;if(!n||!o)return!1;const{tr:l,schema:c}=t.state,d=c.text(n.replace(/\r\n?/g,` +`);return!o||!l?!1:t.chain().command(({tr:c})=>(c.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:o}=n;if(!o||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const c=i.after();return c===void 0?!1:r.nodeAt(c)?t.commands.command(({tr:f})=>(f.setSelection(Se.near(r.resolve(c))),!0)):t.commands.exitCode()}}},addInputRules(){return[b2({find:UH,type:this.type,getAttributes:t=>({language:t[1]})}),b2({find:PH,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Ue({key:new Ze("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,o=i?.mode;if(!n||!o)return!1;const{tr:l,schema:c}=t.state,d=c.text(n.replace(/\r\n?/g,` `));return l.replaceSelectionWith(this.type.create({language:o},d)),l.selection.$from.parent.type!==this.type&&l.setSelection(ue.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),$H=st.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` -`):""}),qH=st.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",Pe(this.options.HTMLAttributes,t)]},renderText(){return` +`):""}),qH=st.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",Fe(this.options.HTMLAttributes,t)]},renderText(){return` `},renderMarkdown:()=>` -`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:o}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:l}=this.options,{splittableMarks:c}=r.extensionManager,d=o||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:f,dispatch:h})=>{if(h&&d&&l){const m=d.filter(g=>c.includes(g.type.name));f.ensureMarks(m)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),ZH=st.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Pe(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,i="#".repeat(r);return t.content?`${i} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>b2({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),KH=st.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Pe(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!y_(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return Ky(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:o,tr:l,dispatch:c})=>{if(c){const{$to:d}=l.selection,f=d.end();if(d.nodeAfter)d.nodeAfter.isTextblock?l.setSelection(ue.create(l.doc,d.pos+1)):d.nodeAfter.isBlock?l.setSelection(me.create(l.doc,d.pos)):l.setSelection(ue.create(l.doc,d.pos));else{const h=o.schema.nodes[this.options.nextNodeType]||d.parent.type.contentMatch.defaultType,m=h?.create();m&&(l.insert(f,m),l.setSelection(ue.create(l.doc,f+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[g_({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),GH=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,YH=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,WH=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,JH=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,XH=Xi.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Pe(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ba({find:GH,type:this.type}),ba({find:WH,type:this.type})]},addPasteRules(){return[Ks({find:YH,type:this.type}),Ks({find:JH,type:this.type})]}});const QH="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",eI="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",S2="numeric",T2="ascii",k2="alpha",Yc="asciinumeric",Fc="alphanumeric",E2="domain",vS="emoji",tI="scheme",nI="slashscheme",m0="whitespace";function rI(t,e){return t in e||(e[t]=[]),e[t]}function Hs(t,e,n){e[S2]&&(e[Yc]=!0,e[Fc]=!0),e[T2]&&(e[Yc]=!0,e[k2]=!0),e[Yc]&&(e[Fc]=!0),e[k2]&&(e[Fc]=!0),e[Fc]&&(e[E2]=!0),e[vS]&&(e[E2]=!0);for(const r in e){const i=rI(r,n);i.indexOf(t)<0&&i.push(t)}}function iI(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function qn(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}qn.groups={};qn.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;rt.ta(e,n,r,i),kt=(t,e,n,r,i)=>t.tr(e,n,r,i),Pw=(t,e,n,r,i)=>t.ts(e,n,r,i),ie=(t,e,n,r,i)=>t.tt(e,n,r,i),Bi="WORD",M2="UWORD",bS="ASCIINUMERICAL",CS="ALPHANUMERICAL",mu="LOCALHOST",A2="TLD",N2="UTLD",$f="SCHEME",na="SLASH_SCHEME",t3="NUM",R2="WS",n3="NL",Wc="OPENBRACE",Jc="CLOSEBRACE",yh="OPENBRACKET",vh="CLOSEBRACKET",bh="OPENPAREN",Ch="CLOSEPAREN",wh="OPENANGLEBRACKET",xh="CLOSEANGLEBRACKET",Sh="FULLWIDTHLEFTPAREN",Th="FULLWIDTHRIGHTPAREN",kh="LEFTCORNERBRACKET",Eh="RIGHTCORNERBRACKET",Mh="LEFTWHITECORNERBRACKET",Ah="RIGHTWHITECORNERBRACKET",Nh="FULLWIDTHLESSTHAN",Rh="FULLWIDTHGREATERTHAN",Oh="AMPERSAND",Dh="APOSTROPHE",Lh="ASTERISK",Ho="AT",_h="BACKSLASH",Hh="BACKTICK",Ih="CARET",Bo="COLON",r3="COMMA",zh="DOLLAR",oi="DOT",Bh="EQUALS",i3="EXCLAMATION",xr="HYPHEN",Xc="PERCENT",jh="PIPE",Vh="PLUS",Uh="POUND",Qc="QUERY",o3="QUOTE",wS="FULLWIDTHMIDDLEDOT",s3="SEMI",si="SLASH",eu="TILDE",Ph="UNDERSCORE",xS="EMOJI",Fh="SYM";var SS=Object.freeze({__proto__:null,ALPHANUMERICAL:CS,AMPERSAND:Oh,APOSTROPHE:Dh,ASCIINUMERICAL:bS,ASTERISK:Lh,AT:Ho,BACKSLASH:_h,BACKTICK:Hh,CARET:Ih,CLOSEANGLEBRACKET:xh,CLOSEBRACE:Jc,CLOSEBRACKET:vh,CLOSEPAREN:Ch,COLON:Bo,COMMA:r3,DOLLAR:zh,DOT:oi,EMOJI:xS,EQUALS:Bh,EXCLAMATION:i3,FULLWIDTHGREATERTHAN:Rh,FULLWIDTHLEFTPAREN:Sh,FULLWIDTHLESSTHAN:Nh,FULLWIDTHMIDDLEDOT:wS,FULLWIDTHRIGHTPAREN:Th,HYPHEN:xr,LEFTCORNERBRACKET:kh,LEFTWHITECORNERBRACKET:Mh,LOCALHOST:mu,NL:n3,NUM:t3,OPENANGLEBRACKET:wh,OPENBRACE:Wc,OPENBRACKET:yh,OPENPAREN:bh,PERCENT:Xc,PIPE:jh,PLUS:Vh,POUND:Uh,QUERY:Qc,QUOTE:o3,RIGHTCORNERBRACKET:Eh,RIGHTWHITECORNERBRACKET:Ah,SCHEME:$f,SEMI:s3,SLASH:si,SLASH_SCHEME:na,SYM:Fh,TILDE:eu,TLD:A2,UNDERSCORE:Ph,UTLD:N2,UWORD:M2,WORD:Bi,WS:R2});const Hi=/[a-z]/,Hc=/\p{L}/u,g0=/\p{Emoji}/u,Ii=/\d/,y0=/\s/,Fw="\r",v0=` -`,oI="️",sI="‍",b0="";let Cf=null,wf=null;function lI(t=[]){const e={};qn.groups=e;const n=new qn;Cf==null&&(Cf=$w(QH)),wf==null&&(wf=$w(eI)),ie(n,"'",Dh),ie(n,"{",Wc),ie(n,"}",Jc),ie(n,"[",yh),ie(n,"]",vh),ie(n,"(",bh),ie(n,")",Ch),ie(n,"<",wh),ie(n,">",xh),ie(n,"(",Sh),ie(n,")",Th),ie(n,"「",kh),ie(n,"」",Eh),ie(n,"『",Mh),ie(n,"』",Ah),ie(n,"<",Nh),ie(n,">",Rh),ie(n,"&",Oh),ie(n,"*",Lh),ie(n,"@",Ho),ie(n,"`",Hh),ie(n,"^",Ih),ie(n,":",Bo),ie(n,",",r3),ie(n,"$",zh),ie(n,".",oi),ie(n,"=",Bh),ie(n,"!",i3),ie(n,"-",xr),ie(n,"%",Xc),ie(n,"|",jh),ie(n,"+",Vh),ie(n,"#",Uh),ie(n,"?",Qc),ie(n,'"',o3),ie(n,"/",si),ie(n,";",s3),ie(n,"~",eu),ie(n,"_",Ph),ie(n,"\\",_h),ie(n,"・",wS);const r=kt(n,Ii,t3,{[S2]:!0});kt(r,Ii,r);const i=kt(r,Hi,bS,{[Yc]:!0}),o=kt(r,Hc,CS,{[Fc]:!0}),l=kt(n,Hi,Bi,{[T2]:!0});kt(l,Ii,i),kt(l,Hi,l),kt(i,Ii,i),kt(i,Hi,i);const c=kt(n,Hc,M2,{[k2]:!0});kt(c,Hi),kt(c,Ii,o),kt(c,Hc,c),kt(o,Ii,o),kt(o,Hi),kt(o,Hc,o);const d=ie(n,v0,n3,{[m0]:!0}),f=ie(n,Fw,R2,{[m0]:!0}),h=kt(n,y0,R2,{[m0]:!0});ie(n,b0,h),ie(f,v0,d),ie(f,b0,h),kt(f,y0,h),ie(h,Fw),ie(h,v0),kt(h,y0,h),ie(h,b0,h);const m=kt(n,g0,xS,{[vS]:!0});ie(m,"#"),kt(m,g0,m),ie(m,oI,m);const g=ie(m,sI);ie(g,"#"),kt(g,g0,m);const y=[[Hi,l],[Ii,i]],C=[[Hi,null],[Hc,c],[Ii,o]];for(let w=0;ww[0]>x[0]?1:-1);for(let w=0;w=0?A[E2]=!0:Hi.test(x)?Ii.test(x)?A[Yc]=!0:A[T2]=!0:A[S2]=!0,Pw(n,x,x,A)}return Pw(n,"localhost",mu,{ascii:!0}),n.jd=new qn(Fh),{start:n,tokens:Object.assign({groups:e},SS)}}function TS(t,e){const n=aI(e.replace(/[A-Z]/g,c=>c.toLowerCase())),r=n.length,i=[];let o=0,l=0;for(;l=0&&(m+=n[l].length,g++),f+=n[l].length,o+=n[l].length,l++;o-=m,l-=g,f-=m,i.push({t:h.t,v:e.slice(o-f,o),s:o-f,e:o})}return i}function aI(t){const e=[],n=t.length;let r=0;for(;r56319||r+1===n||(o=t.charCodeAt(r+1))<56320||o>57343?t[r]:t.slice(r,r+2);e.push(l),r+=l.length}return e}function No(t,e,n,r,i){let o;const l=e.length;for(let c=0;c=0;)o++;if(o>0){e.push(n.join(""));for(let l=parseInt(t.substring(r,r+o),10);l>0;l--)n.pop();r+=o}else n.push(t[r]),r++}return e}const gu={defaultProtocol:"http",events:null,format:qw,formatHref:qw,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function l3(t,e=null){let n=Object.assign({},gu);t&&(n=Object.assign(n,t instanceof l3?t.o:t));const r=n.ignoreTags,i=[];for(let o=0;on?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=gu.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),o=this.toFormattedString(t),l={},c=t.get("className",n,e),d=t.get("target",n,e),f=t.get("rel",n,e),h=t.getObj("attributes",n,e),m=t.getObj("events",n,e);return l.href=r,c&&(l.class=c),d&&(l.target=d),f&&(l.rel=f),h&&Object.assign(l,h),{tagName:i,attributes:l,content:o,eventListeners:m}}};function Hp(t,e){class n extends kS{constructor(i,o){super(i,o),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const Zw=Hp("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Kw=Hp("text"),cI=Hp("nl"),xf=Hp("url",{isLink:!0,toHref(t=gu.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==mu&&t[1].t===Bo}}),Cr=t=>new qn(t);function uI({groups:t}){const e=t.domain.concat([Oh,Lh,Ho,_h,Hh,Ih,zh,Bh,xr,t3,Xc,jh,Vh,Uh,si,Fh,eu,Ph]),n=[Dh,Bo,r3,oi,i3,Xc,Qc,o3,s3,wh,xh,Wc,Jc,vh,yh,bh,Ch,Sh,Th,kh,Eh,Mh,Ah,Nh,Rh],r=[Oh,Dh,Lh,_h,Hh,Ih,zh,Bh,xr,Wc,Jc,Xc,jh,Vh,Uh,Qc,si,Fh,eu,Ph],i=Cr(),o=ie(i,eu);Oe(o,r,o),Oe(o,t.domain,o);const l=Cr(),c=Cr(),d=Cr();Oe(i,t.domain,l),Oe(i,t.scheme,c),Oe(i,t.slashscheme,d),Oe(l,r,o),Oe(l,t.domain,l);const f=ie(l,Ho);ie(o,Ho,f),ie(c,Ho,f),ie(d,Ho,f);const h=ie(o,oi);Oe(h,r,o),Oe(h,t.domain,o);const m=Cr();Oe(f,t.domain,m),Oe(m,t.domain,m);const g=ie(m,oi);Oe(g,t.domain,m);const y=Cr(Zw);Oe(g,t.tld,y),Oe(g,t.utld,y),ie(f,mu,y);const C=ie(m,xr);ie(C,xr,C),Oe(C,t.domain,m),Oe(y,t.domain,m),ie(y,oi,g),ie(y,xr,C);const w=ie(y,Bo);Oe(w,t.numeric,Zw);const x=ie(l,xr),k=ie(l,oi);ie(x,xr,x),Oe(x,t.domain,l),Oe(k,r,o),Oe(k,t.domain,l);const A=Cr(xf);Oe(k,t.tld,A),Oe(k,t.utld,A),Oe(A,t.domain,l),Oe(A,r,o),ie(A,oi,k),ie(A,xr,x),ie(A,Ho,f);const N=ie(A,Bo),R=Cr(xf);Oe(N,t.numeric,R);const L=Cr(xf),z=Cr();Oe(L,e,L),Oe(L,n,z),Oe(z,e,L),Oe(z,n,z),ie(A,si,L),ie(R,si,L);const _=ie(c,Bo),q=ie(d,Bo),J=ie(q,si),U=ie(J,si);Oe(c,t.domain,l),ie(c,oi,k),ie(c,xr,x),Oe(d,t.domain,l),ie(d,oi,k),ie(d,xr,x),Oe(_,t.domain,L),ie(_,si,L),ie(_,Qc,L),Oe(U,t.domain,L),Oe(U,e,L),ie(U,si,L);const ne=[[Wc,Jc],[yh,vh],[bh,Ch],[wh,xh],[Sh,Th],[kh,Eh],[Mh,Ah],[Nh,Rh]];for(let le=0;le=0&&g++,i++,h++;if(g<0)i-=h,i0&&(o.push(C0(Kw,e,l)),l=[]),i-=g,h-=g;const y=m.t,C=n.slice(i-h,i);o.push(C0(y,e,C))}}return l.length>0&&o.push(C0(Kw,e,l)),o}function C0(t,e,n){const r=n[0].s,i=n[n.length-1].e,o=e.slice(r,i);return new t(o,n)}const fI=typeof console<"u"&&console&&console.warn||(()=>{}),hI="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",gt={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function pI(){return qn.groups={},gt.scanner=null,gt.parser=null,gt.tokenQueue=[],gt.pluginQueue=[],gt.customSchemes=[],gt.initialized=!1,gt}function Gw(t,e=!1){if(gt.initialized&&fI(`linkifyjs: already initialized - will not register custom scheme "${t}" ${hI}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format. +`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:o}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:l}=this.options,{splittableMarks:c}=r.extensionManager,d=o||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:f,dispatch:h})=>{if(h&&d&&l){const m=d.filter(g=>c.includes(g.type.name));f.ensureMarks(m)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),ZH=st.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Fe(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,i="#".repeat(r);return t.content?`${i} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>b2({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),KH=st.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Fe(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!y_(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return Ky(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:o,tr:l,dispatch:c})=>{if(c){const{$to:d}=l.selection,f=d.end();if(d.nodeAfter)d.nodeAfter.isTextblock?l.setSelection(ue.create(l.doc,d.pos+1)):d.nodeAfter.isBlock?l.setSelection(me.create(l.doc,d.pos)):l.setSelection(ue.create(l.doc,d.pos));else{const h=o.schema.nodes[this.options.nextNodeType]||d.parent.type.contentMatch.defaultType,m=h?.create();m&&(l.insert(f,m),l.setSelection(ue.create(l.doc,f+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[g_({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),GH=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,YH=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,WH=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,JH=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,XH=Xi.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Fe(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ba({find:GH,type:this.type}),ba({find:WH,type:this.type})]},addPasteRules(){return[Ks({find:YH,type:this.type}),Ks({find:JH,type:this.type})]}});const QH="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",eI="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",S2="numeric",T2="ascii",k2="alpha",Yc="asciinumeric",Fc="alphanumeric",E2="domain",vS="emoji",tI="scheme",nI="slashscheme",m0="whitespace";function rI(t,e){return t in e||(e[t]=[]),e[t]}function Hs(t,e,n){e[S2]&&(e[Yc]=!0,e[Fc]=!0),e[T2]&&(e[Yc]=!0,e[k2]=!0),e[Yc]&&(e[Fc]=!0),e[k2]&&(e[Fc]=!0),e[Fc]&&(e[E2]=!0),e[vS]&&(e[E2]=!0);for(const r in e){const i=rI(r,n);i.indexOf(t)<0&&i.push(t)}}function iI(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function qn(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}qn.groups={};qn.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;rt.ta(e,n,r,i),kt=(t,e,n,r,i)=>t.tr(e,n,r,i),Pw=(t,e,n,r,i)=>t.ts(e,n,r,i),ie=(t,e,n,r,i)=>t.tt(e,n,r,i),Bi="WORD",M2="UWORD",bS="ASCIINUMERICAL",CS="ALPHANUMERICAL",mu="LOCALHOST",A2="TLD",N2="UTLD",$f="SCHEME",na="SLASH_SCHEME",t3="NUM",R2="WS",n3="NL",Wc="OPENBRACE",Jc="CLOSEBRACE",yh="OPENBRACKET",vh="CLOSEBRACKET",bh="OPENPAREN",Ch="CLOSEPAREN",wh="OPENANGLEBRACKET",xh="CLOSEANGLEBRACKET",Sh="FULLWIDTHLEFTPAREN",Th="FULLWIDTHRIGHTPAREN",kh="LEFTCORNERBRACKET",Eh="RIGHTCORNERBRACKET",Mh="LEFTWHITECORNERBRACKET",Ah="RIGHTWHITECORNERBRACKET",Nh="FULLWIDTHLESSTHAN",Rh="FULLWIDTHGREATERTHAN",Oh="AMPERSAND",Dh="APOSTROPHE",Lh="ASTERISK",Ho="AT",_h="BACKSLASH",Hh="BACKTICK",Ih="CARET",Bo="COLON",r3="COMMA",zh="DOLLAR",oi="DOT",Bh="EQUALS",i3="EXCLAMATION",xr="HYPHEN",Xc="PERCENT",jh="PIPE",Vh="PLUS",Uh="POUND",Qc="QUERY",o3="QUOTE",wS="FULLWIDTHMIDDLEDOT",s3="SEMI",si="SLASH",eu="TILDE",Ph="UNDERSCORE",xS="EMOJI",Fh="SYM";var SS=Object.freeze({__proto__:null,ALPHANUMERICAL:CS,AMPERSAND:Oh,APOSTROPHE:Dh,ASCIINUMERICAL:bS,ASTERISK:Lh,AT:Ho,BACKSLASH:_h,BACKTICK:Hh,CARET:Ih,CLOSEANGLEBRACKET:xh,CLOSEBRACE:Jc,CLOSEBRACKET:vh,CLOSEPAREN:Ch,COLON:Bo,COMMA:r3,DOLLAR:zh,DOT:oi,EMOJI:xS,EQUALS:Bh,EXCLAMATION:i3,FULLWIDTHGREATERTHAN:Rh,FULLWIDTHLEFTPAREN:Sh,FULLWIDTHLESSTHAN:Nh,FULLWIDTHMIDDLEDOT:wS,FULLWIDTHRIGHTPAREN:Th,HYPHEN:xr,LEFTCORNERBRACKET:kh,LEFTWHITECORNERBRACKET:Mh,LOCALHOST:mu,NL:n3,NUM:t3,OPENANGLEBRACKET:wh,OPENBRACE:Wc,OPENBRACKET:yh,OPENPAREN:bh,PERCENT:Xc,PIPE:jh,PLUS:Vh,POUND:Uh,QUERY:Qc,QUOTE:o3,RIGHTCORNERBRACKET:Eh,RIGHTWHITECORNERBRACKET:Ah,SCHEME:$f,SEMI:s3,SLASH:si,SLASH_SCHEME:na,SYM:Fh,TILDE:eu,TLD:A2,UNDERSCORE:Ph,UTLD:N2,UWORD:M2,WORD:Bi,WS:R2});const Hi=/[a-z]/,Hc=/\p{L}/u,g0=/\p{Emoji}/u,Ii=/\d/,y0=/\s/,Fw="\r",v0=` +`,oI="️",sI="‍",b0="";let Cf=null,wf=null;function lI(t=[]){const e={};qn.groups=e;const n=new qn;Cf==null&&(Cf=$w(QH)),wf==null&&(wf=$w(eI)),ie(n,"'",Dh),ie(n,"{",Wc),ie(n,"}",Jc),ie(n,"[",yh),ie(n,"]",vh),ie(n,"(",bh),ie(n,")",Ch),ie(n,"<",wh),ie(n,">",xh),ie(n,"(",Sh),ie(n,")",Th),ie(n,"「",kh),ie(n,"」",Eh),ie(n,"『",Mh),ie(n,"』",Ah),ie(n,"<",Nh),ie(n,">",Rh),ie(n,"&",Oh),ie(n,"*",Lh),ie(n,"@",Ho),ie(n,"`",Hh),ie(n,"^",Ih),ie(n,":",Bo),ie(n,",",r3),ie(n,"$",zh),ie(n,".",oi),ie(n,"=",Bh),ie(n,"!",i3),ie(n,"-",xr),ie(n,"%",Xc),ie(n,"|",jh),ie(n,"+",Vh),ie(n,"#",Uh),ie(n,"?",Qc),ie(n,'"',o3),ie(n,"/",si),ie(n,";",s3),ie(n,"~",eu),ie(n,"_",Ph),ie(n,"\\",_h),ie(n,"・",wS);const r=kt(n,Ii,t3,{[S2]:!0});kt(r,Ii,r);const i=kt(r,Hi,bS,{[Yc]:!0}),o=kt(r,Hc,CS,{[Fc]:!0}),l=kt(n,Hi,Bi,{[T2]:!0});kt(l,Ii,i),kt(l,Hi,l),kt(i,Ii,i),kt(i,Hi,i);const c=kt(n,Hc,M2,{[k2]:!0});kt(c,Hi),kt(c,Ii,o),kt(c,Hc,c),kt(o,Ii,o),kt(o,Hi),kt(o,Hc,o);const d=ie(n,v0,n3,{[m0]:!0}),f=ie(n,Fw,R2,{[m0]:!0}),h=kt(n,y0,R2,{[m0]:!0});ie(n,b0,h),ie(f,v0,d),ie(f,b0,h),kt(f,y0,h),ie(h,Fw),ie(h,v0),kt(h,y0,h),ie(h,b0,h);const m=kt(n,g0,xS,{[vS]:!0});ie(m,"#"),kt(m,g0,m),ie(m,oI,m);const g=ie(m,sI);ie(g,"#"),kt(g,g0,m);const y=[[Hi,l],[Ii,i]],C=[[Hi,null],[Hc,c],[Ii,o]];for(let w=0;ww[0]>x[0]?1:-1);for(let w=0;w=0?A[E2]=!0:Hi.test(x)?Ii.test(x)?A[Yc]=!0:A[T2]=!0:A[S2]=!0,Pw(n,x,x,A)}return Pw(n,"localhost",mu,{ascii:!0}),n.jd=new qn(Fh),{start:n,tokens:Object.assign({groups:e},SS)}}function TS(t,e){const n=aI(e.replace(/[A-Z]/g,c=>c.toLowerCase())),r=n.length,i=[];let o=0,l=0;for(;l=0&&(m+=n[l].length,g++),f+=n[l].length,o+=n[l].length,l++;o-=m,l-=g,f-=m,i.push({t:h.t,v:e.slice(o-f,o),s:o-f,e:o})}return i}function aI(t){const e=[],n=t.length;let r=0;for(;r56319||r+1===n||(o=t.charCodeAt(r+1))<56320||o>57343?t[r]:t.slice(r,r+2);e.push(l),r+=l.length}return e}function No(t,e,n,r,i){let o;const l=e.length;for(let c=0;c=0;)o++;if(o>0){e.push(n.join(""));for(let l=parseInt(t.substring(r,r+o),10);l>0;l--)n.pop();r+=o}else n.push(t[r]),r++}return e}const gu={defaultProtocol:"http",events:null,format:qw,formatHref:qw,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function l3(t,e=null){let n=Object.assign({},gu);t&&(n=Object.assign(n,t instanceof l3?t.o:t));const r=n.ignoreTags,i=[];for(let o=0;on?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=gu.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),o=this.toFormattedString(t),l={},c=t.get("className",n,e),d=t.get("target",n,e),f=t.get("rel",n,e),h=t.getObj("attributes",n,e),m=t.getObj("events",n,e);return l.href=r,c&&(l.class=c),d&&(l.target=d),f&&(l.rel=f),h&&Object.assign(l,h),{tagName:i,attributes:l,content:o,eventListeners:m}}};function Hp(t,e){class n extends kS{constructor(i,o){super(i,o),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const Zw=Hp("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Kw=Hp("text"),cI=Hp("nl"),xf=Hp("url",{isLink:!0,toHref(t=gu.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==mu&&t[1].t===Bo}}),Cr=t=>new qn(t);function uI({groups:t}){const e=t.domain.concat([Oh,Lh,Ho,_h,Hh,Ih,zh,Bh,xr,t3,Xc,jh,Vh,Uh,si,Fh,eu,Ph]),n=[Dh,Bo,r3,oi,i3,Xc,Qc,o3,s3,wh,xh,Wc,Jc,vh,yh,bh,Ch,Sh,Th,kh,Eh,Mh,Ah,Nh,Rh],r=[Oh,Dh,Lh,_h,Hh,Ih,zh,Bh,xr,Wc,Jc,Xc,jh,Vh,Uh,Qc,si,Fh,eu,Ph],i=Cr(),o=ie(i,eu);Oe(o,r,o),Oe(o,t.domain,o);const l=Cr(),c=Cr(),d=Cr();Oe(i,t.domain,l),Oe(i,t.scheme,c),Oe(i,t.slashscheme,d),Oe(l,r,o),Oe(l,t.domain,l);const f=ie(l,Ho);ie(o,Ho,f),ie(c,Ho,f),ie(d,Ho,f);const h=ie(o,oi);Oe(h,r,o),Oe(h,t.domain,o);const m=Cr();Oe(f,t.domain,m),Oe(m,t.domain,m);const g=ie(m,oi);Oe(g,t.domain,m);const y=Cr(Zw);Oe(g,t.tld,y),Oe(g,t.utld,y),ie(f,mu,y);const C=ie(m,xr);ie(C,xr,C),Oe(C,t.domain,m),Oe(y,t.domain,m),ie(y,oi,g),ie(y,xr,C);const w=ie(y,Bo);Oe(w,t.numeric,Zw);const x=ie(l,xr),k=ie(l,oi);ie(x,xr,x),Oe(x,t.domain,l),Oe(k,r,o),Oe(k,t.domain,l);const A=Cr(xf);Oe(k,t.tld,A),Oe(k,t.utld,A),Oe(A,t.domain,l),Oe(A,r,o),ie(A,oi,k),ie(A,xr,x),ie(A,Ho,f);const N=ie(A,Bo),R=Cr(xf);Oe(N,t.numeric,R);const L=Cr(xf),z=Cr();Oe(L,e,L),Oe(L,n,z),Oe(z,e,L),Oe(z,n,z),ie(A,si,L),ie(R,si,L);const _=ie(c,Bo),$=ie(d,Bo),J=ie($,si),U=ie(J,si);Oe(c,t.domain,l),ie(c,oi,k),ie(c,xr,x),Oe(d,t.domain,l),ie(d,oi,k),ie(d,xr,x),Oe(_,t.domain,L),ie(_,si,L),ie(_,Qc,L),Oe(U,t.domain,L),Oe(U,e,L),ie(U,si,L);const ne=[[Wc,Jc],[yh,vh],[bh,Ch],[wh,xh],[Sh,Th],[kh,Eh],[Mh,Ah],[Nh,Rh]];for(let se=0;se=0&&g++,i++,h++;if(g<0)i-=h,i0&&(o.push(C0(Kw,e,l)),l=[]),i-=g,h-=g;const y=m.t,C=n.slice(i-h,i);o.push(C0(y,e,C))}}return l.length>0&&o.push(C0(Kw,e,l)),o}function C0(t,e,n){const r=n[0].s,i=n[n.length-1].e,o=e.slice(r,i);return new t(o,n)}const fI=typeof console<"u"&&console&&console.warn||(()=>{}),hI="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",gt={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function pI(){return qn.groups={},gt.scanner=null,gt.parser=null,gt.tokenQueue=[],gt.pluginQueue=[],gt.customSchemes=[],gt.initialized=!1,gt}function Gw(t,e=!1){if(gt.initialized&&fI(`linkifyjs: already initialized - will not register custom scheme "${t}" ${hI}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format. 1. Must only contain digits, lowercase ASCII letters or "-" 2. Cannot start or end with "-" -3. "-" cannot repeat`);gt.customSchemes.push([t,e])}function mI(){gt.scanner=lI(gt.customSchemes);for(let t=0;t{const i=e.some(f=>f.docChanged)&&!n.doc.eq(r.doc),o=e.some(f=>f.getMeta("preventAutolink"));if(!i||o)return;const{tr:l}=r,c=jx(n.doc,[...e]);if(Gx(c).forEach(({newRange:f})=>{const h=CL(r.doc,f,y=>y.isTextblock);let m,g;if(h.length>1)m=h[0],g=r.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(h.length){const y=r.doc.textBetween(f.from,f.to," "," ");if(!yI.test(y))return;m=h[0],g=r.doc.textBetween(m.pos,f.to,void 0," ")}if(m&&g){const y=g.split(gI).filter(Boolean);if(y.length<=0)return!1;const C=y[y.length-1],w=m.pos+g.lastIndexOf(C);if(!C)return!1;const x=a3(C).map(k=>k.toObject(t.defaultProtocol));if(!bI(x))return!1;x.filter(k=>k.isLink).map(k=>({...k,from:w+k.start+1,to:w+k.end+1})).filter(k=>r.schema.marks.code?!r.doc.rangeHasMark(k.from,k.to,r.schema.marks.code):!0).filter(k=>t.validate(k.value)).filter(k=>t.shouldAutoLink(k.value)).forEach(k=>{Zy(k.from,k.to,r.doc).some(A=>A.mark.type===t.type)||l.addMark(k.from,k.to,t.type.create({href:k.href}))})}}),!!l.steps.length)return l}})}function wI(t){return new Ve({key:new qe("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,o;if(r.button!==0||!e.editable)return!1;let l=!1;if(t.enableClickSelection&&(l=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){let c=null;if(r.target instanceof HTMLAnchorElement)c=r.target;else{let m=r.target;const g=[];for(;m.nodeName!=="DIV";)g.push(m),m=m.parentNode;c=g.find(y=>y.nodeName==="A")}if(!c)return l;const d=Kx(e.state,t.type.name),f=(i=c?.href)!=null?i:d.href,h=(o=c?.target)!=null?o:d.target;c&&f&&(window.open(f,h),l=!0)}return l}}})}function xI(t){return new Ve({key:new qe("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:o}=e,{selection:l}=o,{empty:c}=l;if(c)return!1;let d="";r.content.forEach(h=>{d+=h.textContent});const f=ES(d,{defaultProtocol:t.defaultProtocol}).find(h=>h.isLink&&h.value===d);return!d||!f||i!==void 0&&!i(f.href)?!1:t.editor.commands.setMark(t.type,{href:f.href})}}})}function Ms(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(vI,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var SI=Xi.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){Gw(t);return}Gw(t.scheme,t.optionalSlashes)})},onDestroy(){pI()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Ms(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Ms(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Ms(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Pe(this.options.HTMLAttributes,t),0]:["a",Pe(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n;const r=((n=t.attrs)==null?void 0:n.href)||"";return`[${e.renderChildren(t)}](${r})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Ms(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Ms(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Ks({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=ES(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:l=>!!Ms(l,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(o=>{this.options.shouldAutoLink(o.value)&&e.push({text:o.value,data:{href:o.href},index:o.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(CI({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Ms(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(wI({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(xI({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),TI=Object.defineProperty,kI=(t,e)=>{for(var n in e)TI(t,n,{get:e[n],enumerable:!0})},EI="listItem",Yw="textStyle",Ww=/^\s*([-+*])\s$/,MS=st.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",Pe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` -`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(EI,this.editor.getAttributes(Yw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Ca({find:Ww,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ca({find:Ww,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Yw),editor:this.editor})),[t]}}),AS=st.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Pe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(i=>i.type==="paragraph"))n=e.parseChildren(t.tokens);else{const i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(i.tokens)}],t.tokens.length>1){const l=t.tokens.slice(1),c=e.parseChildren(l);n.push(...c)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>Xy(t,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.index+1}. `:"- ",n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),MI={};kI(MI,{findListItemPos:()=>Iu,getNextListDepth:()=>u3,handleBackspace:()=>O2,handleDelete:()=>D2,hasListBefore:()=>NS,hasListItemAfter:()=>AI,hasListItemBefore:()=>RS,listItemHasSubList:()=>OS,nextListIsDeeper:()=>DS,nextListIsHigher:()=>LS});var Iu=(t,e)=>{const{$from:n}=e.selection,r=$t(t,e.schema);let i=null,o=n.depth,l=n.pos,c=null;for(;o>0&&c===null;)i=n.node(o),i.type===r?c=o:(o-=1,l-=1);return c===null?null:{$pos:e.doc.resolve(l),depth:c}},u3=(t,e)=>{const n=Iu(t,e);if(!n)return!1;const[,r]=AL(e,t,n.$pos.pos+4);return r},NS=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),o=t.doc.resolve(i).node();return!(!o||!n.includes(o.type.name))},RS=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return!(i.index()===0||((n=i.nodeBefore)==null?void 0:n.type.name)!==t)},OS=(t,e,n)=>{if(!n)return!1;const r=$t(t,e.schema);let i=!1;return n.descendants(o=>{o.type===r&&(i=!0)}),i},O2=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Jo(t.state,e)&&NS(t.state,e,n)){const{$anchor:c}=t.state.selection,d=t.state.doc.resolve(c.before()-1),f=[];d.node().descendants((g,y)=>{g.type.name===e&&f.push({node:g,pos:y})});const h=f.at(-1);if(!h)return!1;const m=t.state.doc.resolve(d.start()+h.pos+1);return t.chain().cut({from:c.start()-1,to:c.end()+1},m.end()).joinForward().run()}if(!Jo(t.state,e)||!DL(t.state))return!1;const r=Iu(e,t.state);if(!r)return!1;const o=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),l=OS(e,t.state,o);return RS(e,t.state)&&!l?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},DS=(t,e)=>{const n=u3(t,e),r=Iu(t,e);return!r||!n?!1:n>r.depth},LS=(t,e)=>{const n=u3(t,e),r=Iu(t,e);return!r||!n?!1:n{if(!Jo(t.state,e)||!OL(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:DS(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():LS(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},AI=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((n=i.nodeAfter)==null?void 0:n.type.name)!==t)},_S=Ze.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&D2(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&D2(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&O2(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&O2(t,n,r)&&(e=!0)}),e}}}}),Jw=/^(\s*)(\d+)\.\s+(.*)$/,NI=/^\s/;function RI(t){const e=[];let n=0,r=0;for(;n{const i=e.some(f=>f.docChanged)&&!n.doc.eq(r.doc),o=e.some(f=>f.getMeta("preventAutolink"));if(!i||o)return;const{tr:l}=r,c=jx(n.doc,[...e]);if(Gx(c).forEach(({newRange:f})=>{const h=CL(r.doc,f,y=>y.isTextblock);let m,g;if(h.length>1)m=h[0],g=r.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(h.length){const y=r.doc.textBetween(f.from,f.to," "," ");if(!yI.test(y))return;m=h[0],g=r.doc.textBetween(m.pos,f.to,void 0," ")}if(m&&g){const y=g.split(gI).filter(Boolean);if(y.length<=0)return!1;const C=y[y.length-1],w=m.pos+g.lastIndexOf(C);if(!C)return!1;const x=a3(C).map(k=>k.toObject(t.defaultProtocol));if(!bI(x))return!1;x.filter(k=>k.isLink).map(k=>({...k,from:w+k.start+1,to:w+k.end+1})).filter(k=>r.schema.marks.code?!r.doc.rangeHasMark(k.from,k.to,r.schema.marks.code):!0).filter(k=>t.validate(k.value)).filter(k=>t.shouldAutoLink(k.value)).forEach(k=>{Zy(k.from,k.to,r.doc).some(A=>A.mark.type===t.type)||l.addMark(k.from,k.to,t.type.create({href:k.href}))})}}),!!l.steps.length)return l}})}function wI(t){return new Ue({key:new Ze("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,o;if(r.button!==0||!e.editable)return!1;let l=!1;if(t.enableClickSelection&&(l=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){let c=null;if(r.target instanceof HTMLAnchorElement)c=r.target;else{let m=r.target;const g=[];for(;m.nodeName!=="DIV";)g.push(m),m=m.parentNode;c=g.find(y=>y.nodeName==="A")}if(!c)return l;const d=Kx(e.state,t.type.name),f=(i=c?.href)!=null?i:d.href,h=(o=c?.target)!=null?o:d.target;c&&f&&(window.open(f,h),l=!0)}return l}}})}function xI(t){return new Ue({key:new Ze("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:o}=e,{selection:l}=o,{empty:c}=l;if(c)return!1;let d="";r.content.forEach(h=>{d+=h.textContent});const f=ES(d,{defaultProtocol:t.defaultProtocol}).find(h=>h.isLink&&h.value===d);return!d||!f||i!==void 0&&!i(f.href)?!1:t.editor.commands.setMark(t.type,{href:f.href})}}})}function Ms(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(vI,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var SI=Xi.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){Gw(t);return}Gw(t.scheme,t.optionalSlashes)})},onDestroy(){pI()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Ms(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Ms(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Ms(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Fe(this.options.HTMLAttributes,t),0]:["a",Fe(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n;const r=((n=t.attrs)==null?void 0:n.href)||"";return`[${e.renderChildren(t)}](${r})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Ms(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Ms(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Ks({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=ES(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:l=>!!Ms(l,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(o=>{this.options.shouldAutoLink(o.value)&&e.push({text:o.value,data:{href:o.href},index:o.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(CI({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Ms(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(wI({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(xI({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),TI=Object.defineProperty,kI=(t,e)=>{for(var n in e)TI(t,n,{get:e[n],enumerable:!0})},EI="listItem",Yw="textStyle",Ww=/^\s*([-+*])\s$/,MS=st.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",Fe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` +`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(EI,this.editor.getAttributes(Yw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Ca({find:Ww,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ca({find:Ww,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Yw),editor:this.editor})),[t]}}),AS=st.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Fe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(i=>i.type==="paragraph"))n=e.parseChildren(t.tokens);else{const i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(i.tokens)}],t.tokens.length>1){const l=t.tokens.slice(1),c=e.parseChildren(l);n.push(...c)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>Xy(t,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.index+1}. `:"- ",n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),MI={};kI(MI,{findListItemPos:()=>Iu,getNextListDepth:()=>u3,handleBackspace:()=>O2,handleDelete:()=>D2,hasListBefore:()=>NS,hasListItemAfter:()=>AI,hasListItemBefore:()=>RS,listItemHasSubList:()=>OS,nextListIsDeeper:()=>DS,nextListIsHigher:()=>LS});var Iu=(t,e)=>{const{$from:n}=e.selection,r=$t(t,e.schema);let i=null,o=n.depth,l=n.pos,c=null;for(;o>0&&c===null;)i=n.node(o),i.type===r?c=o:(o-=1,l-=1);return c===null?null:{$pos:e.doc.resolve(l),depth:c}},u3=(t,e)=>{const n=Iu(t,e);if(!n)return!1;const[,r]=AL(e,t,n.$pos.pos+4);return r},NS=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),o=t.doc.resolve(i).node();return!(!o||!n.includes(o.type.name))},RS=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return!(i.index()===0||((n=i.nodeBefore)==null?void 0:n.type.name)!==t)},OS=(t,e,n)=>{if(!n)return!1;const r=$t(t,e.schema);let i=!1;return n.descendants(o=>{o.type===r&&(i=!0)}),i},O2=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Jo(t.state,e)&&NS(t.state,e,n)){const{$anchor:c}=t.state.selection,d=t.state.doc.resolve(c.before()-1),f=[];d.node().descendants((g,y)=>{g.type.name===e&&f.push({node:g,pos:y})});const h=f.at(-1);if(!h)return!1;const m=t.state.doc.resolve(d.start()+h.pos+1);return t.chain().cut({from:c.start()-1,to:c.end()+1},m.end()).joinForward().run()}if(!Jo(t.state,e)||!DL(t.state))return!1;const r=Iu(e,t.state);if(!r)return!1;const o=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),l=OS(e,t.state,o);return RS(e,t.state)&&!l?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},DS=(t,e)=>{const n=u3(t,e),r=Iu(t,e);return!r||!n?!1:n>r.depth},LS=(t,e)=>{const n=u3(t,e),r=Iu(t,e);return!r||!n?!1:n{if(!Jo(t.state,e)||!OL(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:DS(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():LS(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},AI=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((n=i.nodeAfter)==null?void 0:n.type.name)!==t)},_S=Ke.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&D2(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&D2(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&O2(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&O2(t,n,r)&&(e=!0)}),e}}}}),Jw=/^(\s*)(\d+)\.\s+(.*)$/,NI=/^\s/;function RI(t){const e=[];let n=0,r=0;for(;ne;)g.push(t[m]),m+=1;if(g.length>0){const y=Math.min(...g.map(w=>w.indent)),C=HS(g,y,n);f.push({type:"list",ordered:!0,start:g[0].number,items:C,raw:g.map(w=>w.raw).join(` -`)})}i.push({type:"list_item",raw:l.raw,tokens:f}),o=m}else o+=1}return i}function OI(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const o=e.parseChildren([i]);r.push({type:"paragraph",content:o})}else{const o=e.parseChildren([i]);o.length>0&&r.push(...o)}}),{type:"listItem",content:r}})}var DI="listItem",Xw="textStyle",Qw=/^(\d+)\.\s$/,IS=st.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",Pe(this.options.HTMLAttributes,n),0]:["ol",Pe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?OI(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` +`)})}i.push({type:"list_item",raw:l.raw,tokens:f}),o=m}else o+=1}return i}function OI(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const o=e.parseChildren([i]);r.push({type:"paragraph",content:o})}else{const o=e.parseChildren([i]);o.length>0&&r.push(...o)}}),{type:"listItem",content:r}})}var DI="listItem",Xw="textStyle",Qw=/^(\d+)\.\s$/,IS=st.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",Fe(this.options.HTMLAttributes,n),0]:["ol",Fe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?OI(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const i=t.split(` `),[o,l]=RI(i);if(o.length===0)return;const c=HS(o,0,n);return c.length===0?void 0:{type:"list",ordered:!0,start:((r=o[0])==null?void 0:r.number)||1,items:c,raw:i.slice(0,l).join(` -`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(DI,this.editor.getAttributes(Xw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Ca({find:Qw,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ca({find:Qw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Xw)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),LI=/^\s*(\[([( |x])?\])\s$/,_I=st.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",Pe(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const i=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Xy(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),o=document.createElement("label"),l=document.createElement("span"),c=document.createElement("input"),d=document.createElement("div"),f=h=>{var m,g;c.ariaLabel=((g=(m=this.options.a11y)==null?void 0:m.checkboxLabel)==null?void 0:g.call(m,h,c.checked))||`Task item checkbox for ${h.textContent||"empty task item"}`};return f(t),o.contentEditable="false",c.type="checkbox",c.addEventListener("mousedown",h=>h.preventDefault()),c.addEventListener("change",h=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){c.checked=!c.checked;return}const{checked:m}=h.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:g})=>{const y=n();if(typeof y!="number")return!1;const C=g.doc.nodeAt(y);return g.setNodeMarkup(y,void 0,{...C?.attrs,checked:m}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,m)||(c.checked=!c.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([h,m])=>{i.setAttribute(h,m)}),i.dataset.checked=t.attrs.checked,c.checked=t.attrs.checked,o.append(c,l),i.append(o,d),Object.entries(e).forEach(([h,m])=>{i.setAttribute(h,m)}),{dom:i,contentDOM:d,update:h=>h.type!==this.type?!1:(i.dataset.checked=h.attrs.checked,c.checked=h.attrs.checked,f(h),!0)}}},addInputRules(){return[Ca({find:LI,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),HI=st.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",Pe(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` -`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=o=>{const l=C2(o,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:c=>({indentLevel:c[1].length,mainContent:c[4],checked:c[3].toLowerCase()==="x"}),createToken:(c,d)=>({type:"taskItem",raw:"",mainContent:c.mainContent,indentLevel:c.indentLevel,checked:c.checked,text:c.mainContent,tokens:n.inlineTokens(c.mainContent),nestedTokens:d}),customNestedParser:r},n);return l?[{type:"taskList",raw:l.raw,items:l.items}]:n.blockTokens(o)},i=C2(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,l)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:l}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Ze.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(MS.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(AS.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(_S.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(IS.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(_I.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(HI.configure(this.options.taskList)),t}});var zS=st.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Pe(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];return n.length===1&&n[0].type==="image"?e.parseChildren([n[0]]):e.createNode("paragraph",void 0,e.parseInline(n))},renderMarkdown:(t,e)=>!t||!Array.isArray(t.content)?"":e.renderChildren(t.content),addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),II=zS,zI=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,BI=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,jI=Xi.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",Pe(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ba({find:zI,type:this.type})]},addPasteRules(){return[Ks({find:BI,type:this.type})]}}),VI=st.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),UI=Xi.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Pe(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const o=i[2].trim();return{type:"underline",raw:i[0],text:o,tokens:n.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function PI(t={}){return new Ve({view(e){return new FI(e,t)}})}class FI{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=l=>{this[i](l)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,o=i.getBoundingClientRect(),l=o.width/i.offsetWidth,c=o.height/i.offsetHeight;if(n){let m=e.nodeBefore,g=e.nodeAfter;if(m||g){let y=this.editorView.nodeDOM(this.cursorPos-(m?m.nodeSize:0));if(y){let C=y.getBoundingClientRect(),w=m?C.bottom:C.top;m&&g&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*c;r={left:C.left,right:C.right,top:w-x,bottom:w+x}}}}if(!r){let m=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*l;r={left:m.left-g,right:m.left+g,top:m.top,bottom:m.bottom}}let d=this.editorView.dom.offsetParent;this.element||(this.element=d.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let f,h;if(!d||d==document.body&&getComputedStyle(d).position=="static")f=-pageXOffset,h=-pageYOffset;else{let m=d.getBoundingClientRect(),g=m.width/d.offsetWidth,y=m.height/d.offsetHeight;f=m.left-d.scrollLeft*g,h=m.top-d.scrollTop*y}this.element.style.left=(r.left-f)/l+"px",this.element.style.top=(r.top-h)/c+"px",this.element.style.width=(r.right-r.left)/l+"px",this.element.style.height=(r.bottom-r.top)/c+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!o){let l=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let c=D9(this.editorView.state.doc,l,this.editorView.dragging.slice);c!=null&&(l=c)}this.setCursor(l),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Et extends Se{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Et.valid(r)?new Et(r):Se.near(r)}content(){return ce.empty}eq(e){return e instanceof Et&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Et(e.resolve(n.pos))}getBookmark(){return new d3(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!$I(e)||!qI(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Et.valid(e))return e;let i=e.pos,o=null;for(let l=e.depth;;l--){let c=e.node(l);if(n>0?e.indexAfter(l)0){o=c.child(n>0?e.indexAfter(l):e.index(l)-1);break}else if(l==0)return null;i+=n;let d=e.doc.resolve(i);if(Et.valid(d))return d}for(;;){let l=n>0?o.firstChild:o.lastChild;if(!l){if(o.isAtom&&!o.isText&&!me.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*n),r=!1;continue e}break}o=l,i+=n;let c=e.doc.resolve(i);if(Et.valid(c))return c}return null}}}Et.prototype.visible=!1;Et.findFrom=Et.findGapCursorFrom;Se.jsonID("gapcursor",Et);class d3{constructor(e){this.pos=e}map(e){return new d3(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Et.valid(n)?new Et(n):Se.near(n)}}function BS(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function $I(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||BS(i.type))return!0;if(i.inlineContent)return!1}}return!0}function qI(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||BS(i.type))return!0;if(i.inlineContent)return!1}}return!0}function ZI(){return new Ve({props:{decorations:WI,createSelectionBetween(t,e,n){return e.pos==n.pos&&Et.valid(n)?new Et(n):null},handleClick:GI,handleKeyDown:KI,handleDOMEvents:{beforeinput:YI}}})}const KI=zy({ArrowLeft:Sf("horiz",-1),ArrowRight:Sf("horiz",1),ArrowUp:Sf("vert",-1),ArrowDown:Sf("vert",1)});function Sf(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let l=r.selection,c=e>0?l.$to:l.$from,d=l.empty;if(l instanceof ue){if(!o.endOfTextblock(n)||c.depth==0)return!1;d=!1,c=r.doc.resolve(e>0?c.after():c.before())}let f=Et.findGapCursorFrom(c,e,d);return f?(i&&i(r.tr.setSelection(new Et(f))),!0):!1}}function GI(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Et.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&me.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Et(r))),!0)}function YI(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Et))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=te.empty;for(let l=r.length-1;l>=0;l--)i=te.from(r[l].createAndFill(null,i));let o=t.state.tr.replace(n.pos,n.pos,new ce(i,0,0));return o.setSelection(ue.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function WI(t){if(!(t.selection instanceof Et))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Xe.create(t.doc,[Ft.widget(t.selection.head,e,{key:"gapcursor"})])}var $h=200,nn=function(){};nn.prototype.append=function(e){return e.length?(e=nn.from(e),!this.length&&e||e.length<$h&&this.leafAppend(e)||this.length<$h&&e.leafPrepend(this)||this.appendInner(e)):this};nn.prototype.prepend=function(e){return e.length?nn.from(e).append(this):this};nn.prototype.appendInner=function(e){return new JI(this,e)};nn.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?nn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};nn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};nn.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};nn.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,l){return i.push(e(o,l))},n,r),i};nn.from=function(e){return e instanceof nn?e:e&&e.length?new jS(e):nn.empty};var jS=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,l,c){for(var d=o;d=l;d--)if(i(this.values[d],c+d)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=$h)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=$h)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(nn);nn.empty=new jS([]);var JI=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return rc&&this.right.forEachInner(r,Math.max(i-c,0),Math.min(this.length,o)-c,l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,l){var c=this.left.length;if(i>c&&this.right.forEachInvertedInner(r,i-c,Math.max(o,c)-c,l+c)===!1||o=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(nn);const XI=500;class zr{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;n&&(i=this.remapping(r,this.items.length),o=i.maps.length);let l=e.tr,c,d,f=[],h=[];return this.items.forEach((m,g)=>{if(!m.step){i||(i=this.remapping(r,g+1),o=i.maps.length),o--,h.push(m);return}if(i){h.push(new Ro(m.map));let y=m.step.map(i.slice(o)),C;y&&l.maybeStep(y).doc&&(C=l.mapping.maps[l.mapping.maps.length-1],f.push(new Ro(C,void 0,void 0,f.length+h.length))),o--,C&&i.appendMap(C,o)}else l.maybeStep(m.step);if(m.selection)return c=i?m.selection.map(i.slice(o)):m.selection,d=new zr(this.items.slice(0,r).append(h.reverse().concat(f)),this.eventCount-1),!1},this.items.length,0),{remaining:d,transform:l,selection:c}}addTransform(e,n,r,i){let o=[],l=this.eventCount,c=this.items,d=!i&&c.length?c.get(c.length-1):null;for(let h=0;hez&&(c=QI(c,f),l-=f),new zr(c.append(o),l)}remapping(e,n){let r=new au;return this.items.forEach((i,o)=>{let l=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,l)},e,n),r}addMaps(e){return this.eventCount==0?this:new zr(this.items.append(e.map(n=>new Ro(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),o=e.mapping,l=e.steps.length,c=this.eventCount;this.items.forEach(g=>{g.selection&&c--},i);let d=n;this.items.forEach(g=>{let y=o.getMirror(--d);if(y==null)return;l=Math.min(l,y);let C=o.maps[y];if(g.step){let w=e.steps[y].invert(e.docs[y]),x=g.selection&&g.selection.map(o.slice(d+1,y));x&&c++,r.push(new Ro(C,w,x))}else r.push(new Ro(C))},i);let f=[];for(let g=n;gXI&&(m=m.compress(this.items.length-r.length)),m}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],o=0;return this.items.forEach((l,c)=>{if(c>=e)i.push(l),l.selection&&o++;else if(l.step){let d=l.step.map(n.slice(r)),f=d&&d.getMap();if(r--,f&&n.appendMap(f,r),d){let h=l.selection&&l.selection.map(n.slice(r));h&&o++;let m=new Ro(f.invert(),d,h),g,y=i.length-1;(g=i.length&&i[y].merge(m))?i[y]=g:i.push(m)}}else l.map&&r--},this.items.length,0),new zr(nn.from(i.reverse()),o)}}zr.empty=new zr(nn.empty,0);function QI(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}let Ro=class VS{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new VS(n.getMap().invert(),n,this.selection)}}};class Io{constructor(e,n,r,i,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const ez=20;function tz(t,e,n,r){let i=n.getMeta(Vs),o;if(i)return i.historyState;n.getMeta(iz)&&(t=new Io(t.done,t.undone,null,0,-1));let l=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(l&&l.getMeta(Vs))return l.getMeta(Vs).redo?new Io(t.done.addTransform(n,void 0,r,qf(e)),t.undone,e5(n.mapping.maps),t.prevTime,t.prevComposition):new Io(t.done,t.undone.addTransform(n,void 0,r,qf(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(l&&l.getMeta("addToHistory")===!1)){let c=n.getMeta("composition"),d=t.prevTime==0||!l&&t.prevComposition!=c&&(t.prevTime<(n.time||0)-r.newGroupDelay||!nz(n,t.prevRanges)),f=l?w0(t.prevRanges,n.mapping):e5(n.mapping.maps);return new Io(t.done.addTransform(n,d?e.selection.getBookmark():void 0,r,qf(e)),zr.empty,f,n.time,c??t.prevComposition)}else return(o=n.getMeta("rebased"))?new Io(t.done.rebased(n,o),t.undone.rebased(n,o),w0(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Io(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),w0(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function nz(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let o=0;o=e[o]&&(n=!0)}),n}function e5(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,o,l)=>e.push(o,l));return e}function w0(t,e){if(!t)return null;let n=[];for(let r=0;r{let i=Vs.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let o=rz(i,n,t);o&&r(e?o.scrollIntoView():o)}return!0}}const PS=US(!1,!0),FS=US(!0,!0);Ze.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new Ve({key:new qe("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const o=this.storage.characters({node:r.doc});if(o>i){const l=o-i,c=0,d=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const f=r.tr.deleteRange(c,d);return t=!0,f}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),o=this.storage.characters({node:e.doc});if(o<=r||i>r&&o>r&&o<=i)return!0;if(i>r&&o>r&&o>i||!e.getMeta("paste"))return!1;const c=e.selection.$head.pos,d=o-r,f=c-d,h=c;return e.deleteRange(f,h),!(this.storage.characters({node:e.doc})>r)}})]}});var sz=Ze.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[PI(this.options)]}});Ze.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Ve({key:new qe("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,o=[];if(!n||!r)return Xe.create(t,[]);let l=0;this.options.mode==="deepest"&&t.descendants((d,f)=>{if(d.isText)return;if(!(i>=f&&i<=f+d.nodeSize-1))return!1;l+=1});let c=0;return t.descendants((d,f)=>{if(d.isText||!(i>=f&&i<=f+d.nodeSize-1))return!1;if(c+=1,this.options.mode==="deepest"&&l-c>0||this.options.mode==="shallowest"&&c>1)return this.options.mode==="deepest";o.push(Ft.node(f,f+d.nodeSize,{class:this.options.className}))}),Xe.create(t,o)}}})]}});var lz=Ze.create({name:"gapCursor",addProseMirrorPlugins(){return[ZI()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Ge(be(t,"allowGapCursor",n)))!=null?e:null}}}),az=Ze.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Ve({key:new qe("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const o=this.editor.isEmpty;return t.descendants((l,c)=>{const d=r>=c&&r<=c+l.nodeSize,f=!l.isLeaf&&Lp(l);if((d||!this.options.showOnlyCurrent)&&f){const h=[this.options.emptyNodeClass];o&&h.push(this.options.emptyEditorClass);const m=Ft.node(c,c+l.nodeSize,{class:h.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:c,hasAnchor:d}):this.options.placeholder});i.push(m)}return this.options.includeChildren}),Xe.create(t,i)}}})]}});Ze.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Ve({key:new qe("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Ky(n.selection)||t.view.dragging?null:Xe.create(n.doc,[Ft.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function n5({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var cz=Ze.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new qe(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new Ve({key:e,appendTransaction:(i,o,l)=>{const{doc:c,tr:d,schema:f}=l,h=e.getState(l),m=c.content.size,g=f.nodes[n];if(h)return d.insert(m,g.create())},state:{init:(i,o)=>{const l=o.tr.doc.lastChild;return!n5({node:l,types:r})},apply:(i,o)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return o;const l=i.doc.lastChild;return!n5({node:l,types:r})}}})]}}),uz=Ze.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>PS(t,e),redo:()=>({state:t,dispatch:e})=>FS(t,e)}},addProseMirrorPlugins(){return[oz(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),dz=Ze.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(zH.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(DH.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(MS.configure(this.options.bulletList)),this.options.code!==!1&&i.push(VH.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(FH.configure(this.options.codeBlock)),this.options.document!==!1&&i.push($H.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(sz.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(lz.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(qH.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(ZH.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(uz.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(KH.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(XH.configure(this.options.italic)),this.options.listItem!==!1&&i.push(AS.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(_S.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(SI.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(IS.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(zS.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(jI.configure(this.options.strike)),this.options.text!==!1&&i.push(VI.configure(this.options.text)),this.options.underline!==!1&&i.push(UI.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(cz.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),fz=Ze.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),hz=Xi.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",Pe(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),pz=t=>Nt({find:/--$/,replace:t??"—"}),mz=t=>Nt({find:/\.\.\.$/,replace:t??"…"}),gz=t=>Nt({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:t??"“"}),yz=t=>Nt({find:/"$/,replace:t??"”"}),vz=t=>Nt({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:t??"‘"}),bz=t=>Nt({find:/'$/,replace:t??"’"}),Cz=t=>Nt({find:/<-$/,replace:t??"←"}),wz=t=>Nt({find:/->$/,replace:t??"→"}),xz=t=>Nt({find:/\(c\)$/,replace:t??"©"}),Sz=t=>Nt({find:/\(tm\)$/,replace:t??"™"}),Tz=t=>Nt({find:/\(sm\)$/,replace:t??"℠"}),kz=t=>Nt({find:/\(r\)$/,replace:t??"®"}),Ez=t=>Nt({find:/(?:^|\s)(1\/2)\s$/,replace:t??"½"}),Mz=t=>Nt({find:/\+\/-$/,replace:t??"±"}),Az=t=>Nt({find:/!=$/,replace:t??"≠"}),Nz=t=>Nt({find:/<<$/,replace:t??"«"}),Rz=t=>Nt({find:/>>$/,replace:t??"»"}),Oz=t=>Nt({find:/\d+\s?([*x])\s?\d+$/,replace:t??"×"}),Dz=t=>Nt({find:/\^2$/,replace:t??"²"}),Lz=t=>Nt({find:/\^3$/,replace:t??"³"}),_z=t=>Nt({find:/(?:^|\s)(1\/4)\s$/,replace:t??"¼"}),Hz=t=>Nt({find:/(?:^|\s)(3\/4)\s$/,replace:t??"¾"}),r5=Ze.create({name:"typography",addOptions(){return{closeDoubleQuote:"”",closeSingleQuote:"’",copyright:"©",ellipsis:"…",emDash:"—",laquo:"«",leftArrow:"←",multiplication:"×",notEqual:"≠",oneHalf:"½",oneQuarter:"¼",openDoubleQuote:"“",openSingleQuote:"‘",plusMinus:"±",raquo:"»",registeredTrademark:"®",rightArrow:"→",servicemark:"℠",superscriptThree:"³",superscriptTwo:"²",threeQuarters:"¾",trademark:"™"}},addInputRules(){const t=[];return this.options.emDash!==!1&&t.push(pz(this.options.emDash)),this.options.ellipsis!==!1&&t.push(mz(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&t.push(gz(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&t.push(yz(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&t.push(vz(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&t.push(bz(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&t.push(Cz(this.options.leftArrow)),this.options.rightArrow!==!1&&t.push(wz(this.options.rightArrow)),this.options.copyright!==!1&&t.push(xz(this.options.copyright)),this.options.trademark!==!1&&t.push(Sz(this.options.trademark)),this.options.servicemark!==!1&&t.push(Tz(this.options.servicemark)),this.options.registeredTrademark!==!1&&t.push(kz(this.options.registeredTrademark)),this.options.oneHalf!==!1&&t.push(Ez(this.options.oneHalf)),this.options.plusMinus!==!1&&t.push(Mz(this.options.plusMinus)),this.options.notEqual!==!1&&t.push(Az(this.options.notEqual)),this.options.laquo!==!1&&t.push(Nz(this.options.laquo)),this.options.raquo!==!1&&t.push(Rz(this.options.raquo)),this.options.multiplication!==!1&&t.push(Oz(this.options.multiplication)),this.options.superscriptTwo!==!1&&t.push(Dz(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&t.push(Lz(this.options.superscriptThree)),this.options.oneQuarter!==!1&&t.push(_z(this.options.oneQuarter)),this.options.threeQuarters!==!1&&t.push(Hz(this.options.threeQuarters)),t}});function Iz(){const t=document.documentElement.lang||"en";return t.startsWith("cs")||t.startsWith("cz")?r5.configure({openDoubleQuote:"„",closeDoubleQuote:"“",openSingleQuote:"‚",closeSingleQuote:"‘"}):r5}var zz=Xi.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",Pe(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});let L2,_2;if(typeof WeakMap<"u"){let t=new WeakMap;L2=e=>t.get(e),_2=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;L2=r=>{for(let i=0;i(n==10&&(n=0),t[n++]=r,t[n++]=i)}var Mt=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e=n){(o||(o=[])).push({type:"overlong_rowspan",pos:h,n:k-N});break}const R=i+N*e;for(let L=0;Lr&&(o+=f.attrs.colspan)}}for(let l=0;l1&&(n=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function Vz(t,e,n){t.problems||(t.problems=[]);const r={};for(let i=0;i0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Pz(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Yr(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function Ip(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Gs(e.$head)||Fz(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function Fz(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function H2(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function $z(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function f3(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function $S(t,e,n){const r=t.node(-1),i=Mt.get(r),o=t.start(-1),l=i.nextCell(t.pos-o,e,n);return l==null?null:t.node(0).resolve(o+l)}function Ys(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function qS(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;ih!=n.pos-o);d.unshift(n.pos-o);const f=d.map(h=>{const m=r.nodeAt(h);if(!m)throw new RangeError(`No cell with offset ${h} found`);const g=o+h+1;return new wy(c.resolve(g),c.resolve(g+m.content.size))});super(f[0].$from,f[0].$to,f),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),i=e.resolve(n.map(this.$headCell.pos));if(H2(r)&&H2(i)&&f3(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?ji.rowSelection(r,i):o&&this.isColSelection()?ji.colSelection(r,i):new ji(r,i)}return ue.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=Mt.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},l=[];for(let d=i.top;d0||x>0){let k=C.attrs;if(w>0&&(k=Ys(k,0,w)),x>0&&(k=Ys(k,k.colspan-x,x)),y.lefti.bottom){const k={...C.attrs,rowspan:Math.min(y.bottom,i.bottom)-Math.max(y.top,i.top)};y.top0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),i=Mt.get(r),o=e.start(-1),l=i.findCell(e.pos-o),c=i.findCell(n.pos-o),d=e.node(0);return l.top<=c.top?(l.top>0&&(e=d.resolve(o+i.map[l.left])),c.bottom0&&(n=d.resolve(o+i.map[c.left])),l.bottom0)return!1;const l=i+this.$anchorCell.nodeAfter.attrs.colspan,c=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(l,c)==n.width}eq(e){return e instanceof ji&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=Mt.get(r),o=e.start(-1),l=i.findCell(e.pos-o),c=i.findCell(n.pos-o),d=e.node(0);return l.left<=c.left?(l.left>0&&(e=d.resolve(o+i.map[l.top*i.width])),c.right0&&(n=d.resolve(o+i.map[c.top*i.width])),l.right{e.push(Ft.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Xe.create(t.doc,e)}function Gz({$from:t,$to:e}){if(t.pos==e.pos||t.pos=0&&!(t.after(i+1)=0&&!(e.before(o+1)>e.start(o));o--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function Yz({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){const o=t.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}for(let i=e.depth;i>0;i--){const o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return n!==r&&e.parentOffset===0}function Wz(t,e,n){const r=(e||t).selection,i=(e||t).doc;let o,l;if(r instanceof me&&(l=r.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")o=dt.create(i,r.from);else if(l=="row"){const c=i.resolve(r.from+1);o=dt.rowSelection(c,c)}else if(!n){const c=Mt.get(r.node),d=r.from+1,f=d+c.map[c.width*c.height-1];o=dt.create(i,d+1,f)}}else r instanceof ue&&Gz(r)?o=ue.create(i,r.from):r instanceof ue&&Yz(r)&&(o=ue.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=t.tr)).setSelection(o),e}const Jz=new qe("fix-tables");function KS(t,e,n,r){const i=t.childCount,o=e.childCount;e:for(let l=0,c=0;l{i.type.spec.tableRole=="table"&&(n=Xz(t,i,o,n))};return e?e.doc!=t.doc&&KS(e.doc,t.doc,0,r):t.doc.descendants(r),n}function Xz(t,e,n,r){const i=Mt.get(e);if(!i.problems)return r;r||(r=t.tr);const o=[];for(let d=0;d0){let y="cell";h.firstChild&&(y=h.firstChild.type.spec.tableRole);const C=[];for(let x=0;x0?-1:0;qz(e,r,i+o)&&(o=i==0||i==e.width?null:0);for(let l=0;l0&&i0&&e.map[c-1]==d||i0?-1:0;rB(e,r,i+c)&&(c=i==0||i==e.height?null:0);for(let f=0,h=e.width*i;f0&&i0&&m==e.map[h-e.width]){const g=n.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(c).map(m+r),null,{...g,rowspan:g.rowspan-1}),f+=g.colspan-1}else if(i0&&n[o]==n[o-1]||r.right0&&n[i]==n[i-t]||r.bottom0){const h=d+1+f.content.size,m=i5(f)?d+1:h;o.replaceWith(m+r.tableStart,h+r.tableStart,c)}o.setSelection(new dt(o.doc.resolve(d+r.tableStart))),e(o)}return!0}function s5(t,e){const n=kn(t.schema);return cB(({node:r})=>n[r.type.spec.tableRole])(t,e)}function cB(t){return(e,n)=>{const r=e.selection;let i,o;if(r instanceof dt){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,o=r.$anchorCell.pos}else{var l;if(i=Pz(r.$from),!i)return!1;o=(l=Gs(r.$from))===null||l===void 0?void 0:l.pos}if(i==null||o==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let c=i.attrs;const d=[],f=c.colwidth;c.rowspan>1&&(c={...c,rowspan:1}),c.colspan>1&&(c={...c,colspan:1});const h=hi(e),m=e.tr;for(let y=0;y{l.attrs[t]!==e&&o.setNodeMarkup(c,null,{...l.attrs,[t]:e})}):o.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[t]:e}),r(o)}return!0}}function dB(t){return function(e,n){if(!Yr(e))return!1;if(n){const r=kn(e.schema),i=hi(e),o=e.tr,l=i.map.cellsInRect(t=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:t=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),c=l.map(d=>i.table.nodeAt(d));for(let d=0;d{const y=g+o.tableStart,C=l.doc.nodeAt(y);C&&l.setNodeMarkup(y,m,C.attrs)}),r(l)}return!0}}yu("row",{useDeprecatedLogic:!0});yu("column",{useDeprecatedLogic:!0});const fB=yu("cell",{useDeprecatedLogic:!0});function hB(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,i=t.before();r>=0;r--){const o=t.node(-1).child(r),l=o.lastChild;if(l)return i-1-l.nodeSize;i-=o.nodeSize}}else{if(t.index()0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Tf(t,e){const n=t.selection;if(!(n instanceof dt))return!1;if(e){const r=t.tr,i=kn(t.schema).cell.createAndFill().content;n.forEachCell((o,l)=>{o.content.eq(i)||r.replace(r.mapping.map(l+1),r.mapping.map(l+o.nodeSize-1),new ce(i,0,0))}),r.docChanged&&e(r)}return!0}function mB(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const i=e.child(0),o=i.type.spec.tableRole,l=i.type.schema,c=[];if(o=="row")for(let d=0;d=0;l--){const{rowspan:c,colspan:d}=o.child(l).attrs;for(let f=i;f=e.length&&e.push(te.empty),n[i]r&&(g=g.type.createChecked(Ys(g.attrs,g.attrs.colspan,h+g.attrs.colspan-r),g.content)),f.push(g),h+=g.attrs.colspan;for(let y=1;yi&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,i-m.attrs.rowspan)},m.content)),d.push(m)}o.push(te.from(d))}n=o,e=i}return{width:t,height:e,rows:n}}function vB(t,e,n,r,i,o,l){const c=t.doc.type.schema,d=kn(c);let f,h;if(i>e.width)for(let m=0,g=0;me.height){const m=[];for(let C=0,w=(e.height-1)*e.width;C=e.width?!1:n.nodeAt(e.map[w+C]).type==d.header_cell;m.push(x?h||(h=d.header_cell.createAndFill()):f||(f=d.cell.createAndFill()))}const g=d.row.create(null,te.from(m)),y=[];for(let C=e.height;C{if(!i)return!1;const o=n.selection;if(o instanceof dt)return Zf(n,r,Se.near(o.$headCell,e));if(t!="horiz"&&!o.empty)return!1;const l=JS(i,t,e);if(l==null)return!1;if(t=="horiz")return Zf(n,r,Se.near(n.doc.resolve(o.head+e),e));{const c=n.doc.resolve(l),d=$S(c,t,e);let f;return d?f=Se.near(d,1):e<0?f=Se.near(n.doc.resolve(c.before(-1)),-1):f=Se.near(n.doc.resolve(c.after(-1)),1),Zf(n,r,f)}}}function Ef(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;let l;if(o instanceof dt)l=o;else{const d=JS(i,t,e);if(d==null)return!1;l=new dt(n.doc.resolve(d))}const c=$S(l.$headCell,t,e);return c?Zf(n,r,new dt(l.$anchorCell,c)):!1}}function CB(t,e){const n=t.state.doc,r=Gs(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new dt(r))),!0):!1}function wB(t,e,n){if(!Yr(t.state))return!1;let r=mB(n);const i=t.state.selection;if(i instanceof dt){r||(r={width:1,height:1,rows:[te.from(I2(kn(t.state.schema).cell,n))]});const o=i.$anchorCell.node(-1),l=i.$anchorCell.start(-1),c=Mt.get(o).rectBetween(i.$anchorCell.pos-l,i.$headCell.pos-l);return r=yB(r,c.right-c.left,c.bottom-c.top),d5(t.state,t.dispatch,l,c,r),!0}else if(r){const o=Ip(t.state),l=o.start(-1);return d5(t.state,t.dispatch,l,Mt.get(o.node(-1)).findCell(o.pos-l),r),!0}else return!1}function xB(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=f5(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof dt)o(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Gs(t.state.selection.$anchor))!=null&&((n=S0(t,e))===null||n===void 0?void 0:n.pos)!=i.pos)o(i,e),e.preventDefault();else if(!r)return;function o(d,f){let h=S0(t,f);const m=jo.getState(t.state)==null;if(!h||!f3(d,h))if(m)h=d;else return;const g=new dt(d,h);if(m||!t.state.selection.eq(g)){const y=t.state.tr.setSelection(g);m&&y.setMeta(jo,d.pos),t.dispatch(y)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",c),jo.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(jo,-1))}function c(d){const f=d,h=jo.getState(t.state);let m;if(h!=null)m=t.state.doc.resolve(h);else if(f5(t,f.target)!=r&&(m=S0(t,e),!m))return l();m&&o(m,f)}t.root.addEventListener("mouseup",l),t.root.addEventListener("dragstart",l),t.root.addEventListener("mousemove",c)}function JS(t,e,n){if(!(t.state.selection instanceof ue))return null;const{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const l=r.before(i),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?l:null}}return null}function f5(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function S0(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&Gs(t.state.doc.resolve(r))||Gs(t.state.doc.resolve(i))}var SB=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),z2(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,z2(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function z2(t,e,n,r,i,o){let l=0,c=!0,d=e.firstChild;const f=t.firstChild;if(f){for(let m=0,g=0;mnew r(m,n,g)),new kB(-1,!1)},apply(l,c){return c.apply(l)}},props:{attributes:l=>{const c=ar.getState(l);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,c)=>{EB(l,c,t,i)},mouseleave:l=>{MB(l)},mousedown:(l,c)=>{AB(l,c,e,n)}},decorations:l=>{const c=ar.getState(l);if(c&&c.activeHandle>-1)return LB(l,c.activeHandle)},nodeViews:{}}});return o}var kB=class Kf{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(ar);if(r&&r.setHandle!=null)return new Kf(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Kf(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);return H2(e.doc.resolve(i))||(i=-1),new Kf(i,n.dragging)}return n}};function EB(t,e,n,r){if(!t.editable)return;const i=ar.getState(t.state);if(i&&!i.dragging){const o=RB(e.target);let l=-1;if(o){const{left:c,right:d}=o.getBoundingClientRect();e.clientX-c<=n?l=h5(t,e,"left",n):d-e.clientX<=n&&(l=h5(t,e,"right",n))}if(l!=i.activeHandle){if(!r&&l!==-1){const c=t.state.doc.resolve(l),d=c.node(-1),f=Mt.get(d),h=c.start(-1);if(f.colCount(c.pos-h)+c.nodeAfter.attrs.colspan-1==f.width-1)return}XS(t,l)}}}function MB(t){if(!t.editable)return;const e=ar.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&XS(t,-1)}function AB(t,e,n,r){var i;if(!t.editable)return!1;const o=(i=t.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,l=ar.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const c=t.state.doc.nodeAt(l.activeHandle),d=NB(t,l.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(ar,{setDragging:{startX:e.clientX,startWidth:d}}));function f(m){o.removeEventListener("mouseup",f),o.removeEventListener("mousemove",h);const g=ar.getState(t.state);g?.dragging&&(OB(t,g.activeHandle,p5(g.dragging,m,n)),t.dispatch(t.state.tr.setMeta(ar,{setDragging:null})))}function h(m){if(!m.which)return f(m);const g=ar.getState(t.state);if(g&&g.dragging){const y=p5(g.dragging,m,n);m5(t,g.activeHandle,y,r)}}return m5(t,l.activeHandle,d,r),o.addEventListener("mouseup",f),o.addEventListener("mousemove",h),e.preventDefault(),!0}function NB(t,e,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const o=t.domAtPos(e);let l=o.node.childNodes[o.offset].offsetWidth,c=n;if(r)for(let d=0;d{var e,n;const r=t.getAttribute("colwidth"),i=r?r.split(",").map(o=>parseInt(o,10)):null;if(!i){const o=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),l=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(l&&l>-1&&o&&o[l]){const c=o[l].getAttribute("width");return c?[parseInt(c,10)]:null}}return i}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",Pe(this.options.HTMLAttributes,t),0]}}),IB=st.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",Pe(this.options.HTMLAttributes,t),0]}}),zB=st.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Pe(this.options.HTMLAttributes,t),0]}});function B2(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function g5(t,e,n,r,i,o){var l;let c=0,d=!0,f=e.firstChild;const h=t.firstChild;if(h!==null)for(let g=0,y=0;g{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function UB(t,e,n,r,i){const o=VB(t),l=[],c=[];for(let f=0;f{const{selection:e}=t.state;if(!PB(e))return!1;let n=0;const r=Ux(e.ranges[0].$from,o=>o.type.name==="table");return r?.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},FB="";function $B(t){return(t||"").replace(/\s+/g," ").trim()}function qB(t,e,n={}){var r;const i=(r=n.cellLineSeparator)!=null?r:FB;if(!t||!t.content||t.content.length===0)return"";const o=[];t.content.forEach(C=>{const w=[];C.content&&C.content.forEach(x=>{let k="";x.content&&Array.isArray(x.content)&&x.content.length>1?k=x.content.map(L=>e.renderChildren(L)).join(i):k=x.content?e.renderChildren(x.content):"";const A=$B(k),N=x.type==="tableHeader";w.push({text:A,isHeader:N})}),o.push(w)});const l=o.reduce((C,w)=>Math.max(C,w.length),0);if(l===0)return"";const c=new Array(l).fill(0);o.forEach(C=>{var w;for(let x=0;xc[x]&&(c[x]=A),c[x]<3&&(c[x]=3)}});const d=(C,w)=>C+" ".repeat(Math.max(0,w-C.length)),f=o[0],h=f.some(C=>C.isHeader);let m=` +`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(DI,this.editor.getAttributes(Xw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Ca({find:Qw,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ca({find:Qw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Xw)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),LI=/^\s*(\[([( |x])?\])\s$/,_I=st.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",Fe(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const i=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Xy(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),o=document.createElement("label"),l=document.createElement("span"),c=document.createElement("input"),d=document.createElement("div"),f=h=>{var m,g;c.ariaLabel=((g=(m=this.options.a11y)==null?void 0:m.checkboxLabel)==null?void 0:g.call(m,h,c.checked))||`Task item checkbox for ${h.textContent||"empty task item"}`};return f(t),o.contentEditable="false",c.type="checkbox",c.addEventListener("mousedown",h=>h.preventDefault()),c.addEventListener("change",h=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){c.checked=!c.checked;return}const{checked:m}=h.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:g})=>{const y=n();if(typeof y!="number")return!1;const C=g.doc.nodeAt(y);return g.setNodeMarkup(y,void 0,{...C?.attrs,checked:m}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,m)||(c.checked=!c.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([h,m])=>{i.setAttribute(h,m)}),i.dataset.checked=t.attrs.checked,c.checked=t.attrs.checked,o.append(c,l),i.append(o,d),Object.entries(e).forEach(([h,m])=>{i.setAttribute(h,m)}),{dom:i,contentDOM:d,update:h=>h.type!==this.type?!1:(i.dataset.checked=h.attrs.checked,c.checked=h.attrs.checked,f(h),!0)}}},addInputRules(){return[Ca({find:LI,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),HI=st.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",Fe(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` +`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=o=>{const l=C2(o,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:c=>({indentLevel:c[1].length,mainContent:c[4],checked:c[3].toLowerCase()==="x"}),createToken:(c,d)=>({type:"taskItem",raw:"",mainContent:c.mainContent,indentLevel:c.indentLevel,checked:c.checked,text:c.mainContent,tokens:n.inlineTokens(c.mainContent),nestedTokens:d}),customNestedParser:r},n);return l?[{type:"taskList",raw:l.raw,items:l.items}]:n.blockTokens(o)},i=C2(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,l)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:l}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Ke.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(MS.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(AS.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(_S.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(IS.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(_I.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(HI.configure(this.options.taskList)),t}});var zS=st.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Fe(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];return n.length===1&&n[0].type==="image"?e.parseChildren([n[0]]):e.createNode("paragraph",void 0,e.parseInline(n))},renderMarkdown:(t,e)=>!t||!Array.isArray(t.content)?"":e.renderChildren(t.content),addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),II=zS,zI=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,BI=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,jI=Xi.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",Fe(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ba({find:zI,type:this.type})]},addPasteRules(){return[Ks({find:BI,type:this.type})]}}),VI=st.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),UI=Xi.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Fe(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const o=i[2].trim();return{type:"underline",raw:i[0],text:o,tokens:n.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function PI(t={}){return new Ue({view(e){return new FI(e,t)}})}class FI{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=l=>{this[i](l)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,o=i.getBoundingClientRect(),l=o.width/i.offsetWidth,c=o.height/i.offsetHeight;if(n){let m=e.nodeBefore,g=e.nodeAfter;if(m||g){let y=this.editorView.nodeDOM(this.cursorPos-(m?m.nodeSize:0));if(y){let C=y.getBoundingClientRect(),w=m?C.bottom:C.top;m&&g&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*c;r={left:C.left,right:C.right,top:w-x,bottom:w+x}}}}if(!r){let m=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*l;r={left:m.left-g,right:m.left+g,top:m.top,bottom:m.bottom}}let d=this.editorView.dom.offsetParent;this.element||(this.element=d.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let f,h;if(!d||d==document.body&&getComputedStyle(d).position=="static")f=-pageXOffset,h=-pageYOffset;else{let m=d.getBoundingClientRect(),g=m.width/d.offsetWidth,y=m.height/d.offsetHeight;f=m.left-d.scrollLeft*g,h=m.top-d.scrollTop*y}this.element.style.left=(r.left-f)/l+"px",this.element.style.top=(r.top-h)/c+"px",this.element.style.width=(r.right-r.left)/l+"px",this.element.style.height=(r.bottom-r.top)/c+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!o){let l=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let c=D9(this.editorView.state.doc,l,this.editorView.dragging.slice);c!=null&&(l=c)}this.setCursor(l),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Et extends Se{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Et.valid(r)?new Et(r):Se.near(r)}content(){return ce.empty}eq(e){return e instanceof Et&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Et(e.resolve(n.pos))}getBookmark(){return new d3(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!$I(e)||!qI(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Et.valid(e))return e;let i=e.pos,o=null;for(let l=e.depth;;l--){let c=e.node(l);if(n>0?e.indexAfter(l)0){o=c.child(n>0?e.indexAfter(l):e.index(l)-1);break}else if(l==0)return null;i+=n;let d=e.doc.resolve(i);if(Et.valid(d))return d}for(;;){let l=n>0?o.firstChild:o.lastChild;if(!l){if(o.isAtom&&!o.isText&&!me.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*n),r=!1;continue e}break}o=l,i+=n;let c=e.doc.resolve(i);if(Et.valid(c))return c}return null}}}Et.prototype.visible=!1;Et.findFrom=Et.findGapCursorFrom;Se.jsonID("gapcursor",Et);class d3{constructor(e){this.pos=e}map(e){return new d3(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Et.valid(n)?new Et(n):Se.near(n)}}function BS(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function $I(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||BS(i.type))return!0;if(i.inlineContent)return!1}}return!0}function qI(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||BS(i.type))return!0;if(i.inlineContent)return!1}}return!0}function ZI(){return new Ue({props:{decorations:WI,createSelectionBetween(t,e,n){return e.pos==n.pos&&Et.valid(n)?new Et(n):null},handleClick:GI,handleKeyDown:KI,handleDOMEvents:{beforeinput:YI}}})}const KI=zy({ArrowLeft:Sf("horiz",-1),ArrowRight:Sf("horiz",1),ArrowUp:Sf("vert",-1),ArrowDown:Sf("vert",1)});function Sf(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let l=r.selection,c=e>0?l.$to:l.$from,d=l.empty;if(l instanceof ue){if(!o.endOfTextblock(n)||c.depth==0)return!1;d=!1,c=r.doc.resolve(e>0?c.after():c.before())}let f=Et.findGapCursorFrom(c,e,d);return f?(i&&i(r.tr.setSelection(new Et(f))),!0):!1}}function GI(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Et.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&me.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Et(r))),!0)}function YI(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Et))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=te.empty;for(let l=r.length-1;l>=0;l--)i=te.from(r[l].createAndFill(null,i));let o=t.state.tr.replace(n.pos,n.pos,new ce(i,0,0));return o.setSelection(ue.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function WI(t){if(!(t.selection instanceof Et))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Qe.create(t.doc,[Ft.widget(t.selection.head,e,{key:"gapcursor"})])}var $h=200,nn=function(){};nn.prototype.append=function(e){return e.length?(e=nn.from(e),!this.length&&e||e.length<$h&&this.leafAppend(e)||this.length<$h&&e.leafPrepend(this)||this.appendInner(e)):this};nn.prototype.prepend=function(e){return e.length?nn.from(e).append(this):this};nn.prototype.appendInner=function(e){return new JI(this,e)};nn.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?nn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};nn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};nn.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};nn.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,l){return i.push(e(o,l))},n,r),i};nn.from=function(e){return e instanceof nn?e:e&&e.length?new jS(e):nn.empty};var jS=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,l,c){for(var d=o;d=l;d--)if(i(this.values[d],c+d)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=$h)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=$h)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(nn);nn.empty=new jS([]);var JI=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return rc&&this.right.forEachInner(r,Math.max(i-c,0),Math.min(this.length,o)-c,l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,l){var c=this.left.length;if(i>c&&this.right.forEachInvertedInner(r,i-c,Math.max(o,c)-c,l+c)===!1||o=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(nn);const XI=500;class zr{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;n&&(i=this.remapping(r,this.items.length),o=i.maps.length);let l=e.tr,c,d,f=[],h=[];return this.items.forEach((m,g)=>{if(!m.step){i||(i=this.remapping(r,g+1),o=i.maps.length),o--,h.push(m);return}if(i){h.push(new Ro(m.map));let y=m.step.map(i.slice(o)),C;y&&l.maybeStep(y).doc&&(C=l.mapping.maps[l.mapping.maps.length-1],f.push(new Ro(C,void 0,void 0,f.length+h.length))),o--,C&&i.appendMap(C,o)}else l.maybeStep(m.step);if(m.selection)return c=i?m.selection.map(i.slice(o)):m.selection,d=new zr(this.items.slice(0,r).append(h.reverse().concat(f)),this.eventCount-1),!1},this.items.length,0),{remaining:d,transform:l,selection:c}}addTransform(e,n,r,i){let o=[],l=this.eventCount,c=this.items,d=!i&&c.length?c.get(c.length-1):null;for(let h=0;hez&&(c=QI(c,f),l-=f),new zr(c.append(o),l)}remapping(e,n){let r=new au;return this.items.forEach((i,o)=>{let l=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,l)},e,n),r}addMaps(e){return this.eventCount==0?this:new zr(this.items.append(e.map(n=>new Ro(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),o=e.mapping,l=e.steps.length,c=this.eventCount;this.items.forEach(g=>{g.selection&&c--},i);let d=n;this.items.forEach(g=>{let y=o.getMirror(--d);if(y==null)return;l=Math.min(l,y);let C=o.maps[y];if(g.step){let w=e.steps[y].invert(e.docs[y]),x=g.selection&&g.selection.map(o.slice(d+1,y));x&&c++,r.push(new Ro(C,w,x))}else r.push(new Ro(C))},i);let f=[];for(let g=n;gXI&&(m=m.compress(this.items.length-r.length)),m}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],o=0;return this.items.forEach((l,c)=>{if(c>=e)i.push(l),l.selection&&o++;else if(l.step){let d=l.step.map(n.slice(r)),f=d&&d.getMap();if(r--,f&&n.appendMap(f,r),d){let h=l.selection&&l.selection.map(n.slice(r));h&&o++;let m=new Ro(f.invert(),d,h),g,y=i.length-1;(g=i.length&&i[y].merge(m))?i[y]=g:i.push(m)}}else l.map&&r--},this.items.length,0),new zr(nn.from(i.reverse()),o)}}zr.empty=new zr(nn.empty,0);function QI(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}let Ro=class VS{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new VS(n.getMap().invert(),n,this.selection)}}};class Io{constructor(e,n,r,i,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const ez=20;function tz(t,e,n,r){let i=n.getMeta(Vs),o;if(i)return i.historyState;n.getMeta(iz)&&(t=new Io(t.done,t.undone,null,0,-1));let l=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(l&&l.getMeta(Vs))return l.getMeta(Vs).redo?new Io(t.done.addTransform(n,void 0,r,qf(e)),t.undone,e5(n.mapping.maps),t.prevTime,t.prevComposition):new Io(t.done,t.undone.addTransform(n,void 0,r,qf(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(l&&l.getMeta("addToHistory")===!1)){let c=n.getMeta("composition"),d=t.prevTime==0||!l&&t.prevComposition!=c&&(t.prevTime<(n.time||0)-r.newGroupDelay||!nz(n,t.prevRanges)),f=l?w0(t.prevRanges,n.mapping):e5(n.mapping.maps);return new Io(t.done.addTransform(n,d?e.selection.getBookmark():void 0,r,qf(e)),zr.empty,f,n.time,c??t.prevComposition)}else return(o=n.getMeta("rebased"))?new Io(t.done.rebased(n,o),t.undone.rebased(n,o),w0(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Io(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),w0(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function nz(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let o=0;o=e[o]&&(n=!0)}),n}function e5(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,o,l)=>e.push(o,l));return e}function w0(t,e){if(!t)return null;let n=[];for(let r=0;r{let i=Vs.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let o=rz(i,n,t);o&&r(e?o.scrollIntoView():o)}return!0}}const PS=US(!1,!0),FS=US(!0,!0);Ke.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new Ue({key:new Ze("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const o=this.storage.characters({node:r.doc});if(o>i){const l=o-i,c=0,d=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const f=r.tr.deleteRange(c,d);return t=!0,f}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),o=this.storage.characters({node:e.doc});if(o<=r||i>r&&o>r&&o<=i)return!0;if(i>r&&o>r&&o>i||!e.getMeta("paste"))return!1;const c=e.selection.$head.pos,d=o-r,f=c-d,h=c;return e.deleteRange(f,h),!(this.storage.characters({node:e.doc})>r)}})]}});var sz=Ke.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[PI(this.options)]}});Ke.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Ue({key:new Ze("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,o=[];if(!n||!r)return Qe.create(t,[]);let l=0;this.options.mode==="deepest"&&t.descendants((d,f)=>{if(d.isText)return;if(!(i>=f&&i<=f+d.nodeSize-1))return!1;l+=1});let c=0;return t.descendants((d,f)=>{if(d.isText||!(i>=f&&i<=f+d.nodeSize-1))return!1;if(c+=1,this.options.mode==="deepest"&&l-c>0||this.options.mode==="shallowest"&&c>1)return this.options.mode==="deepest";o.push(Ft.node(f,f+d.nodeSize,{class:this.options.className}))}),Qe.create(t,o)}}})]}});var lz=Ke.create({name:"gapCursor",addProseMirrorPlugins(){return[ZI()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Ye(be(t,"allowGapCursor",n)))!=null?e:null}}}),az=Ke.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Ue({key:new Ze("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const o=this.editor.isEmpty;return t.descendants((l,c)=>{const d=r>=c&&r<=c+l.nodeSize,f=!l.isLeaf&&Lp(l);if((d||!this.options.showOnlyCurrent)&&f){const h=[this.options.emptyNodeClass];o&&h.push(this.options.emptyEditorClass);const m=Ft.node(c,c+l.nodeSize,{class:h.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:c,hasAnchor:d}):this.options.placeholder});i.push(m)}return this.options.includeChildren}),Qe.create(t,i)}}})]}});Ke.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Ue({key:new Ze("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Ky(n.selection)||t.view.dragging?null:Qe.create(n.doc,[Ft.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function n5({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var cz=Ke.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Ze(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new Ue({key:e,appendTransaction:(i,o,l)=>{const{doc:c,tr:d,schema:f}=l,h=e.getState(l),m=c.content.size,g=f.nodes[n];if(h)return d.insert(m,g.create())},state:{init:(i,o)=>{const l=o.tr.doc.lastChild;return!n5({node:l,types:r})},apply:(i,o)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return o;const l=i.doc.lastChild;return!n5({node:l,types:r})}}})]}}),uz=Ke.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>PS(t,e),redo:()=>({state:t,dispatch:e})=>FS(t,e)}},addProseMirrorPlugins(){return[oz(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),dz=Ke.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(zH.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(DH.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(MS.configure(this.options.bulletList)),this.options.code!==!1&&i.push(VH.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(FH.configure(this.options.codeBlock)),this.options.document!==!1&&i.push($H.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(sz.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(lz.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(qH.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(ZH.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(uz.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(KH.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(XH.configure(this.options.italic)),this.options.listItem!==!1&&i.push(AS.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(_S.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(SI.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(IS.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(zS.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(jI.configure(this.options.strike)),this.options.text!==!1&&i.push(VI.configure(this.options.text)),this.options.underline!==!1&&i.push(UI.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(cz.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),fz=Ke.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),hz=Xi.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",Fe(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),pz=t=>Nt({find:/--$/,replace:t??"—"}),mz=t=>Nt({find:/\.\.\.$/,replace:t??"…"}),gz=t=>Nt({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:t??"“"}),yz=t=>Nt({find:/"$/,replace:t??"”"}),vz=t=>Nt({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:t??"‘"}),bz=t=>Nt({find:/'$/,replace:t??"’"}),Cz=t=>Nt({find:/<-$/,replace:t??"←"}),wz=t=>Nt({find:/->$/,replace:t??"→"}),xz=t=>Nt({find:/\(c\)$/,replace:t??"©"}),Sz=t=>Nt({find:/\(tm\)$/,replace:t??"™"}),Tz=t=>Nt({find:/\(sm\)$/,replace:t??"℠"}),kz=t=>Nt({find:/\(r\)$/,replace:t??"®"}),Ez=t=>Nt({find:/(?:^|\s)(1\/2)\s$/,replace:t??"½"}),Mz=t=>Nt({find:/\+\/-$/,replace:t??"±"}),Az=t=>Nt({find:/!=$/,replace:t??"≠"}),Nz=t=>Nt({find:/<<$/,replace:t??"«"}),Rz=t=>Nt({find:/>>$/,replace:t??"»"}),Oz=t=>Nt({find:/\d+\s?([*x])\s?\d+$/,replace:t??"×"}),Dz=t=>Nt({find:/\^2$/,replace:t??"²"}),Lz=t=>Nt({find:/\^3$/,replace:t??"³"}),_z=t=>Nt({find:/(?:^|\s)(1\/4)\s$/,replace:t??"¼"}),Hz=t=>Nt({find:/(?:^|\s)(3\/4)\s$/,replace:t??"¾"}),r5=Ke.create({name:"typography",addOptions(){return{closeDoubleQuote:"”",closeSingleQuote:"’",copyright:"©",ellipsis:"…",emDash:"—",laquo:"«",leftArrow:"←",multiplication:"×",notEqual:"≠",oneHalf:"½",oneQuarter:"¼",openDoubleQuote:"“",openSingleQuote:"‘",plusMinus:"±",raquo:"»",registeredTrademark:"®",rightArrow:"→",servicemark:"℠",superscriptThree:"³",superscriptTwo:"²",threeQuarters:"¾",trademark:"™"}},addInputRules(){const t=[];return this.options.emDash!==!1&&t.push(pz(this.options.emDash)),this.options.ellipsis!==!1&&t.push(mz(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&t.push(gz(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&t.push(yz(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&t.push(vz(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&t.push(bz(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&t.push(Cz(this.options.leftArrow)),this.options.rightArrow!==!1&&t.push(wz(this.options.rightArrow)),this.options.copyright!==!1&&t.push(xz(this.options.copyright)),this.options.trademark!==!1&&t.push(Sz(this.options.trademark)),this.options.servicemark!==!1&&t.push(Tz(this.options.servicemark)),this.options.registeredTrademark!==!1&&t.push(kz(this.options.registeredTrademark)),this.options.oneHalf!==!1&&t.push(Ez(this.options.oneHalf)),this.options.plusMinus!==!1&&t.push(Mz(this.options.plusMinus)),this.options.notEqual!==!1&&t.push(Az(this.options.notEqual)),this.options.laquo!==!1&&t.push(Nz(this.options.laquo)),this.options.raquo!==!1&&t.push(Rz(this.options.raquo)),this.options.multiplication!==!1&&t.push(Oz(this.options.multiplication)),this.options.superscriptTwo!==!1&&t.push(Dz(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&t.push(Lz(this.options.superscriptThree)),this.options.oneQuarter!==!1&&t.push(_z(this.options.oneQuarter)),this.options.threeQuarters!==!1&&t.push(Hz(this.options.threeQuarters)),t}});function Iz(){const t=document.documentElement.lang||"en";return t.startsWith("cs")||t.startsWith("cz")?r5.configure({openDoubleQuote:"„",closeDoubleQuote:"“",openSingleQuote:"‚",closeSingleQuote:"‘"}):r5}var zz=Xi.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",Fe(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});let L2,_2;if(typeof WeakMap<"u"){let t=new WeakMap;L2=e=>t.get(e),_2=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;L2=r=>{for(let i=0;i(n==10&&(n=0),t[n++]=r,t[n++]=i)}var Mt=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e=n){(o||(o=[])).push({type:"overlong_rowspan",pos:h,n:k-N});break}const R=i+N*e;for(let L=0;Lr&&(o+=f.attrs.colspan)}}for(let l=0;l1&&(n=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function Vz(t,e,n){t.problems||(t.problems=[]);const r={};for(let i=0;i0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Pz(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Yr(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function Ip(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Gs(e.$head)||Fz(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function Fz(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function H2(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function $z(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function f3(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function $S(t,e,n){const r=t.node(-1),i=Mt.get(r),o=t.start(-1),l=i.nextCell(t.pos-o,e,n);return l==null?null:t.node(0).resolve(o+l)}function Ys(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function qS(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;ih!=n.pos-o);d.unshift(n.pos-o);const f=d.map(h=>{const m=r.nodeAt(h);if(!m)throw new RangeError(`No cell with offset ${h} found`);const g=o+h+1;return new wy(c.resolve(g),c.resolve(g+m.content.size))});super(f[0].$from,f[0].$to,f),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),i=e.resolve(n.map(this.$headCell.pos));if(H2(r)&&H2(i)&&f3(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?ji.rowSelection(r,i):o&&this.isColSelection()?ji.colSelection(r,i):new ji(r,i)}return ue.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=Mt.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},l=[];for(let d=i.top;d0||x>0){let k=C.attrs;if(w>0&&(k=Ys(k,0,w)),x>0&&(k=Ys(k,k.colspan-x,x)),y.lefti.bottom){const k={...C.attrs,rowspan:Math.min(y.bottom,i.bottom)-Math.max(y.top,i.top)};y.top0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),i=Mt.get(r),o=e.start(-1),l=i.findCell(e.pos-o),c=i.findCell(n.pos-o),d=e.node(0);return l.top<=c.top?(l.top>0&&(e=d.resolve(o+i.map[l.left])),c.bottom0&&(n=d.resolve(o+i.map[c.left])),l.bottom0)return!1;const l=i+this.$anchorCell.nodeAfter.attrs.colspan,c=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(l,c)==n.width}eq(e){return e instanceof ji&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=Mt.get(r),o=e.start(-1),l=i.findCell(e.pos-o),c=i.findCell(n.pos-o),d=e.node(0);return l.left<=c.left?(l.left>0&&(e=d.resolve(o+i.map[l.top*i.width])),c.right0&&(n=d.resolve(o+i.map[c.top*i.width])),l.right{e.push(Ft.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Qe.create(t.doc,e)}function Gz({$from:t,$to:e}){if(t.pos==e.pos||t.pos=0&&!(t.after(i+1)=0&&!(e.before(o+1)>e.start(o));o--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function Yz({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){const o=t.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}for(let i=e.depth;i>0;i--){const o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return n!==r&&e.parentOffset===0}function Wz(t,e,n){const r=(e||t).selection,i=(e||t).doc;let o,l;if(r instanceof me&&(l=r.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")o=dt.create(i,r.from);else if(l=="row"){const c=i.resolve(r.from+1);o=dt.rowSelection(c,c)}else if(!n){const c=Mt.get(r.node),d=r.from+1,f=d+c.map[c.width*c.height-1];o=dt.create(i,d+1,f)}}else r instanceof ue&&Gz(r)?o=ue.create(i,r.from):r instanceof ue&&Yz(r)&&(o=ue.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=t.tr)).setSelection(o),e}const Jz=new Ze("fix-tables");function KS(t,e,n,r){const i=t.childCount,o=e.childCount;e:for(let l=0,c=0;l{i.type.spec.tableRole=="table"&&(n=Xz(t,i,o,n))};return e?e.doc!=t.doc&&KS(e.doc,t.doc,0,r):t.doc.descendants(r),n}function Xz(t,e,n,r){const i=Mt.get(e);if(!i.problems)return r;r||(r=t.tr);const o=[];for(let d=0;d0){let y="cell";h.firstChild&&(y=h.firstChild.type.spec.tableRole);const C=[];for(let x=0;x0?-1:0;qz(e,r,i+o)&&(o=i==0||i==e.width?null:0);for(let l=0;l0&&i0&&e.map[c-1]==d||i0?-1:0;rB(e,r,i+c)&&(c=i==0||i==e.height?null:0);for(let f=0,h=e.width*i;f0&&i0&&m==e.map[h-e.width]){const g=n.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(c).map(m+r),null,{...g,rowspan:g.rowspan-1}),f+=g.colspan-1}else if(i0&&n[o]==n[o-1]||r.right0&&n[i]==n[i-t]||r.bottom0){const h=d+1+f.content.size,m=i5(f)?d+1:h;o.replaceWith(m+r.tableStart,h+r.tableStart,c)}o.setSelection(new dt(o.doc.resolve(d+r.tableStart))),e(o)}return!0}function s5(t,e){const n=kn(t.schema);return cB(({node:r})=>n[r.type.spec.tableRole])(t,e)}function cB(t){return(e,n)=>{const r=e.selection;let i,o;if(r instanceof dt){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,o=r.$anchorCell.pos}else{var l;if(i=Pz(r.$from),!i)return!1;o=(l=Gs(r.$from))===null||l===void 0?void 0:l.pos}if(i==null||o==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let c=i.attrs;const d=[],f=c.colwidth;c.rowspan>1&&(c={...c,rowspan:1}),c.colspan>1&&(c={...c,colspan:1});const h=hi(e),m=e.tr;for(let y=0;y{l.attrs[t]!==e&&o.setNodeMarkup(c,null,{...l.attrs,[t]:e})}):o.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[t]:e}),r(o)}return!0}}function dB(t){return function(e,n){if(!Yr(e))return!1;if(n){const r=kn(e.schema),i=hi(e),o=e.tr,l=i.map.cellsInRect(t=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:t=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),c=l.map(d=>i.table.nodeAt(d));for(let d=0;d{const y=g+o.tableStart,C=l.doc.nodeAt(y);C&&l.setNodeMarkup(y,m,C.attrs)}),r(l)}return!0}}yu("row",{useDeprecatedLogic:!0});yu("column",{useDeprecatedLogic:!0});const fB=yu("cell",{useDeprecatedLogic:!0});function hB(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,i=t.before();r>=0;r--){const o=t.node(-1).child(r),l=o.lastChild;if(l)return i-1-l.nodeSize;i-=o.nodeSize}}else{if(t.index()0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Tf(t,e){const n=t.selection;if(!(n instanceof dt))return!1;if(e){const r=t.tr,i=kn(t.schema).cell.createAndFill().content;n.forEachCell((o,l)=>{o.content.eq(i)||r.replace(r.mapping.map(l+1),r.mapping.map(l+o.nodeSize-1),new ce(i,0,0))}),r.docChanged&&e(r)}return!0}function mB(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const i=e.child(0),o=i.type.spec.tableRole,l=i.type.schema,c=[];if(o=="row")for(let d=0;d=0;l--){const{rowspan:c,colspan:d}=o.child(l).attrs;for(let f=i;f=e.length&&e.push(te.empty),n[i]r&&(g=g.type.createChecked(Ys(g.attrs,g.attrs.colspan,h+g.attrs.colspan-r),g.content)),f.push(g),h+=g.attrs.colspan;for(let y=1;yi&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,i-m.attrs.rowspan)},m.content)),d.push(m)}o.push(te.from(d))}n=o,e=i}return{width:t,height:e,rows:n}}function vB(t,e,n,r,i,o,l){const c=t.doc.type.schema,d=kn(c);let f,h;if(i>e.width)for(let m=0,g=0;me.height){const m=[];for(let C=0,w=(e.height-1)*e.width;C=e.width?!1:n.nodeAt(e.map[w+C]).type==d.header_cell;m.push(x?h||(h=d.header_cell.createAndFill()):f||(f=d.cell.createAndFill()))}const g=d.row.create(null,te.from(m)),y=[];for(let C=e.height;C{if(!i)return!1;const o=n.selection;if(o instanceof dt)return Zf(n,r,Se.near(o.$headCell,e));if(t!="horiz"&&!o.empty)return!1;const l=JS(i,t,e);if(l==null)return!1;if(t=="horiz")return Zf(n,r,Se.near(n.doc.resolve(o.head+e),e));{const c=n.doc.resolve(l),d=$S(c,t,e);let f;return d?f=Se.near(d,1):e<0?f=Se.near(n.doc.resolve(c.before(-1)),-1):f=Se.near(n.doc.resolve(c.after(-1)),1),Zf(n,r,f)}}}function Ef(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;let l;if(o instanceof dt)l=o;else{const d=JS(i,t,e);if(d==null)return!1;l=new dt(n.doc.resolve(d))}const c=$S(l.$headCell,t,e);return c?Zf(n,r,new dt(l.$anchorCell,c)):!1}}function CB(t,e){const n=t.state.doc,r=Gs(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new dt(r))),!0):!1}function wB(t,e,n){if(!Yr(t.state))return!1;let r=mB(n);const i=t.state.selection;if(i instanceof dt){r||(r={width:1,height:1,rows:[te.from(I2(kn(t.state.schema).cell,n))]});const o=i.$anchorCell.node(-1),l=i.$anchorCell.start(-1),c=Mt.get(o).rectBetween(i.$anchorCell.pos-l,i.$headCell.pos-l);return r=yB(r,c.right-c.left,c.bottom-c.top),d5(t.state,t.dispatch,l,c,r),!0}else if(r){const o=Ip(t.state),l=o.start(-1);return d5(t.state,t.dispatch,l,Mt.get(o.node(-1)).findCell(o.pos-l),r),!0}else return!1}function xB(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=f5(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof dt)o(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Gs(t.state.selection.$anchor))!=null&&((n=S0(t,e))===null||n===void 0?void 0:n.pos)!=i.pos)o(i,e),e.preventDefault();else if(!r)return;function o(d,f){let h=S0(t,f);const m=jo.getState(t.state)==null;if(!h||!f3(d,h))if(m)h=d;else return;const g=new dt(d,h);if(m||!t.state.selection.eq(g)){const y=t.state.tr.setSelection(g);m&&y.setMeta(jo,d.pos),t.dispatch(y)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",c),jo.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(jo,-1))}function c(d){const f=d,h=jo.getState(t.state);let m;if(h!=null)m=t.state.doc.resolve(h);else if(f5(t,f.target)!=r&&(m=S0(t,e),!m))return l();m&&o(m,f)}t.root.addEventListener("mouseup",l),t.root.addEventListener("dragstart",l),t.root.addEventListener("mousemove",c)}function JS(t,e,n){if(!(t.state.selection instanceof ue))return null;const{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const l=r.before(i),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?l:null}}return null}function f5(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function S0(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&Gs(t.state.doc.resolve(r))||Gs(t.state.doc.resolve(i))}var SB=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),z2(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,z2(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function z2(t,e,n,r,i,o){let l=0,c=!0,d=e.firstChild;const f=t.firstChild;if(f){for(let m=0,g=0;mnew r(m,n,g)),new kB(-1,!1)},apply(l,c){return c.apply(l)}},props:{attributes:l=>{const c=ar.getState(l);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,c)=>{EB(l,c,t,i)},mouseleave:l=>{MB(l)},mousedown:(l,c)=>{AB(l,c,e,n)}},decorations:l=>{const c=ar.getState(l);if(c&&c.activeHandle>-1)return LB(l,c.activeHandle)},nodeViews:{}}});return o}var kB=class Kf{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(ar);if(r&&r.setHandle!=null)return new Kf(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Kf(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);return H2(e.doc.resolve(i))||(i=-1),new Kf(i,n.dragging)}return n}};function EB(t,e,n,r){if(!t.editable)return;const i=ar.getState(t.state);if(i&&!i.dragging){const o=RB(e.target);let l=-1;if(o){const{left:c,right:d}=o.getBoundingClientRect();e.clientX-c<=n?l=h5(t,e,"left",n):d-e.clientX<=n&&(l=h5(t,e,"right",n))}if(l!=i.activeHandle){if(!r&&l!==-1){const c=t.state.doc.resolve(l),d=c.node(-1),f=Mt.get(d),h=c.start(-1);if(f.colCount(c.pos-h)+c.nodeAfter.attrs.colspan-1==f.width-1)return}XS(t,l)}}}function MB(t){if(!t.editable)return;const e=ar.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&XS(t,-1)}function AB(t,e,n,r){var i;if(!t.editable)return!1;const o=(i=t.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,l=ar.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const c=t.state.doc.nodeAt(l.activeHandle),d=NB(t,l.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(ar,{setDragging:{startX:e.clientX,startWidth:d}}));function f(m){o.removeEventListener("mouseup",f),o.removeEventListener("mousemove",h);const g=ar.getState(t.state);g?.dragging&&(OB(t,g.activeHandle,p5(g.dragging,m,n)),t.dispatch(t.state.tr.setMeta(ar,{setDragging:null})))}function h(m){if(!m.which)return f(m);const g=ar.getState(t.state);if(g&&g.dragging){const y=p5(g.dragging,m,n);m5(t,g.activeHandle,y,r)}}return m5(t,l.activeHandle,d,r),o.addEventListener("mouseup",f),o.addEventListener("mousemove",h),e.preventDefault(),!0}function NB(t,e,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const o=t.domAtPos(e);let l=o.node.childNodes[o.offset].offsetWidth,c=n;if(r)for(let d=0;d{var e,n;const r=t.getAttribute("colwidth"),i=r?r.split(",").map(o=>parseInt(o,10)):null;if(!i){const o=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),l=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(l&&l>-1&&o&&o[l]){const c=o[l].getAttribute("width");return c?[parseInt(c,10)]:null}}return i}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",Fe(this.options.HTMLAttributes,t),0]}}),IB=st.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",Fe(this.options.HTMLAttributes,t),0]}}),zB=st.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Fe(this.options.HTMLAttributes,t),0]}});function B2(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function g5(t,e,n,r,i,o){var l;let c=0,d=!0,f=e.firstChild;const h=t.firstChild;if(h!==null)for(let g=0,y=0;g{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function UB(t,e,n,r,i){const o=VB(t),l=[],c=[];for(let f=0;f{const{selection:e}=t.state;if(!PB(e))return!1;let n=0;const r=Ux(e.ranges[0].$from,o=>o.type.name==="table");return r?.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},FB="";function $B(t){return(t||"").replace(/\s+/g," ").trim()}function qB(t,e,n={}){var r;const i=(r=n.cellLineSeparator)!=null?r:FB;if(!t||!t.content||t.content.length===0)return"";const o=[];t.content.forEach(C=>{const w=[];C.content&&C.content.forEach(x=>{let k="";x.content&&Array.isArray(x.content)&&x.content.length>1?k=x.content.map(L=>e.renderChildren(L)).join(i):k=x.content?e.renderChildren(x.content):"";const A=$B(k),N=x.type==="tableHeader";w.push({text:A,isHeader:N})}),o.push(w)});const l=o.reduce((C,w)=>Math.max(C,w.length),0);if(l===0)return"";const c=new Array(l).fill(0);o.forEach(C=>{var w;for(let x=0;xc[x]&&(c[x]=A),c[x]<3&&(c[x]=3)}});const d=(C,w)=>C+" ".repeat(Math.max(0,w-C.length)),f=o[0],h=f.some(C=>C.isHeader);let m=` `;const g=new Array(l).fill(0).map((C,w)=>h&&f[w]&&f[w].text||"");return m+=`| ${g.map((C,w)=>d(C,c[w])).join(" | ")} | `,m+=`| ${c.map(C=>"-".repeat(Math.max(3,C))).join(" | ")} | `,(h?o.slice(1):o).forEach(C=>{m+=`| ${new Array(l).fill(0).map((w,x)=>d(C[x]&&C[x].text||"",c[x])).join(" | ")} | -`}),m}var ZB=qB,QS=st.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:BB,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:i}=jB(t,this.options.cellMinWidth),o=e.style;function l(){return o||(r?`width: ${r}`:`min-width: ${i}`)}const c=["table",Pe(this.options.HTMLAttributes,e,{style:l()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},c]:c},parseMarkdown:(t,e)=>{const n=[];if(t.header){const r=[];t.header.forEach(i=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(r=>{const i=[];r.forEach(o=>{i.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(o.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>ZB(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:o})=>{const l=UB(o.schema,t,e,n);if(i){const c=r.selection.from+1;r.replaceSelectionWith(l).scrollIntoView().setSelection(ue.near(r.doc.resolve(c)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>Qz(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>eB(t,e),deleteColumn:()=>({state:t,dispatch:e})=>nB(t,e),addRowBefore:()=>({state:t,dispatch:e})=>iB(t,e),addRowAfter:()=>({state:t,dispatch:e})=>oB(t,e),deleteRow:()=>({state:t,dispatch:e})=>lB(t,e),deleteTable:()=>({state:t,dispatch:e})=>pB(t,e),mergeCells:()=>({state:t,dispatch:e})=>o5(t,e),splitCell:()=>({state:t,dispatch:e})=>s5(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>yu("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>yu("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>fB(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>o5(t,e)?!0:s5(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>uB(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>a5(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>a5(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&GS(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=dt.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Mf,"Mod-Backspace":Mf,Delete:Mf,"Mod-Delete":Mf}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[TB({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],_B({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:Ge(be(t,"tableRole",e))}}}),KB=Ze.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(QS.configure(this.options.table)),this.options.tableCell!==!1&&t.push(HB.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(IB.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(zB.configure(this.options.tableRow)),t}});let GB=1;const Ui=()=>`folioTiptapNode-${GB++}`,j2=(t,e)=>{window.parent.postMessage({type:"f-tiptap-node:click",attrs:t,uniqueId:e},"*")},e8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[S.jsx("rect",{width:"10",height:"20",x:"2",y:"2",rx:"2"}),S.jsx("path",{d:"M21.593 11.998H15.19M18.39 15.201V8.8"})]}));e8.displayName="AddColumnAfter";const t8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:S.jsxs("g",{transform:"rotate(180 12 12)",children:[S.jsx("rect",{width:"10",height:"20",x:"2",y:"2",rx:"2"}),S.jsx("path",{d:"M21.593 11.998H15.19M18.39 15.201V8.8"})]})}));t8.displayName="AddColumnBefore";const n8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2ZM4 12C4 7.58172 7.58172 4 12 4C16.4183 4 20 7.58172 20 12C20 16.4183 16.4183 20 12 20C7.58172 20 4 16.4183 4 12Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 7C12.5523 7 13 7.44772 13 8V12C13 12.5523 12.5523 13 12 13C11.4477 13 11 12.5523 11 12V8C11 7.44772 11.4477 7 12 7Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 15C12.5523 15 13 15.4477 13 16C13 16.5523 12.5523 17 12 17C11.4477 17 11 16.5523 11 16C11 15.4477 11.4477 15 12 15Z",fill:"currentColor"})]}));n8.displayName="AlertCircleIcon";const r8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 12C6 11.4477 6.44772 11 7 11H17C17.5523 11 18 11.4477 18 12C18 12.5523 17.5523 13 17 13H7C6.44772 13 6 12.5523 6 12Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 18C4 17.4477 4.44772 17 5 17H19C19.5523 17 20 17.4477 20 18C20 18.5523 19.5523 19 19 19H5C4.44772 19 4 18.5523 4 18Z",fill:"currentColor"})]}));r8.displayName="AlignCenterIcon";const YB=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));YB.displayName="AlignJustifyIcon";const h3=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H15C15.5523 11 16 11.4477 16 12C16 12.5523 15.5523 13 15 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H17C17.5523 17 18 17.4477 18 18C18 18.5523 17.5523 19 17 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));h3.displayName="AlignLeftIcon";const i8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 18C6 17.4477 6.44772 17 7 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H7C6.44772 19 6 18.5523 6 18Z",fill:"currentColor"})]}));i8.displayName="AlignRightIcon";const o8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M11.92 19.92L4 12L11.92 4.08L13.33 5.5L7.83 11H22V13H7.83L13.34 18.5L11.92 19.92ZM4 12V2H2V22H4V12Z",fill:"currentColor"})}));o8.displayName="ArrowCollapseLeft";const s8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M12.08 4.08L20 12L12.08 19.92L10.67 18.5L16.17 13H2V11H16.17L10.67 5.5L12.08 4.08ZM20 12V22H22V2H20V12Z",fill:"currentColor"})}));s8.displayName="ArrowCollapseRight";const p3=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M11.0001 4H13.0001V16L18.5001 10.5L19.9201 11.92L12.0001 19.84L4.08008 11.92L5.50008 10.5L11.0001 16V4Z",fill:"currentColor"})}));p3.displayName="ArrowDownIcon";const WB=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M12.7071 5.70711C13.0976 5.31658 13.0976 4.68342 12.7071 4.29289C12.3166 3.90237 11.6834 3.90237 11.2929 4.29289L4.29289 11.2929C3.90237 11.6834 3.90237 12.3166 4.29289 12.7071L11.2929 19.7071C11.6834 20.0976 12.3166 20.0976 12.7071 19.7071C13.0976 19.3166 13.0976 18.6834 12.7071 18.2929L7.41421 13L19 13C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11L7.41421 11L12.7071 5.70711Z",fill:"currentColor"})}));WB.displayName="ArrowLeftIcon";const l8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M18 16V13H15V22H13V2H15V11H18V8L22 12L18 16ZM2 12L6 16V13H9V22H11V2H9V11H6V8L2 12Z",fill:"currentColor"})}));l8.displayName="ArrowSplitVerticalIcon";const m3=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M13.0001 20H11.0001V8.00003L5.50008 13.5L4.08008 12.08L12.0001 4.16003L19.9201 12.08L18.5001 13.5L13.0001 8.00003V20Z",fill:"currentColor"})}));m3.displayName="ArrowUpIcon";const JB=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.43471 4.01458C4.34773 4.06032 4.26607 4.11977 4.19292 4.19292C4.11977 4.26607 4.06032 4.34773 4.01458 4.43471C2.14611 6.40628 1 9.0693 1 12C1 18.0751 5.92487 23 12 23C14.9306 23 17.5936 21.854 19.5651 19.9856C19.6522 19.9398 19.7339 19.8803 19.8071 19.8071C19.8803 19.7339 19.9398 19.6522 19.9856 19.5651C21.854 17.5936 23 14.9306 23 12C23 5.92487 18.0751 1 12 1C9.0693 1 6.40628 2.14611 4.43471 4.01458ZM6.38231 4.9681C7.92199 3.73647 9.87499 3 12 3C16.9706 3 21 7.02944 21 12C21 14.125 20.2635 16.078 19.0319 17.6177L6.38231 4.9681ZM17.6177 19.0319C16.078 20.2635 14.125 21 12 21C7.02944 21 3 16.9706 3 12C3 9.87499 3.73647 7.92199 4.9681 6.38231L17.6177 19.0319Z",fill:"currentColor"})}));JB.displayName="BanIcon";const XB=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 6C8 5.44772 8.44772 5 9 5H16C16.5523 5 17 5.44772 17 6C17 6.55228 16.5523 7 16 7H9C8.44772 7 8 6.55228 8 6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 3C4.55228 3 5 3.44772 5 4L5 20C5 20.5523 4.55229 21 4 21C3.44772 21 3 20.5523 3 20L3 4C3 3.44772 3.44772 3 4 3Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H20C20.5523 11 21 11.4477 21 12C21 12.5523 20.5523 13 20 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 18C8 17.4477 8.44772 17 9 17H16C16.5523 17 17 17.4477 17 18C17 18.5523 16.5523 19 16 19H9C8.44772 19 8 18.5523 8 18Z",fill:"currentColor"})]}));XB.displayName="BlockQuoteIcon";const a8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 2.5C5.17157 2.5 4.5 3.17157 4.5 4V20C4.5 20.8284 5.17157 21.5 6 21.5H15C16.4587 21.5 17.8576 20.9205 18.8891 19.8891C19.9205 18.8576 20.5 17.4587 20.5 16C20.5 14.5413 19.9205 13.1424 18.8891 12.1109C18.6781 11.9 18.4518 11.7079 18.2128 11.5359C19.041 10.5492 19.5 9.29829 19.5 8C19.5 6.54131 18.9205 5.14236 17.8891 4.11091C16.8576 3.07946 15.4587 2.5 14 2.5H6ZM14 10.5C14.663 10.5 15.2989 10.2366 15.7678 9.76777C16.2366 9.29893 16.5 8.66304 16.5 8C16.5 7.33696 16.2366 6.70107 15.7678 6.23223C15.2989 5.76339 14.663 5.5 14 5.5H7.5V10.5H14ZM7.5 18.5V13.5H15C15.663 13.5 16.2989 13.7634 16.7678 14.2322C17.2366 14.7011 17.5 15.337 17.5 16C17.5 16.663 17.2366 17.2989 16.7678 17.7678C16.2989 18.2366 15.663 18.5 15 18.5H7.5Z",fill:"currentColor"})}));a8.displayName="BoldIcon";const QB=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.7071 6.29289C21.0976 6.68342 21.0976 7.31658 20.7071 7.70711L10.7071 17.7071C10.3166 18.0976 9.68342 18.0976 9.29289 17.7071L4.29289 12.7071C3.90237 12.3166 3.90237 11.6834 4.29289 11.2929C4.68342 10.9024 5.31658 10.9024 5.70711 11.2929L10 15.5858L19.2929 6.29289C19.6834 5.90237 20.3166 5.90237 20.7071 6.29289Z",fill:"currentColor"})}));QB.displayName="CheckIcon";const g3=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.29289 8.29289C5.68342 7.90237 6.31658 7.90237 6.70711 8.29289L12 13.5858L17.2929 8.29289C17.6834 7.90237 18.3166 7.90237 18.7071 8.29289C19.0976 8.68342 19.0976 9.31658 18.7071 9.70711L12.7071 15.7071C12.3166 16.0976 11.6834 16.0976 11.2929 15.7071L5.29289 9.70711C4.90237 9.31658 4.90237 8.68342 5.29289 8.29289Z",fill:"currentColor"})}));g3.displayName="ChevronDownIcon";const zp=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12L19 6.41Z",fill:"currentColor"})}));zp.displayName="CloseIcon";const ej=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.70711 2.29289C7.09763 2.68342 7.09763 3.31658 6.70711 3.70711L4.41421 6L6.70711 8.29289C7.09763 8.68342 7.09763 9.31658 6.70711 9.70711C6.31658 10.0976 5.68342 10.0976 5.29289 9.70711L2.29289 6.70711C1.90237 6.31658 1.90237 5.68342 2.29289 5.29289L5.29289 2.29289C5.68342 1.90237 6.31658 1.90237 6.70711 2.29289Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.2929 2.29289C10.6834 1.90237 11.3166 1.90237 11.7071 2.29289L14.7071 5.29289C15.0976 5.68342 15.0976 6.31658 14.7071 6.70711L11.7071 9.70711C11.3166 10.0976 10.6834 10.0976 10.2929 9.70711C9.90237 9.31658 9.90237 8.68342 10.2929 8.29289L12.5858 6L10.2929 3.70711C9.90237 3.31658 9.90237 2.68342 10.2929 2.29289Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17 4C17 3.44772 17.4477 3 18 3H19C20.6569 3 22 4.34315 22 6V18C22 19.6569 20.6569 21 19 21H5C3.34315 21 2 19.6569 2 18V12C2 11.4477 2.44772 11 3 11C3.55228 11 4 11.4477 4 12V18C4 18.5523 4.44772 19 5 19H19C19.5523 19 20 18.5523 20 18V6C20 5.44772 19.5523 5 19 5H18C17.4477 5 17 4.55228 17 4Z",fill:"currentColor"})]}));ej.displayName="CodeBlockIcon";const c8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M15.4545 4.2983C15.6192 3.77115 15.3254 3.21028 14.7983 3.04554C14.2712 2.88081 13.7103 3.1746 13.5455 3.70175L8.54554 19.7017C8.38081 20.2289 8.6746 20.7898 9.20175 20.9545C9.72889 21.1192 10.2898 20.8254 10.4545 20.2983L15.4545 4.2983Z",fill:"currentColor"}),S.jsx("path",{d:"M6.70711 7.29289C7.09763 7.68342 7.09763 8.31658 6.70711 8.70711L3.41421 12L6.70711 15.2929C7.09763 15.6834 7.09763 16.3166 6.70711 16.7071C6.31658 17.0976 5.68342 17.0976 5.29289 16.7071L1.29289 12.7071C0.902369 12.3166 0.902369 11.6834 1.29289 11.2929L5.29289 7.29289C5.68342 6.90237 6.31658 6.90237 6.70711 7.29289Z",fill:"currentColor"}),S.jsx("path",{d:"M17.2929 7.29289C17.6834 6.90237 18.3166 6.90237 18.7071 7.29289L22.7071 11.2929C23.0976 11.6834 23.0976 12.3166 22.7071 12.7071L18.7071 16.7071C18.3166 17.0976 17.6834 17.0976 17.2929 16.7071C16.9024 16.3166 16.9024 15.6834 17.2929 15.2929L20.5858 12L17.2929 8.70711C16.9024 8.31658 16.9024 7.68342 17.2929 7.29289Z",fill:"currentColor"})]}));c8.displayName="Code2Icon";const u8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21 4C21 3.44772 20.5523 3 20 3C19.4477 3 19 3.44772 19 4V11C19 11.7956 18.6839 12.5587 18.1213 13.1213C17.5587 13.6839 16.7956 14 16 14H6.41421L9.70711 10.7071C10.0976 10.3166 10.0976 9.68342 9.70711 9.29289C9.31658 8.90237 8.68342 8.90237 8.29289 9.29289L3.29289 14.2929C2.90237 14.6834 2.90237 15.3166 3.29289 15.7071L8.29289 20.7071C8.68342 21.0976 9.31658 21.0976 9.70711 20.7071C10.0976 20.3166 10.0976 19.6834 9.70711 19.2929L6.41421 16H16C17.3261 16 18.5979 15.4732 19.5355 14.5355C20.4732 13.5979 21 12.3261 21 11V4Z",fill:"currentColor"})}));u8.displayName="CornerDownLeftIcon";const d8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M20.71 7.04006C21.1 6.65006 21.1 6.00006 20.71 5.63006L18.37 3.29006C18 2.90006 17.35 2.90006 16.96 3.29006L15.12 5.12006L18.87 8.87006M3 17.2501V21.0001H6.75L17.81 9.93006L14.06 6.18006L3 17.2501Z",fill:"currentColor"})}));d8.displayName="EditIcon";const f8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M14 3C14 2.44772 14.4477 2 15 2H21C21.5523 2 22 2.44772 22 3V9C22 9.55228 21.5523 10 21 10C20.4477 10 20 9.55228 20 9V5.41421L10.7071 14.7071C10.3166 15.0976 9.68342 15.0976 9.29289 14.7071C8.90237 14.3166 8.90237 13.6834 9.29289 13.2929L18.5858 4H15C14.4477 4 14 3.55228 14 3Z",fill:"currentColor"}),S.jsx("path",{d:"M4.29289 7.29289C4.48043 7.10536 4.73478 7 5 7H11C11.5523 7 12 6.55228 12 6C12 5.44772 11.5523 5 11 5H5C4.20435 5 3.44129 5.31607 2.87868 5.87868C2.31607 6.44129 2 7.20435 2 8V19C2 19.7957 2.31607 20.5587 2.87868 21.1213C3.44129 21.6839 4.20435 22 5 22H16C16.7957 22 17.5587 21.6839 18.1213 21.1213C18.6839 20.5587 19 19.7957 19 19V13C19 12.4477 18.5523 12 18 12C17.4477 12 17 12.4477 17 13V19C17 19.2652 16.8946 19.5196 16.7071 19.7071C16.5196 19.8946 16.2652 20 16 20H5C4.73478 20 4.48043 19.8946 4.29289 19.7071C4.10536 19.5196 4 19.2652 4 19V8C4 7.73478 4.10536 7.48043 4.29289 7.29289Z",fill:"currentColor"})]}));f8.displayName="ExternalLinkIcon";const h8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"17",height:"16",className:t,viewBox:"0 0 17 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M16.1789 8.32686L11.616 3.76343C11.4016 3.54914 11.1109 3.42877 10.8077 3.42877C10.5046 3.42877 10.2139 3.54914 9.99944 3.76343L6.93773 6.82514L4.50001 0H3.35715L0.5 8H1.64286L2.21372 6.28571H5.64229L6.10115 7.66171L1.97772 11.7851C1.87154 11.8913 1.78732 12.0173 1.72986 12.156C1.67239 12.2947 1.64282 12.4433 1.64282 12.5934C1.64282 12.7435 1.67239 12.8922 1.72986 13.0309C1.78732 13.1696 1.87154 13.2956 1.97772 13.4017L4.57544 16H10.0554L16.1789 9.876C16.2807 9.77427 16.3614 9.65348 16.4165 9.52052C16.4716 9.38757 16.5 9.24506 16.5 9.10114C16.5 8.95722 16.4716 8.81472 16.4165 8.68176C16.3614 8.54881 16.2807 8.42859 16.1789 8.32686ZM2.59429 5.14286L3.92629 1.14286L5.26115 5.14286H2.59429ZM9.58287 14.8571H5.04858L2.78572 12.5931L6.39258 8.98686L10.9229 13.5166L9.58287 14.8571ZM11.7314 12.7086L7.20115 8.17886L10.808 4.57143L15.3377 9.10114L11.7314 12.7086Z",fill:"currentColor"})}));h8.displayName="FormatEraseIcon";const p8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 -960 960 960",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M120-280v-400h400v400H120Zm80-80h240v-240H200v240Zm-80-400v-80h720v80H120Zm480 160v-80h240v80H600Zm0 160v-80h240v80H600Zm0 160v-80h240v80H600ZM120-120v-80h720v80H120Z",fill:"currentColor"})}));p8.displayName="FormatImageLeft";const m8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),S.jsx("path",{d:"M16 10C16 9.44772 16.4477 9 17 9H21C21.5523 9 22 9.44772 22 10C22 10.5523 21.5523 11 21 11H18V12H18.3C20.2754 12 22 13.4739 22 15.5C22 17.5261 20.2754 19 18.3 19C17.6457 19 17.0925 18.8643 16.5528 18.5944C16.0588 18.3474 15.8586 17.7468 16.1055 17.2528C16.3525 16.7588 16.9532 16.5586 17.4472 16.8056C17.7074 16.9357 17.9542 17 18.3 17C19.3246 17 20 16.2739 20 15.5C20 14.7261 19.3246 14 18.3 14H17C16.4477 14 16 13.5523 16 13L16 12.9928V10Z",fill:"currentColor"})]}));m8.displayName="HeadingFiveIcon";const y3=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",fill:"currentColor"}),S.jsx("path",{d:"M17 9C17.5523 9 18 9.44772 18 10V13H20V10C20 9.44772 20.4477 9 21 9C21.5523 9 22 9.44772 22 10V18C22 18.5523 21.5523 19 21 19C20.4477 19 20 18.5523 20 18V15H17C16.4477 15 16 14.5523 16 14V10C16 9.44772 16.4477 9 17 9Z",fill:"currentColor"})]}));y3.displayName="HeadingFourIcon";const g8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M6 3C6.55228 3 7 3.44772 7 4V11H17V4C17 3.44772 17.4477 3 18 3C18.5523 3 19 3.44772 19 4V20C19 20.5523 18.5523 21 18 21C17.4477 21 17 20.5523 17 20V13H7V20C7 20.5523 6.55228 21 6 21C5.44772 21 5 20.5523 5 20V4C5 3.44772 5.44772 3 6 3Z",fill:"currentColor"})}));g8.displayName="HeadingIcon";const y8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),S.jsx("path",{d:"M21.0001 10C21.0001 9.63121 20.7971 9.29235 20.472 9.11833C20.1468 8.94431 19.7523 8.96338 19.4454 9.16795L16.4454 11.168C15.9859 11.4743 15.8617 12.0952 16.1681 12.5547C16.4744 13.0142 17.0953 13.1384 17.5548 12.8321L19.0001 11.8685V18C19.0001 18.5523 19.4478 19 20.0001 19C20.5524 19 21.0001 18.5523 21.0001 18V10Z",fill:"currentColor"})]}));y8.displayName="HeadingOneIcon";const v8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.7071 9.29289C21.0976 9.68342 21.0976 10.3166 20.7071 10.7071C19.8392 11.575 19.2179 12.2949 18.7889 13.0073C18.8587 13.0025 18.929 13 19 13C20.6569 13 22 14.3431 22 16C22 17.6569 20.6569 19 19 19C17.3431 19 16 17.6569 16 16C16 14.6007 16.2837 13.4368 16.8676 12.3419C17.4384 11.2717 18.2728 10.3129 19.2929 9.29289C19.6834 8.90237 20.3166 8.90237 20.7071 9.29289ZM19 17C18.4477 17 18 16.5523 18 16C18 15.4477 18.4477 15 19 15C19.5523 15 20 15.4477 20 16C20 16.5523 19.5523 17 19 17Z",fill:"currentColor"})]}));v8.displayName="HeadingSixIcon";const v3=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.4608 11.2169C19.1135 11.0531 18.5876 11.0204 18.0069 11.3619C17.5309 11.642 16.918 11.4831 16.638 11.007C16.358 10.531 16.5169 9.91809 16.9929 9.63807C18.1123 8.97962 19.3364 8.94691 20.314 9.40808C21.2839 9.86558 21.9999 10.818 21.9999 12C21.9999 12.7957 21.6838 13.5587 21.1212 14.1213C20.5586 14.6839 19.7956 15 18.9999 15C18.4476 15 17.9999 14.5523 17.9999 14C17.9999 13.4477 18.4476 13 18.9999 13C19.2651 13 19.5195 12.8947 19.707 12.7071C19.8946 12.5196 19.9999 12.2652 19.9999 12C19.9999 11.6821 19.8159 11.3844 19.4608 11.2169Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.0001 14C18.0001 13.4477 18.4478 13 19.0001 13C19.7957 13 20.5588 13.3161 21.1214 13.8787C21.684 14.4413 22.0001 15.2043 22.0001 16C22.0001 17.2853 21.2767 18.3971 20.1604 18.8994C19.0257 19.41 17.642 19.2315 16.4001 18.3C15.9582 17.9686 15.8687 17.3418 16.2001 16.9C16.5314 16.4582 17.1582 16.3686 17.6001 16.7C18.3581 17.2685 18.9744 17.24 19.3397 17.0756C19.7234 16.9029 20.0001 16.5147 20.0001 16C20.0001 15.7348 19.8947 15.4804 19.7072 15.2929C19.5196 15.1054 19.2653 15 19.0001 15C18.4478 15 18.0001 14.5523 18.0001 14Z",fill:"currentColor"})]}));v3.displayName="HeadingThreeIcon";const b3=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),S.jsx("path",{d:"M22.0001 12C22.0001 10.7611 21.1663 9.79297 20.0663 9.42632C18.9547 9.05578 17.6171 9.28724 16.4001 10.2C15.9582 10.5314 15.8687 11.1582 16.2001 11.6C16.5314 12.0418 17.1582 12.1314 17.6001 11.8C18.383 11.2128 19.0455 11.1942 19.4338 11.3237C19.8339 11.457 20.0001 11.7389 20.0001 12C20.0001 12.4839 19.8554 12.7379 19.6537 12.9481C19.4275 13.1837 19.1378 13.363 18.7055 13.6307C18.6313 13.6767 18.553 13.7252 18.4701 13.777C17.9572 14.0975 17.3128 14.5261 16.8163 15.2087C16.3007 15.9177 16.0001 16.8183 16.0001 18C16.0001 18.5523 16.4478 19 17.0001 19H21.0001C21.5523 19 22.0001 18.5523 22.0001 18C22.0001 17.4477 21.5523 17 21.0001 17H18.131C18.21 16.742 18.3176 16.5448 18.4338 16.385C18.6873 16.0364 19.0429 15.7775 19.5301 15.473C19.5898 15.4357 19.6536 15.3966 19.7205 15.3556C20.139 15.0992 20.6783 14.7687 21.0964 14.3332C21.6447 13.7621 22.0001 13.0161 22.0001 12Z",fill:"currentColor"})]}));b3.displayName="HeadingTwoIcon";const tj=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.7072 4.70711C15.0977 4.31658 15.0977 3.68342 14.7072 3.29289C14.3167 2.90237 13.6835 2.90237 13.293 3.29289L8.69294 7.89286L8.68594 7.9C8.13626 8.46079 7.82837 9.21474 7.82837 10C7.82837 10.2306 7.85491 10.4584 7.90631 10.6795L2.29289 16.2929C2.10536 16.4804 2 16.7348 2 17V20C2 20.5523 2.44772 21 3 21H12C12.2652 21 12.5196 20.8946 12.7071 20.7071L15.3205 18.0937C15.5416 18.1452 15.7695 18.1717 16.0001 18.1717C16.7853 18.1717 17.5393 17.8639 18.1001 17.3142L22.7072 12.7071C23.0977 12.3166 23.0977 11.6834 22.7072 11.2929C22.3167 10.9024 21.6835 10.9024 21.293 11.2929L16.6971 15.8887C16.5105 16.0702 16.2605 16.1717 16.0001 16.1717C15.7397 16.1717 15.4897 16.0702 15.303 15.8887L10.1113 10.697C9.92992 10.5104 9.82837 10.2604 9.82837 10C9.82837 9.73963 9.92992 9.48958 10.1113 9.30297L14.7072 4.70711ZM13.5858 17L9.00004 12.4142L4 17.4142V19H11.5858L13.5858 17Z",fill:"currentColor"})}));tj.displayName="HighlighterIcon";const nj=E.memo(({className:t,...e})=>S.jsx("svg",{width:"17",height:"16",className:t,viewBox:"0 0 17 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M13.8333 1.33317C13.8333 0.964984 13.5348 0.666504 13.1666 0.666504C12.7984 0.666504 12.4999 0.964984 12.4999 1.33317V2.6665H11.1666C10.7984 2.6665 10.4999 2.96498 10.4999 3.33317C10.4999 3.70136 10.7984 3.99984 11.1666 3.99984H12.4999V5.33317C12.4999 5.70136 12.7984 5.99984 13.1666 5.99984C13.5348 5.99984 13.8333 5.70136 13.8333 5.33317V3.99984H15.1666C15.5348 3.99984 15.8333 3.70136 15.8333 3.33317C15.8333 2.96498 15.5348 2.6665 15.1666 2.6665H13.8333V1.33317ZM3.83325 2.6665C3.65644 2.6665 3.48687 2.73674 3.36185 2.86176C3.23683 2.98679 3.16659 3.15636 3.16659 3.33317V12.6665C3.16659 12.8433 3.23683 13.0129 3.36185 13.1379C3.48687 13.2629 3.65644 13.3332 3.83325 13.3332H4.22378L10.0859 7.47104C10.461 7.0961 10.9696 6.88544 11.4999 6.88544C12.0303 6.88544 12.5389 7.0961 12.9139 7.47104L13.8333 8.39037V7.99984C13.8333 7.63164 14.1317 7.33317 14.4999 7.33317C14.8681 7.33317 15.1666 7.63164 15.1666 7.99984V9.9985V10.0012V12.6665C15.1666 13.197 14.9559 13.7056 14.5808 14.0807C14.2057 14.4558 13.6971 14.6665 13.1666 14.6665H4.50138H4.49846H3.83325C3.30282 14.6665 2.79411 14.4558 2.41904 14.0807C2.04397 13.7056 1.83325 13.197 1.83325 12.6665V3.33317C1.83325 2.80274 2.04397 2.29403 2.41904 1.91896C2.79411 1.54388 3.30282 1.33317 3.83325 1.33317H8.49992C8.86812 1.33317 9.16659 1.63165 9.16659 1.99984C9.16659 2.36802 8.86812 2.6665 8.49992 2.6665H3.83325ZM6.1094 13.3332H13.1666C13.3434 13.3332 13.513 13.2629 13.638 13.1379C13.763 13.0129 13.8333 12.8433 13.8333 12.6665V10.276L11.9713 8.41397C11.8463 8.28904 11.6767 8.21877 11.4999 8.21877C11.3232 8.21877 11.1537 8.28897 11.0287 8.4139L6.1094 13.3332ZM5.08571 4.58562C5.46078 4.21055 5.96949 3.99984 6.49992 3.99984C7.03035 3.99984 7.53905 4.21055 7.91412 4.58562C8.28919 4.9607 8.49992 5.4694 8.49992 5.99984C8.49992 6.53027 8.28919 7.03897 7.91412 7.41404C7.53905 7.7891 7.03035 7.99984 6.49992 7.99984C5.96949 7.99984 5.46078 7.7891 5.08571 7.41404C4.71063 7.03897 4.49992 6.53027 4.49992 5.99984C4.49992 5.4694 4.71063 4.9607 5.08571 4.58562ZM6.49992 5.33317C6.32311 5.33317 6.15354 5.40341 6.02851 5.52843C5.90349 5.65346 5.83325 5.82302 5.83325 5.99984C5.83325 6.17665 5.90349 6.34622 6.02851 6.47124C6.15354 6.59626 6.32311 6.6665 6.49992 6.6665C6.67673 6.6665 6.8463 6.59626 6.97133 6.47124C7.09635 6.34622 7.16659 6.17665 7.16659 5.99984C7.16659 5.82302 7.09635 5.65346 6.97133 5.52843C6.8463 5.40341 6.67673 5.33317 6.49992 5.33317Z",fill:"currentColor"})}));nj.displayName="ImageIcon";const Bp=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M15.0222 3H19C19.5523 3 20 3.44772 20 4C20 4.55228 19.5523 5 19 5H15.693L10.443 19H14C14.5523 19 15 19.4477 15 20C15 20.5523 14.5523 21 14 21H9.02418C9.00802 21.0004 8.99181 21.0004 8.97557 21H5C4.44772 21 4 20.5523 4 20C4 19.4477 4.44772 19 5 19H8.30704L13.557 5H10C9.44772 5 9 4.55228 9 4C9 3.44772 9.44772 3 10 3H14.9782C14.9928 2.99968 15.0075 2.99967 15.0222 3Z",fill:"currentColor"})}));Bp.displayName="ItalicIcon";const b8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M16.9958 1.06669C15.4226 1.05302 13.907 1.65779 12.7753 2.75074L12.765 2.76086L11.045 4.47086C10.6534 4.86024 10.6515 5.49341 11.0409 5.88507C11.4303 6.27673 12.0634 6.27858 12.4551 5.88919L14.1697 4.18456C14.9236 3.45893 15.9319 3.05752 16.9784 3.06662C18.0272 3.07573 19.0304 3.49641 19.772 4.23804C20.5137 4.97967 20.9344 5.98292 20.9435 7.03171C20.9526 8.07776 20.5515 9.08563 19.8265 9.83941L16.833 12.8329C16.4274 13.2386 15.9393 13.5524 15.4019 13.7529C14.8645 13.9533 14.2903 14.0359 13.7181 13.9949C13.146 13.9539 12.5894 13.7904 12.0861 13.5154C11.5827 13.2404 11.1444 12.8604 10.8008 12.401C10.47 11.9588 9.84333 11.8685 9.40108 12.1993C8.95883 12.5301 8.86849 13.1568 9.1993 13.599C9.71464 14.288 10.3721 14.858 11.1272 15.2705C11.8822 15.683 12.7171 15.9283 13.5753 15.9898C14.4334 16.0513 15.2948 15.9274 16.1009 15.6267C16.907 15.326 17.639 14.8555 18.2473 14.247L21.2472 11.2471L21.2593 11.2347C22.3523 10.1031 22.9571 8.58751 22.9434 7.01433C22.9297 5.44115 22.2987 3.93628 21.1863 2.82383C20.0738 1.71138 18.5689 1.08036 16.9958 1.06669Z",fill:"currentColor"}),S.jsx("path",{d:"M10.4247 8.0102C9.56657 7.94874 8.70522 8.07256 7.89911 8.37326C7.09305 8.67395 6.36096 9.14458 5.75272 9.753L2.75285 12.7529L2.74067 12.7653C1.64772 13.8969 1.04295 15.4125 1.05662 16.9857C1.07029 18.5589 1.70131 20.0637 2.81376 21.1762C3.9262 22.2886 5.43108 22.9196 7.00426 22.9333C8.57744 22.947 10.0931 22.3422 11.2247 21.2493L11.2371 21.2371L12.9471 19.5271C13.3376 19.1366 13.3376 18.5034 12.9471 18.1129C12.5565 17.7223 11.9234 17.7223 11.5328 18.1129L9.82932 19.8164C9.07555 20.5414 8.06768 20.9425 7.02164 20.9334C5.97285 20.9243 4.9696 20.5036 4.22797 19.762C3.48634 19.0203 3.06566 18.0171 3.05655 16.9683C3.04746 15.9222 3.44851 14.9144 4.17355 14.1606L7.16719 11.167C7.5727 10.7613 8.06071 10.4476 8.59811 10.2471C9.13552 10.0467 9.70976 9.96412 10.2819 10.0051C10.854 10.0461 11.4106 10.2096 11.9139 10.4846C12.4173 10.7596 12.8556 11.1397 13.1992 11.599C13.53 12.0412 14.1567 12.1316 14.5989 11.8007C15.0412 11.4699 15.1315 10.8433 14.8007 10.401C14.2854 9.71205 13.6279 9.14198 12.8729 8.72948C12.1178 8.31697 11.2829 8.07166 10.4247 8.0102Z",fill:"currentColor"})]}));b8.displayName="LinkIcon";const C3=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 6C7 5.44772 7.44772 5 8 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H8C7.44772 7 7 6.55228 7 6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12C7 11.4477 7.44772 11 8 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H8C7.44772 13 7 12.5523 7 12Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 18C7 17.4477 7.44772 17 8 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H8C7.44772 19 7 18.5523 7 18Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H3.01C3.56228 5 4.01 5.44772 4.01 6C4.01 6.55228 3.56228 7 3.01 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H3.01C3.56228 11 4.01 11.4477 4.01 12C4.01 12.5523 3.56228 13 3.01 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H3.01C3.56228 17 4.01 17.4477 4.01 18C4.01 18.5523 3.56228 19 3.01 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));C3.displayName="ListIcon";const C8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 6C9 5.44772 9.44772 5 10 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H10C9.44772 7 9 6.55228 9 6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 12C9 11.4477 9.44772 11 10 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H10C9.44772 13 9 12.5523 9 12Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 18C9 17.4477 9.44772 17 10 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H10C9.44772 19 9 18.5523 9 18Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 6C3 5.44772 3.44772 5 4 5H5C5.55228 5 6 5.44772 6 6V10C6 10.5523 5.55228 11 5 11C4.44772 11 4 10.5523 4 10V7C3.44772 7 3 6.55228 3 6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 10C3 9.44772 3.44772 9 4 9H6C6.55228 9 7 9.44772 7 10C7 10.5523 6.55228 11 6 11H4C3.44772 11 3 10.5523 3 10Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.82219 13.0431C6.54543 13.4047 6.99997 14.1319 6.99997 15C6.99997 15.5763 6.71806 16.0426 6.48747 16.35C6.31395 16.5814 6.1052 16.8044 5.91309 17H5.99997C6.55226 17 6.99997 17.4477 6.99997 18C6.99997 18.5523 6.55226 19 5.99997 19H3.99997C3.44769 19 2.99997 18.5523 2.99997 18C2.99997 17.4237 3.28189 16.9575 3.51247 16.65C3.74323 16.3424 4.03626 16.0494 4.26965 15.8161C4.27745 15.8083 4.2852 15.8006 4.29287 15.7929C4.55594 15.5298 4.75095 15.3321 4.88748 15.15C4.96287 15.0495 4.99021 14.9922 4.99911 14.9714C4.99535 14.9112 4.9803 14.882 4.9739 14.8715C4.96613 14.8588 4.95382 14.845 4.92776 14.8319C4.87723 14.8067 4.71156 14.7623 4.44719 14.8944C3.95321 15.1414 3.35254 14.9412 3.10555 14.4472C2.85856 13.9533 3.05878 13.3526 3.55276 13.1056C4.28839 12.7378 5.12272 12.6934 5.82219 13.0431Z",fill:"currentColor"})]}));C8.displayName="ListOrderedIcon";const rj=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C12.5523 2 13 2.44772 13 3V6C13 6.55228 12.5523 7 12 7C11.4477 7 11 6.55228 11 6V3C11 2.44772 11.4477 2 12 2Z",fill:"currentColor",opacity:"0.2"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.9497 4.22183C17.3402 4.61236 17.3402 5.24552 16.9497 5.63604L14.8284 7.75736C14.4379 8.14789 13.8047 8.14789 13.4142 7.75736C13.0237 7.36684 13.0237 6.73367 13.4142 6.34315L15.5355 4.22183C15.926 3.8313 16.5592 3.8313 16.9497 4.22183Z",fill:"currentColor",opacity:"0.3"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22 12C22 12.5523 21.5523 13 21 13H18C17.4477 13 17 12.5523 17 12C17 11.4477 17.4477 11 18 11H21C21.5523 11 22 11.4477 22 12Z",fill:"currentColor",opacity:"0.4"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.7782 16.9497C20.1687 16.5592 20.1687 15.926 19.7782 15.5355L17.6569 13.4142C17.2663 13.0237 16.6332 13.0237 16.2426 13.4142C15.8521 13.8047 15.8521 14.4379 16.2426 14.8284L18.364 16.9497C18.7545 17.3402 19.3876 17.3402 19.7782 16.9497Z",fill:"currentColor",opacity:"0.5"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 17C12.5523 17 13 17.4477 13 18V21C13 21.5523 12.5523 22 12 22C11.4477 22 11 21.5523 11 21V18C11 17.4477 11.4477 17 12 17Z",fill:"currentColor",opacity:"0.6"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.05025 19.7782C7.44078 20.1687 7.44078 20.8019 7.05025 21.1924C6.65973 21.5829 6.02656 21.5829 5.63604 21.1924L3.51472 19.0711C3.12419 18.6805 3.12419 18.0474 3.51472 17.6569C3.90524 17.2663 4.53841 17.2663 4.92893 17.6569L7.05025 19.7782Z",fill:"currentColor",opacity:"0.7"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12C7 12.5523 6.55228 13 6 13H3C2.44772 13 2 12.5523 2 12C2 11.4477 2.44772 11 3 11H6C6.55228 11 7 11.4477 7 12Z",fill:"currentColor",opacity:"0.8"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.22183 7.05025C4.61236 7.44078 5.24552 7.44078 5.63604 7.05025L7.75736 4.92893C8.14789 4.53841 8.14789 3.90524 7.75736 3.51472C7.36684 3.12419 6.73367 3.12419 6.34315 3.51472L4.22183 5.63604C3.8313 6.02656 3.8313 6.65973 4.22183 7.05025Z",fill:"currentColor",opacity:"0.9"})]}));rj.displayName="LoaderIcon";const w8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M7 10L12 15L17 10H7Z",fill:"currentColor"})}));w8.displayName="MenuDownIcon";const x8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M7 15L12 10L17 15H7Z",fill:"currentColor"})}));x8.displayName="MenuUpIcon";const S8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"16",height:"16",className:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.66669 2.66634C2.2985 2.66634 2.00002 2.96482 2.00002 3.33301V9.99967C2.00002 10.3679 2.2985 10.6663 2.66669 10.6663H13.3334C13.7015 10.6663 14 10.3679 14 9.99967V3.33301C14 2.96482 13.7015 2.66634 13.3334 2.66634H2.66669ZM0.666687 3.33301C0.666687 2.22844 1.56212 1.33301 2.66669 1.33301H13.3334C14.4379 1.33301 15.3334 2.22844 15.3334 3.33301V9.99967C15.3334 11.1042 14.4379 11.9997 13.3334 11.9997H2.66669C1.56212 11.9997 0.666687 11.1042 0.666687 9.99967V3.33301Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.66669 13.9997C4.66669 13.6315 4.96516 13.333 5.33335 13.333H10.6667C11.0349 13.333 11.3334 13.6315 11.3334 13.9997C11.3334 14.3679 11.0349 14.6663 10.6667 14.6663H5.33335C4.96516 14.6663 4.66669 14.3679 4.66669 13.9997Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.99998 10.667C8.36817 10.667 8.66665 10.9655 8.66665 11.3337V14.0003C8.66665 14.3685 8.36817 14.667 7.99998 14.667C7.63179 14.667 7.33331 14.3685 7.33331 14.0003V11.3337C7.33331 10.9655 7.63179 10.667 7.99998 10.667Z",fill:"currentColor"})]}));S8.displayName="MonitorIcon";const ij=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C10.0222 2 8.08879 2.58649 6.4443 3.6853C4.79981 4.78412 3.51809 6.3459 2.76121 8.17317C2.00433 10.0004 1.8063 12.0111 2.19215 13.9509C2.578 15.8907 3.53041 17.6725 4.92894 19.0711C6.32746 20.4696 8.10929 21.422 10.0491 21.8079C11.9889 22.1937 13.9996 21.9957 15.8268 21.2388C17.6541 20.4819 19.2159 19.2002 20.3147 17.5557C21.4135 15.9112 22 13.9778 22 12C22 11.5955 21.7564 11.2309 21.3827 11.0761C21.009 10.9213 20.5789 11.0069 20.2929 11.2929C19.287 12.2988 17.9226 12.864 16.5 12.864C15.0774 12.864 13.713 12.2988 12.7071 11.2929C11.7012 10.287 11.136 8.92261 11.136 7.5C11.136 6.07739 11.7012 4.71304 12.7071 3.70711C12.9931 3.42111 13.0787 2.99099 12.9239 2.61732C12.7691 2.24364 12.4045 2 12 2ZM7.55544 5.34824C8.27036 4.87055 9.05353 4.51389 9.87357 4.28778C9.39271 5.27979 9.13604 6.37666 9.13604 7.5C9.13604 9.45304 9.91189 11.3261 11.2929 12.7071C12.6739 14.0881 14.547 14.864 16.5 14.864C17.6233 14.864 18.7202 14.6073 19.7122 14.1264C19.4861 14.9465 19.1295 15.7296 18.6518 16.4446C17.7727 17.7602 16.5233 18.7855 15.0615 19.391C13.5997 19.9965 11.9911 20.155 10.4393 19.8463C8.88743 19.5376 7.46197 18.7757 6.34315 17.6569C5.22433 16.538 4.4624 15.1126 4.15372 13.5607C3.84504 12.0089 4.00347 10.4003 4.60897 8.93853C5.21447 7.47672 6.23985 6.22729 7.55544 5.34824Z",fill:"currentColor"}),S.jsx("path",{d:"M19 2C19.5523 2 20 2.44772 20 3V4H21C21.5523 4 22 4.44772 22 5C22 5.55228 21.5523 6 21 6H20V7C20 7.55228 19.5523 8 19 8C18.4477 8 18 7.55228 18 7V6H17C16.4477 6 16 5.55228 16 5C16 4.44772 16.4477 4 17 4H18V3C18 2.44772 18.4477 2 19 2Z",fill:"currentColor"})]}));ij.displayName="MoonStarIcon";const T8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M13 14L11 14L11 17L8 17L8 19L11 19L11 22L13 22L13 19L16 19L16 17L13 17L13 14Z",fill:"currentColor"}),S.jsx("path",{d:"M2.58579 10.4142C2.21071 10.0391 2 9.53043 2 9L2 3L4 3L4 9L20 9L20 3L22 3L22 9C22 9.53043 21.7893 10.0391 21.4142 10.4142C21.0391 10.7893 20.5304 11 20 11L4 11C3.46957 11 2.96086 10.7893 2.58579 10.4142Z",fill:"currentColor"})]}));T8.displayName="PaginatedPlusAfterIcon";const k8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M11 10H13V7H16V5H13V2H11V5H8V7H11V10Z",fill:"currentColor"}),S.jsx("path",{d:"M21.4142 13.5858C21.7893 13.9609 22 14.4696 22 15V21H20V15H4V21H2V15C2 14.4696 2.21071 13.9609 2.58579 13.5858C2.96086 13.2107 3.46957 13 4 13H20C20.5304 13 21.0391 13.2107 21.4142 13.5858Z",fill:"currentColor"})]}));k8.displayName="PaginatedPlusBeforeIcon";const E8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,...e,children:S.jsx("path",{d:"M12.6667 2C13.0203 2 13.3594 2.14048 13.6095 2.39052C13.8595 2.64057 14 2.97971 14 3.33333V12.6667C14 13.4067 13.4 14 12.6667 14H3.33333C2.97971 14 2.64057 13.8595 2.39052 13.6095C2.14048 13.3594 2 13.0203 2 12.6667V3.33333C2 2.97971 2.14048 2.64057 2.39052 2.39052C2.64057 2.14048 2.97971 2 3.33333 2H12.6667ZM11.1333 6.23333C11.28 6.09333 11.28 5.86 11.1333 5.72L10.28 4.86667C10.14 4.72 9.90667 4.72 9.76667 4.86667L9.1 5.53333L10.4667 6.9L11.1333 6.23333ZM4.66667 9.96V11.3333H6.04L10.08 7.29333L8.70667 5.92L4.66667 9.96Z",fill:"currentColor"})}));E8.displayName="PencilBoxIcon";const M8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.7071 2.29289C15.3166 1.90237 14.6834 1.90237 14.2929 2.29289C13.9024 2.68342 13.9024 3.31658 14.2929 3.70711L17.5858 7H9.5C7.77609 7 6.12279 7.68482 4.90381 8.90381C3.68482 10.1228 3 11.7761 3 13.5C3 14.3536 3.16813 15.1988 3.49478 15.9874C3.82144 16.7761 4.30023 17.4926 4.90381 18.0962C6.12279 19.3152 7.77609 20 9.5 20H13C13.5523 20 14 19.5523 14 19C14 18.4477 13.5523 18 13 18H9.5C8.30653 18 7.16193 17.5259 6.31802 16.682C5.90016 16.2641 5.56869 15.768 5.34254 15.2221C5.1164 14.6761 5 14.0909 5 13.5C5 12.3065 5.47411 11.1619 6.31802 10.318C7.16193 9.47411 8.30653 9 9.5 9H17.5858L14.2929 12.2929C13.9024 12.6834 13.9024 13.3166 14.2929 13.7071C14.6834 14.0976 15.3166 14.0976 15.7071 13.7071L20.7071 8.70711C21.0976 8.31658 21.0976 7.68342 20.7071 7.29289L15.7071 2.29289Z",fill:"currentColor"})}));M8.displayName="Redo2Icon";const oj=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.8159 21H11.1841C10.9072 21 10.6478 20.8616 10.4969 20.6343C10.346 20.407 10.3244 20.1188 10.4394 19.8708L10.8045 19.0156C11.0696 18.4636 11.0186 17.8184 10.6683 17.3164C10.3181 16.8145 9.72183 16.5364 9.09901 16.5734C8.476 16.6104 7.91775 16.9571 7.63604 17.4938L7.36396 18.0062C7.24896 18.2542 6.98962 18.4221 6.70219 18.4518C6.41477 18.4815 6.12535 18.3695 5.94721 18.1514L4.84869 16.8486C4.67054 16.6305 4.62917 16.3367 4.73916 16.0797C4.84915 15.8227 5.09135 15.6422 5.36827 15.6062L6.24173 15.4938C6.86455 15.4071 7.40265 14.9929 7.68436 14.4062C7.96608 13.8196 7.94604 13.1304 7.63604 12.5562C7.32604 11.9821 6.76392 11.6105 6.14099 11.5734C5.518 11.5364 4.91871 11.8428 4.63604 12.3438L4.30396 12.9062C4.18896 13.1542 3.92962 13.3221 3.64219 13.3518C3.35477 13.3815 3.06535 13.2695 2.88721 13.0514L1.94869 11.8486C1.77054 11.6305 1.72917 11.3367 1.83916 11.0797C1.94915 10.8227 2.19135 10.6422 2.46827 10.6062L3.34173 10.4938C3.96455 10.4071 4.50265 9.99294 4.78436 9.40625C5.06608 8.81956 5.04604 8.13044 4.73604 7.55625C4.42604 6.98206 3.86392 6.61044 3.24099 6.57344C2.618 6.53644 2.01871 6.84279 1.73604 7.34375L1.46396 7.85625C1.34896 8.10425 1.08962 8.27213 0.802186 8.30181C0.514754 8.33148 0.225332 8.21948 0.0471854 8.00135L-0.85134 6.69865C-1.02949 6.48052 -1.07086 6.18669 -1.03916 5.92972C-1.00747 5.67274 -0.826704 5.49213 -0.549206 5.45622L0.324236 5.34375C0.947054 5.257 1.48516 4.84283 1.76687 4.25614C2.04858 3.66945 2.02854 2.98033 1.71854 2.40614C1.40854 1.83195 0.846424 1.46033 0.223493 1.42333C-0.399496 1.38633 -0.998788 1.69268 -1.28146 2.19364L-1.5533 2.70614C-1.6683 2.95414 -1.92764 3.122 -2.21507 3.15168C-2.5025 3.18135 -2.79192 3.06935 -2.97006 2.85122L-3.86858 1.54849C-4.04673 1.33036 -4.0881 1.03653 -4.0564 0.779558C-4.02471 0.522582 -3.84931 0.341969 -3.57182 0.305993L-2.69838 0.193524C-2.07556 0.106778 -1.53746 -0.307387 -1.25574 -0.894082C-0.974032 -1.48078 -0.994072 -2.1699 -1.30407 -2.74408C-1.61407 -3.31827 -2.17619 -3.68989 -2.79912 -3.72689C-3.42211 -3.76389 -4.0214 -3.45754 -4.30407 -2.95658L-4.57595 -2.44408C-4.69095 -2.19608 -4.95029 -2.0282 -5.23772 -1.99852C-5.52515 -1.96885 -5.81457 -2.08085 -5.99272 -2.29898L-6.89124 -3.60171C-7.06939 -3.81984 -7.11076 -4.11366 -7.07906 -4.37064C-7.04737 -4.62762 -6.87197 -4.80823 -6.59448 -4.84421L-5.72104 -4.95668C-5.09822 -5.04343 -4.56012 -5.4576 -4.2784 -6.04429C-3.99669 -6.63098 -4.01673 -7.3201 -4.32673 -7.89429C-4.63673 -8.46848 -5.19885 -8.8401 -5.82178 -8.8771C-6.44477 -8.9141 -7.04406 -8.60775 -7.32673 -8.10679L-7.59861 -7.59429C-7.71361 -7.34629 -7.97295 -7.17841 -8.26038 -7.14873C-8.54781 -7.11906 -8.83723 -7.23106 -9.01538 -7.44919L-9.9139 -8.75192C-10.091 -8.97005 -10.1324 -9.26388 -10.1007 -9.52085C-10.069 -9.77783 -9.89363 -9.95844 -9.61614 -9.99442L-8.7427 -10.1069C-8.11988 -10.1936 -7.58178 -10.6078 -7.30006 -11.1945C-7.01835 -11.7812 -7.03839 -12.4703 -7.34839 -13.0445C-7.65839 -13.6187 -8.22051 -13.9903 -8.84344 -14.0273C-9.46643 -14.0643 -10.0657 -13.758 -10.3484 -13.2571L-10.6203 -12.7446C-10.7353 -12.4966 -10.9946 -12.3287 -11.282 -12.299C-11.5695 -12.2693 -11.8589 -12.3813 -12.037 -12.5995L-12.9356 -13.9022C-13.1137 -14.1203 -13.1551 -14.4142 -13.1234 -14.6711C-13.0917 -14.9281 -12.9163 -15.1087 -12.6388 -15.1447L-11.7654 -15.2572C-11.1425 -15.3439 -10.6044 -15.7581 -10.3227 -16.3448C-10.041 -16.9315 -10.061 -17.6206 -10.371 -18.1948C-10.681 -18.769 -11.2432 -19.1406 -11.8661 -19.1776C-12.4891 -19.2146 -13.0884 -18.9083 -13.371 -18.4073L-13.6429 -17.8948C-13.7579 -17.6468 -14.0173 -17.4789 -14.3047 -17.4492C-14.5921 -17.4195 -14.8815 -17.5315 -15.0597 -17.7497L-15.9582 -19.0524C-16.1363 -19.2705 -16.1777 -19.5644 -16.146 -19.8213C-16.1143 -20.0783 -15.9389 -20.2589 -15.6614 -20.2949L-14.788 -20.4074C-14.1651 -20.4941 -13.627 -20.9083 -13.3453 -21.495C-13.0636 -22.0817 -13.0836 -22.7708 -13.3936 -23.345C-13.7036 -23.9192 -14.2657 -24.2908 -14.8887 -24.3278C-15.5117 -24.3648 -16.111 -24.0585 -16.3936 -23.5575L-16.6655 -23.045C-16.7805 -22.797 -17.0398 -22.6291 -17.3273 -22.5994C-17.6147 -22.5697 -17.9041 -22.6817 -18.0823 -22.8999L-18.9808 -24.2026C-19.1589 -24.4207 -19.2003 -24.7145 -19.1686 -24.9715C-19.1369 -25.2285 -18.9615 -25.4091 -18.684 -25.4451L-17.8106 -25.5576C-17.1877 -25.6443 -16.6496 -26.0585 -16.3679 -26.6452C-16.0862 -27.2319 -16.1062 -27.921 -16.4162 -28.4952C-16.7262 -29.0694 -17.2883 -29.441 -17.9113 -29.478C-18.5343 -29.515 -19.1336 -29.2087 -19.4162 -28.7077L-19.6881 -28.1952C-19.8031 -27.9472 -20.0624 -27.7793 -20.3499 -27.7496C-20.6373 -27.7199 -20.9267 -27.8319 -21.1049 -28.0501L-22.0034 -29.3528C-22.1815 -29.5709 -22.2229 -29.8647 -22.1912 -30.1217C-22.1595 -30.3787 -21.9841 -30.5593 -21.7066 -30.5953L-20.8332 -30.7078Z",fill:"currentColor"}),S.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor"})]}));oj.displayName="SettingsIcon";const A8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M9 7V17H15V15H11V7H9Z",fill:"currentColor"})}));A8.displayName="SizeLIcon";const N8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M9 7C7.9 7 7 7.9 7 9V17H9V9H11V16H13V9H15V17H17V9C17 7.9 16.11 7 15 7H9Z",fill:"currentColor"})}));N8.displayName="SizeMIcon";const R8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M11 7C9.9 7 9 7.9 9 9V11C9 12.11 9.9 13 11 13H13V15H9V17H13C14.11 17 15 16.11 15 15V13C15 11.9 14.11 11 13 11H11V9H15V7H11Z",fill:"currentColor"})}));R8.displayName="SizeSIcon";const O8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"16",height:"16",className:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.66669 2.00033C4.2985 2.00033 4.00002 2.2988 4.00002 2.66699V13.3337C4.00002 13.7018 4.2985 14.0003 4.66669 14.0003H11.3334C11.7015 14.0003 12 13.7018 12 13.3337V2.66699C12 2.2988 11.7015 2.00033 11.3334 2.00033H4.66669ZM2.66669 2.66699C2.66669 1.56242 3.56212 0.666992 4.66669 0.666992H11.3334C12.4379 0.666992 13.3334 1.56242 13.3334 2.66699V13.3337C13.3334 14.4382 12.4379 15.3337 11.3334 15.3337H4.66669C3.56212 15.3337 2.66669 14.4382 2.66669 13.3337V2.66699Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.33331 11.9997C7.33331 11.6315 7.63179 11.333 7.99998 11.333H8.00665C8.37484 11.333 8.67331 11.6315 8.67331 11.9997C8.67331 12.3679 8.37484 12.6663 8.00665 12.6663H7.99998C7.63179 12.6663 7.33331 12.3679 7.33331 11.9997Z",fill:"currentColor"})]}));O8.displayName="SmartphoneIcon";const w3=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M9.00039 3H16.0001C16.5524 3 17.0001 3.44772 17.0001 4C17.0001 4.55229 16.5524 5 16.0001 5H9.00011C8.68006 4.99983 8.36412 5.07648 8.07983 5.22349C7.79555 5.37051 7.55069 5.5836 7.36585 5.84487C7.181 6.10614 7.06155 6.40796 7.01754 6.72497C6.97352 7.04198 7.00623 7.36492 7.11292 7.66667C7.29701 8.18737 7.02414 8.75872 6.50344 8.94281C5.98274 9.1269 5.4114 8.85403 5.2273 8.33333C5.01393 7.72984 4.94851 7.08396 5.03654 6.44994C5.12456 5.81592 5.36346 5.21229 5.73316 4.68974C6.10285 4.1672 6.59256 3.74101 7.16113 3.44698C7.72955 3.15303 8.36047 2.99975 9.00039 3Z",fill:"currentColor"}),S.jsx("path",{d:"M18 13H20C20.5523 13 21 12.5523 21 12C21 11.4477 20.5523 11 20 11H4C3.44772 11 3 11.4477 3 12C3 12.5523 3.44772 13 4 13H14C14.7956 13 15.5587 13.3161 16.1213 13.8787C16.6839 14.4413 17 15.2044 17 16C17 16.7956 16.6839 17.5587 16.1213 18.1213C15.5587 18.6839 14.7956 19 14 19H6C5.44772 19 5 19.4477 5 20C5 20.5523 5.44772 21 6 21H14C15.3261 21 16.5979 20.4732 17.5355 19.5355C18.4732 18.5979 19 17.3261 19 16C19 14.9119 18.6453 13.8604 18 13Z",fill:"currentColor"})]}));w3.displayName="StrikeIcon";const x3=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.29289 7.29289C3.68342 6.90237 4.31658 6.90237 4.70711 7.29289L12.7071 15.2929C13.0976 15.6834 13.0976 16.3166 12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L3.29289 8.70711C2.90237 8.31658 2.90237 7.68342 3.29289 7.29289Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 7.29289C13.0976 7.68342 13.0976 8.31658 12.7071 8.70711L4.70711 16.7071C4.31658 17.0976 3.68342 17.0976 3.29289 16.7071C2.90237 16.3166 2.90237 15.6834 3.29289 15.2929L11.2929 7.29289C11.6834 6.90237 12.3166 6.90237 12.7071 7.29289Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.4079 14.3995C18.0284 14.0487 18.7506 13.9217 19.4536 14.0397C20.1566 14.1578 20.7977 14.5138 21.2696 15.0481L21.2779 15.0574L21.2778 15.0575C21.7439 15.5988 22 16.2903 22 17C22 18.0823 21.3962 18.8401 20.7744 19.3404C20.194 19.8073 19.4858 20.141 18.9828 20.378C18.9638 20.387 18.9451 20.3958 18.9266 20.4045C18.4473 20.6306 18.2804 20.7817 18.1922 20.918C18.1773 20.9412 18.1619 20.9681 18.1467 21H21C21.5523 21 22 21.4477 22 22C22 22.5523 21.5523 23 21 23H17C16.4477 23 16 22.5523 16 22C16 21.1708 16.1176 20.4431 16.5128 19.832C16.9096 19.2184 17.4928 18.8695 18.0734 18.5956C18.6279 18.334 19.138 18.0901 19.5207 17.7821C19.8838 17.49 20 17.2477 20 17C20 16.7718 19.9176 16.5452 19.7663 16.3672C19.5983 16.1792 19.3712 16.0539 19.1224 16.0121C18.8722 15.9701 18.6152 16.015 18.3942 16.1394C18.1794 16.2628 18.0205 16.4549 17.9422 16.675C17.7572 17.1954 17.1854 17.4673 16.665 17.2822C16.1446 17.0972 15.8728 16.5254 16.0578 16.005C16.2993 15.3259 16.7797 14.7584 17.4039 14.4018L17.4079 14.3995L17.4079 14.3995Z",fill:"currentColor"})]}));x3.displayName="SubscriptIcon";const sj=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M12 1C12.5523 1 13 1.44772 13 2V4C13 4.55228 12.5523 5 12 5C11.4477 5 11 4.55228 11 4V2C11 1.44772 11.4477 1 12 1Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12C7 9.23858 9.23858 7 12 7C14.7614 7 17 9.23858 17 12C17 14.7614 14.7614 17 12 17C9.23858 17 7 14.7614 7 12ZM12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9Z",fill:"currentColor"}),S.jsx("path",{d:"M13 20C13 19.4477 12.5523 19 12 19C11.4477 19 11 19.4477 11 20V22C11 22.5523 11.4477 23 12 23C12.5523 23 13 22.5523 13 22V20Z",fill:"currentColor"}),S.jsx("path",{d:"M4.22282 4.22289C4.61335 3.83236 5.24651 3.83236 5.63704 4.22289L7.04704 5.63289C7.43756 6.02341 7.43756 6.65658 7.04704 7.0471C6.65651 7.43762 6.02335 7.43762 5.63283 7.0471L4.22282 5.6371C3.8323 5.24658 3.8323 4.61341 4.22282 4.22289Z",fill:"currentColor"}),S.jsx("path",{d:"M18.367 16.9529C17.9765 16.5623 17.3433 16.5623 16.9528 16.9529C16.5623 17.3434 16.5623 17.9766 16.9528 18.3671L18.3628 19.7771C18.7533 20.1676 19.3865 20.1676 19.777 19.7771C20.1675 19.3866 20.1675 18.7534 19.777 18.3629L18.367 16.9529Z",fill:"currentColor"}),S.jsx("path",{d:"M1 12C1 11.4477 1.44772 11 2 11H4C4.55228 11 5 11.4477 5 12C5 12.5523 4.55228 13 4 13H2C1.44772 13 1 12.5523 1 12Z",fill:"currentColor"}),S.jsx("path",{d:"M20 11C19.4477 11 19 11.4477 19 12C19 12.5523 19.4477 13 20 13H22C22.5523 13 23 12.5523 23 12C23 11.4477 22.5523 11 22 11H20Z",fill:"currentColor"}),S.jsx("path",{d:"M7.04704 16.9529C7.43756 17.3434 7.43756 17.9766 7.04704 18.3671L5.63704 19.7771C5.24651 20.1676 4.61335 20.1676 4.22282 19.7771C3.8323 19.3866 3.8323 18.7534 4.22283 18.3629L5.63283 16.9529C6.02335 16.5623 6.65651 16.5623 7.04704 16.9529Z",fill:"currentColor"}),S.jsx("path",{d:"M19.777 5.6371C20.1675 5.24657 20.1675 4.61341 19.777 4.22289C19.3865 3.83236 18.7533 3.83236 18.3628 4.22289L16.9528 5.63289C16.5623 6.02341 16.5623 6.65658 16.9528 7.0471C17.3433 7.43762 17.9765 7.43762 18.367 7.0471L19.777 5.6371Z",fill:"currentColor"})]}));sj.displayName="SunIcon";const S3=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 7.29289C13.0976 7.68342 13.0976 8.31658 12.7071 8.70711L4.70711 16.7071C4.31658 17.0976 3.68342 17.0976 3.29289 16.7071C2.90237 16.3166 2.90237 15.6834 3.29289 15.2929L11.2929 7.29289C11.6834 6.90237 12.3166 6.90237 12.7071 7.29289Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.29289 7.29289C3.68342 6.90237 4.31658 6.90237 4.70711 7.29289L12.7071 15.2929C13.0976 15.6834 13.0976 16.3166 12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L3.29289 8.70711C2.90237 8.31658 2.90237 7.68342 3.29289 7.29289Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.405 1.40657C18.0246 1.05456 18.7463 0.92634 19.4492 1.04344C20.1521 1.16054 20.7933 1.51583 21.2652 2.0497L21.2697 2.05469L21.2696 2.05471C21.7431 2.5975 22 3.28922 22 4.00203C22 5.08579 21.3952 5.84326 20.7727 6.34289C20.1966 6.80531 19.4941 7.13675 18.9941 7.37261C18.9714 7.38332 18.9491 7.39383 18.9273 7.40415C18.4487 7.63034 18.2814 7.78152 18.1927 7.91844C18.1778 7.94155 18.1625 7.96834 18.1473 8.00003H21C21.5523 8.00003 22 8.44774 22 9.00003C22 9.55231 21.5523 10 21 10H17C16.4477 10 16 9.55231 16 9.00003C16 8.17007 16.1183 7.44255 16.5138 6.83161C16.9107 6.21854 17.4934 5.86971 18.0728 5.59591C18.6281 5.33347 19.1376 5.09075 19.5208 4.78316C19.8838 4.49179 20 4.25026 20 4.00203C20 3.77192 19.9178 3.54865 19.7646 3.37182C19.5968 3.18324 19.3696 3.05774 19.1205 3.01625C18.8705 2.97459 18.6137 3.02017 18.3933 3.14533C18.1762 3.26898 18.0191 3.45826 17.9406 3.67557C17.7531 4.19504 17.18 4.46414 16.6605 4.27662C16.141 4.0891 15.8719 3.51596 16.0594 2.99649C16.303 2.3219 16.7817 1.76125 17.4045 1.40689L17.405 1.40657Z",fill:"currentColor"})]}));S3.displayName="SuperscriptIcon";const D8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,...e,children:S.jsx("path",{d:"M11 2C11.5304 2 12.0391 2.21071 12.4142 2.58579C12.7893 2.96086 13 3.46957 13 4V20C13 20.5304 12.7893 21.0391 12.4142 21.4142C12.0391 21.7893 11.5304 22 11 22H2V2H11ZM4 10V14H11V10H4ZM4 16V20H11V16H4ZM4 4V8H11V4H4ZM15 11H18V8H20V11H23V13H20V16H18V13H15V11Z",fill:"currentColor"})}));D8.displayName="TableAddColumnAfter";const L8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,...e,children:S.jsx("path",{d:"M13 2C12.4696 2 11.9609 2.21071 11.5858 2.58579C11.2107 2.96086 11 3.46957 11 4V20C11 20.5304 11.2107 21.0391 11.5858 21.4142C11.9609 21.7893 12.4696 22 13 22H22V2H13ZM20 10V14H13V10H20ZM20 16V20H13V16H20ZM20 4V8H13V4H20ZM9 11H6V8H4V11H1V13H4V16H6V13H9V11Z",fill:"currentColor"})}));L8.displayName="TableAddColumnBefore";const _8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M22 10C22 10.5304 21.7893 11.0391 21.4142 11.4142C21.0391 11.7893 20.5304 12 20 12H4C3.46957 12 2.96086 11.7893 2.58579 11.4142C2.21071 11.0391 2 10.5304 2 10V3H4V5H8V3H10V5H14V3H16V5H20V3H22V10ZM4 10H8V7H4V10ZM10 10H14V7H10V10ZM20 10V7H16V10H20ZM11 14H13V17H16V19H13V22H11V19H8V17H11V14Z",fill:"currentColor"})}));_8.displayName="TableAddRowAfter";const H8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,...e,children:S.jsx("path",{d:"M22 14C22 13.4696 21.7893 12.9609 21.4142 12.5858C21.0391 12.2107 20.5304 12 20 12H4C3.46957 12 2.96086 12.2107 2.58579 12.5858C2.21071 12.9609 2 13.4696 2 14V21H4V19H8V21H10V19H14V21H16V19H20V21H22V14ZM4 14H8V17H4V14ZM10 14H14V17H10V14ZM20 14V17H16V14H20ZM11 10H13V7H16V5H13V2H11V5H8V7H11V10Z",fill:"currentColor"})}));H8.displayName="TableAddRowBefore";const I8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M4 2H11C11.5304 2 12.0391 2.21071 12.4142 2.58579C12.7893 2.96086 13 3.46957 13 4V20C13 20.5304 12.7893 21.0391 12.4142 21.4142C12.0391 21.7893 11.5304 22 11 22H4C3.46957 22 2.96086 21.7893 2.58579 21.4142C2.21071 21.0391 2 20.5304 2 20V4C2 3.46957 2.21071 2.96086 2.58579 2.58579C2.96086 2.21071 3.46957 2 4 2ZM4 10V14H11V10H4ZM4 16V20H11V16H4ZM4 4V8H11V4H4ZM17.59 12L15 9.41L16.41 8L19 10.59L21.59 8L23 9.41L20.41 12L23 14.59L21.59 16L19 13.41L16.41 16L15 14.59L17.59 12Z",fill:"currentColor"})}));I8.displayName="TableDeleteColumn";const z8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,...e,children:S.jsx("path",{d:"M9.41 13L12 15.59L14.59 13L16 14.41L13.41 17L16 19.59L14.59 21L12 18.41L9.41 21L8 19.59L10.59 17L8 14.41L9.41 13ZM22 9C22 9.53043 21.7893 10.0391 21.4142 10.4142C21.0391 10.7893 20.5304 11 20 11H4C3.46957 11 2.96086 10.7893 2.58579 10.4142C2.21071 10.0391 2 9.53043 2 9V6C2 5.46957 2.21071 4.96086 2.58579 4.58579C2.96086 4.21071 3.46957 4 4 4H20C20.5304 4 21.0391 4.21071 21.4142 4.58579C21.7893 4.96086 22 5.46957 22 6V9ZM4 9H8V6H4V9ZM10 9H14V6H10V9ZM16 9H20V6H16V9Z",fill:"currentColor"})}));z8.displayName="TableDeleteRow";const B8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M15.46 15.88L16.88 14.46L19 16.59L21.12 14.46L22.54 15.88L20.41 18L22.54 20.12L21.12 21.54L19 19.41L16.88 21.54L15.46 20.12L17.59 18L15.46 15.88ZM4 3H18C18.5304 3 19.0391 3.21071 19.4142 3.58579C19.7893 3.96086 20 4.46957 20 5V12.08C18.45 11.82 16.92 12.18 15.68 13H12V17H13.08C12.97 17.68 12.97 18.35 13.08 19H4C3.46957 19 2.96086 18.7893 2.58579 18.4142C2.21071 18.0391 2 17.5304 2 17V5C2 4.46957 2.21071 3.96086 2.58579 3.58579C2.96086 3.21071 3.46957 3 4 3ZM4 7V11H10V7H4ZM12 7V11H18V7H12ZM4 13V17H10V13H4Z",fill:"currentColor"})}));B8.displayName="TableDeleteTable";const T3=E.memo(({className:t,...e})=>S.jsx("svg",{width:"17",height:"16",className:t,viewBox:"0 0 17 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M13.8333 8.66683H9.16659V13.3335H13.1666C13.5348 13.3335 13.8333 13.035 13.8333 12.6668V8.66683ZM3.16659 12.6668C3.16659 13.035 3.46506 13.3335 3.83325 13.3335H7.83325V8.66683H3.16659V12.6668ZM13.8333 3.3335C13.8333 2.96531 13.5348 2.66683 13.1666 2.66683H9.16659V7.3335H13.8333V3.3335ZM3.16659 7.3335H7.83325V2.66683H3.83325C3.46506 2.66683 3.16659 2.96531 3.16659 3.3335V7.3335ZM15.1666 12.6668C15.1666 13.7714 14.2712 14.6668 13.1666 14.6668H3.83325C2.72868 14.6668 1.83325 13.7714 1.83325 12.6668V3.3335C1.83325 2.22893 2.72868 1.3335 3.83325 1.3335H13.1666C14.2712 1.3335 15.1666 2.22893 15.1666 3.3335V12.6668Z",fill:"currentColor"})}));T3.displayName="TableIcon";const j8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,...e,children:S.jsx("path",{d:"M5 10H3V4H11V6H5V10ZM19 18H13V20H21V14H19V18ZM5 18V14H3V20H11V18H5ZM21 4H13V6H19V10H21V4ZM8 13V15L11 12L8 9V11H3V13H8ZM16 11V9L13 12L16 15V13H21V11H16Z",fill:"currentColor"})}));j8.displayName="TableMergeCells";const V8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,...e,children:S.jsx("path",{d:"M19 14H21V20H3V14H5V18H19V14ZM3 4V10H5V6H19V10H21V4H3ZM11 11V13H8V15L5 12L8 9V11H11ZM16 11V9L19 12L16 15V13H13V11H16Z",fill:"currentColor"})}));V8.displayName="TableSplitCell";const U8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("rect",{x:"6",y:"7",width:"4",height:"3",fill:"currentColor"}),S.jsx("path",{d:"M19 4C20.1046 4 21 4.89543 21 6V18C21 19.0357 20.2128 19.887 19.2041 19.9893L19 20H5L4.7959 19.9893C3.78722 19.887 3 19.0357 3 18V6C3 4.89543 3.89543 4 5 4H19ZM5 18H11V13H5V18ZM13 18H19V13H13V18ZM5 11H11V6H5V11ZM13 11H19V6H13V11Z",fill:"currentColor"})]}));U8.displayName="TableToggleHeaderCell";const P8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,...e,children:[S.jsx("rect",{x:"6",y:"7",width:"4",height:"3",fill:"currentColor"}),S.jsx("rect",{x:"6",y:"14",width:"4",height:"3",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 4C20.1046 4 21 4.89543 21 6V18C21 19.0357 20.2128 19.887 19.2041 19.9893L19 20H5L4.7959 19.9893C3.78722 19.887 3 19.0357 3 18V6C3 4.89543 3.89543 4 5 4H19ZM5 18H11V13H5V18ZM13 13V18H19V13H13ZM13 11H19V6H13V11ZM5 11H11V6H5V11Z",fill:"currentColor"})]}));P8.displayName="TableToggleHeaderColumn";const F8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,...e,children:[S.jsx("rect",{x:"6",y:"7",width:"4",height:"3",fill:"currentColor"}),S.jsx("rect",{x:"14",y:"7",width:"4",height:"3",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 4C20.1046 4 21 4.89543 21 6V18C21 19.0357 20.2128 19.887 19.2041 19.9893L19 20H5L4.7959 19.9893C3.78722 19.887 3 19.0357 3 18V6C3 4.89543 3.89543 4 5 4H19ZM5 18H11V13H5V18ZM13 13V18H19V13H13ZM13 11H19V6H13V11ZM5 11H11V6H5V11Z",fill:"currentColor"})]}));F8.displayName="TableToggleHeaderRow";const $8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 5V4C7 3.17477 7.40255 2.43324 7.91789 1.91789C8.43324 1.40255 9.17477 1 10 1H14C14.8252 1 15.5668 1.40255 16.0821 1.91789C16.5975 2.43324 17 3.17477 17 4V5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H20V20C20 20.8252 19.5975 21.5668 19.0821 22.0821C18.5668 22.5975 17.8252 23 17 23H7C6.17477 23 5.43324 22.5975 4.91789 22.0821C4.40255 21.5668 4 20.8252 4 20V7H3C2.44772 7 2 6.55228 2 6C2 5.44772 2.44772 5 3 5H7ZM9 4C9 3.82523 9.09745 3.56676 9.33211 3.33211C9.56676 3.09745 9.82523 3 10 3H14C14.1748 3 14.4332 3.09745 14.6679 3.33211C14.9025 3.56676 15 3.82523 15 4V5H9V4ZM6 7V20C6 20.1748 6.09745 20.4332 6.33211 20.6679C6.56676 20.9025 6.82523 21 7 21H17C17.1748 21 17.4332 20.9025 17.6679 20.6679C17.9025 20.4332 18 20.1748 18 20V7H6Z",fill:"currentColor"})}));$8.displayName="TrashIcon";const k3=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4V10C5 11.8565 5.7375 13.637 7.05025 14.9497C8.36301 16.2625 10.1435 17 12 17C13.8565 17 15.637 16.2625 16.9497 14.9497C18.2625 13.637 19 11.8565 19 10V4C19 3.44772 18.5523 3 18 3C17.4477 3 17 3.44772 17 4V10C17 11.3261 16.4732 12.5979 15.5355 13.5355C14.5979 14.4732 13.3261 15 12 15C10.6739 15 9.40215 14.4732 8.46447 13.5355C7.52678 12.5979 7 11.3261 7 10V4ZM4 19C3.44772 19 3 19.4477 3 20C3 20.5523 3.44772 21 4 21H20C20.5523 21 21 20.5523 21 20C21 19.4477 20.5523 19 20 19H4Z",fill:"currentColor"})}));k3.displayName="UnderlineIcon";const q8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.70711 3.70711C10.0976 3.31658 10.0976 2.68342 9.70711 2.29289C9.31658 1.90237 8.68342 1.90237 8.29289 2.29289L3.29289 7.29289C2.90237 7.68342 2.90237 8.31658 3.29289 8.70711L8.29289 13.7071C8.68342 14.0976 9.31658 14.0976 9.70711 13.7071C10.0976 13.3166 10.0976 12.6834 9.70711 12.2929L6.41421 9H14.5C15.0909 9 15.6761 9.1164 16.2221 9.34254C16.768 9.56869 17.2641 9.90016 17.682 10.318C18.0998 10.7359 18.4313 11.232 18.6575 11.7779C18.8836 12.3239 19 12.9091 19 13.5C19 14.0909 18.8836 14.6761 18.6575 15.2221C18.4313 15.768 18.0998 16.2641 17.682 16.682C17.2641 17.0998 16.768 17.4313 16.2221 17.6575C15.6761 17.8836 15.0909 18 14.5 18H11C10.4477 18 10 18.4477 10 19C10 19.5523 10.4477 20 11 20H14.5C15.3536 20 16.1988 19.8319 16.9874 19.5052C17.7761 19.1786 18.4926 18.6998 19.0962 18.0962C19.6998 17.4926 20.1786 16.7761 20.5052 15.9874C20.8319 15.1988 21 14.3536 21 13.5C21 12.6464 20.8319 11.8012 20.5052 11.0126C20.1786 10.2239 19.6998 9.50739 19.0962 8.90381C18.4926 8.30022 17.7761 7.82144 16.9874 7.49478C16.1988 7.16813 15.3536 7 14.5 7H6.41421L9.70711 3.70711Z",fill:"currentColor"})}));q8.displayName="Undo2Icon";const lj=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.7071 5.29289C19.0976 5.68342 19.0976 6.31658 18.7071 6.70711L13.4142 12L18.7071 17.2929C19.0976 17.6834 19.0976 18.3166 18.7071 18.7071C18.3166 19.0976 17.6834 19.0976 17.2929 18.7071L12 13.4142L6.70711 18.7071C6.31658 19.0976 5.68342 19.0976 5.29289 18.7071C4.90237 18.3166 4.90237 17.6834 5.29289 17.2929L10.5858 12L5.29289 6.70711C4.90237 6.31658 4.90237 5.68342 5.29289 5.29289C5.68342 4.90237 6.31658 4.90237 6.70711 5.29289L12 10.5858L17.2929 5.29289C17.6834 4.90237 18.3166 4.90237 18.7071 5.29289Z",fill:"currentColor"})}));lj.displayName="XIcon";const pe=(t,e)=>(t[document.documentElement.lang]||t.en)[e]||e,Ic="f-tiptap-invalid-node-indicator",v5={cs:{title:"Nevalidní obsah",errorMessageHint:"Chyba"},en:{title:"Invalid content",errorMessageHint:"Error"}},aj={type:"Unknown type"},E3=({invalidNodeHash:t,message:e,errorMessage:n})=>S.jsxs("div",{className:Ic,children:[S.jsxs("h4",{className:`${Ic}__title`,children:[S.jsx(n8,{}),pe(v5,"title")]}),e&&S.jsx("p",{className:`${Ic}__message`,children:e}),n&&S.jsxs("p",{className:`${Ic}__message`,children:[S.jsxs("strong",{children:[pe(v5,"errorMessageHint"),":"]})," ",n]}),S.jsx("pre",{className:`${Ic}__pre`,children:S.jsx("code",{children:JSON.stringify(t||aj,null,2)})})]});E3.displayName="InvalidNodeIndicator";const cj={cs:{remove:"Odstranit",edit:"Upravit",errorMessage:"Tento obsah nebude veřejně zobrazen, protože při jeho zobrazení došlo k chybě. Můžete ho zkusit upravit nebo odstranit.",invalidMessage:"Tento obsah nebude veřejně zobrazen. Můžete ho upravit nebo odstranit."},en:{remove:"Remove",edit:"Edit",errorMessage:"This content will not be publicly displayed because an error occurred while rendering it. You can try to edit or remove it.",invalidMessage:"This content will not be publicly displayed. You can edit or remove it."}};let V2=[];const Z8=({html:t,serializedAttrs:e})=>{V2=[{html:t,serializedAttrs:e},...V2.slice(0,9)]},uj=t=>V2.find(n=>n.serializedAttrs===t)?.html,dj=t=>{try{const e=sessionStorage.getItem(`f-tiptap-node-height:${t}`);return e?parseInt(e,10):null}catch{return null}},fj=(t,e)=>{try{sessionStorage.setItem(`f-tiptap-node-height:${t}`,e.toString())}catch{}},hj=t=>{const{uniqueId:e,...n}=t.node.attrs,{updateAttributes:r}=t,i=E.useCallback(w=>r(w),[r]),[o,l]=E.useState("initial"),[c,d]=E.useState({}),f=E.useRef(null),h=E.useRef(null),m=E.useCallback(w=>{w.defaultPrevented||j2(n,e)},[n,e]),g=E.useCallback(()=>{const w=t.getPos();if(typeof w!="number")return;const{state:x,dispatch:k}=t.editor.view,A=me.create(x.doc,w);k(x.tr.setSelection(A))},[t]),y=E.useCallback(()=>{j2(n,e)},[n,e]);E.useEffect(()=>{e||i({uniqueId:Ui()})},[e,i]),E.useEffect(()=>{if(o==="initial"&&e){const w=JSON.stringify(n),x=uj(w);if(x){l("loaded"),d({html:x});return}else l("loading"),window.parent.postMessage({type:"f-tiptap-node:render",uniqueId:e,attrs:n},"*")}},[o,e,n]),E.useEffect(()=>{if(f&&f.current){const w=f.current;return w.addEventListener("f-tiptap-node:edit",y),()=>{w.removeEventListener("f-tiptap-node:edit",y)}}},[f,y]),E.useEffect(()=>{const w=x=>{x.origin===window.origin&&(x.data.type==="f-input-tiptap:render-nodes"?x.data.nodes.forEach(k=>{if(k.unique_id===e)if(k.html){const A=JSON.stringify(n);Z8({html:k.html,serializedAttrs:A}),d({html:k.html}),l("loaded")}else d({invalid:!0,errorMessage:k.error_message}),l("loaded")}):x.data&&x.data.type==="f-c-tiptap-overlay:saved"&&x.data.uniqueId===e&&x.data.node&&x.data.node.attrs&&(d({}),l("initial"),i(x.data.node.attrs)))};return window.addEventListener("message",w),()=>{window.removeEventListener("message",w)}},[e,n,o,i]),E.useEffect(()=>{if(c.html&&h.current){const w=JSON.stringify(n),x=h.current.offsetHeight;x>0&&fj(w,x)}},[c.html,n]);const C=E.useMemo(()=>{if(c.html)return{__html:c.html}},[c.html]);return e?S.jsx(Qi,{className:"f-tiptap-node",tabIndex:0,"data-drag-handle":"","data-folio-tiptap-node-version":t.node.attrs.version,"data-folio-tiptap-node-type":t.node.attrs.type,"data-folio-tiptap-node-data":JSON.stringify(t.node.attrs.data),"data-folio-tiptap-node-unique-id":t.node.attrs.uniqueId,onClick:g,onDoubleClick:m,ref:f,children:c.html?S.jsx("div",{ref:h,className:"f-tiptap-node__html",dangerouslySetInnerHTML:C}):c.invalid?S.jsx(E3,{invalidNodeHash:t.node.toJSON(),message:pe(cj,c.errorMessage?"errorMessage":"invalidMessage"),errorMessage:c.errorMessage}):S.jsx("div",{className:"f-tiptap-node__loader-wrap rounded",style:(()=>{const w=JSON.stringify(n),x=dj(w);return x?{height:`${x}px`}:void 0})(),children:S.jsx("span",{className:"folio-loader"})})}):null},b5=({direction:t,state:e,dispatch:n})=>{if(e.selection.from!==e.selection.to-1)return!1;const r=e.selection.node;if(!r||r.type.name!=="folioTiptapNode")return!1;let i;if(t==="up"){const o=e.doc.resolve(e.selection.from).nodeBefore;if(!o)return!1;i=e.selection.from-o.nodeSize}else{const o=e.doc.resolve(e.selection.to).nodeAfter;if(!o)return!1;i=e.selection.to+o.nodeSize-1}if(n){const o=e.tr;o.deleteRange(e.selection.from,e.selection.to),o.insert(i,r),o.setSelection(ue.near(o.doc.resolve(i))),n(o)}return!0};function K8(t,e){try{t.setSelection(ue.create(t.doc,e))}catch{t.setSelection(ue.near(t.doc.resolve(e)))}}function pj(t,e,n){const r=e.nodes.paragraph.create();t.insert(n,r),K8(t,n+1)}function T0(t,e,n){const i=t.doc.resolve(n).nodeAfter;!i||i.type.name==="folioTiptapNode"?pj(t,e,n):K8(t,n+1)}const G8=({node:t,pos:e,tr:n,schema:r})=>{const i=n.doc.resolve(e);if(n.doc.nodeAt(e)?.isBlock===!0){n.replaceWith(e,e+1,t);const c=e+t.nodeSize;T0(n,r,c)}else{const c=i.start(i.depth)-1,d=i.end(i.depth)+1,f=i.parent;if(f.content.size===0||f.textContent.trim().length===0){n.replaceWith(c,d,t);const m=c+t.nodeSize;T0(n,r,m)}else{n.insert(d,t);const m=d+t.nodeSize;T0(n,r,m)}}n.scrollIntoView()},mj="^https://(?:www\\.)?instagram\\.com/(?:p|reel)/([a-zA-Z0-9\\-_]+)/?",gj="^https://(?:\\w+\\.)?pinterest\\.com/pin/([a-zA-Z0-9\\-_]+)/?",yj="^https://(?:www\\.)?(?:twitter\\.com|x\\.com)/([a-zA-Z0-9\\-_]+)(?:/.*)?/?",vj="^https://(?:www\\.youtube\\.com/watch\\?v=|youtu\\.be/)([a-zA-Z0-9\\-_]+)/?",bj={instagram:mj,pinterest:gj,twitter:yj,youtube:vj},Cj=Object.entries(bj).reduce((t,[e,n])=>(t[e]=new RegExp(n),t),{});function wj(t){for(const[e,n]of Object.entries(Cj))if(n.test(t))return e;return null}function C5(t){return/]*src="https:\/\/www\.facebook\.com\/plugins\/[^"]*"[^>]*>/.test(t)}const Y8=st.create({name:"folioTiptapNode",group:"block",draggable:!0,selectable:!0,atom:!0,addAttributes(){return{version:{default:1,parseHTML:t=>{let e;try{const n=t.dataset.folioTiptapNodeVersion||"1";e=parseInt(n,10)}catch(n){console.error("Error parsing folioTiptapNode version:",n),e=1}return e}},type:{default:"",parseHTML:t=>t.dataset.folioTiptapNodeType||""},data:{default:{},parseHTML:t=>{const e=t.dataset.folioTiptapNodeData||"{}";try{return JSON.parse(e)}catch(n){return console.error("Error parsing folioTiptapNode data:",n),{}}}},uniqueId:{default:"",parseHTML:()=>Ui()}}},parseHTML(){return[{tag:"div.f-tiptap-node",getAttrs:t=>{if(typeof t=="string")return!1;const e=t.dataset.folioTiptapNodeType||"";return this.options.nodes&&this.options.nodes.length>0&&!this.options.nodes.map(r=>r.type).includes(e)?!1:{version:parseInt(t.dataset.folioTiptapNodeVersion||"1",10),type:e,data:(()=>{try{return JSON.parse(t.dataset.folioTiptapNodeData||"{}")}catch(n){return console.error("Error parsing folioTiptapNode data:",n),{}}})(),uniqueId:Ui()}}}]},renderHTML({HTMLAttributes:t}){return["div",{class:"f-tiptap-node","data-folio-tiptap-node-version":t.version,"data-folio-tiptap-node-type":t.type,"data-folio-tiptap-node-data":JSON.stringify(t.data)}]},addNodeView(){return eo(hj,{stopEvent:()=>!1})},addProseMirrorPlugins(){const t={transformPastedHTML:n=>{if(!this.options.nodes||this.options.nodes.length===0)return n;const r=this.options.nodes.map(l=>l.type),i=document.createElement("div");return i.innerHTML=n,i.querySelectorAll("div.f-tiptap-node").forEach(l=>{const c=l.getAttribute("data-folio-tiptap-node-type")||"";r.includes(c)||l.remove()}),i.innerHTML}},e=[];return this.options.nodes&&this.options.nodes.forEach(n=>{if(n.config?.paste?.pattern)try{let r=n.config.paste.pattern;r=r.replace(/\\A/g,"^").replace(/\\z/g,"$");const i=new RegExp(r);e.push({type:n.type,pattern:i})}catch(r){console.error(`Failed to create RegExp for node ${n.type}:`,r)}}),(e.length>0||this.options.embedNodeClassName)&&(t.handlePaste=(n,r,i)=>{const o=r.clipboardData?.getData("text/plain"),l=r.clipboardData?.getData("text/html");if(e.length>0){const c=o?.trim()||l?.trim();if(c){for(const d of e)if(d.pattern.test(c)){const f=n.state.schema.nodes.folioTiptapNodePastePlaceholder.create({pasted_string:c,target_node_type:d.type,uniqueId:Ui()});return n.dispatch(n.state.tr.replaceSelectionWith(f)),!0}}}if(this.options.embedNodeClassName){if(o){const c=o.trim(),d=wj(c);if(d)return n.dispatch(n.state.tr.replaceSelectionWith(this.type.create({type:this.options.embedNodeClassName,version:1,uniqueId:Ui(),data:{folio_embed_data:{active:!0,type:d,url:c}}}))),!0;if(C5(c))return n.dispatch(n.state.tr.replaceSelectionWith(this.type.create({type:this.options.embedNodeClassName,version:1,uniqueId:Ui(),data:{folio_embed_data:{active:!0,html:c}}}))),!0}if(l&&C5(l))return n.dispatch(n.state.tr.replaceSelectionWith(this.type.create({type:this.options.embedNodeClassName,version:1,uniqueId:Ui(),data:{folio_embed_data:{active:!0,html:l}}}))),!0}return!1}),[new Ve({props:t})]},addCommands(){return{insertFolioTiptapNode:t=>({tr:e,dispatch:n,editor:r})=>{const i=r.schema.nodes.folioTiptapNode.createChecked({...t.attrs,uniqueId:t.attrs.uniqueId||Ui()},null);if(n){r.view.dom.focus();const l=e.selection.anchor;G8({node:i,pos:l,tr:e,schema:r.schema}),n(e)}return!0},moveFolioTiptapNodeDown:()=>({state:t,dispatch:e})=>b5({direction:"down",state:t,dispatch:e}),moveFolioTiptapNodeUp:()=>({state:t,dispatch:e})=>b5({direction:"up",state:t,dispatch:e}),editFolioTipapNode:()=>({state:t})=>{const e=t.selection.node;if(!e||e.type.name!==this.name)return!1;const{uniqueId:n,...r}=e.attrs;return j2(r,n),!0},removeFolioTiptapNode:()=>({state:t,dispatch:e})=>{const n=t.selection.node;if(!n||n.type.name!==this.name)return!1;const r=t.tr;return r.deleteRange(t.selection.from,t.selection.to),e(r),!0}}}}),w5="f-tiptap-node-paste-placeholder",xj=t=>{const{node:e,editor:n,getPos:r}=t,{pasted_string:i,target_node_type:o,uniqueId:l}=e.attrs;return E.useEffect(()=>{if(!l||!i||!o)return;window.parent.postMessage({type:"f-tiptap-node:paste",uniqueId:l,pasted_string:i,tiptap_node_type:o},"*");const c=d=>{if(d.origin===window.origin&&d.data.type==="f-input-tiptap:paste-node"&&d.data.unique_id===l){const f=r();if(typeof f!="number")return;if(d.data.tiptap_node){const{state:h}=n.view,{tr:m}=h,g={...d.data.tiptap_node.attrs,uniqueId:l};if(d.data.html){const{uniqueId:C,...w}=g,x=JSON.stringify(w);Z8({html:d.data.html,serializedAttrs:x})}const y=n.schema.nodes.folioTiptapNode.createChecked(g,null);G8({node:y,pos:f,tr:m,schema:n.schema}),n.view.dispatch(m)}else if(d.data.error){const{state:h}=n.view,{tr:m}=h;m.delete(f,f+1),n.view.dispatch(m),window.alert(d.data.error)}window.removeEventListener("message",c)}};return window.addEventListener("message",c),()=>{window.removeEventListener("message",c)}},[l,i,o,n,r]),S.jsx(Qi,{className:w5,"data-pasted-string":i,"data-target-node-type":o,"data-unique-id":l,children:S.jsx("div",{className:`${w5}__loader-wrap rounded`,children:S.jsx("span",{className:"folio-loader"})})})},x5="f-tiptap-node-paste-placeholder",Sj=st.create({name:"folioTiptapNodePastePlaceholder",group:"block",draggable:!0,selectable:!0,atom:!0,isolating:!0,renderHTML({HTMLAttributes:t}){return["div",{...t,class:x5},0]},addAttributes(){return{pasted_string:{default:"",parseHTML:t=>t.getAttribute("data-pasted-string")||"",renderHTML:t=>({"data-pasted-string":t.pasted_string})},target_node_type:{default:"",parseHTML:t=>t.getAttribute("data-target-node-type")||"",renderHTML:t=>({"data-target-node-type":t.target_node_type})},uniqueId:{default:"",parseHTML:t=>t.getAttribute("data-unique-id")||"",renderHTML:t=>({"data-unique-id":t.uniqueId})}}},addNodeView(){return eo(xj,{stopEvent:()=>!1})},parseHTML(){return[{tag:`div.${x5}`,getAttrs:t=>typeof t=="string"?!1:{pasted_string:t.getAttribute("data-pasted-string")||"",target_node_type:t.getAttribute("data-target-node-type")||"",uniqueId:t.getAttribute("data-unique-id")||""}}]}}),Af={cs:{moveFolioTiptapNodeUp:"Posunout nahoru",moveFolioTiptapNodeDown:"Posunout dolů",editFolioTipapNode:"Upravit",removeFolioTiptapNode:"Odstranit"},en:{moveFolioTiptapNodeUp:"Move up",moveFolioTiptapNodeDown:"Move down",editFolioTipapNode:"Edit",removeFolioTiptapNode:"Remove"}},Tj={pluginKey:"folioTiptapNodeBubbleMenu",priority:1,offset:({rects:t})=>-t.reference.height/2-t.floating.height/2,shouldShow:({editor:t})=>t.isActive(Y8.name),disabledKeys:({state:t})=>{const e=[];return t.doc.resolve(t.selection.from).nodeBefore||e.push("moveFolioTiptapNodeUp"),t.doc.resolve(t.selection.to).nodeAfter||e.push("moveFolioTiptapNodeDown"),e},items:[[{key:"moveFolioTiptapNodeUp",title:pe(Af,"moveFolioTiptapNodeUp"),icon:m3,command:({editor:t})=>{t.chain().focus().moveFolioTiptapNodeUp().run()}},{key:"moveFolioTiptapNodeDown",title:pe(Af,"moveFolioTiptapNodeDown"),icon:p3,command:({editor:t})=>{t.chain().focus().moveFolioTiptapNodeDown().run()}},{key:"editFolioTipapNode",title:pe(Af,"editFolioTipapNode"),icon:d8,command:({editor:t})=>{t.chain().focus().editFolioTipapNode().run()}},{key:"removeFolioTiptapNode",title:pe(Af,"removeFolioTiptapNode"),icon:zp,command:({editor:t})=>{t.chain().focus().removeFolioTiptapNode().run()}}]]},W8=t=>{const e={...t};return e.type==="folioTiptapNode"&&(e.attrs={...e.attrs,uniqueId:Ui()}),e.content&&Array.isArray(e.content)&&(e.content=e.content.map(n=>W8(n))),e},M3=t=>{const e={...t};return e.type==="folioTiptapNode"&&(e.attrs={...e.attrs},delete e.attrs.uniqueId),e.content&&Array.isArray(e.content)&&(e.content=e.content.map(n=>M3(n))),e},kj=Ze.create({name:"folioTiptapColumnsExtension"});function Ej(t,e=null){return e?t.createChecked({},e):t.createAndFill({})}function Mj(t){if(t.cached.columnsNodeTypes)return t.cached.columnsNodeTypes;const e={columns:t.nodes.folioTiptapColumns,column:t.nodes.folioTiptapColumn};return t.cached.columnsNodeTypes=e,e}function Aj(t,e,n=null){const r=Mj(t),i=[];for(let o=0;oo.type.name===o1.name)(t.selection),i=At(o=>o.type.name===tp.name)(t.selection);if(!r||!i)return!1;if(e){const o=r.node;let l=null;if(o.content.forEach((g,y,C)=>{if(l===null&&g===i.node){l=C;return}}),l===null)return console.warn("Current page not found in cols node"),!1;const c=o.toJSON();let d=l;if(n==="delete"){if(c.content.length<=2){const x=[];c.content.forEach(A=>{A.content&&A.content.length>0&&x.push(...A.content)}),x.length===0&&x.push({type:"paragraph"});const k=t.tr;return k.replaceWith(r.pos,r.pos+r.node.nodeSize,x.map(A=>Gn.fromJSON(t.schema,A))),k.setSelection(ue.near(k.doc.resolve(r.pos+1))),e(k),!0}const y=c.content[l].content||[],C=l>0?l-1:l+1,w=c.content[C];y.length>0&&(w.content||(w.content=[]),w.content.push(...y)),c.content.splice(l,1),d=l>0?l-1:0}else d=n==="addBefore"?l:l+1,c.content.splice(d,0,{type:tp.name,content:[{type:"paragraph"}]});const f=Gn.fromJSON(t.schema,c);let h=r.pos;f.content.forEach((g,y,C)=>{Co.type.name===o1.name)(t.selection),i=At(o=>o.type.name===tp.name)(t.selection);if(e&&r&&i){const o=r.node,l=i.node;let c=null;if(o.content.forEach((m,g,y)=>{if(c===null&&m===l){c=y;return}}),c===null)return console.warn("Current col not found in cols node"),!1;let d=0;n==="before"?d=(c-1+o.childCount)%o.childCount:d=(c+1)%o.childCount;let f=r.pos;o.content.forEach((m,g,y)=>{y"u"?!1:t instanceof ShadowRoot||t instanceof Jn(t).ShadowRoot}const Nj=new Set(["inline","contents"]);function zu(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=Rr(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!Nj.has(i)}const Rj=new Set(["table","td","th"]);function Oj(t){return Rj.has(ss(t))}const Dj=[":popover-open",":modal"];function Vp(t){return Dj.some(e=>{try{return t.matches(e)}catch{return!1}})}const Lj=["transform","translate","scale","rotate","perspective"],_j=["transform","translate","scale","rotate","perspective","filter"],Hj=["paint","layout","strict","content"];function N3(t){const e=Up(),n=yt(t)?Rr(t):t;return Lj.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||_j.some(r=>(n.willChange||"").includes(r))||Hj.some(r=>(n.contain||"").includes(r))}function Ij(t){let e=Wi(t);for(;_t(e)&&!Ki(e);){if(N3(e))return e;if(Vp(e))return null;e=Wi(e)}return null}function Up(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const zj=new Set(["html","body","#document"]);function Ki(t){return zj.has(ss(t))}function Rr(t){return Jn(t).getComputedStyle(t)}function Pp(t){return yt(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Wi(t){if(ss(t)==="html")return t;const e=t.assignedSlot||t.parentNode||U2(t)&&t.host||pi(t);return U2(e)?e.host:e}function J8(t){const e=Wi(t);return Ki(e)?t.ownerDocument?t.ownerDocument.body:t.body:_t(e)&&zu(e)?e:J8(e)}function Yo(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=J8(t),o=i===((r=t.ownerDocument)==null?void 0:r.body),l=Jn(i);if(o){const c=P2(l);return e.concat(l,l.visualViewport||[],zu(i)?i:[],c&&n?Yo(c):[])}return e.concat(i,Yo(i,[],n))}function P2(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}const X8=["top","right","bottom","left"],T5=["start","end"],k5=X8.reduce((t,e)=>t.concat(e,e+"-"+T5[0],e+"-"+T5[1]),[]),$r=Math.min,wn=Math.max,qh=Math.round,ia=Math.floor,ai=t=>({x:t,y:t}),Bj={left:"right",right:"left",bottom:"top",top:"bottom"},jj={start:"end",end:"start"};function F2(t,e,n){return wn(t,$r(e,n))}function qr(t,e){return typeof t=="function"?t(e):t}function cr(t){return t.split("-")[0]}function Pr(t){return t.split("-")[1]}function R3(t){return t==="x"?"y":"x"}function O3(t){return t==="y"?"height":"width"}const Vj=new Set(["top","bottom"]);function Vr(t){return Vj.has(cr(t))?"y":"x"}function D3(t){return R3(Vr(t))}function Q8(t,e,n){n===void 0&&(n=!1);const r=Pr(t),i=D3(t),o=O3(i);let l=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(l=Kh(l)),[l,Kh(l)]}function Uj(t){const e=Kh(t);return[Zh(t),e,Zh(e)]}function Zh(t){return t.replace(/start|end/g,e=>jj[e])}const E5=["left","right"],M5=["right","left"],Pj=["top","bottom"],Fj=["bottom","top"];function $j(t,e,n){switch(t){case"top":case"bottom":return n?e?M5:E5:e?E5:M5;case"left":case"right":return e?Pj:Fj;default:return[]}}function qj(t,e,n,r){const i=Pr(t);let o=$j(cr(t),n==="start",r);return i&&(o=o.map(l=>l+"-"+i),e&&(o=o.concat(o.map(Zh)))),o}function Kh(t){return t.replace(/left|right|bottom|top/g,e=>Bj[e])}function Zj(t){return{top:0,right:0,bottom:0,left:0,...t}}function L3(t){return typeof t!="number"?Zj(t):{top:t,right:t,bottom:t,left:t}}function wa(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}var Kj=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],Gh=Kj.join(","),eT=typeof Element>"u",xa=eT?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Yh=!eT&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t?.ownerDocument},Wh=function(e,n){var r;n===void 0&&(n=!0);var i=e==null||(r=e.getAttribute)===null||r===void 0?void 0:r.call(e,"inert"),o=i===""||i==="true",l=o||n&&e&&(typeof e.closest=="function"?e.closest("[inert]"):Wh(e.parentNode));return l},Gj=function(e){var n,r=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"contenteditable");return r===""||r==="true"},tT=function(e,n,r){if(Wh(e))return[];var i=Array.prototype.slice.apply(e.querySelectorAll(Gh));return n&&xa.call(e,Gh)&&i.unshift(e),i=i.filter(r),i},Jh=function(e,n,r){for(var i=[],o=Array.from(e);o.length;){var l=o.shift();if(!Wh(l,!1))if(l.tagName==="SLOT"){var c=l.assignedElements(),d=c.length?c:l.children,f=Jh(d,!0,r);r.flatten?i.push.apply(i,f):i.push({scopeParent:l,candidates:f})}else{var h=xa.call(l,Gh);h&&r.filter(l)&&(n||!e.includes(l))&&i.push(l);var m=l.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(l),g=!Wh(m,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(l));if(m&&g){var y=Jh(m===!0?l.children:m.children,!0,r);r.flatten?i.push.apply(i,y):i.push({scopeParent:l,candidates:y})}else o.unshift.apply(o,l.children)}}return i},nT=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},rT=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||Gj(e))&&!nT(e)?0:e.tabIndex},Yj=function(e,n){var r=rT(e);return r<0&&n&&!nT(e)?0:r},Wj=function(e,n){return e.tabIndex===n.tabIndex?e.documentOrder-n.documentOrder:e.tabIndex-n.tabIndex},iT=function(e){return e.tagName==="INPUT"},Jj=function(e){return iT(e)&&e.type==="hidden"},Xj=function(e){var n=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(r){return r.tagName==="SUMMARY"});return n},Qj=function(e,n){for(var r=0;rsummary:first-of-type"),c=l?e.parentElement:e;if(xa.call(c,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof i=="function"){for(var d=e;e;){var f=e.parentElement,h=Yh(e);if(f&&!f.shadowRoot&&i(f)===!0)return A5(e);e.assignedSlot?e=e.assignedSlot:!f&&h!==e.ownerDocument?e=h.host:e=f}e=d}if(rV(e))return!e.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return A5(e);return!1},oV=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var n=e.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r=0)},oT=function(e){var n=[],r=[];return e.forEach(function(i,o){var l=!!i.scopeParent,c=l?i.scopeParent:i,d=Yj(c,l),f=l?oT(i.candidates):c;d===0?l?n.push.apply(n,f):n.push(c):r.push({documentOrder:o,tabIndex:d,item:i,isScope:l,content:f})}),r.sort(Wj).reduce(function(i,o){return o.isScope?i.push.apply(i,o.content):i.push(o.content),i},[]).concat(n)},Fp=function(e,n){n=n||{};var r;return n.getShadowRoot?r=Jh([e],n.includeContainer,{filter:q2.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:sV}):r=tT(e,n.includeContainer,q2.bind(null,n)),oT(r)},lV=function(e,n){n=n||{};var r;return n.getShadowRoot?r=Jh([e],n.includeContainer,{filter:$2.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=tT(e,n.includeContainer,$2.bind(null,n)),r},sT=function(e,n){if(n=n||{},!e)throw new Error("No node provided");return xa.call(e,Gh)===!1?!1:q2(n,e)};function lT(){const t=navigator.userAgentData;return t!=null&&t.platform?t.platform:navigator.platform}function aT(){const t=navigator.userAgentData;return t&&Array.isArray(t.brands)?t.brands.map(e=>{let{brand:n,version:r}=e;return n+"/"+r}).join(" "):navigator.userAgent}function cT(){return/apple/i.test(navigator.vendor)}function Z2(){const t=/android/i;return t.test(lT())||t.test(aT())}function aV(){return lT().toLowerCase().startsWith("mac")&&!navigator.maxTouchPoints}function uT(){return aT().includes("jsdom/")}const N5="data-floating-ui-focusable",cV="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",E0="ArrowLeft",M0="ArrowRight",uV="ArrowUp",dV="ArrowDown";function li(t){let e=t.activeElement;for(;((n=e)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;e=e.shadowRoot.activeElement}return e}function fn(t,e){if(!t||!e)return!1;const n=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(n&&U2(n)){let r=e;for(;r;){if(t===r)return!0;r=r.parentNode||r.host}}return!1}function Pi(t){return"composedPath"in t?t.composedPath()[0]:t.target}function A0(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const n=t;return n.target!=null&&e.contains(n.target)}function fV(t){return t.matches("html,body")}function gn(t){return t?.ownerDocument||document}function _3(t){return _t(t)&&t.matches(cV)}function K2(t){return t?t.getAttribute("role")==="combobox"&&_3(t):!1}function hV(t){if(!t||uT())return!0;try{return t.matches(":focus-visible")}catch{return!0}}function Xh(t){return t?t.hasAttribute(N5)?t:t.querySelector("["+N5+"]")||t:null}function Us(t,e,n){return n===void 0&&(n=!0),t.filter(i=>{var o;return i.parentId===e&&(!n||((o=i.context)==null?void 0:o.open))}).flatMap(i=>[i,...Us(t,i.id,n)])}function pV(t,e){let n,r=-1;function i(o,l){l>r&&(n=o,r=l),Us(t,o).forEach(d=>{i(d.id,l+1)})}return i(e,0),t.find(o=>o.id===n)}function R5(t,e){var n;let r=[],i=(n=t.find(o=>o.id===e))==null?void 0:n.parentId;for(;i;){const o=t.find(l=>l.id===i);i=o?.parentId,o&&(r=r.concat(o))}return r}function hn(t){t.preventDefault(),t.stopPropagation()}function mV(t){return"nativeEvent"in t}function dT(t){return t.mozInputSource===0&&t.isTrusted?!0:Z2()&&t.pointerType?t.type==="click"&&t.buttons===1:t.detail===0&&!t.pointerType}function fT(t){return uT()?!1:!Z2()&&t.width===0&&t.height===0||Z2()&&t.width===1&&t.height===1&&t.pressure===0&&t.detail===0&&t.pointerType==="mouse"||t.width<1&&t.height<1&&t.pressure===0&&t.detail===0&&t.pointerType==="touch"}function vu(t,e){const n=["mouse","pen"];return e||n.push("",void 0),n.includes(t)}var gV=typeof document<"u",yV=function(){},ft=gV?E.useLayoutEffect:yV;const vV={...n9};function Zn(t){const e=E.useRef(t);return ft(()=>{e.current=t}),e}const bV=vV.useInsertionEffect,CV=bV||(t=>t());function Ht(t){const e=E.useRef(()=>{});return CV(()=>{e.current=t}),E.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i=t.current.length}function N0(t,e){return Cn(t,{disabledIndices:e})}function O5(t,e){return Cn(t,{decrement:!0,startingIndex:t.current.length,disabledIndices:e})}function Cn(t,e){let{startingIndex:n=-1,decrement:r=!1,disabledIndices:i,amount:o=1}=e===void 0?{}:e,l=n;do l+=r?-o:o;while(l>=0&&l<=t.current.length-1&&Gf(t,l,i));return l}function wV(t,e){let{event:n,orientation:r,loop:i,rtl:o,cols:l,disabledIndices:c,minIndex:d,maxIndex:f,prevIndex:h,stopEvent:m=!1}=e,g=h;if(n.key===uV){if(m&&hn(n),h===-1)g=f;else if(g=Cn(t,{startingIndex:g,amount:l,decrement:!0,disabledIndices:c}),i&&(h-ly?w:w-l}tu(t,g)&&(g=h)}if(n.key===dV&&(m&&hn(n),h===-1?g=d:(g=Cn(t,{startingIndex:h,amount:l,disabledIndices:c}),i&&h+l>f&&(g=Cn(t,{startingIndex:h%l-l,amount:l,disabledIndices:c}))),tu(t,g)&&(g=h)),r==="both"){const y=ia(h/l);n.key===(o?E0:M0)&&(m&&hn(n),h%l!==l-1?(g=Cn(t,{startingIndex:h,disabledIndices:c}),i&&Nf(g,l,y)&&(g=Cn(t,{startingIndex:h-h%l-1,disabledIndices:c}))):i&&(g=Cn(t,{startingIndex:h-h%l-1,disabledIndices:c})),Nf(g,l,y)&&(g=h)),n.key===(o?M0:E0)&&(m&&hn(n),h%l!==0?(g=Cn(t,{startingIndex:h,decrement:!0,disabledIndices:c}),i&&Nf(g,l,y)&&(g=Cn(t,{startingIndex:h+(l-h%l),decrement:!0,disabledIndices:c}))):i&&(g=Cn(t,{startingIndex:h+(l-h%l),decrement:!0,disabledIndices:c})),Nf(g,l,y)&&(g=h));const C=ia(f/l)===y;tu(t,g)&&(i&&C?g=n.key===(o?M0:E0)?f:Cn(t,{startingIndex:h-h%l-1,disabledIndices:c}):g=h)}return g}function xV(t,e,n){const r=[];let i=0;return t.forEach((o,l)=>{let{width:c,height:d}=o,f=!1;for(n&&(i=0);!f;){const h=[];for(let m=0;mr[m]==null)?(h.forEach(m=>{r[m]=l}),f=!0):i++}}),[...r]}function SV(t,e,n,r,i){if(t===-1)return-1;const o=n.indexOf(t),l=e[t];switch(i){case"tl":return o;case"tr":return l?o+l.width-1:o;case"bl":return l?o+(l.height-1)*r:o;case"br":return n.lastIndexOf(t)}}function TV(t,e){return e.flatMap((n,r)=>t.includes(n)?[r]:[])}function Gf(t,e,n){if(typeof n=="function")return n(e);if(n)return n.includes(e);const r=t.current[e];return r==null||r.hasAttribute("disabled")||r.getAttribute("aria-disabled")==="true"}const Bu=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function hT(t,e){const n=Fp(t,Bu()),r=n.length;if(r===0)return;const i=li(gn(t)),o=n.indexOf(i),l=o===-1?e===1?0:r-1:o+e;return n[l]}function pT(t){return hT(gn(t).body,1)||t}function mT(t){return hT(gn(t).body,-1)||t}function nu(t,e){const n=e||t.currentTarget,r=t.relatedTarget;return!r||!fn(n,r)}function kV(t){Fp(t,Bu()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function D5(t){t.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}function L5(t,e,n){let{reference:r,floating:i}=t;const o=Vr(e),l=D3(e),c=O3(l),d=cr(e),f=o==="y",h=r.x+r.width/2-i.width/2,m=r.y+r.height/2-i.height/2,g=r[c]/2-i[c]/2;let y;switch(d){case"top":y={x:h,y:r.y-i.height};break;case"bottom":y={x:h,y:r.y+r.height};break;case"right":y={x:r.x+r.width,y:m};break;case"left":y={x:r.x-i.width,y:m};break;default:y={x:r.x,y:r.y}}switch(Pr(e)){case"start":y[l]-=g*(n&&f?-1:1);break;case"end":y[l]+=g*(n&&f?-1:1);break}return y}const EV=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:l}=n,c=o.filter(Boolean),d=await(l.isRTL==null?void 0:l.isRTL(e));let f=await l.getElementRects({reference:t,floating:e,strategy:i}),{x:h,y:m}=L5(f,r,d),g=r,y={},C=0;for(let w=0;w({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:i,rects:o,platform:l,elements:c,middlewareData:d}=e,{element:f,padding:h=0}=qr(t,e)||{};if(f==null)return{};const m=L3(h),g={x:n,y:r},y=D3(i),C=O3(y),w=await l.getDimensions(f),x=y==="y",k=x?"top":"left",A=x?"bottom":"right",N=x?"clientHeight":"clientWidth",R=o.reference[C]+o.reference[y]-g[y]-o.floating[C],L=g[y]-o.reference[y],z=await(l.getOffsetParent==null?void 0:l.getOffsetParent(f));let _=z?z[N]:0;(!_||!await(l.isElement==null?void 0:l.isElement(z)))&&(_=c.floating[N]||o.floating[C]);const q=R/2-L/2,J=_/2-w[C]/2-1,U=$r(m[k],J),ne=$r(m[A],J),le=U,oe=_-w[C]-ne,G=_/2-w[C]/2+q,P=F2(le,G,oe),H=!d.arrow&&Pr(i)!=null&&G!==P&&o.reference[C]/2-(GPr(i)===t),...n.filter(i=>Pr(i)!==t)]:n.filter(i=>cr(i)===i)).filter(i=>t?Pr(i)===t||(e?Zh(i)!==i:!1):!0)}const NV=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,r,i;const{rects:o,middlewareData:l,placement:c,platform:d,elements:f}=e,{crossAxis:h=!1,alignment:m,allowedPlacements:g=k5,autoAlignment:y=!0,...C}=qr(t,e),w=m!==void 0||g===k5?AV(m||null,y,g):g,x=await Sa(e,C),k=((n=l.autoPlacement)==null?void 0:n.index)||0,A=w[k];if(A==null)return{};const N=Q8(A,o,await(d.isRTL==null?void 0:d.isRTL(f.floating)));if(c!==A)return{reset:{placement:w[0]}};const R=[x[cr(A)],x[N[0]],x[N[1]]],L=[...((r=l.autoPlacement)==null?void 0:r.overflows)||[],{placement:A,overflows:R}],z=w[k+1];if(z)return{data:{index:k+1,overflows:L},reset:{placement:z}};const _=L.map(U=>{const ne=Pr(U.placement);return[U.placement,ne&&h?U.overflows.slice(0,2).reduce((le,oe)=>le+oe,0):U.overflows[0],U.overflows]}).sort((U,ne)=>U[1]-ne[1]),J=((i=_.filter(U=>U[2].slice(0,Pr(U[0])?2:3).every(ne=>ne<=0))[0])==null?void 0:i[0])||_[0][0];return J!==c?{data:{index:k+1,overflows:L},reset:{placement:J}}:{}}}},RV=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:o,rects:l,initialPlacement:c,platform:d,elements:f}=e,{mainAxis:h=!0,crossAxis:m=!0,fallbackPlacements:g,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:C="none",flipAlignment:w=!0,...x}=qr(t,e);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const k=cr(i),A=Vr(c),N=cr(c)===c,R=await(d.isRTL==null?void 0:d.isRTL(f.floating)),L=g||(N||!w?[Kh(c)]:Uj(c)),z=C!=="none";!g&&z&&L.push(...qj(c,w,C,R));const _=[c,...L],q=await Sa(e,x),J=[];let U=((r=o.flip)==null?void 0:r.overflows)||[];if(h&&J.push(q[k]),m){const G=Q8(i,l,R);J.push(q[G[0]],q[G[1]])}if(U=[...U,{placement:i,overflows:J}],!J.every(G=>G<=0)){var ne,le;const G=(((ne=o.flip)==null?void 0:ne.index)||0)+1,P=_[G];if(P&&(!(m==="alignment"?A!==Vr(P):!1)||U.every(B=>Vr(B.placement)===A?B.overflows[0]>0:!0)))return{data:{index:G,overflows:U},reset:{placement:P}};let H=(le=U.filter(j=>j.overflows[0]<=0).sort((j,B)=>j.overflows[1]-B.overflows[1])[0])==null?void 0:le.placement;if(!H)switch(y){case"bestFit":{var oe;const j=(oe=U.filter(B=>{if(z){const re=Vr(B.placement);return re===A||re==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(re=>re>0).reduce((re,ae)=>re+ae,0)]).sort((B,re)=>B[1]-re[1])[0])==null?void 0:oe[0];j&&(H=j);break}case"initialPlacement":H=c;break}if(i!==H)return{reset:{placement:H}}}return{}}}};function _5(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function H5(t){return X8.some(e=>t[e]>=0)}const OV=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...i}=qr(t,e);switch(r){case"referenceHidden":{const o=await Sa(e,{...i,elementContext:"reference"}),l=_5(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:H5(l)}}}case"escaped":{const o=await Sa(e,{...i,altBoundary:!0}),l=_5(o,n.floating);return{data:{escapedOffsets:l,escaped:H5(l)}}}default:return{}}}}};function gT(t){const e=$r(...t.map(o=>o.left)),n=$r(...t.map(o=>o.top)),r=wn(...t.map(o=>o.right)),i=wn(...t.map(o=>o.bottom));return{x:e,y:n,width:r-e,height:i-n}}function DV(t){const e=t.slice().sort((i,o)=>i.y-o.y),n=[];let r=null;for(let i=0;ir.height/2?n.push([o]):n[n.length-1].push(o),r=o}return n.map(i=>wa(gT(i)))}const LV=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:r,rects:i,platform:o,strategy:l}=e,{padding:c=2,x:d,y:f}=qr(t,e),h=Array.from(await(o.getClientRects==null?void 0:o.getClientRects(r.reference))||[]),m=DV(h),g=wa(gT(h)),y=L3(c);function C(){if(m.length===2&&m[0].left>m[1].right&&d!=null&&f!=null)return m.find(x=>d>x.left-y.left&&dx.top-y.top&&f=2){if(Vr(n)==="y"){const U=m[0],ne=m[m.length-1],le=cr(n)==="top",oe=U.top,G=ne.bottom,P=le?U.left:ne.left,H=le?U.right:ne.right,j=H-P,B=G-oe;return{top:oe,bottom:G,left:P,right:H,width:j,height:B,x:P,y:oe}}const x=cr(n)==="left",k=wn(...m.map(U=>U.right)),A=$r(...m.map(U=>U.left)),N=m.filter(U=>x?U.left===A:U.right===k),R=N[0].top,L=N[N.length-1].bottom,z=A,_=k,q=_-z,J=L-R;return{top:R,bottom:L,left:z,right:_,width:q,height:J,x:z,y:R}}return g}const w=await o.getElementRects({reference:{getBoundingClientRect:C},floating:r.floating,strategy:l});return i.reference.x!==w.reference.x||i.reference.y!==w.reference.y||i.reference.width!==w.reference.width||i.reference.height!==w.reference.height?{reset:{rects:w}}:{}}}},yT=new Set(["left","top"]);async function _V(t,e){const{placement:n,platform:r,elements:i}=t,o=await(r.isRTL==null?void 0:r.isRTL(i.floating)),l=cr(n),c=Pr(n),d=Vr(n)==="y",f=yT.has(l)?-1:1,h=o&&d?-1:1,m=qr(e,t);let{mainAxis:g,crossAxis:y,alignmentAxis:C}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof C=="number"&&(y=c==="end"?C*-1:C),d?{x:y*h,y:g*f}:{x:g*f,y:y*h}}const HV=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:o,placement:l,middlewareData:c}=e,d=await _V(e,t);return l===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:i+d.x,y:o+d.y,data:{...d,placement:l}}}}},IV=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i}=e,{mainAxis:o=!0,crossAxis:l=!1,limiter:c={fn:x=>{let{x:k,y:A}=x;return{x:k,y:A}}},...d}=qr(t,e),f={x:n,y:r},h=await Sa(e,d),m=Vr(cr(i)),g=R3(m);let y=f[g],C=f[m];if(o){const x=g==="y"?"top":"left",k=g==="y"?"bottom":"right",A=y+h[x],N=y-h[k];y=F2(A,y,N)}if(l){const x=m==="y"?"top":"left",k=m==="y"?"bottom":"right",A=C+h[x],N=C-h[k];C=F2(A,C,N)}const w=c.fn({...e,[g]:y,[m]:C});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[g]:o,[m]:l}}}}}},zV=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:i,rects:o,middlewareData:l}=e,{offset:c=0,mainAxis:d=!0,crossAxis:f=!0}=qr(t,e),h={x:n,y:r},m=Vr(i),g=R3(m);let y=h[g],C=h[m];const w=qr(c,e),x=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(d){const N=g==="y"?"height":"width",R=o.reference[g]-o.floating[N]+x.mainAxis,L=o.reference[g]+o.reference[N]-x.mainAxis;yL&&(y=L)}if(f){var k,A;const N=g==="y"?"width":"height",R=yT.has(cr(i)),L=o.reference[m]-o.floating[N]+(R&&((k=l.offset)==null?void 0:k[m])||0)+(R?0:x.crossAxis),z=o.reference[m]+o.reference[N]+(R?0:((A=l.offset)==null?void 0:A[m])||0)-(R?x.crossAxis:0);Cz&&(C=z)}return{[g]:y,[m]:C}}}},BV=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:i,rects:o,platform:l,elements:c}=e,{apply:d=()=>{},...f}=qr(t,e),h=await Sa(e,f),m=cr(i),g=Pr(i),y=Vr(i)==="y",{width:C,height:w}=o.floating;let x,k;m==="top"||m==="bottom"?(x=m,k=g===(await(l.isRTL==null?void 0:l.isRTL(c.floating))?"start":"end")?"left":"right"):(k=m,x=g==="end"?"top":"bottom");const A=w-h.top-h.bottom,N=C-h.left-h.right,R=$r(w-h[x],A),L=$r(C-h[k],N),z=!e.middlewareData.shift;let _=R,q=L;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(q=N),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(_=A),z&&!g){const U=wn(h.left,0),ne=wn(h.right,0),le=wn(h.top,0),oe=wn(h.bottom,0);y?q=C-2*(U!==0||ne!==0?U+ne:wn(h.left,h.right)):_=w-2*(le!==0||oe!==0?le+oe:wn(h.top,h.bottom))}await d({...e,availableWidth:q,availableHeight:_});const J=await l.getDimensions(c.floating);return C!==J.width||w!==J.height?{reset:{rects:!0}}:{}}}};function vT(t){const e=Rr(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=_t(t),o=i?t.offsetWidth:n,l=i?t.offsetHeight:r,c=qh(n)!==o||qh(r)!==l;return c&&(n=o,r=l),{width:n,height:r,$:c}}function H3(t){return yt(t)?t:t.contextElement}function la(t){const e=H3(t);if(!_t(e))return ai(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:o}=vT(e);let l=(o?qh(n.width):n.width)/r,c=(o?qh(n.height):n.height)/i;return(!l||!Number.isFinite(l))&&(l=1),(!c||!Number.isFinite(c))&&(c=1),{x:l,y:c}}const jV=ai(0);function bT(t){const e=Jn(t);return!Up()||!e.visualViewport?jV:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function VV(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Jn(t)?!1:e}function Ws(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),o=H3(t);let l=ai(1);e&&(r?yt(r)&&(l=la(r)):l=la(t));const c=VV(o,n,r)?bT(o):ai(0);let d=(i.left+c.x)/l.x,f=(i.top+c.y)/l.y,h=i.width/l.x,m=i.height/l.y;if(o){const g=Jn(o),y=r&&yt(r)?Jn(r):r;let C=g,w=P2(C);for(;w&&r&&y!==C;){const x=la(w),k=w.getBoundingClientRect(),A=Rr(w),N=k.left+(w.clientLeft+parseFloat(A.paddingLeft))*x.x,R=k.top+(w.clientTop+parseFloat(A.paddingTop))*x.y;d*=x.x,f*=x.y,h*=x.x,m*=x.y,d+=N,f+=R,C=Jn(w),w=P2(C)}}return wa({width:h,height:m,x:d,y:f})}function $p(t,e){const n=Pp(t).scrollLeft;return e?e.left+n:Ws(pi(t)).left+n}function CT(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-$p(t,n),i=n.top+e.scrollTop;return{x:r,y:i}}function UV(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const o=i==="fixed",l=pi(r),c=e?Vp(e.floating):!1;if(r===l||c&&o)return n;let d={scrollLeft:0,scrollTop:0},f=ai(1);const h=ai(0),m=_t(r);if((m||!m&&!o)&&((ss(r)!=="body"||zu(l))&&(d=Pp(r)),_t(r))){const y=Ws(r);f=la(r),h.x=y.x+r.clientLeft,h.y=y.y+r.clientTop}const g=l&&!m&&!o?CT(l,d):ai(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-d.scrollLeft*f.x+h.x+g.x,y:n.y*f.y-d.scrollTop*f.y+h.y+g.y}}function PV(t){return Array.from(t.getClientRects())}function FV(t){const e=pi(t),n=Pp(t),r=t.ownerDocument.body,i=wn(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),o=wn(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let l=-n.scrollLeft+$p(t);const c=-n.scrollTop;return Rr(r).direction==="rtl"&&(l+=wn(e.clientWidth,r.clientWidth)-i),{width:i,height:o,x:l,y:c}}const I5=25;function $V(t,e){const n=Jn(t),r=pi(t),i=n.visualViewport;let o=r.clientWidth,l=r.clientHeight,c=0,d=0;if(i){o=i.width,l=i.height;const h=Up();(!h||h&&e==="fixed")&&(c=i.offsetLeft,d=i.offsetTop)}const f=$p(r);if(f<=0){const h=r.ownerDocument,m=h.body,g=getComputedStyle(m),y=h.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,C=Math.abs(r.clientWidth-m.clientWidth-y);C<=I5&&(o-=C)}else f<=I5&&(o+=f);return{width:o,height:l,x:c,y:d}}const qV=new Set(["absolute","fixed"]);function ZV(t,e){const n=Ws(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,o=_t(t)?la(t):ai(1),l=t.clientWidth*o.x,c=t.clientHeight*o.y,d=i*o.x,f=r*o.y;return{width:l,height:c,x:d,y:f}}function z5(t,e,n){let r;if(e==="viewport")r=$V(t,n);else if(e==="document")r=FV(pi(t));else if(yt(e))r=ZV(e,n);else{const i=bT(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return wa(r)}function wT(t,e){const n=Wi(t);return n===e||!yt(n)||Ki(n)?!1:Rr(n).position==="fixed"||wT(n,e)}function KV(t,e){const n=e.get(t);if(n)return n;let r=Yo(t,[],!1).filter(c=>yt(c)&&ss(c)!=="body"),i=null;const o=Rr(t).position==="fixed";let l=o?Wi(t):t;for(;yt(l)&&!Ki(l);){const c=Rr(l),d=N3(l);!d&&c.position==="fixed"&&(i=null),(o?!d&&!i:!d&&c.position==="static"&&!!i&&qV.has(i.position)||zu(l)&&!d&&wT(t,l))?r=r.filter(h=>h!==l):i=c,l=Wi(l)}return e.set(t,r),r}function GV(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const l=[...n==="clippingAncestors"?Vp(e)?[]:KV(e,this._c):[].concat(n),r],c=l[0],d=l.reduce((f,h)=>{const m=z5(e,h,i);return f.top=wn(m.top,f.top),f.right=$r(m.right,f.right),f.bottom=$r(m.bottom,f.bottom),f.left=wn(m.left,f.left),f},z5(e,c,i));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function YV(t){const{width:e,height:n}=vT(t);return{width:e,height:n}}function WV(t,e,n){const r=_t(e),i=pi(e),o=n==="fixed",l=Ws(t,!0,o,e);let c={scrollLeft:0,scrollTop:0};const d=ai(0);function f(){d.x=$p(i)}if(r||!r&&!o)if((ss(e)!=="body"||zu(i))&&(c=Pp(e)),r){const y=Ws(e,!0,o,e);d.x=y.x+e.clientLeft,d.y=y.y+e.clientTop}else i&&f();o&&!r&&i&&f();const h=i&&!r&&!o?CT(i,c):ai(0),m=l.left+c.scrollLeft-d.x-h.x,g=l.top+c.scrollTop-d.y-h.y;return{x:m,y:g,width:l.width,height:l.height}}function R0(t){return Rr(t).position==="static"}function B5(t,e){if(!_t(t)||Rr(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return pi(t)===n&&(n=n.ownerDocument.body),n}function xT(t,e){const n=Jn(t);if(Vp(t))return n;if(!_t(t)){let i=Wi(t);for(;i&&!Ki(i);){if(yt(i)&&!R0(i))return i;i=Wi(i)}return n}let r=B5(t,e);for(;r&&Oj(r)&&R0(r);)r=B5(r,e);return r&&Ki(r)&&R0(r)&&!N3(r)?n:r||Ij(t)||n}const JV=async function(t){const e=this.getOffsetParent||xT,n=this.getDimensions,r=await n(t.floating);return{reference:WV(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function XV(t){return Rr(t).direction==="rtl"}const QV={convertOffsetParentRelativeRectToViewportRelativeRect:UV,getDocumentElement:pi,getClippingRect:GV,getOffsetParent:xT,getElementRects:JV,getClientRects:PV,getDimensions:YV,getScale:la,isElement:yt,isRTL:XV};function ST(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function eU(t,e){let n=null,r;const i=pi(t);function o(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function l(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),o();const f=t.getBoundingClientRect(),{left:h,top:m,width:g,height:y}=f;if(c||e(),!g||!y)return;const C=ia(m),w=ia(i.clientWidth-(h+g)),x=ia(i.clientHeight-(m+y)),k=ia(h),N={rootMargin:-C+"px "+-w+"px "+-x+"px "+-k+"px",threshold:wn(0,$r(1,d))||1};let R=!0;function L(z){const _=z[0].intersectionRatio;if(_!==d){if(!R)return l();_?l(!1,_):r=setTimeout(()=>{l(!1,1e-7)},1e3)}_===1&&!ST(f,t.getBoundingClientRect())&&l(),R=!1}try{n=new IntersectionObserver(L,{...N,root:i.ownerDocument})}catch{n=new IntersectionObserver(L,N)}n.observe(t)}return l(!0),o}function qp(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=r,f=H3(t),h=i||o?[...f?Yo(f):[],...Yo(e)]:[];h.forEach(k=>{i&&k.addEventListener("scroll",n,{passive:!0}),o&&k.addEventListener("resize",n)});const m=f&&c?eU(f,n):null;let g=-1,y=null;l&&(y=new ResizeObserver(k=>{let[A]=k;A&&A.target===f&&y&&(y.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var N;(N=y)==null||N.observe(e)})),n()}),f&&!d&&y.observe(f),y.observe(e));let C,w=d?Ws(t):null;d&&x();function x(){const k=Ws(t);w&&!ST(w,k)&&n(),w=k,C=requestAnimationFrame(x)}return n(),()=>{var k;h.forEach(A=>{i&&A.removeEventListener("scroll",n),o&&A.removeEventListener("resize",n)}),m?.(),(k=y)==null||k.disconnect(),y=null,d&&cancelAnimationFrame(C)}}const Zp=HV,TT=NV,I3=IV,Kp=RV,Gp=BV,kT=OV,ET=MV,MT=LV,tU=zV,ju=(t,e,n)=>{const r=new Map,i={platform:QV,...n},o={...i.platform,_c:r};return EV(t,e,{...i,platform:o})};var nU=typeof document<"u",rU=function(){},Yf=nU?E.useLayoutEffect:rU;function Qh(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,i;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!Qh(t[r],e[r]))return!1;return!0}if(i=Object.keys(t),n=i.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=n;r--!==0;){const o=i[r];if(!(o==="_owner"&&t.$$typeof)&&!Qh(t[o],e[o]))return!1}return!0}return t!==t&&e!==e}function AT(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function j5(t,e){const n=AT(t);return Math.round(e*n)/n}function O0(t){const e=E.useRef(t);return Yf(()=>{e.current=t}),e}function iU(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:o,floating:l}={},transform:c=!0,whileElementsMounted:d,open:f}=t,[h,m]=E.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[g,y]=E.useState(r);Qh(g,r)||y(r);const[C,w]=E.useState(null),[x,k]=E.useState(null),A=E.useCallback(B=>{B!==z.current&&(z.current=B,w(B))},[]),N=E.useCallback(B=>{B!==_.current&&(_.current=B,k(B))},[]),R=o||C,L=l||x,z=E.useRef(null),_=E.useRef(null),q=E.useRef(h),J=d!=null,U=O0(d),ne=O0(i),le=O0(f),oe=E.useCallback(()=>{if(!z.current||!_.current)return;const B={placement:e,strategy:n,middleware:g};ne.current&&(B.platform=ne.current),ju(z.current,_.current,B).then(re=>{const ae={...re,isPositioned:le.current!==!1};G.current&&!Qh(q.current,ae)&&(q.current=ae,Oa.flushSync(()=>{m(ae)}))})},[g,e,n,ne,le]);Yf(()=>{f===!1&&q.current.isPositioned&&(q.current.isPositioned=!1,m(B=>({...B,isPositioned:!1})))},[f]);const G=E.useRef(!1);Yf(()=>(G.current=!0,()=>{G.current=!1}),[]),Yf(()=>{if(R&&(z.current=R),L&&(_.current=L),R&&L){if(U.current)return U.current(R,L,oe);oe()}},[R,L,oe,U,J]);const P=E.useMemo(()=>({reference:z,floating:_,setReference:A,setFloating:N}),[A,N]),H=E.useMemo(()=>({reference:R,floating:L}),[R,L]),j=E.useMemo(()=>{const B={position:n,left:0,top:0};if(!H.floating)return B;const re=j5(H.floating,h.x),ae=j5(H.floating,h.y);return c?{...B,transform:"translate("+re+"px, "+ae+"px)",...AT(H.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:re,top:ae}},[n,c,H.floating,h.x,h.y]);return E.useMemo(()=>({...h,update:oe,refs:P,elements:H,floatingStyles:j}),[h,oe,P,H,j])}const Yp=(t,e)=>({...Zp(t),options:[t,e]}),z3=(t,e)=>({...I3(t),options:[t,e]}),oU=(t,e)=>({...tU(t),options:[t,e]}),B3=(t,e)=>({...Kp(t),options:[t,e]}),NT=(t,e)=>({...Gp(t),options:[t,e]});function ol(t){const e=E.useRef(void 0),n=E.useCallback(r=>{const i=t.map(o=>{if(o!=null){if(typeof o=="function"){const l=o,c=l(r);return typeof c=="function"?c:()=>{l(null)}}return o.current=r,()=>{o.current=null}}});return()=>{i.forEach(o=>o?.())}},t);return E.useMemo(()=>t.every(r=>r==null)?null:r=>{e.current&&(e.current(),e.current=void 0),r!=null&&(e.current=n(r))},t)}function sU(t,e){const n=t.compareDocumentPosition(e);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const RT=E.createContext({register:()=>{},unregister:()=>{},map:new Map,elementsRef:{current:[]}});function lU(t){const{children:e,elementsRef:n,labelsRef:r}=t,[i,o]=E.useState(()=>new Set),l=E.useCallback(f=>{o(h=>new Set(h).add(f))},[]),c=E.useCallback(f=>{o(h=>{const m=new Set(h);return m.delete(f),m})},[]),d=E.useMemo(()=>{const f=new Map;return Array.from(i.keys()).sort(sU).forEach((m,g)=>{f.set(m,g)}),f},[i]);return S.jsx(RT.Provider,{value:E.useMemo(()=>({register:l,unregister:c,map:d,elementsRef:n,labelsRef:r}),[l,c,d,n,r]),children:e})}function aU(t){t===void 0&&(t={});const{label:e}=t,{register:n,unregister:r,map:i,elementsRef:o,labelsRef:l}=E.useContext(RT),[c,d]=E.useState(null),f=E.useRef(null),h=E.useCallback(m=>{if(f.current=m,c!==null&&(o.current[c]=m,l)){var g;const y=e!==void 0;l.current[c]=y?e:(g=m?.textContent)!=null?g:null}},[c,o,l,e]);return ft(()=>{const m=f.current;if(m)return n(m),()=>{r(m)}},[n,r]),ft(()=>{const m=f.current?i.get(f.current):null;m!=null&&d(m)},[i]),E.useMemo(()=>({ref:h,index:c??-1}),[c,h])}const cU="data-floating-ui-focusable",V5="active",U5="selected",Vu="ArrowLeft",Uu="ArrowRight",OT="ArrowUp",Wp="ArrowDown",uU={...n9};let P5=!1,dU=0;const F5=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+dU++;function fU(){const[t,e]=E.useState(()=>P5?F5():void 0);return ft(()=>{t==null&&e(F5())},[]),E.useEffect(()=>{P5=!0},[]),t}const hU=uU.useId,j3=hU||fU;function pU(){const t=new Map;return{emit(e,n){var r;(r=t.get(e))==null||r.forEach(i=>i(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var r;(r=t.get(e))==null||r.delete(n)}}}const mU=E.createContext(null),gU=E.createContext(null),Jp=()=>{var t;return((t=E.useContext(mU))==null?void 0:t.id)||null},Pu=()=>E.useContext(gU);function Js(t){return"data-floating-ui-"+t}function On(t){t.current!==-1&&(clearTimeout(t.current),t.current=-1)}const $5=Js("safe-polygon");function D0(t,e,n){if(n&&!vu(n))return 0;if(typeof t=="number")return t;if(typeof t=="function"){const r=t();return typeof r=="number"?r:r?.[e]}return t?.[e]}function L0(t){return typeof t=="function"?t():t}function yU(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,dataRef:i,events:o,elements:l}=t,{enabled:c=!0,delay:d=0,handleClose:f=null,mouseOnly:h=!1,restMs:m=0,move:g=!0}=e,y=Pu(),C=Jp(),w=Zn(f),x=Zn(d),k=Zn(n),A=Zn(m),N=E.useRef(),R=E.useRef(-1),L=E.useRef(),z=E.useRef(-1),_=E.useRef(!0),q=E.useRef(!1),J=E.useRef(()=>{}),U=E.useRef(!1),ne=Ht(()=>{var j;const B=(j=i.current.openEvent)==null?void 0:j.type;return B?.includes("mouse")&&B!=="mousedown"});E.useEffect(()=>{if(!c)return;function j(B){let{open:re}=B;re||(On(R),On(z),_.current=!0,U.current=!1)}return o.on("openchange",j),()=>{o.off("openchange",j)}},[c,o]),E.useEffect(()=>{if(!c||!w.current||!n)return;function j(re){ne()&&r(!1,re,"hover")}const B=gn(l.floating).documentElement;return B.addEventListener("mouseleave",j),()=>{B.removeEventListener("mouseleave",j)}},[l.floating,n,r,c,w,ne]);const le=E.useCallback(function(j,B,re){B===void 0&&(B=!0),re===void 0&&(re="hover");const ae=D0(x.current,"close",N.current);ae&&!L.current?(On(R),R.current=window.setTimeout(()=>r(!1,j,re),ae)):B&&(On(R),r(!1,j,re))},[x,r]),oe=Ht(()=>{J.current(),L.current=void 0}),G=Ht(()=>{if(q.current){const j=gn(l.floating).body;j.style.pointerEvents="",j.removeAttribute($5),q.current=!1}}),P=Ht(()=>i.current.openEvent?["click","mousedown"].includes(i.current.openEvent.type):!1);E.useEffect(()=>{if(!c)return;function j(Z){if(On(R),_.current=!1,h&&!vu(N.current)||L0(A.current)>0&&!D0(x.current,"open"))return;const W=D0(x.current,"open",N.current);W?R.current=window.setTimeout(()=>{k.current||r(!0,Z,"hover")},W):n||r(!0,Z,"hover")}function B(Z){if(P()){G();return}J.current();const W=gn(l.floating);if(On(z),U.current=!1,w.current&&i.current.floatingContext){n||On(R),L.current=w.current({...i.current.floatingContext,tree:y,x:Z.clientX,y:Z.clientY,onClose(){G(),oe(),P()||le(Z,!0,"safe-polygon")}});const de=L.current;W.addEventListener("mousemove",de),J.current=()=>{W.removeEventListener("mousemove",de)};return}(N.current!=="touch"||!fn(l.floating,Z.relatedTarget))&&le(Z)}function re(Z){P()||i.current.floatingContext&&(w.current==null||w.current({...i.current.floatingContext,tree:y,x:Z.clientX,y:Z.clientY,onClose(){G(),oe(),P()||le(Z)}})(Z))}function ae(){On(R)}function D(Z){P()||le(Z,!1)}if(yt(l.domReference)){const Z=l.domReference,W=l.floating;return n&&Z.addEventListener("mouseleave",re),g&&Z.addEventListener("mousemove",j,{once:!0}),Z.addEventListener("mouseenter",j),Z.addEventListener("mouseleave",B),W&&(W.addEventListener("mouseleave",re),W.addEventListener("mouseenter",ae),W.addEventListener("mouseleave",D)),()=>{n&&Z.removeEventListener("mouseleave",re),g&&Z.removeEventListener("mousemove",j),Z.removeEventListener("mouseenter",j),Z.removeEventListener("mouseleave",B),W&&(W.removeEventListener("mouseleave",re),W.removeEventListener("mouseenter",ae),W.removeEventListener("mouseleave",D))}}},[l,c,t,h,g,le,oe,G,r,n,k,y,x,w,i,P,A]),ft(()=>{var j;if(c&&n&&(j=w.current)!=null&&(j=j.__options)!=null&&j.blockPointerEvents&&ne()){q.current=!0;const re=l.floating;if(yt(l.domReference)&&re){var B;const ae=gn(l.floating).body;ae.setAttribute($5,"");const D=l.domReference,Z=y==null||(B=y.nodesRef.current.find(W=>W.id===C))==null||(B=B.context)==null?void 0:B.elements.floating;return Z&&(Z.style.pointerEvents=""),ae.style.pointerEvents="none",D.style.pointerEvents="auto",re.style.pointerEvents="auto",()=>{ae.style.pointerEvents="",D.style.pointerEvents="",re.style.pointerEvents=""}}}},[c,n,C,l,y,w,ne]),ft(()=>{n||(N.current=void 0,U.current=!1,oe(),G())},[n,oe,G]),E.useEffect(()=>()=>{oe(),On(R),On(z),G()},[c,l.domReference,oe,G]);const H=E.useMemo(()=>{function j(B){N.current=B.pointerType}return{onPointerDown:j,onPointerEnter:j,onMouseMove(B){const{nativeEvent:re}=B;function ae(){!_.current&&!k.current&&r(!0,re,"hover")}h&&!vu(N.current)||n||L0(A.current)===0||U.current&&B.movementX**2+B.movementY**2<2||(On(z),N.current==="touch"?ae():(U.current=!0,z.current=window.setTimeout(ae,L0(A.current))))}}},[h,r,n,k,A]);return E.useMemo(()=>c?{reference:H}:{},[c,H])}const q5=()=>{},vU=E.createContext({delay:0,initialDelay:0,timeoutMs:0,currentId:null,setCurrentId:q5,setState:q5,isInstantPhase:!1});function bU(t){const{children:e,delay:n,timeoutMs:r=0}=t,[i,o]=E.useReducer((d,f)=>({...d,...f}),{delay:n,timeoutMs:r,initialDelay:n,currentId:null,isInstantPhase:!1}),l=E.useRef(null),c=E.useCallback(d=>{o({currentId:d})},[]);return ft(()=>{i.currentId?l.current===null?l.current=i.currentId:i.isInstantPhase||o({isInstantPhase:!0}):(i.isInstantPhase&&o({isInstantPhase:!1}),l.current=null)},[i.currentId,i.isInstantPhase]),S.jsx(vU.Provider,{value:E.useMemo(()=>({...i,setState:o,setCurrentId:c}),[i,c]),children:e})}let Z5=0;function Rs(t,e){e===void 0&&(e={});const{preventScroll:n=!1,cancelPrevious:r=!0,sync:i=!1}=e;r&&cancelAnimationFrame(Z5);const o=()=>t?.focus({preventScroll:n});i?o():Z5=requestAnimationFrame(o)}function CU(t){return t?.ownerDocument||document}const aa={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function K5(t){return t==="inert"?aa.inert:t==="aria-hidden"?aa["aria-hidden"]:aa.none}let Rf=new WeakSet,Of={},_0=0;const wU=()=>typeof HTMLElement<"u"&&"inert"in HTMLElement.prototype,DT=t=>t&&(t.host||DT(t.parentNode)),xU=(t,e)=>e.map(n=>{if(t.contains(n))return n;const r=DT(n);return t.contains(r)?r:null}).filter(n=>n!=null);function SU(t,e,n,r){const i="data-floating-ui-inert",o=r?"inert":n?"aria-hidden":null,l=xU(e,t),c=new Set,d=new Set(l),f=[];Of[i]||(Of[i]=new WeakMap);const h=Of[i];l.forEach(m),g(e),c.clear();function m(y){!y||c.has(y)||(c.add(y),y.parentNode&&m(y.parentNode))}function g(y){!y||d.has(y)||[].forEach.call(y.children,C=>{if(ss(C)!=="script")if(c.has(C))g(C);else{const w=o?C.getAttribute(o):null,x=w!==null&&w!=="false",k=K5(o),A=(k.get(C)||0)+1,N=(h.get(C)||0)+1;k.set(C,A),h.set(C,N),f.push(C),A===1&&x&&Rf.add(C),N===1&&C.setAttribute(i,""),!x&&o&&C.setAttribute(o,o==="inert"?"":"true")}})}return _0++,()=>{f.forEach(y=>{const C=K5(o),x=(C.get(y)||0)-1,k=(h.get(y)||0)-1;C.set(y,x),h.set(y,k),x||(!Rf.has(y)&&o&&y.removeAttribute(o),Rf.delete(y)),k||y.removeAttribute(i)}),_0--,_0||(aa.inert=new WeakMap,aa["aria-hidden"]=new WeakMap,aa.none=new WeakMap,Rf=new WeakSet,Of={})}}function G5(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);const r=CU(t[0]).body;return SU(t.concat(Array.from(r.querySelectorAll('[aria-live],[role="status"],output'))),r,e,n)}const Xp={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},ep=E.forwardRef(function(e,n){const[r,i]=E.useState();ft(()=>{cT()&&i("button")},[]);const o={ref:n,tabIndex:0,role:r,"aria-hidden":r?void 0:!0,[Js("focus-guard")]:"",style:Xp};return S.jsx("span",{...e,...o})}),LT=E.createContext(null),Y5=Js("portal");function TU(t){t===void 0&&(t={});const{id:e,root:n}=t,r=j3(),i=_T(),[o,l]=E.useState(null),c=E.useRef(null);return ft(()=>()=>{o?.remove(),queueMicrotask(()=>{c.current=null})},[o]),ft(()=>{if(!r||c.current)return;const d=e?document.getElementById(e):null;if(!d)return;const f=document.createElement("div");f.id=r,f.setAttribute(Y5,""),d.appendChild(f),c.current=f,l(f)},[e,r]),ft(()=>{if(n===null||!r||c.current)return;let d=n||i?.portalNode;d&&!A3(d)&&(d=d.current),d=d||document.body;let f=null;e&&(f=document.createElement("div"),f.id=e,d.appendChild(f));const h=document.createElement("div");h.id=r,h.setAttribute(Y5,""),d=f||d,d.appendChild(h),c.current=h,l(h)},[e,n,r,i]),o}function Qp(t){const{children:e,id:n,root:r,preserveTabOrder:i=!0}=t,o=TU({id:n,root:r}),[l,c]=E.useState(null),d=E.useRef(null),f=E.useRef(null),h=E.useRef(null),m=E.useRef(null),g=l?.modal,y=l?.open,C=!!l&&!l.modal&&l.open&&i&&!!(r||o);return E.useEffect(()=>{if(!o||!i||g)return;function w(x){o&&nu(x)&&(x.type==="focusin"?D5:kV)(o)}return o.addEventListener("focusin",w,!0),o.addEventListener("focusout",w,!0),()=>{o.removeEventListener("focusin",w,!0),o.removeEventListener("focusout",w,!0)}},[o,i,g]),E.useEffect(()=>{o&&(y||D5(o))},[y,o]),S.jsxs(LT.Provider,{value:E.useMemo(()=>({preserveTabOrder:i,beforeOutsideRef:d,afterOutsideRef:f,beforeInsideRef:h,afterInsideRef:m,portalNode:o,setFocusManagerState:c}),[i,o]),children:[C&&o&&S.jsx(ep,{"data-type":"outside",ref:d,onFocus:w=>{if(nu(w,o)){var x;(x=h.current)==null||x.focus()}else{const k=l?l.domReference:null,A=mT(k);A?.focus()}}}),C&&o&&S.jsx("span",{"aria-owns":o.id,style:Xp}),o&&Oa.createPortal(e,o),C&&o&&S.jsx(ep,{"data-type":"outside",ref:f,onFocus:w=>{if(nu(w,o)){var x;(x=m.current)==null||x.focus()}else{const k=l?l.domReference:null,A=pT(k);A?.focus(),l?.closeOnFocusOut&&l?.onOpenChange(!1,w.nativeEvent,"focus-out")}}})]})}const _T=()=>E.useContext(LT);function W5(t){return E.useMemo(()=>e=>{t.forEach(n=>{n&&(n.current=e)})},t)}const kU=20;let Fo=[];function V3(){Fo=Fo.filter(t=>t.isConnected)}function EU(t){V3(),t&&ss(t)!=="body"&&(Fo.push(t),Fo.length>kU&&(Fo=Fo.slice(-20)))}function J5(){return V3(),Fo[Fo.length-1]}function MU(t){const e=Bu();return sT(t,e)?t:Fp(t,e)[0]||t}function X5(t,e){var n;if(!e.current.includes("floating")&&!((n=t.getAttribute("role"))!=null&&n.includes("dialog")))return;const r=Bu(),o=lV(t,r).filter(c=>{const d=c.getAttribute("data-tabindex")||"";return sT(c,r)||c.hasAttribute("data-tabindex")&&!d.startsWith("-")}),l=t.getAttribute("tabindex");e.current.includes("floating")||o.length===0?l!=="0"&&t.setAttribute("tabindex","0"):(l!=="-1"||t.hasAttribute("data-tabindex")&&t.getAttribute("data-tabindex")!=="-1")&&(t.setAttribute("tabindex","-1"),t.setAttribute("data-tabindex","-1"))}const AU=E.forwardRef(function(e,n){return S.jsx("button",{...e,type:"button",ref:n,tabIndex:-1,style:Xp})});function HT(t){const{context:e,children:n,disabled:r=!1,order:i=["content"],guards:o=!0,initialFocus:l=0,returnFocus:c=!0,restoreFocus:d=!1,modal:f=!0,visuallyHiddenDismiss:h=!1,closeOnFocusOut:m=!0,outsideElementsInert:g=!1,getInsideElements:y=()=>[]}=t,{open:C,onOpenChange:w,events:x,dataRef:k,elements:{domReference:A,floating:N}}=e,R=Ht(()=>{var Me;return(Me=k.current.floatingContext)==null?void 0:Me.nodeId}),L=Ht(y),z=typeof l=="number"&&l<0,_=K2(A)&&z,q=wU(),J=q?o:!0,U=!J||q&&g,ne=Zn(i),le=Zn(l),oe=Zn(c),G=Pu(),P=_T(),H=E.useRef(null),j=E.useRef(null),B=E.useRef(!1),re=E.useRef(!1),ae=E.useRef(-1),D=E.useRef(-1),Z=P!=null,W=Xh(N),se=Ht(function(Me){return Me===void 0&&(Me=W),Me?Fp(Me,Bu()):[]}),de=Ht(Me=>{const He=se(Me);return ne.current.map(Te=>A&&Te==="reference"?A:W&&Te==="floating"?W:He).filter(Boolean).flat()});E.useEffect(()=>{if(r||!f)return;function Me(Te){if(Te.key==="Tab"){fn(W,li(gn(W)))&&se().length===0&&!_&&hn(Te);const nt=de(),ht=Pi(Te);ne.current[0]==="reference"&&ht===A&&(hn(Te),Te.shiftKey?Rs(nt[nt.length-1]):Rs(nt[1])),ne.current[1]==="floating"&&ht===W&&Te.shiftKey&&(hn(Te),Rs(nt[0]))}}const He=gn(W);return He.addEventListener("keydown",Me),()=>{He.removeEventListener("keydown",Me)}},[r,A,W,f,ne,_,se,de]),E.useEffect(()=>{if(r||!N)return;function Me(He){const Te=Pi(He),ht=se().indexOf(Te);ht!==-1&&(ae.current=ht)}return N.addEventListener("focusin",Me),()=>{N.removeEventListener("focusin",Me)}},[r,N,se]),E.useEffect(()=>{if(r||!m)return;function Me(){re.current=!0,setTimeout(()=>{re.current=!1})}function He(ht){const Be=ht.relatedTarget,Gt=ht.currentTarget,Ot=Pi(ht);queueMicrotask(()=>{const zt=R(),Hn=!(fn(A,Be)||fn(N,Be)||fn(Be,N)||fn(P?.portalNode,Be)||Be!=null&&Be.hasAttribute(Js("focus-guard"))||G&&(Us(G.nodesRef.current,zt).find(ve=>{var Re,fe;return fn((Re=ve.context)==null?void 0:Re.elements.floating,Be)||fn((fe=ve.context)==null?void 0:fe.elements.domReference,Be)})||R5(G.nodesRef.current,zt).find(ve=>{var Re,fe,Ye;return[(Re=ve.context)==null?void 0:Re.elements.floating,Xh((fe=ve.context)==null?void 0:fe.elements.floating)].includes(Be)||((Ye=ve.context)==null?void 0:Ye.elements.domReference)===Be})));if(Gt===A&&W&&X5(W,ne),d&&Gt!==A&&!(Ot!=null&&Ot.isConnected)&&li(gn(W))===gn(W).body){_t(W)&&W.focus();const ve=ae.current,Re=se(),fe=Re[ve]||Re[Re.length-1]||W;_t(fe)&&fe.focus()}if(k.current.insideReactTree){k.current.insideReactTree=!1;return}(_||!f)&&Be&&Hn&&!re.current&&Be!==J5()&&(B.current=!0,w(!1,ht,"focus-out"))})}const Te=!!(!G&&P);function nt(){On(D),k.current.insideReactTree=!0,D.current=window.setTimeout(()=>{k.current.insideReactTree=!1})}if(N&&_t(A))return A.addEventListener("focusout",He),A.addEventListener("pointerdown",Me),N.addEventListener("focusout",He),Te&&N.addEventListener("focusout",nt,!0),()=>{A.removeEventListener("focusout",He),A.removeEventListener("pointerdown",Me),N.removeEventListener("focusout",He),Te&&N.removeEventListener("focusout",nt,!0)}},[r,A,N,W,f,G,P,w,m,d,se,_,R,ne,k]);const ye=E.useRef(null),Ee=E.useRef(null),Rt=W5([ye,P?.beforeInsideRef]),tt=W5([Ee,P?.afterInsideRef]);E.useEffect(()=>{var Me,He;if(r||!N)return;const Te=Array.from((P==null||(Me=P.portalNode)==null?void 0:Me.querySelectorAll("["+Js("portal")+"]"))||[]),ht=(He=(G?R5(G.nodesRef.current,R()):[]).find(Ot=>{var zt;return K2(((zt=Ot.context)==null?void 0:zt.elements.domReference)||null)}))==null||(He=He.context)==null?void 0:He.elements.domReference,Be=[N,ht,...Te,...L(),H.current,j.current,ye.current,Ee.current,P?.beforeOutsideRef.current,P?.afterOutsideRef.current,ne.current.includes("reference")||_?A:null].filter(Ot=>Ot!=null),Gt=f||_?G5(Be,!U,U):G5(Be);return()=>{Gt()}},[r,A,N,f,ne,P,_,J,U,G,R,L]),ft(()=>{if(r||!_t(W))return;const Me=gn(W),He=li(Me);queueMicrotask(()=>{const Te=de(W),nt=le.current,ht=(typeof nt=="number"?Te[nt]:nt.current)||W,Be=fn(W,He);!z&&!Be&&C&&Rs(ht,{preventScroll:ht===W})})},[r,C,W,z,de,le]),ft(()=>{if(r||!W)return;const Me=gn(W),He=li(Me);EU(He);function Te(Be){let{reason:Gt,event:Ot,nested:zt}=Be;if(["hover","safe-polygon"].includes(Gt)&&Ot.type==="mouseleave"&&(B.current=!0),Gt==="outside-press")if(zt)B.current=!1;else if(dT(Ot)||fT(Ot))B.current=!1;else{let Hn=!1;document.createElement("div").focus({get preventScroll(){return Hn=!0,!1}}),Hn?B.current=!1:B.current=!0}}x.on("openchange",Te);const nt=Me.createElement("span");nt.setAttribute("tabindex","-1"),nt.setAttribute("aria-hidden","true"),Object.assign(nt.style,Xp),Z&&A&&A.insertAdjacentElement("afterend",nt);function ht(){if(typeof oe.current=="boolean"){const Be=A||J5();return Be&&Be.isConnected?Be:nt}return oe.current.current||nt}return()=>{x.off("openchange",Te);const Be=li(Me),Gt=fn(N,Be)||G&&Us(G.nodesRef.current,R(),!1).some(zt=>{var Hn;return fn((Hn=zt.context)==null?void 0:Hn.elements.floating,Be)}),Ot=ht();queueMicrotask(()=>{const zt=MU(Ot);oe.current&&!B.current&&_t(zt)&&(!(zt!==Be&&Be!==Me.body)||Gt)&&zt.focus({preventScroll:!0}),nt.remove()})}},[r,N,W,oe,k,x,G,Z,A,R]),E.useEffect(()=>(queueMicrotask(()=>{B.current=!1}),()=>{queueMicrotask(V3)}),[r]),ft(()=>{if(!r&&P)return P.setFocusManagerState({modal:f,closeOnFocusOut:m,open:C,onOpenChange:w,domReference:A}),()=>{P.setFocusManagerState(null)}},[r,P,f,C,w,m,A]),ft(()=>{r||W&&X5(W,ne)},[r,W,ne]);function Nn(Me){return r||!h||!f?null:S.jsx(AU,{ref:Me==="start"?H:j,onClick:He=>w(!1,He.nativeEvent),children:typeof h=="string"?h:"Dismiss"})}const Or=!r&&J&&(f?!_:!0)&&(Z||f);return S.jsxs(S.Fragment,{children:[Or&&S.jsx(ep,{"data-type":"inside",ref:Rt,onFocus:Me=>{if(f){const Te=de();Rs(i[0]==="reference"?Te[0]:Te[Te.length-1])}else if(P!=null&&P.preserveTabOrder&&P.portalNode)if(B.current=!1,nu(Me,P.portalNode)){const Te=pT(A);Te?.focus()}else{var He;(He=P.beforeOutsideRef.current)==null||He.focus()}}}),!_&&Nn("start"),n,Nn("end"),Or&&S.jsx(ep,{"data-type":"inside",ref:tt,onFocus:Me=>{if(f)Rs(de()[0]);else if(P!=null&&P.preserveTabOrder&&P.portalNode)if(m&&(B.current=!0),nu(Me,P.portalNode)){const Te=mT(A);Te?.focus()}else{var He;(He=P.afterOutsideRef.current)==null||He.focus()}}})]})}function Q5(t){return _t(t.target)&&t.target.tagName==="BUTTON"}function NU(t){return _t(t.target)&&t.target.tagName==="A"}function e6(t){return _3(t)}function IT(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,dataRef:i,elements:{domReference:o}}=t,{enabled:l=!0,event:c="click",toggle:d=!0,ignoreMouse:f=!1,keyboardHandlers:h=!0,stickIfOpen:m=!0}=e,g=E.useRef(),y=E.useRef(!1),C=E.useMemo(()=>({onPointerDown(w){g.current=w.pointerType},onMouseDown(w){const x=g.current;w.button===0&&c!=="click"&&(vu(x,!0)&&f||(n&&d&&(!(i.current.openEvent&&m)||i.current.openEvent.type==="mousedown")?r(!1,w.nativeEvent,"click"):(w.preventDefault(),r(!0,w.nativeEvent,"click"))))},onClick(w){const x=g.current;if(c==="mousedown"&&g.current){g.current=void 0;return}vu(x,!0)&&f||(n&&d&&(!(i.current.openEvent&&m)||i.current.openEvent.type==="click")?r(!1,w.nativeEvent,"click"):r(!0,w.nativeEvent,"click"))},onKeyDown(w){g.current=void 0,!(w.defaultPrevented||!h||Q5(w))&&(w.key===" "&&!e6(o)&&(w.preventDefault(),y.current=!0),!NU(w)&&w.key==="Enter"&&r(!(n&&d),w.nativeEvent,"click"))},onKeyUp(w){w.defaultPrevented||!h||Q5(w)||e6(o)||w.key===" "&&y.current&&(y.current=!1,r(!(n&&d),w.nativeEvent,"click"))}}),[i,o,c,f,h,r,n,m,d]);return E.useMemo(()=>l?{reference:C}:{},[l,C])}const RU={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},OU={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},t6=t=>{var e,n;return{escapeKey:typeof t=="boolean"?t:(e=t?.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(n=t?.outsidePress)!=null?n:!0}};function U3(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,elements:i,dataRef:o}=t,{enabled:l=!0,escapeKey:c=!0,outsidePress:d=!0,outsidePressEvent:f="pointerdown",referencePress:h=!1,referencePressEvent:m="pointerdown",ancestorScroll:g=!1,bubbles:y,capture:C}=e,w=Pu(),x=Ht(typeof d=="function"?d:()=>!1),k=typeof d=="function"?x:d,A=E.useRef(!1),{escapeKey:N,outsidePress:R}=t6(y),{escapeKey:L,outsidePress:z}=t6(C),_=E.useRef(!1),q=Ht(G=>{var P;if(!n||!l||!c||G.key!=="Escape"||_.current)return;const H=(P=o.current.floatingContext)==null?void 0:P.nodeId,j=w?Us(w.nodesRef.current,H):[];if(!N&&(G.stopPropagation(),j.length>0)){let B=!0;if(j.forEach(re=>{var ae;if((ae=re.context)!=null&&ae.open&&!re.context.dataRef.current.__escapeKeyBubbles){B=!1;return}}),!B)return}r(!1,mV(G)?G.nativeEvent:G,"escape-key")}),J=Ht(G=>{var P;const H=()=>{var j;q(G),(j=Pi(G))==null||j.removeEventListener("keydown",H)};(P=Pi(G))==null||P.addEventListener("keydown",H)}),U=Ht(G=>{var P;const H=o.current.insideReactTree;o.current.insideReactTree=!1;const j=A.current;if(A.current=!1,f==="click"&&j||H||typeof k=="function"&&!k(G))return;const B=Pi(G),re="["+Js("inert")+"]",ae=gn(i.floating).querySelectorAll(re);let D=yt(B)?B:null;for(;D&&!Ki(D);){const de=Wi(D);if(Ki(de)||!yt(de))break;D=de}if(ae.length&&yt(B)&&!fV(B)&&!fn(B,i.floating)&&Array.from(ae).every(de=>!fn(D,de)))return;if(_t(B)&&oe){const de=Ki(B),ye=Rr(B),Ee=/auto|scroll/,Rt=de||Ee.test(ye.overflowX),tt=de||Ee.test(ye.overflowY),Nn=Rt&&B.clientWidth>0&&B.scrollWidth>B.clientWidth,Or=tt&&B.clientHeight>0&&B.scrollHeight>B.clientHeight,Me=ye.direction==="rtl",He=Or&&(Me?G.offsetX<=B.offsetWidth-B.clientWidth:G.offsetX>B.clientWidth),Te=Nn&&G.offsetY>B.clientHeight;if(He||Te)return}const Z=(P=o.current.floatingContext)==null?void 0:P.nodeId,W=w&&Us(w.nodesRef.current,Z).some(de=>{var ye;return A0(G,(ye=de.context)==null?void 0:ye.elements.floating)});if(A0(G,i.floating)||A0(G,i.domReference)||W)return;const se=w?Us(w.nodesRef.current,Z):[];if(se.length>0){let de=!0;if(se.forEach(ye=>{var Ee;if((Ee=ye.context)!=null&&Ee.open&&!ye.context.dataRef.current.__outsidePressBubbles){de=!1;return}}),!de)return}r(!1,G,"outside-press")}),ne=Ht(G=>{var P;const H=()=>{var j;U(G),(j=Pi(G))==null||j.removeEventListener(f,H)};(P=Pi(G))==null||P.addEventListener(f,H)});E.useEffect(()=>{if(!n||!l)return;o.current.__escapeKeyBubbles=N,o.current.__outsidePressBubbles=R;let G=-1;function P(ae){r(!1,ae,"ancestor-scroll")}function H(){window.clearTimeout(G),_.current=!0}function j(){G=window.setTimeout(()=>{_.current=!1},Up()?5:0)}const B=gn(i.floating);c&&(B.addEventListener("keydown",L?J:q,L),B.addEventListener("compositionstart",H),B.addEventListener("compositionend",j)),k&&B.addEventListener(f,z?ne:U,z);let re=[];return g&&(yt(i.domReference)&&(re=Yo(i.domReference)),yt(i.floating)&&(re=re.concat(Yo(i.floating))),!yt(i.reference)&&i.reference&&i.reference.contextElement&&(re=re.concat(Yo(i.reference.contextElement)))),re=re.filter(ae=>{var D;return ae!==((D=B.defaultView)==null?void 0:D.visualViewport)}),re.forEach(ae=>{ae.addEventListener("scroll",P,{passive:!0})}),()=>{c&&(B.removeEventListener("keydown",L?J:q,L),B.removeEventListener("compositionstart",H),B.removeEventListener("compositionend",j)),k&&B.removeEventListener(f,z?ne:U,z),re.forEach(ae=>{ae.removeEventListener("scroll",P)}),window.clearTimeout(G)}},[o,i,c,k,f,n,r,g,l,N,R,q,L,J,U,z,ne]),E.useEffect(()=>{o.current.insideReactTree=!1},[o,k,f]);const le=E.useMemo(()=>({onKeyDown:q,...h&&{[RU[m]]:G=>{r(!1,G.nativeEvent,"reference-press")},...m!=="click"&&{onClick(G){r(!1,G.nativeEvent,"reference-press")}}}}),[q,r,h,m]),oe=E.useMemo(()=>({onKeyDown:q,onMouseDown(){A.current=!0},onMouseUp(){A.current=!0},[OU[f]]:()=>{o.current.insideReactTree=!0}}),[q,f,o]);return E.useMemo(()=>l?{reference:le,floating:oe}:{},[l,le,oe])}function DU(t){const{open:e=!1,onOpenChange:n,elements:r}=t,i=j3(),o=E.useRef({}),[l]=E.useState(()=>pU()),c=Jp()!=null,[d,f]=E.useState(r.reference),h=Ht((y,C,w)=>{o.current.openEvent=y?C:void 0,l.emit("openchange",{open:y,event:C,reason:w,nested:c}),n?.(y,C,w)}),m=E.useMemo(()=>({setPositionReference:f}),[]),g=E.useMemo(()=>({reference:d||r.reference||null,floating:r.floating||null,domReference:r.reference}),[d,r.reference,r.floating]);return E.useMemo(()=>({dataRef:o,open:e,onOpenChange:h,elements:g,events:l,floatingId:i,refs:m}),[e,h,g,l,i,m])}function e1(t){t===void 0&&(t={});const{nodeId:e}=t,n=DU({...t,elements:{reference:null,floating:null,...t.elements}}),r=t.rootContext||n,i=r.elements,[o,l]=E.useState(null),[c,d]=E.useState(null),h=i?.domReference||o,m=E.useRef(null),g=Pu();ft(()=>{h&&(m.current=h)},[h]);const y=iU({...t,elements:{...i,...c&&{reference:c}}}),C=E.useCallback(N=>{const R=yt(N)?{getBoundingClientRect:()=>N.getBoundingClientRect(),getClientRects:()=>N.getClientRects(),contextElement:N}:N;d(R),y.refs.setReference(R)},[y.refs]),w=E.useCallback(N=>{(yt(N)||N===null)&&(m.current=N,l(N)),(yt(y.refs.reference.current)||y.refs.reference.current===null||N!==null&&!yt(N))&&y.refs.setReference(N)},[y.refs]),x=E.useMemo(()=>({...y.refs,setReference:w,setPositionReference:C,domReference:m}),[y.refs,w,C]),k=E.useMemo(()=>({...y.elements,domReference:h}),[y.elements,h]),A=E.useMemo(()=>({...y,...r,refs:x,elements:k,nodeId:e}),[y,x,k,e,r]);return ft(()=>{r.dataRef.current.floatingContext=A;const N=g?.nodesRef.current.find(R=>R.id===e);N&&(N.context=A)}),E.useMemo(()=>({...y,context:A,refs:x,elements:k}),[y,x,k,A])}function H0(){return aV()&&cT()}function LU(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,events:i,dataRef:o,elements:l}=t,{enabled:c=!0,visibleOnly:d=!0}=e,f=E.useRef(!1),h=E.useRef(-1),m=E.useRef(!0);E.useEffect(()=>{if(!c)return;const y=Jn(l.domReference);function C(){!n&&_t(l.domReference)&&l.domReference===li(gn(l.domReference))&&(f.current=!0)}function w(){m.current=!0}function x(){m.current=!1}return y.addEventListener("blur",C),H0()&&(y.addEventListener("keydown",w,!0),y.addEventListener("pointerdown",x,!0)),()=>{y.removeEventListener("blur",C),H0()&&(y.removeEventListener("keydown",w,!0),y.removeEventListener("pointerdown",x,!0))}},[l.domReference,n,c]),E.useEffect(()=>{if(!c)return;function y(C){let{reason:w}=C;(w==="reference-press"||w==="escape-key")&&(f.current=!0)}return i.on("openchange",y),()=>{i.off("openchange",y)}},[i,c]),E.useEffect(()=>()=>{On(h)},[]);const g=E.useMemo(()=>({onMouseLeave(){f.current=!1},onFocus(y){if(f.current)return;const C=Pi(y.nativeEvent);if(d&&yt(C)){if(H0()&&!y.relatedTarget){if(!m.current&&!_3(C))return}else if(!hV(C))return}r(!0,y.nativeEvent,"focus")},onBlur(y){f.current=!1;const C=y.relatedTarget,w=y.nativeEvent,x=yt(C)&&C.hasAttribute(Js("focus-guard"))&&C.getAttribute("data-type")==="outside";h.current=window.setTimeout(()=>{var k;const A=li(l.domReference?l.domReference.ownerDocument:document);!C&&A===l.domReference||fn((k=o.current.floatingContext)==null?void 0:k.refs.floating.current,A)||fn(l.domReference,A)||x||r(!1,w,"focus")})}}),[o,l.domReference,r,d]);return E.useMemo(()=>c?{reference:g}:{},[c,g])}function I0(t,e,n){const r=new Map,i=n==="item";let o=t;if(i&&t){const{[V5]:l,[U5]:c,...d}=t;o=d}return{...n==="floating"&&{tabIndex:-1,[cU]:""},...o,...e.map(l=>{const c=l?l[n]:null;return typeof c=="function"?t?c(t):null:c}).concat(t).reduce((l,c)=>(c&&Object.entries(c).forEach(d=>{let[f,h]=d;if(!(i&&[V5,U5].includes(f)))if(f.indexOf("on")===0){if(r.has(f)||r.set(f,[]),typeof h=="function"){var m;(m=r.get(f))==null||m.push(h),l[f]=function(){for(var g,y=arguments.length,C=new Array(y),w=0;wx(...C)).find(x=>x!==void 0)}}}else l[f]=h}),l),{})}}function t1(t){t===void 0&&(t=[]);const e=t.map(c=>c?.reference),n=t.map(c=>c?.floating),r=t.map(c=>c?.item),i=E.useCallback(c=>I0(c,t,"reference"),e),o=E.useCallback(c=>I0(c,t,"floating"),n),l=E.useCallback(c=>I0(c,t,"item"),r);return E.useMemo(()=>({getReferenceProps:i,getFloatingProps:o,getItemProps:l}),[i,o,l])}const _U="Escape";function n1(t,e,n){switch(t){case"vertical":return e;case"horizontal":return n;default:return e||n}}function Df(t,e){return n1(e,t===OT||t===Wp,t===Vu||t===Uu)}function z0(t,e,n){return n1(e,t===Wp,n?t===Vu:t===Uu)||t==="Enter"||t===" "||t===""}function n6(t,e,n){return n1(e,n?t===Vu:t===Uu,t===Wp)}function r6(t,e,n,r){const i=n?t===Uu:t===Vu,o=t===OT;return e==="both"||e==="horizontal"&&r&&r>1?t===_U:n1(e,i,o)}function HU(t,e){const{open:n,onOpenChange:r,elements:i,floatingId:o}=t,{listRef:l,activeIndex:c,onNavigate:d=()=>{},enabled:f=!0,selectedIndex:h=null,allowEscape:m=!1,loop:g=!1,nested:y=!1,rtl:C=!1,virtual:w=!1,focusItemOnOpen:x="auto",focusItemOnHover:k=!0,openOnArrowKeyDown:A=!0,disabledIndices:N=void 0,orientation:R="vertical",parentOrientation:L,cols:z=1,scrollItemIntoView:_=!0,virtualItemRef:q,itemSizes:J,dense:U=!1}=e,ne=Xh(i.floating),le=Zn(ne),oe=Jp(),G=Pu();ft(()=>{t.dataRef.current.orientation=R},[t,R]);const P=Ht(()=>{d(B.current===-1?null:B.current)}),H=K2(i.domReference),j=E.useRef(x),B=E.useRef(h??-1),re=E.useRef(null),ae=E.useRef(!0),D=E.useRef(P),Z=E.useRef(!!i.floating),W=E.useRef(n),se=E.useRef(!1),de=E.useRef(!1),ye=Zn(N),Ee=Zn(n),Rt=Zn(_),tt=Zn(h),[Nn,Or]=E.useState(),[Me,He]=E.useState(),Te=Ht(()=>{function ve(lt){if(w){var wt;(wt=lt.id)!=null&&wt.endsWith("-fui-option")&&(lt.id=o+"-"+Math.random().toString(16).slice(2,10)),Or(lt.id),G?.events.emit("virtualfocus",lt),q&&(q.current=lt)}else Rs(lt,{sync:se.current,preventScroll:!0})}const Re=l.current[B.current],fe=de.current;Re&&ve(Re),(se.current?lt=>lt():requestAnimationFrame)(()=>{const lt=l.current[B.current]||Re;if(!lt)return;Re||ve(lt);const wt=Rt.current;wt&&ht&&(fe||!ae.current)&&(lt.scrollIntoView==null||lt.scrollIntoView(typeof wt=="boolean"?{block:"nearest",inline:"nearest"}:wt))})});ft(()=>{f&&(n&&i.floating?j.current&&h!=null&&(de.current=!0,B.current=h,P()):Z.current&&(B.current=-1,D.current()))},[f,n,i.floating,h,P]),ft(()=>{if(f&&n&&i.floating)if(c==null){if(se.current=!1,tt.current!=null)return;if(Z.current&&(B.current=-1,Te()),(!W.current||!Z.current)&&j.current&&(re.current!=null||j.current===!0&&re.current==null)){let ve=0;const Re=()=>{l.current[0]==null?(ve<2&&(ve?requestAnimationFrame:queueMicrotask)(Re),ve++):(B.current=re.current==null||z0(re.current,R,C)||y?N0(l,ye.current):O5(l,ye.current),re.current=null,P())};Re()}}else tu(l,c)||(B.current=c,Te(),de.current=!1)},[f,n,i.floating,c,tt,y,l,R,C,P,Te,ye]),ft(()=>{var ve;if(!f||i.floating||!G||w||!Z.current)return;const Re=G.nodesRef.current,fe=(ve=Re.find(wt=>wt.id===oe))==null||(ve=ve.context)==null?void 0:ve.elements.floating,Ye=li(gn(i.floating)),lt=Re.some(wt=>wt.context&&fn(wt.context.elements.floating,Ye));fe&&!lt&&ae.current&&fe.focus({preventScroll:!0})},[f,i.floating,G,oe,w]),ft(()=>{if(!f||!G||!w||oe)return;function ve(Re){He(Re.id),q&&(q.current=Re)}return G.events.on("virtualfocus",ve),()=>{G.events.off("virtualfocus",ve)}},[f,G,w,oe,q]),ft(()=>{D.current=P,W.current=n,Z.current=!!i.floating}),ft(()=>{n||(re.current=null,j.current=x)},[n,x]);const nt=c!=null,ht=E.useMemo(()=>{function ve(fe){if(!Ee.current)return;const Ye=l.current.indexOf(fe);Ye!==-1&&B.current!==Ye&&(B.current=Ye,P())}return{onFocus(fe){let{currentTarget:Ye}=fe;se.current=!0,ve(Ye)},onClick:fe=>{let{currentTarget:Ye}=fe;return Ye.focus({preventScroll:!0})},onMouseMove(fe){let{currentTarget:Ye}=fe;se.current=!0,de.current=!1,k&&ve(Ye)},onPointerLeave(fe){let{pointerType:Ye}=fe;if(!(!ae.current||Ye==="touch")&&(se.current=!0,!!k&&(B.current=-1,P(),!w))){var lt;(lt=le.current)==null||lt.focus({preventScroll:!0})}}}},[Ee,le,k,l,P,w]),Be=E.useCallback(()=>{var ve;return L??(G==null||(ve=G.nodesRef.current.find(Re=>Re.id===oe))==null||(ve=ve.context)==null||(ve=ve.dataRef)==null?void 0:ve.current.orientation)},[oe,G,L]),Gt=Ht(ve=>{if(ae.current=!1,se.current=!0,ve.which===229||!Ee.current&&ve.currentTarget===le.current)return;if(y&&r6(ve.key,R,C,z)){Df(ve.key,Be())||hn(ve),r(!1,ve.nativeEvent,"list-navigation"),_t(i.domReference)&&(w?G?.events.emit("virtualfocus",i.domReference):i.domReference.focus());return}const Re=B.current,fe=N0(l,N),Ye=O5(l,N);if(H||(ve.key==="Home"&&(hn(ve),B.current=fe,P()),ve.key==="End"&&(hn(ve),B.current=Ye,P())),z>1){const lt=J||Array.from({length:l.current.length},()=>({width:1,height:1})),wt=xV(lt,z,U),Jr=wt.findIndex(In=>In!=null&&!Gf(l,In,N)),al=wt.reduce((In,mi,Xr)=>mi!=null&&!Gf(l,mi,N)?Xr:In,-1),ro=wt[wV({current:wt.map(In=>In!=null?l.current[In]:null)},{event:ve,orientation:R,loop:g,rtl:C,cols:z,disabledIndices:TV([...(typeof N!="function"?N:null)||l.current.map((In,mi)=>Gf(l,mi,N)?mi:void 0),void 0],wt),minIndex:Jr,maxIndex:al,prevIndex:SV(B.current>Ye?fe:B.current,lt,wt,z,ve.key===Wp?"bl":ve.key===(C?Vu:Uu)?"tr":"tl"),stopEvent:!0})];if(ro!=null&&(B.current=ro,P()),R==="both")return}if(Df(ve.key,R)){if(hn(ve),n&&!w&&li(ve.currentTarget.ownerDocument)===ve.currentTarget){B.current=z0(ve.key,R,C)?fe:Ye,P();return}z0(ve.key,R,C)?g?B.current=Re>=Ye?m&&Re!==l.current.length?-1:fe:Cn(l,{startingIndex:Re,disabledIndices:N}):B.current=Math.min(Ye,Cn(l,{startingIndex:Re,disabledIndices:N})):g?B.current=Re<=fe?m&&Re!==-1?l.current.length:Ye:Cn(l,{startingIndex:Re,decrement:!0,disabledIndices:N}):B.current=Math.max(fe,Cn(l,{startingIndex:Re,decrement:!0,disabledIndices:N})),tu(l,B.current)&&(B.current=-1),P()}}),Ot=E.useMemo(()=>w&&n&&nt&&{"aria-activedescendant":Me||Nn},[w,n,nt,Me,Nn]),zt=E.useMemo(()=>({"aria-orientation":R==="both"?void 0:R,...H?{}:Ot,onKeyDown:Gt,onPointerMove(){ae.current=!0}}),[Ot,Gt,R,H]),Hn=E.useMemo(()=>{function ve(fe){x==="auto"&&dT(fe.nativeEvent)&&(j.current=!0)}function Re(fe){j.current=x,x==="auto"&&fT(fe.nativeEvent)&&(j.current=!0)}return{...Ot,onKeyDown(fe){ae.current=!1;const Ye=fe.key.startsWith("Arrow"),lt=["Home","End"].includes(fe.key),wt=Ye||lt,Jr=n6(fe.key,R,C),al=r6(fe.key,R,C,z),ro=n6(fe.key,Be(),C),In=Df(fe.key,R),mi=(y?ro:In)||fe.key==="Enter"||fe.key.trim()==="";if(w&&n){const Yt=G?.nodesRef.current.find(cl=>cl.parentId==null),Qr=G&&Yt?pV(G.nodesRef.current,Yt.id):null;if(wt&&Qr&&q){const cl=new KeyboardEvent("keydown",{key:fe.key,bubbles:!0});if(Jr||al){var Xr,yn;const E1=((Xr=Qr.context)==null?void 0:Xr.elements.domReference)===fe.currentTarget,ls=al&&!E1?(yn=Qr.context)==null?void 0:yn.elements.domReference:Jr?l.current.find(as=>as?.id===Nn):null;ls&&(hn(fe),ls.dispatchEvent(cl),He(void 0))}if((In||lt)&&Qr.context&&Qr.context.open&&Qr.parentId&&fe.currentTarget!==Qr.context.elements.domReference){var Dr;hn(fe),(Dr=Qr.context.elements.domReference)==null||Dr.dispatchEvent(cl);return}}return Gt(fe)}if(!(!n&&!A&&Ye)){if(mi){const Yt=Df(fe.key,Be());re.current=y&&Yt?null:fe.key}if(y){ro&&(hn(fe),n?(B.current=N0(l,ye.current),P()):r(!0,fe.nativeEvent,"list-navigation"));return}In&&(h!=null&&(B.current=h),hn(fe),!n&&A?r(!0,fe.nativeEvent,"list-navigation"):Gt(fe),n&&P())}},onFocus(){n&&!w&&(B.current=-1,P())},onPointerDown:Re,onPointerEnter:Re,onMouseDown:ve,onClick:ve}},[Nn,Ot,z,Gt,ye,x,l,y,P,r,n,A,R,Be,C,h,G,w,q]);return E.useMemo(()=>f?{reference:Hn,floating:zt,item:ht}:{},[f,Hn,zt,ht])}const IU=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function P3(t,e){var n,r;e===void 0&&(e={});const{open:i,elements:o,floatingId:l}=t,{enabled:c=!0,role:d="dialog"}=e,f=j3(),h=((n=o.domReference)==null?void 0:n.id)||f,m=E.useMemo(()=>{var A;return((A=Xh(o.floating))==null?void 0:A.id)||l},[o.floating,l]),g=(r=IU.get(d))!=null?r:d,C=Jp()!=null,w=E.useMemo(()=>g==="tooltip"||d==="label"?{["aria-"+(d==="label"?"labelledby":"describedby")]:i?m:void 0}:{"aria-expanded":i?"true":"false","aria-haspopup":g==="alertdialog"?"dialog":g,"aria-controls":i?m:void 0,...g==="listbox"&&{role:"combobox"},...g==="menu"&&{id:h},...g==="menu"&&C&&{role:"menuitem"},...d==="select"&&{"aria-autocomplete":"none"},...d==="combobox"&&{"aria-autocomplete":"list"}},[g,m,C,i,h,d]),x=E.useMemo(()=>{const A={id:m,...g&&{role:g}};return g==="tooltip"||d==="label"?A:{...A,...g==="menu"&&{"aria-labelledby":h}}},[g,m,h,d]),k=E.useCallback(A=>{let{active:N,selected:R}=A;const L={role:"option",...N&&{id:m+"-fui-option"}};switch(d){case"select":case"combobox":return{...L,"aria-selected":R}}return{}},[m,d]);return E.useMemo(()=>c?{reference:w,floating:x,item:k}:{},[c,w,x,k])}function zU(t,e){var n;const{open:r,dataRef:i}=t,{listRef:o,activeIndex:l,onMatch:c,onTypingChange:d,enabled:f=!0,findMatch:h=null,resetMs:m=750,ignoreKeys:g=[],selectedIndex:y=null}=e,C=E.useRef(-1),w=E.useRef(""),x=E.useRef((n=y??l)!=null?n:-1),k=E.useRef(null),A=Ht(c),N=Ht(d),R=Zn(h),L=Zn(g);ft(()=>{r&&(On(C),k.current=null,w.current="")},[r]),ft(()=>{if(r&&w.current===""){var U;x.current=(U=y??l)!=null?U:-1}},[r,y,l]);const z=Ht(U=>{U?i.current.typing||(i.current.typing=U,N(U)):i.current.typing&&(i.current.typing=U,N(U))}),_=Ht(U=>{function ne(H,j,B){const re=R.current?R.current(j,B):j.find(ae=>ae?.toLocaleLowerCase().indexOf(B.toLocaleLowerCase())===0);return re?H.indexOf(re):-1}const le=o.current;if(w.current.length>0&&w.current[0]!==" "&&(ne(le,le,w.current)===-1?z(!1):U.key===" "&&hn(U)),le==null||L.current.includes(U.key)||U.key.length!==1||U.ctrlKey||U.metaKey||U.altKey)return;r&&U.key!==" "&&(hn(U),z(!0)),le.every(H=>{var j,B;return H?((j=H[0])==null?void 0:j.toLocaleLowerCase())!==((B=H[1])==null?void 0:B.toLocaleLowerCase()):!0})&&w.current===U.key&&(w.current="",x.current=k.current),w.current+=U.key,On(C),C.current=window.setTimeout(()=>{w.current="",x.current=k.current,z(!1)},m);const G=x.current,P=ne(le,[...le.slice((G||0)+1),...le.slice(0,(G||0)+1)],w.current);P!==-1?(A(P),k.current=P):U.key!==" "&&(w.current="",z(!1))}),q=E.useMemo(()=>({onKeyDown:_}),[_]),J=E.useMemo(()=>({onKeyDown:_,onKeyUp(U){U.key===" "&&z(!1)}}),[_,z]);return E.useMemo(()=>f?{reference:q,floating:J}:{},[f,q,J])}const BU=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),jU=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),i6=t=>{const e=jU(t);return e.charAt(0).toUpperCase()+e.slice(1)},zT=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),VU=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UU={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const PU=E.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:o,iconNode:l,...c},d)=>E.createElement("svg",{ref:d,...UU,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:zT("lucide",i),...!o&&!VU(c)&&{"aria-hidden":"true"},...c},[...l.map(([f,h])=>E.createElement(f,h)),...Array.isArray(o)?o:[o]]));const we=(t,e)=>{const n=E.forwardRef(({className:r,...i},o)=>E.createElement(PU,{ref:o,iconNode:e,className:zT(`lucide-${BU(i6(t))}`,`lucide-${t}`,r),...i}));return n.displayName=i6(t),n};const FU=[["path",{d:"M3.5 13h6",key:"p1my2r"}],["path",{d:"m2 16 4.5-9 4.5 9",key:"ndf0b3"}],["path",{d:"M18 7v9",key:"pknjwm"}],["path",{d:"m14 12 4 4 4-4",key:"buelq4"}]],$U=we("a-arrow-down",FU);const qU=[["path",{d:"M3.5 13h6",key:"p1my2r"}],["path",{d:"m2 16 4.5-9 4.5 9",key:"ndf0b3"}],["path",{d:"M18 16V7",key:"ty0viw"}],["path",{d:"m14 11 4-4 4 4",key:"1pu57t"}]],ZU=we("a-arrow-up",qU);const KU=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],GU=we("align-left",KU);const YU=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],WU=we("arrow-right",YU);const JU=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M16 12h2",key:"7q9ll5"}],["path",{d:"M16 8h2",key:"msurwy"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}],["path",{d:"M6 12h2",key:"32wvfc"}],["path",{d:"M6 8h2",key:"30oboj"}]],XU=we("book-open-text",JU);const QU=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],eP=we("box",QU);const tP=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],nP=we("check",tP);const rP=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]],iP=we("clipboard-copy",rP);const oP=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],sP=we("clipboard-paste",oP);const lP=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],aP=we("code",lP);const cP=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],uP=we("columns-2",cP);const dP=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],fP=we("credit-card",dP);const hP=[["path",{d:"m21.12 6.4-6.05-4.06a2 2 0 0 0-2.17-.05L2.95 8.41a2 2 0 0 0-.95 1.7v5.82a2 2 0 0 0 .88 1.66l6.05 4.07a2 2 0 0 0 2.17.05l9.95-6.12a2 2 0 0 0 .95-1.7V8.06a2 2 0 0 0-.88-1.66Z",key:"1u2ovd"}],["path",{d:"M10 22v-8L2.25 9.15",key:"11pn4q"}],["path",{d:"m10 14 11.77-6.87",key:"1kt1wh"}]],Xs=we("cuboid",hP);const pP=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],mP=we("file-down",pP);const gP=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],G2=we("file-text",gP);const yP=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],vP=we("folder-open",yP);const bP=[["path",{d:"M3 2h18",key:"15qxfx"}],["rect",{width:"18",height:"12",x:"3",y:"6",rx:"2",key:"1439r6"}],["path",{d:"M3 22h18",key:"8prr45"}]],CP=we("gallery-vertical",bP);const wP=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],xP=we("grid-3x3",wP);const SP=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],TP=we("grip-vertical",SP);const kP=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],BT=we("heading",kP);const EP=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]],MP=we("house",EP);const AP=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],o6=we("image-plus",AP);const NP=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],RP=we("image",NP);const OP=[["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"m22 13-1.296-1.296a2.41 2.41 0 0 0-3.408 0L11 18",key:"nf6bnh"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["rect",{width:"16",height:"16",x:"6",y:"2",rx:"2",key:"12espp"}]],jT=we("images",OP);const DP=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],LP=we("layers",DP);const _P=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]],HP=we("layout-list",_P);const IP=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],zP=we("layout-grid",IP);const BP=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],jP=we("link",BP);const VP=[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]],VT=we("list",VP);const UP=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],PP=we("mail",UP);const FP=[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],$P=we("message-circle-question-mark",FP);const qP=[["path",{d:"M5 12h14",key:"1ays0h"}]],UT=we("minus",qP);const ZP=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],KP=we("monitor",ZP);const GP=[["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-4 0v-9a2 2 0 0 1 2-2h2",key:"39pd36"}],["rect",{width:"8",height:"4",x:"10",y:"6",rx:"1",key:"aywv1n"}]],s6=we("newspaper",GP);const YP=[["path",{d:"M13 4v16",key:"8vvj80"}],["path",{d:"M17 4v16",key:"7dpous"}],["path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13",key:"sh4n9v"}]],WP=we("pilcrow",YP);const JP=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],XP=we("play",JP);const QP=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],r1=we("plus",QP);const eF=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]],tF=we("quote",eF);const nF=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M7 12h.01",key:"eqddd0"}]],rF=we("rectangle-ellipsis",nF);const iF=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]],PT=we("rectangle-horizontal",iF);const oF=[["path",{d:"M13 13H8a1 1 0 0 0-1 1v7",key:"h8g396"}],["path",{d:"M14 8h1",key:"1lfen6"}],["path",{d:"M17 21v-4",key:"1yknxs"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20.41 20.41A2 2 0 0 1 19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 .59-1.41",key:"1t4vdl"}],["path",{d:"M29.5 11.5s5 5 4 5",key:"zzn4i6"}],["path",{d:"M9 3h6.2a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V15",key:"24cby9"}]],l6=we("save-off",oF);const sF=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],lF=we("save",sF);const aF=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],cF=we("send",aF);const uF=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],dF=we("settings",uF);const fF=[["path",{d:"M4 10c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"4i38lg"}],["path",{d:"M10 16c-1.1 0-2-.9-2-2v-4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"mlte4a"}],["rect",{width:"8",height:"8",x:"14",y:"14",rx:"2",key:"1fa9i4"}]],hF=we("square-stack",fF);const pF=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],mF=we("square",pF);const gF=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],FT=we("star",gF);const yF=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],vF=we("tag",yF);const bF=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],CF=we("triangle-alert",bF);const wF=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],xF=we("user",wF);const SF=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],TF=we("video",SF);const kF=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],i1=we("x",kF),EF={cs:{placeholder:"Klikněte pro přidání dalšího obsahu"},en:{placeholder:"Click to add more content"}},_a=({children:t,editor:e,getPos:n,target:r,wrapperRef:i})=>{const[o,l]=E.useState(!1),[c,d]=E.useState(!1),f=E.useRef(null),h=E.useRef(null),m=E.useCallback(()=>{if(!f.current||f.current.closest(".f-tiptap-page")?.classList.contains("f-tiptap-page--collapsed"))return!1;const R=f.current.querySelector("[data-node-view-content-react]")||f.current;if(!R)return!1;const L=R.lastElementChild;return L?L.tagName.toLowerCase()==="div":!1},[]),{refs:g,floatingStyles:y}=e1({open:c,placement:"bottom",middleware:[Yp({mainAxis:0}),NT({apply({rects:N,elements:R}){Object.assign(R.floating.style,{width:`${N.reference.width}px`})}})],whileElementsMounted:qp,strategy:"fixed"}),{getFloatingProps:C}=t1([]),w=E.useCallback(N=>{f.current?.contains(N.target)&&l(!0)},[]),x=E.useCallback(N=>{const R=N.relatedTarget;h.current&&R&&R instanceof Node&&(h.current.contains(R)||h.current===R)||l(!1)},[]),k=E.useCallback(()=>{l(!1)},[]);E.useEffect(()=>{if(!e||!o)return;const N=()=>{m()?(d(!0),f.current&&g.setReference(f.current)):d(!1)};return e.on("update",N),()=>{e.off("update",N)}},[e,o,m,g]),E.useEffect(()=>{o&&m()?(d(!0),f.current&&g.setReference(f.current)):d(!1)},[o,m,g]);const A=E.useCallback(()=>{if(d(!1),n){const N=n();if(typeof N=="number"){const R=e.state.doc.resolve(N+1),L=R.end(R.depth),z=e.schema.nodes.paragraph.create(),_=e.state.tr;_.insert(L,z);const q=L+1;_.setSelection(ue.create(_.doc,q)),e.view.dispatch(_),e.view.focus();return}}e.chain().focus().insertContent({type:"paragraph"}).run()},[e,n]);return!e||!e.isEditable?S.jsx(S.Fragment,{children:t}):S.jsxs(S.Fragment,{children:[S.jsx("div",{ref:N=>{f.current=N,i&&"current"in i&&(i.current=N)},onMouseEnter:w,onMouseLeave:x,onMouseOver:w,style:{position:"relative"},children:t}),c&&S.jsx(Qp,{children:S.jsx("div",{ref:N=>{h.current=N,g.setFloating(N)},onMouseEnter:()=>l(!0),onMouseLeave:k,style:{...y,marginTop:0},...C(),className:"f-tiptap-paragraph-placeholder",children:S.jsxs("div",{className:"f-tiptap-paragraph-placeholder__div",onClick:A,children:[S.jsx(r1,{className:"f-tiptap-paragraph-placeholder__icon"}),pe(EF,"placeholder")]})})})]})};_a.displayName="HasParagraphPlaceholder";const MF=({editor:t,getPos:e})=>t?S.jsx(Qi,{children:S.jsx(_a,{editor:t,getPos:e,target:"column",children:S.jsx(La,{})})}):null,tp=st.create({name:"folioTiptapColumn",content:"block+",isolating:!0,addOptions(){return{HTMLAttributes:{class:"f-tiptap-column"}}},parseHTML(){return[{tag:"div.f-tiptap-column"}]},renderHTML({HTMLAttributes:t}){return["div",Pe(this.options.HTMLAttributes,t),0]},addNodeView(){return eo(MF,{className:"node-folioTiptapColumn f-tiptap-column",stopEvent:()=>!1})}}),o1=st.create({name:"folioTiptapColumns",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,content:"folioTiptapColumn{1,}",draggable:!0,addOptions(){return{HTMLAttributes:{class:"f-tiptap-columns"}}},parseHTML(){return[{tag:"div.f-tiptap-columns"}]},renderHTML({HTMLAttributes:t}){return["div",Pe({class:"f-tiptap-columns f-tiptap-avoid-external-layout"},this.options.HTMLAttributes,t),0]},addCommands(){return{insertFolioTiptapColumns:()=>({tr:t,dispatch:e,editor:n})=>{const r=Aj(n.schema,2);if(e){const i=t.selection.anchor+1;t.replaceSelectionWith(r).scrollIntoView().setSelection(ue.near(t.doc.resolve(i)))}return!0},addFolioTiptapColumnBefore:()=>({dispatch:t,state:e})=>k0({dispatch:t,state:e,type:"addBefore"}),addFolioTiptapColumnAfter:()=>({dispatch:t,state:e})=>k0({dispatch:t,state:e,type:"addAfter"}),deleteFolioTiptapColumn:()=>({dispatch:t,state:e})=>k0({dispatch:t,state:e,type:"delete"})}},addKeyboardShortcuts(){return{Tab:()=>S5({state:this.editor.state,dispatch:this.editor.view.dispatch,type:"after"}),"Shift-Tab":()=>S5({state:this.editor.state,dispatch:this.editor.view.dispatch,type:"before"})}}});function AF(t,e=null,n=null){if(e)return t.createChecked({},e);if(n){const r=[n.nodes.heading.createChecked({level:2})];return t.createChecked({},r)}return t.createAndFill({})}function NF(t){if(t.cached.pagesNodeTypes)return t.cached.pagesNodeTypes;const e={pages:t.nodes.folioTiptapPages,page:t.nodes.folioTiptapPage};return t.cached.pagesNodeTypes=e,e}function RF(t,e,n=null){const r=NF(t),i=[];for(let o=0;oo.type.name===Fu.name)(t.selection),i=At(o=>o.type.name===Xo.name)(t.selection);if(!r||!i)return!1;if(e){const o=r.node;let l=null;if(o.content.forEach((g,y,C)=>{if(l===null&&g===i.node){l=C;return}}),l===null)return console.warn("Current page not found in pages node"),!1;const c=o.toJSON();let d=l;if(n==="delete"){if(c.content.length<=2){const x=[];c.content.forEach(A=>{A.content&&A.content.length>0&&x.push(...A.content)}),x.length===0&&x.push({type:"paragraph"});const k=t.tr;return k.replaceWith(r.pos,r.pos+r.node.nodeSize,x.map(A=>Gn.fromJSON(t.schema,A))),k.setSelection(ue.near(k.doc.resolve(r.pos+1))),e(k),!0}const y=c.content[l].content||[],C=l>0?l-1:l+1,w=c.content[C];y.length>0&&(w.content||(w.content=[]),w.content.push(...y)),c.content.splice(l,1),d=l>0?l-1:0}else d=n==="addBefore"?l:l+1,c.content.splice(d,0,{type:Xo.name,content:[{type:"heading",attrs:{level:2}}]});const f=Gn.fromJSON(t.schema,c);let h=r.pos;f.content.forEach((g,y,C)=>{Co.type.name===Fu.name)(t.selection),i=At(o=>o.type.name===Xo.name)(t.selection);if(r&&i){const o=r.node;let l=null;if(o.content.forEach((w,x,k)=>{if(l===null&&w===i.node){l=k;return}}),l===null)return console.warn("Current page not found in pages node"),!1;let c;if(n==="up"){if(l===0)return!1;c=l-1}else{if(l===o.childCount-1)return!1;c=l+1}const d=o.content.maybeChild(c);if(!d||d.type.name!==Xo.name)return!1;const f=o.toJSON(),h=f.content[l],m=f.content[c];f.content[l]=m,f.content[c]=h;const g=Gn.fromJSON(t.schema,f);let y=r.pos;g.content.forEach((w,x,k)=>{ko.type.name===Fu.name)(t.selection),i=At(o=>o.type.name===Xo.name)(t.selection);if(e&&r&&i){const o=r.node,l=i.node;let c=null;if(o.content.forEach((m,g,y)=>{if(c===null&&m===l){c=y;return}}),c===null)return console.warn("Current page not found in pages node"),!1;let d=0;n==="before"?d=(c-1+o.childCount)%o.childCount:d=(c+1)%o.childCount;let f=r.pos;o.content.forEach((m,g,y)=>{y{const n=e();if(typeof n!="number")return;const r=t.schema.nodes.heading.create({level:2}),i=n+1,o=t.state.tr;o.insert(i,r);const l=i+1;o.setSelection(ue.create(o.doc,l)),t.view.dispatch(o)},LF=({event:t,editor:e,getPos:n})=>{t.preventDefault(),t.stopPropagation();const r=n();if(typeof r!="number")return!1;const i=e.state.doc.resolve(r+1),o=i.end(i.depth),l=e.state.tr.setSelection(ue.create(e.state.doc,o-1));e.view.dispatch(l)},_F=({node:t,getPos:e,editor:n})=>{const r=E.useMemo(()=>Vx(t,h=>h.type.name==="heading"),[t]),i=E.useMemo(()=>r.find(h=>h.node.content.size>0),[r]);if(!n)return null;const o=()=>{$T({state:n.state,dispatch:n.view.dispatch,node:t,getPos:e})};let l="f-tiptap-page";const c=!i,d=r.length===0;c&&(l+=" f-tiptap-page--invalid"),t.attrs.collapsed&&(l+=" f-tiptap-page--collapsed");const f=t.attrs.collapsed?{"data-collapsed":"true"}:{};return S.jsxs(Qi,{className:l,...f,children:[S.jsx("div",{className:"f-tiptap-page__toggle-wrap",onClick:o,children:S.jsx("div",{className:"f-tiptap-page__toggle",children:t.attrs.collapsed?S.jsx(w8,{className:"f-tiptap-page__toggle-ico"}):S.jsx(x8,{className:"f-tiptap-page__toggle-ico"})})}),S.jsxs("div",{className:"f-tiptap-page__content",children:[d?S.jsx("h2",{className:"f-tiptap-page__title-placeholder is-empty","data-placeholder":pe(OF,"missingHeading"),onClick:()=>{DF({editor:n,getPos:e})},children:S.jsx("br",{className:"ProseMirror-trailingBreak"})}):null,S.jsx(_a,{editor:n,getPos:e,target:"page",children:S.jsx(La,{})})]}),S.jsx("span",{className:"f-tiptap-page__content-click-trigger",onClick:h=>LF({event:h,editor:n,getPos:e})})]})},Xo=st.create({name:"folioTiptapPage",content:"block+",isolating:!0,addAttributes(){return{collapsed:{default:!1,parseHTML:t=>t.getAttribute("data-collapsed")==="true",renderHTML:t=>t.collapsed?{"data-collapsed":"true"}:{}}}},addOptions(){return{HTMLAttributes:{class:"f-tiptap-page"}}},parseHTML(){return[{tag:"div.f-tiptap-page"}]},renderHTML({HTMLAttributes:t}){return["div",Pe(this.options.HTMLAttributes,t),0]},addNodeView(){return eo(_F,{stopEvent:()=>!1})}}),HF=({node:t,getPos:e,editor:n})=>(E.useEffect(()=>{if(!n)return;const r=()=>{const i=At(o=>o.type.name==="folioTiptapPage")(n.state.selection);i&&i.node.attrs.collapsed&&$T({state:n.state,dispatch:n.view.dispatch,node:i.node,getPos:()=>i.pos})};return n.on("selectionUpdate",r),()=>{n.off("selectionUpdate",r)}},[n,t,e]),n?S.jsx(Qi,{className:"f-tiptap-pages__view",children:S.jsx(La,{className:"f-tiptap-pages__content"})}):null),u6={cs:{label:"Stránkovaný obsah"},en:{label:"Paged content"}},Fu=st.create({name:"folioTiptapPages",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,content:"folioTiptapPage{2,}",draggable:!0,addOptions(){return{HTMLAttributes:{class:"f-tiptap-pages"}}},parseHTML(){return[{tag:"div.f-tiptap-pages"}]},renderHTML({HTMLAttributes:t}){return["div",Pe({class:"f-tiptap-pages"},this.options.HTMLAttributes,t),0]},addCommands(){return{insertFolioTiptapPages:()=>({tr:t,dispatch:e,editor:n})=>{const r=RF(n.schema,2);if(e){const i=t.selection.anchor+1;t.replaceSelectionWith(r).scrollIntoView().setSelection(ue.near(t.doc.resolve(i)))}return!0},addFolioTiptapPageBefore:()=>({dispatch:t,state:e})=>B0({dispatch:t,state:e,type:"addBefore"}),addFolioTiptapPageAfter:()=>({dispatch:t,state:e})=>B0({dispatch:t,state:e,type:"addAfter"}),deleteFolioTiptapPage:()=>({dispatch:t,state:e})=>B0({dispatch:t,state:e,type:"delete"}),moveFolioTiptapPageUp:()=>({dispatch:t,state:e})=>a6({state:e,dispatch:t,type:"up"}),moveFolioTiptapPageDown:()=>({dispatch:t,state:e})=>a6({state:e,dispatch:t,type:"down"})}},addNodeView(){return eo(HF,{className:"node-folioTiptapPages f-tiptap-pages",stopEvent:()=>!1})},addKeyboardShortcuts(){return{Tab:()=>c6({state:this.editor.state,dispatch:this.editor.view.dispatch,type:"after"}),"Shift-Tab":()=>c6({state:this.editor.state,dispatch:this.editor.view.dispatch,type:"before"})}}}),zc={cs:{addFolioTiptapPageBefore:"Přidat stránku před",moveFolioTiptapPageUp:"Posunout stránku nahoru",addFolioTiptapPageAfter:"Přidat stránku za",moveFolioTiptapPageDown:"Posunout stránku dolů",deleteFolioTiptapPage:"Odstranit stránku"},en:{addFolioTiptapPageBefore:"Add page before",moveFolioTiptapPageUp:"Move page up",addFolioTiptapPageAfter:"Add page after",moveFolioTiptapPageDown:"Move page down",deleteFolioTiptapPage:"Remove page"}},IF={pluginKey:"folioTiptapPagesBubbleMenu",priority:1,shouldShow:({editor:t})=>t.isActive(Fu.name),disabledKeys:({editor:t})=>{const e=[];return t.can().moveFolioTiptapPageUp()||e.push("moveFolioTiptapPageUp"),t.can().moveFolioTiptapPageDown()||e.push("moveFolioTiptapPageDown"),e},items:[[{key:"addFolioTiptapPageBefore",title:pe(zc,"addFolioTiptapPageBefore"),icon:k8,command:({editor:t})=>{t.chain().focus().addFolioTiptapPageBefore().run()}},{key:"moveFolioTiptapPageUp",title:pe(zc,"moveFolioTiptapPageUp"),icon:m3,command:({editor:t})=>{t.chain().focus().moveFolioTiptapPageUp().run()}}],[{key:"addFolioTiptapPageAfter",title:pe(zc,"addFolioTiptapPageAfter"),icon:T8,command:({editor:t})=>{t.chain().focus().addFolioTiptapPageAfter().run()}},{key:"moveFolioTiptapPageDown",title:pe(zc,"moveFolioTiptapPageDown"),icon:p3,command:({editor:t})=>{t.chain().focus().moveFolioTiptapPageDown().run()}}],[{key:"deleteFolioTiptapPage",title:pe(zc,"deleteFolioTiptapPage"),icon:i1,command:({editor:t})=>{t.chain().focus().deleteFolioTiptapPage().run()}}]]},zF=Ze.create({name:"folioTiptapPagesExtension"}),BF=t=>t?[{title:{cs:u6.cs.label,en:u6.en.label},icon:XU,key:"folioTiptapPages",command:({chain:n})=>{n.insertFolioTiptapPages()}}]:[],jF=II.extend({name:"folioTiptapStyledParagraph",parseHTML(){const t=this.options.variants||[],e=r=>typeof r=="string"?!1:{variant:r.getAttribute("data-f-tiptap-styled-paragraph-variant")||null},n=[{tag:"p.f-tiptap-styled-paragraph",getAttrs:e}];return t.forEach(r=>{r.tag&&r.tag!=="p"&&n.push({tag:`${r.tag}.f-tiptap-styled-paragraph`,getAttrs:e})}),n},renderHTML({HTMLAttributes:t}){const e=this.options.variants||[],n=t["data-f-tiptap-styled-paragraph-variant"],r=e.find(d=>d.variant===n),i=r?.tag||"p",o="f-tiptap-styled-paragraph",l=r?.class_name,c=l?`${o} ${l}`:o;return[i,{...t,class:c},0]},addOptions(){return{variants:[],variantCommands:[]}},addAttributes(){return{variant:{default:null,parseHTML:t=>t.getAttribute("data-f-tiptap-styled-paragraph-variant"),renderHTML:t=>({"data-f-tiptap-styled-paragraph-variant":t.variant})}}}}),VF=t=>{const e=(r,i)=>{switch(r){case"arrow-up":return ZU;case"arrow-down":return $U;case"heading":return BT;case"message-circle-question-mark":return $P}switch(i){case"h1":return y8;case"h2":return b3;case"h3":return v3;case"h4":return y3;case"h5":return m8;case"h6":return v8;default:return FT}},n=t.map(r=>({title:r.title,icon:e(r.icon,r.tag),key:`styledParagraphVariant-${r.variant}`,command:({chain:o})=>{const l={variant:r.variant};o.setNode("folioTiptapStyledParagraph",l)}}));return n.sort((r,i)=>{const o=r.title[document.documentElement.lang]||r.title.en,l=i.title[document.documentElement.lang]||i.title.en;return o.localeCompare(l)}),n},UF=({node:t,editor:e,getPos:n})=>{if(!e)return null;const r=t.attrs.variant,i="node-folioTiptapStyledWrap f-tiptap-styled-wrap f-tiptap-avoid-external-layout",o=r?{"data-f-tiptap-styled-wrap-variant":r}:{};return S.jsx(Qi,{className:i,...o,children:S.jsx(_a,{editor:e,getPos:n,target:"styled-wrap",children:S.jsx(La,{})})})},PF=st.create({name:"folioTiptapStyledWrap",defining:!1,isolating:!0,allowGapCursor:!1,content:"block+",group:"block",parseHTML(){return[{tag:"div.f-tiptap-styled-wrap",getAttrs:t=>typeof t=="string"?!1:{variant:t.getAttribute("data-f-tiptap-styled-wrap-variant")||null}}]},renderHTML({HTMLAttributes:t}){return["div",{...t,class:"f-tiptap-styled-wrap f-tiptap-avoid-external-layout"},0]},addOptions(){return{variantCommands:[]}},addAttributes(){return{variant:{default:null,parseHTML:t=>t.getAttribute("data-f-tiptap-styled-wrap-variant"),renderHTML:t=>({"data-f-tiptap-styled-wrap-variant":t.variant})}}},addNodeView(){return eo(UF,{stopEvent:()=>!1})}}),FF=t=>{const e=t.map(n=>({title:n.title,icon:eP,key:`styledWrapVariant-${n.variant}`,command:({chain:i})=>{i.insertContent({type:"folioTiptapStyledWrap",attrs:{variant:n.variant},content:[{type:"paragraph",content:[]}]})}}));return e.sort((n,r)=>{const i=n.title[document.documentElement.lang]||n.title.en,o=r.title[document.documentElement.lang]||r.title.en;return i.localeCompare(o)}),e},$F=({editor:t,getPos:e})=>t?S.jsx(Qi,{children:S.jsx(_a,{editor:t,getPos:e,target:"float-aside",children:S.jsx(La,{})})}):null,qT=st.create({name:"folioTiptapFloatAside",isolating:!0,content:"block+",addOptions(){return{HTMLAttributes:{class:"f-tiptap-float__aside"}}},parseHTML(){return[{tag:"aside.f-tiptap-float__aside"},{tag:"div.f-tiptap-float__aside"}]},renderHTML({HTMLAttributes:t}){return["aside",Pe({class:"f-tiptap-float__aside"},this.options.HTMLAttributes,t),0]},addNodeView(){return eo($F,{as:"aside",className:"node-folioTiptapFloatAside f-tiptap-float__aside",stopEvent:()=>!1})}}),qF=({tr:t,dispatch:e,editor:n})=>{const r=[n.schema.nodes.folioTiptapFloatAside.createAndFill({}),n.schema.nodes.folioTiptapFloatMain.createAndFill({})],i=n.schema.nodes.folioTiptapFloat.createChecked({},r);if(e){const o=t.selection.anchor+1;t.replaceSelectionWith(i).scrollIntoView().setSelection(ue.near(t.doc.resolve(o))),e(t)}return!0},ZF=({attrs:t,tr:e,dispatch:n,state:r})=>{const i=At(c=>c.type.name===Ta.name)(r.selection);if(!i)return!1;let o=!1;const l={side:i.node.attrs.side||"left",size:i.node.attrs.size||"medium"};return t.side&&t.side!==l.side&&["left","right"].includes(t.side)&&(l.side=t.side,o=!0),t.size&&t.size!==l.size&&["small","medium","large"].includes(t.size)&&(l.size=t.size,o=!0),o?(n&&(e.setNodeMarkup(i.pos,void 0,l),n(e)),!0):!1};function d6({state:t,dispatch:e}){const n=At(r=>r.type.name===Ta.name)(t.selection);if(e&&n){if(At(l=>l.type.name==="listItem")(t.selection))return!1;const i=At(l=>l.type.name===qT.name)(t.selection),o=t.tr;if(i){const l=i.pos+i.node.nodeSize;o.setSelection(ue.near(o.doc.resolve(l)))}else{const l=n.pos+1;o.setSelection(ue.near(o.doc.resolve(l)))}return e(o),!0}return!1}function KF({tr:t,dispatch:e,state:n}){const r=At(i=>i.type.name===Ta.name)(n.selection);if(!r)return!1;if(e){const i=[];r.node.toJSON().content.forEach(o=>{o.content&&o.content.length>0&&o.content.forEach(l=>{if(l){if(l.type==="paragraph"&&(!l.content||l.content.length===0))return;i.push(l)}})}),i.length===0&&i.push({type:"paragraph"}),t.replaceWith(r.pos,r.pos+r.node.nodeSize,i.map(o=>Gn.fromJSON(n.schema,o))),t.setSelection(ue.near(t.doc.resolve(r.pos+1))),e(t)}return!0}const Ta=st.create({name:"folioTiptapFloat",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,content:"folioTiptapFloatAside{1} folioTiptapFloatMain{1}",draggable:!1,addOptions(){return{HTMLAttributes:{class:"f-tiptap-float"}}},addAttributes(){return{side:{default:"left",parseHTML:t=>t.getAttribute("data-f-tiptap-float-side")||"left"},size:{default:"medium",parseHTML:t=>t.getAttribute("data-f-tiptap-float-size")||"medium"}}},parseHTML(){return[{tag:"div.f-tiptap-float",getAttrs:t=>typeof t=="string"?!1:{side:t.getAttribute("data-f-tiptap-float-side")||"left",size:t.getAttribute("data-f-tiptap-float-size")||"medium"}}]},renderHTML({HTMLAttributes:t}){return["div",Pe({class:"f-tiptap-float f-tiptap-avoid-external-layout","data-f-tiptap-float-side":t.side,"data-f-tiptap-float-size":t.size},this.options.HTMLAttributes,t),0]},addCommands(){return{insertFolioTiptapFloat:()=>({tr:t,dispatch:e,editor:n})=>qF({tr:t,dispatch:e,editor:n}),cancelFolioTiptapFloat:()=>({tr:t,dispatch:e,state:n,editor:r})=>KF({tr:t,dispatch:e,state:n}),setFolioTiptapFloatAttributes:t=>({tr:e,dispatch:n,state:r,editor:i})=>ZF({attrs:t,tr:e,dispatch:n,state:r})}},addKeyboardShortcuts(){return{Tab:()=>d6({state:this.editor.state,dispatch:this.editor.view.dispatch}),"Shift-Tab":()=>d6({state:this.editor.state,dispatch:this.editor.view.dispatch})}}}),GF=({editor:t,getPos:e})=>t?S.jsx(Qi,{children:S.jsx(_a,{editor:t,getPos:e,target:"float-main",children:S.jsx(La,{})})}):null,YF=st.create({name:"folioTiptapFloatMain",isolating:!0,content:"block+",addOptions(){return{HTMLAttributes:{class:"f-tiptap-float__main"}}},parseHTML(){return[{tag:"div.f-tiptap-float__main"}]},renderHTML({HTMLAttributes:t}){return["div",Pe({class:"f-tiptap-float__main"},this.options.HTMLAttributes,t),0]},addNodeView(){return eo(GF,{as:"main",className:"node-folioTiptapFloatMain f-tiptap-float__main",stopEvent:()=>!1})}}),Wl={cs:{setFloatSideToLeft:"Obtékaný obsah - vlevo",setFloatSideToRight:"Obtékaný obsah - vpravo",cancelFloat:"Zrušit obtékání obsahu",setFloatSizeToSmall:"Obtékaný obsah - úzký",setFloatSizeToMedium:"Obtékaný obsah - střední",setFloatSizeToLarge:"Obtékaný obsah - široký"},en:{setFloatSideToLeft:"Float content - left",setFloatSideToRight:"Float content - right",cancelFloat:"Cancel float content",setFloatSizeToSmall:"Float content - small",setFloatSizeToMedium:"Float content - medium",setFloatSizeToLarge:"Float content - large"}},WF={pluginKey:"folioTiptapFloatBubbleMenu",priority:1,shouldShow:({editor:t})=>t.isActive(Ta.name),activeKeys:({editor:t})=>{const e=At(r=>r.type.name===Ta.name)(t.state.selection);if(!e)return[];const n=[];return e.node.attrs.side==="right"?n.push("setFloatSideToRight"):n.push("setFloatSideToLeft"),e.node.attrs.size==="small"?n.push("setFloatSizeToSmall"):e.node.attrs.size==="large"?n.push("setFloatSizeToLarge"):n.push("setFloatSizeToMedium"),n},items:[[{key:"setFloatSideToLeft",title:pe(Wl,"setFloatSideToLeft"),icon:o8,command:({editor:t})=>{t.chain().focus().setFolioTiptapFloatAttributes({side:"left"}).run()}},{key:"cancelFloat",title:pe(Wl,"cancelFloat"),icon:zp,command:({editor:t})=>{t.chain().focus().cancelFolioTiptapFloat().run()}},{key:"setFloatSideToRight",title:pe(Wl,"setFloatSideToRight"),icon:s8,command:({editor:t})=>{t.chain().focus().setFolioTiptapFloatAttributes({side:"right"}).run()}}],[{key:"setFloatSizeToSmall",title:pe(Wl,"setFloatSizeToSmall"),icon:R8,command:({editor:t})=>{t.chain().focus().setFolioTiptapFloatAttributes({size:"small"}).run()}},{key:"setFloatSizeToMedium",title:pe(Wl,"setFloatSizeToMedium"),icon:N8,command:({editor:t})=>{t.chain().focus().setFolioTiptapFloatAttributes({size:"medium"}).run()}},{key:"setFloatSizeToLarge",title:pe(Wl,"setFloatSizeToLarge"),icon:A8,command:({editor:t})=>{t.chain().focus().setFolioTiptapFloatAttributes({size:"large"}).run()}}]]},Y2="f-tiptap-invalid-node",JF={cs:{message:"Tento obsah nebude veřejně zobrazen. Můžete ho odstranit."},en:{message:"This content will not be publicly displayed. You can remove it."}},XF=t=>{const{node:e}=t;return S.jsx(Qi,{className:Y2,"data-node-string":JSON.stringify(e.attrs.invalidNodeHash),children:S.jsx(E3,{invalidNodeHash:e&&e.attrs&&e.attrs.invalidNodeHash,message:pe(JF,"message")})})},QF=st.create({name:"folioTiptapInvalidNode",group:"block",draggable:!0,selectable:!0,atom:!0,code:!0,isolating:!0,renderHTML({HTMLAttributes:t}){return["div",{...t,class:Y2},0]},addAttributes(){return{invalidNodeHash:{default:{},parseHTML:t=>JSON.parse(t.getAttribute("data-node-string")||"{}"),renderHTML:t=>({"data-node-string":JSON.stringify(t.invalidNodeHash)})}}},addNodeView(){return eo(XF,{stopEvent:()=>!1})},parseHTML(){return[{tag:`div.${Y2}`,getAttrs:t=>typeof t=="string"?!1:{invalidNodeHash:(()=>{try{return JSON.parse(t.getAttribute("data-node-string")||"{}")}catch(e){return console.error("Error parsing invalidNodeHash:",e),{}}})()}}]}}),e$={title:{cs:"Bodový seznam",en:"Bullet List"},icon:C3,key:"bulletList",command:({chain:t})=>{t.toggleBulletList()}},t$={title:{cs:"Sloupce",en:"Columns"},icon:uP,key:"folioTiptapColumns",command:({chain:t})=>{t.insertFolioTiptapColumns({count:2})}},n$={title:{cs:"Obtékaný obsah",en:"Float content"},icon:p8,key:"folioTiptapFloat",command:({chain:t})=>{t.insertFolioTiptapFloat()}},r$={title:{cs:"Nadpis H4",en:"Heading H4"},icon:y3,key:"heading-4",keymap:"####",command:({chain:t})=>{t.setNode("heading",{level:4})}},i$={title:{cs:"Nadpis H3",en:"Heading H3"},icon:v3,key:"heading-3",keymap:"###",command:({chain:t})=>{t.setNode("heading",{level:3})}},o$={title:{cs:"Nadpis H2",en:"Heading H2"},icon:b3,key:"heading-2",keymap:"##",command:({chain:t})=>{t.setNode("heading",{level:2})}},ZT={title:{cs:"Oddělovač",en:"Delimiter"},icon:UT,key:"horizontalRule",hideInToolbarDropdown:!0,command:({chain:t})=>{t.insertContent({type:"horizontalRule"})}},s$={title:{cs:"Číslovaný seznam",en:"Ordered List"},icon:C8,key:"orderedList",command:({chain:t})=>{t.toggleOrderedList()}},l$={title:{cs:"Odstavec",en:"Paragraph"},icon:WP,key:"paragraph",dontShowAsActiveInCollapsedToolbar:!0,command:({chain:t})=>{t.setNode("paragraph")}},a$={title:{cs:"Tabulka",en:"Table"},icon:T3,key:"table",command:({chain:t})=>{t.insertTable({rows:2,cols:2,withHeaderRow:!0})}},c$={title:{cs:"Zarovnat doprostřed",en:"Align center"},icon:r8,key:"align-center",command:({chain:t})=>{t.setTextAlign("center")}},u$={title:{cs:"Zarovnat doleva",en:"Align left"},icon:h3,key:"align-left",command:({chain:t})=>{t.setTextAlign("left")}},d$={title:{cs:"Zarovnat doprava",en:"Align right"},icon:i8,key:"align-right",command:({chain:t})=>{t.setTextAlign("right")}},f$={title:{cs:"Kurzíva",en:"Italic"},icon:Bp,key:"italic",command:({chain:t})=>{t.toggleMark("italic")}},h$={title:{cs:"Podtržené",en:"Underline"},icon:k3,key:"underline",command:({chain:t})=>{t.toggleMark("underline")}},p$={title:{cs:"Horní index",en:"Superscript"},icon:S3,key:"superscript",command:({chain:t})=>{t.toggleMark("superscript")}},m$={title:{cs:"Dolní index",en:"Subscript"},icon:x3,key:"subscript",command:({chain:t})=>{t.toggleMark("subscript")}},g$={title:{cs:"Přeškrtnuté",en:"Strikethrough"},icon:w3,key:"strike",command:({chain:t})=>{t.toggleMark("strike")}},F3={title:{cs:"Seznamy",en:"Lists"},key:"lists",icon:C3,commands:[e$,s$]},y$={title:{cs:"Zarovnání",en:"Text align"},key:"textAlign",icon:h3,commands:[u$,c$,d$]},v$={title:{cs:"Dekorace textu",en:"Text Decorations"},key:"textDecorations",icon:Bp,commands:[f$,h$,g$,p$,m$]},np={image:RP,video:TF,newspaper:s6,plus:r1,content_text:G2,content_title:BT,content_lead:GU,quote:tF,content_divider:UT,content_documents:mP,file_text:G2,image_gallery:jT,image_grid:zP,image_masonry:xP,image_one_two:CP,image_with_text:o6,image_wrapping:o6,user:xF,rectangle_horizontal:PT,card_visual:fP,card_size:mF,card_full:hF,card_padded:LP,list:VT,listing_news:s6,listing_projects:vP,listing_project_card:HP,arrow_right:WU,hero_banner:KP,home:MP,tag:vF,contact_form:PP,link:jP,play:XP,form:rF,send:cF},W2={content:G2,images:jT,cards:PT,listings:VT,special:FT};let Lf=null;const KT=()=>(Lf!==null||(Lf=window.Folio?.Tiptap?.customIcons||{}),Lf),Wf=t=>{if(!t)return Xs;const e=KT();return e[t]?e[t]:np[t]?np[t]:(t&&console.warn(`Unknown icon string: ${t}, using Cuboid as fallback. Define custom icons in window.Folio.Tiptap.customIcons`),Xs)},b$=t=>W2[t]||Xs,f6=t=>{if(!t)return Xs;const e=KT();return e[t]?e[t]:np[t]?np[t]:W2[t]?W2[t]:Xs},C$=(t,e)=>{if(e&&e.length>0){const r={},i=[];t.forEach(c=>{const d=c.config?.group;d?(r[d]||(r[d]=[]),r[d].push(c)):i.push(c)});const o=Object.keys(r).sort((c,d)=>c.localeCompare(d)),l=[];if(o.forEach(c=>{const d=e.find(m=>m.key===c),f=document.documentElement.lang,h=r[c].map(m=>({title:m.title,icon:Wf(m.config?.icon),key:`folioTiptapNode-${m.type}`,command:()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),window.parent.postMessage({type:"f-tiptap-slash-command:selected",attrs:{type:m.type}},"*")}}));h.sort((m,g)=>{const y=m.title[f]||m.title.en,C=g.title[f]||g.title.en;return y.localeCompare(C)}),l.push({title:d?.title||{cs:c,en:c},key:`folioTiptapNodes-${c}`,icon:b$(c),commands:h})}),i.length>0){const c=document.documentElement.lang,d=i.map(f=>({title:f.title,icon:Wf(f.config?.icon),key:`folioTiptapNode-${f.type}`,command:()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),window.parent.postMessage({type:"f-tiptap-slash-command:selected",attrs:{type:f.type}},"*")}}));d.sort((f,h)=>{const m=f.title[c]||f.title.en,g=h.title[c]||h.title.en;return m.localeCompare(g)}),l.push({title:{cs:"Ostatní",en:"Other"},key:"folioTiptapNodes-other",icon:Xs,commands:d})}return l}const n=t.map(r=>({title:r.title,icon:Wf(r.config?.icon),key:`folioTiptapNode-${r.type}`,command:()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),window.parent.postMessage({type:"f-tiptap-slash-command:selected",attrs:{type:r.type}},"*")}}));return n.sort((r,i)=>{const o=r.title[document.documentElement.lang]||r.title.en,l=i.title[document.documentElement.lang]||i.title.en;return o.localeCompare(l)}),{title:{cs:"Bloky",en:"Blocks"},key:"folioTiptapNodes",icon:Xs,commands:n}},w$=({folioTiptapStyledWrapCommands:t,folioTiptapPagesCommands:e})=>({title:{cs:"Rozložení",en:"Layouts"},key:"layouts",icon:T3,commands:[a$,t$,n$,...t,...e,ZT]}),x$=({folioTiptapStyledParagraphCommands:t,folioTiptapHeadingLevels:e})=>{const n=[];return e&&(e.includes(2)&&n.push(o$),e.includes(3)&&n.push(i$),e.includes(4)&&n.push(r$)),e.length===1&&(n[0].title={cs:"Mezititulek",en:"Title"}),{title:{cs:"Formát textu",en:"Text format"},key:"textStyles",icon:g8,commands:[l$,...n,...t]}};function S$(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:o,startOfLine:l,$position:c}=t,d=r&&!i,f=v_(n),h=new RegExp(`\\s${f}$`),m=l?"^":"",g=i?"":f,y=d?new RegExp(`${m}${f}.*?(?=\\s${g}|$)`,"gm"):new RegExp(`${m}(?:^)?${f}[^\\s${g}]*`,"gm"),C=((e=c.nodeBefore)==null?void 0:e.isText)&&c.nodeBefore.text;if(!C)return null;const w=c.pos-C.length,x=Array.from(C.matchAll(y)).pop();if(!x||x.input===void 0||x.index===void 0)return null;const k=x.input.slice(Math.max(0,x.index-1),x.index),A=new RegExp(`^[${o?.join("")}\0]?$`).test(k);if(o!==null&&!A)return null;const N=w+x.index;let R=N+x[0].length;return d&&h.test(C.slice(R-1,R+1))&&(x[0]+=" ",R+=1),N=c.pos?{range:{from:N,to:R},query:x[0].slice(n.length),text:x[0]}:null}var T$=new qe("suggestion");function k$({pluginKey:t=T$,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:o=[" "],startOfLine:l=!1,decorationTag:c="span",decorationClass:d="suggestion",decorationContent:f="",decorationEmptyClass:h="is-empty",command:m=()=>null,items:g=()=>[],render:y=()=>({}),allow:C=()=>!0,findSuggestionMatch:w=S$}){let x;const k=y?.(),A=()=>{const z=e.state.selection.$anchor.pos,_=e.view.coordsAtPos(z),{top:q,right:J,bottom:U,left:ne}=_;try{return new DOMRect(ne,q,J-ne,U-q)}catch{return null}},N=(z,_)=>_?()=>{const q=t.getState(e.state),J=q?.decorationId,U=z.dom.querySelector(`[data-decoration-id="${J}"]`);return U?.getBoundingClientRect()||null}:A;function R(z,_){var q;try{const U=t.getState(z.state),ne=U?.decorationId?z.dom.querySelector(`[data-decoration-id="${U.decorationId}"]`):null,le={editor:e,range:U?.range||{from:0,to:0},query:U?.query||null,text:U?.text||null,items:[],command:oe=>m({editor:e,range:U?.range||{from:0,to:0},props:oe}),decorationNode:ne,clientRect:N(z,ne)};(q=k?.onExit)==null||q.call(k,le)}catch{}const J=z.state.tr.setMeta(_,{exit:!0});z.dispatch(J)}const L=new Ve({key:t,view(){return{update:async(z,_)=>{var q,J,U,ne,le,oe,G;const P=(q=this.key)==null?void 0:q.getState(_),H=(J=this.key)==null?void 0:J.getState(z.state),j=P.active&&H.active&&P.range.from!==H.range.from,B=!P.active&&H.active,re=P.active&&!H.active,ae=!B&&!re&&P.query!==H.query,D=B||j&&ae,Z=ae||j,W=re||j&&ae;if(!D&&!Z&&!W)return;const se=W&&!D?P:H,de=z.dom.querySelector(`[data-decoration-id="${se.decorationId}"]`);x={editor:e,range:se.range,query:se.query,text:se.text,items:[],command:ye=>m({editor:e,range:se.range,props:ye}),decorationNode:de,clientRect:N(z,de)},D&&((U=k?.onBeforeStart)==null||U.call(k,x)),Z&&((ne=k?.onBeforeUpdate)==null||ne.call(k,x)),(Z||D)&&(x.items=await g({editor:e,query:se.query})),W&&((le=k?.onExit)==null||le.call(k,x)),Z&&((oe=k?.onUpdate)==null||oe.call(k,x)),D&&((G=k?.onStart)==null||G.call(k,x))},destroy:()=>{var z;x&&((z=k?.onExit)==null||z.call(k,x))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(z,_,q,J){const{isEditable:U}=e,{composing:ne}=e.view,{selection:le}=z,{empty:oe,from:G}=le,P={..._},H=z.getMeta(t);if(H&&H.exit)return P.active=!1,P.decorationId=null,P.range={from:0,to:0},P.query=null,P.text=null,P;if(P.composing=ne,U&&(oe||e.view.composing)){(G<_.range.from||G>_.range.to)&&!ne&&!_.composing&&(P.active=!1);const j=w({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:o,startOfLine:l,$position:le.$from}),B=`id_${Math.floor(Math.random()*4294967295)}`;j&&C({editor:e,state:J,range:j.range,isActive:_.active})?(P.active=!0,P.decorationId=_.decorationId?_.decorationId:B,P.range=j.range,P.query=j.query,P.text=j.text):P.active=!1}else P.active=!1;return P.active||(P.decorationId=null,P.range={from:0,to:0},P.query=null,P.text=null),P}},props:{handleKeyDown(z,_){var q,J,U,ne;const{active:le,range:oe}=L.getState(z.state);if(!le)return!1;if(_.key==="Escape"||_.key==="Esc"){const P=L.getState(z.state),H=(q=x?.decorationNode)!=null?q:null,j=H??(P?.decorationId?z.dom.querySelector(`[data-decoration-id="${P.decorationId}"]`):null);if(((J=k?.onKeyDown)==null?void 0:J.call(k,{view:z,event:_,range:P.range}))||!1)return!0;const re={editor:e,range:P.range,query:P.query,text:P.text,items:[],command:ae=>m({editor:e,range:P.range,props:ae}),decorationNode:j,clientRect:j?()=>j.getBoundingClientRect()||null:null};return(U=k?.onExit)==null||U.call(k,re),R(z,t),!0}return((ne=k?.onKeyDown)==null?void 0:ne.call(k,{view:z,event:_,range:oe}))||!1},decorations(z){const{active:_,range:q,decorationId:J,query:U}=L.getState(z);if(!_)return null;const ne=!U?.length,le=[d];return ne&&le.push(h),Xe.create(z.doc,[Ft.inline(q.from,q.to,{nodeName:c,class:le.join(" "),"data-decoration-id":J,"data-decoration-content":f})])}}});return L}var E$=k$;const M$=Ze.create({name:"folioTiptapCommands",addOptions(){return{suggestion:{char:"/",command:({editor:t,range:e,props:n})=>{const r=t.chain();r.focus(),r.deleteRange(e),n.command({chain:r}),r.run()}}}},addProseMirrorPlugins(){return[E$({editor:this.editor,...this.options.suggestion})]},addCommands(){return{triggerFolioTiptapCommand:t=>({state:e,dispatch:n})=>{const r=t||e.selection.$from;if(!r)return console.error("Invalid resolved position"),!1;let i=r.node(1);i||(t?i=e.doc.nodeAt(t.pos):e.selection instanceof me&&(i=e.selection.node));let o=!0,l;i&&i.isLeaf?l=r.after(1)+i.nodeSize:i&&i.type.name==="paragraph"&&i.content.size===0?(o=!1,l=r.start(1)):l=r.after(1);const c=e.tr;if(o){const f=e.schema.nodes.paragraph.create({},[e.schema.text("/")]);c.insert(l,f)}else{const f=e.schema.text("/");c.insert(l,f)}const d=l+1+(o?1:0);return c.setSelection(ue.create(c.doc,d)),n&&n(c),!0}}}}),h6={cs:{defaultAction:"Napsat /{query} do obsahu",defaultBlankAction:"Zavřít nabídku"},en:{defaultAction:"Type /{query} to content",defaultBlankAction:"Close menu"}};class A$ extends Qe.Component{constructor(e){super(e),this.state={selectedIndex:0}}onEscape(){this.props.command({title:"",normalizedTitle:"",icon:i1,key:"commandListEscape",command:({chain:e})=>{this.props.query&&e.insertContent(`/${this.props.query} `)}})}onKeyDown({event:e}){return e.key==="ArrowUp"?(this.upHandler(),!0):e.key==="ArrowDown"||e.key==="Tab"?(this.downHandler(),!0):e.key==="Enter"?(this.enterHandler(),!0):!1}setSelectedIndex(e){this.setState({selectedIndex:e})}upHandler(){let e=this.state.selectedIndex-1;if(e<0){let n=0;this.props.items.forEach(r=>{n+=r.commandsForSuggestion.length}),e=n-1}this.setSelectedIndex(e)}downHandler(){let e=0;this.props.items.forEach(r=>{e+=r.commandsForSuggestion.length});let n=this.state.selectedIndex+1;n>=e&&(n=0),this.setSelectedIndex(n)}enterHandler(){let e=-1,n=null;this.props.items.forEach(r=>{n||r.commandsForSuggestion.forEach(i=>{n||(e+=1,e===this.state.selectedIndex&&(n=i))})}),n&&this.selectItem(n)}selectItem(e){e&&this.props.command(e)}componentDidUpdate(e){let n=0;e.items.forEach(i=>{n+=i.commandsForSuggestion.length});let r=0;this.props.items.forEach(i=>{r+=i.commandsForSuggestion.length}),r!==n&&this.setState({selectedIndex:0})}render(){let e=-1;return S.jsxs("div",{className:"f-tiptap-commands-list",children:[this.props.items.length>0?S.jsx("div",{className:"f-tiptap-commands-list__section f-tiptap-commands-list__section--scroll",children:this.props.items.map(n=>S.jsxs(Qe.Fragment,{children:[S.jsx("div",{className:"f-tiptap-commands-list__section-heading",children:n.title}),S.jsx("ul",{className:"f-tiptap-commands-list__section-ul",children:n.commandsForSuggestion.map(r=>{e+=1;const i=r.icon,o=e;return S.jsx("li",{className:"f-tiptap-commands-list__section-li",children:S.jsx("button",{type:"button",className:"f-tiptap-commands-list__item f-tiptap-commands-list__item--active","data-selected":String(e===this.state.selectedIndex),onClick:()=>this.selectItem(r),onMouseOver:()=>this.setSelectedIndex(o),children:S.jsxs("span",{className:"f-tiptap-commands-list__item-inner",children:[i?S.jsx(i,{className:"f-tiptap-commands-list__item-icon"}):null,S.jsx("span",{className:"f-tiptap-commands-list__item-label",children:r.title}),S.jsx("span",{className:"f-tiptap-commands-list__item-keymap","data-keymap":r.keymap})]})})},`${n.title}-${r.title}`)})})]},n.title))}):null,S.jsx("div",{className:"f-tiptap-commands-list__section f-tiptap-commands-list__section--fallback",children:S.jsx("ul",{className:"f-tiptap-commands-list__section-ul",children:S.jsx("li",{className:"f-tiptap-commands-list__section-li",children:S.jsx("span",{className:"f-tiptap-commands-list__item f-tiptap-commands-list__item--fallback",children:S.jsxs("span",{className:"f-tiptap-commands-list__item-inner",children:[S.jsx("span",{className:"f-tiptap-commands-list__item-label",children:this.props.query?pe(h6,"defaultAction").replace("{query}",this.props.query):pe(h6,"defaultBlankAction")}),S.jsx("span",{className:"f-tiptap-commands-list__item-keymap",children:"esc"})]})})})})})]})}}class N$ extends Qe.Component{close(){console.log("close"),this.props.command({title:"",normalizedTitle:"",icon:i1,key:"commandListBackdrop",command:({chain:e})=>{console.log("commandListBackdrop",this.props.query),this.props.query&&(console.log("insertContent"),e.insertContent(" "))}})}render(){return S.jsx("div",{className:"f-tiptap-commands-list-backdrop",onClick:()=>this.close()})}}const GT=t=>t.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase(),YT=t=>({query:e})=>{const n=GT(e);return R$(t).map(r=>{const i=r.commandsForSuggestion.filter(o=>o.normalizedTitle.indexOf(n)!==-1);return i.length>0?{...r,commandsForSuggestion:i}:null}).filter(r=>r!==null)},R$=t=>{const e=document.documentElement.lang;return t.map(n=>{let r;return typeof n.title=="string"?r=n.title:r=n.title[e]||n.title.en,{title:r,key:n.key,commandsForSuggestion:n.commands.map(i=>{let o;return typeof i.title=="string"?o=i.title:o=i.title[e]||i.title.en,{...i,title:o,normalizedTitle:GT(o)}})}})},WT={allowSpaces:!1,render:()=>{let t=null,e=null;function n(r,i){if(!t||!t.element)return;const o={getBoundingClientRect(){return r}};let l="bottom-start";i==="update"&&t&&t.element&&t.element.dataset.placement&&(l=t.element.dataset.placement),ju(o,t.element,{placement:l,middleware:[Kp(),Zp(12),Gp({apply({availableWidth:c,availableHeight:d}){Object.assign(t.element.style,{maxWidth:`${Math.max(0,c)}px`,maxHeight:`${Math.max(0,d)}px`,pointerEvents:"none"})}})]}).then(c=>{t.element.dataset.placement=c.placement,Object.assign(t.element.style,{left:`${c.x}px`,top:`${c.y}px`,zIndex:"11",position:c.strategy==="fixed"?"fixed":"absolute",display:"flex",flexDirection:"column"}),Object.assign(e.element.style,{inset:0,position:c.strategy==="fixed"?"fixed":"absolute",zIndex:"10"})})}return{onStart:r=>{r.editor.chain().setMeta("hideDragHandle",!0).setMeta("lockDragHandle",!0).run(),e=new x2(N$,{props:{...r,query:r.query},editor:r.editor}),document.body.appendChild(e.element),t=new x2(A$,{props:{...r,query:r.query},editor:r.editor}),document.body.appendChild(t.element),n(r.clientRect(),"start")},onUpdate(r){t?.updateProps(r),n(r.clientRect(),"update")},onKeyDown(r){return r.event.key==="Escape"?(t?.ref&&typeof t.ref.onEscape=="function"&&t.ref.onEscape(),e?.element&&(e.element.remove(),e.destroy()),t?.element&&(t.element.remove(),t.destroy()),!0):t?.ref?.onKeyDown(r)},onExit(r){r.editor.chain().setMeta("hideDragHandle",!1).setMeta("lockDragHandle",!1).run(),t&&(e&&(e.element&&document.body.contains(e.element)&&document.body.removeChild(e.element),e.destroy()),t.element&&document.body.contains(t.element)&&document.body.removeChild(t.element),t.destroy())}}}},O$=({textStylesCommandGroup:t})=>({...WT,items:YT([t,F3])}),Fr=()=>new Map,J2=t=>{const e=Fr();return t.forEach((n,r)=>{e.set(r,n)}),e},to=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},D$=(t,e)=>{const n=[];for(const[r,i]of t)n.push(e(i,r));return n},L$=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},Qs=()=>new Set,j0=t=>t[t.length-1],_$=(t,e)=>{for(let n=0;n{for(let n=0;n{for(let n=0;n{const n=new Array(t);for(let r=0;r{this.off(e,r),n(...i)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return el((this._observers.get(e)||Fr()).values()).forEach(r=>r(...n))}destroy(){this._observers=Fr()}}const Zr=Math.floor,Jf=Math.abs,Ea=(t,e)=>tt>e?t:e,XT=t=>t!==0?t<0:1/t<0,p6=1,m6=2,V0=4,U0=8,bu=32,Gi=64,Dn=128,I$=1<<29,s1=31,X2=63,Ps=127,z$=2147483647,rp=Number.MAX_SAFE_INTEGER,g6=Number.MIN_SAFE_INTEGER,B$=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&Zr(t)===t),QT=String.fromCharCode,j$=t=>t.toLowerCase(),V$=/^\s*/g,U$=t=>t.replace(V$,""),P$=/([A-Z])/g,y6=(t,e)=>U$(t.replace(P$,n=>`${e}${j$(n)}`)),F$=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let i=0;iCu.encode(t),q$=Cu?$$:F$;let ru=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});ru&&ru.decode(new Uint8Array).length===1&&(ru=null);const Z$=(t,e)=>H$(e,()=>t).join("");class $u{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const qu=()=>new $u,K$=t=>{const e=qu();return t(e),Ur(e)},G$=t=>{let e=t.cpos;for(let n=0;n{const e=new Uint8Array(G$(t));let n=0;for(let r=0;r{const n=t.cbuf.length;n-t.cpos{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},Q2=Xt,Ue=(t,e)=>{for(;e>Ps;)Xt(t,Dn|Ps&e),e=Zr(e/128);Xt(t,Ps&e)},Z3=(t,e)=>{const n=XT(e);for(n&&(e=-e),Xt(t,(e>X2?Dn:0)|(n?Gi:0)|X2&e),e=Zr(e/64);e>0;)Xt(t,(e>Ps?Dn:0)|Ps&e),e=Zr(e/128)},ey=new Uint8Array(3e4),W$=ey.length/3,J$=(t,e)=>{if(e.length{const n=unescape(encodeURIComponent(e)),r=n.length;Ue(t,r);for(let i=0;i{const n=t.cbuf.length,r=t.cpos,i=Ea(n-r,e.length),o=e.length-i;t.cbuf.set(e.subarray(0,i),r),t.cpos+=i,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(Qo(n*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o)},sr=(t,e)=>{Ue(t,e.byteLength),l1(t,e)},K3=(t,e)=>{Y$(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},Q$=(t,e)=>K3(t,4).setFloat32(0,e,!1),eq=(t,e)=>K3(t,8).setFloat64(0,e,!1),tq=(t,e)=>K3(t,8).setBigInt64(0,e,!1),v6=new DataView(new ArrayBuffer(4)),nq=t=>(v6.setFloat32(0,t),v6.getFloat32(0)===t),Ma=(t,e)=>{switch(typeof e){case"string":Xt(t,119),ca(t,e);break;case"number":B$(e)&&Jf(e)<=z$?(Xt(t,125),Z3(t,e)):nq(e)?(Xt(t,124),Q$(t,e)):(Xt(t,123),eq(t,e));break;case"bigint":Xt(t,122),tq(t,e);break;case"object":if(e===null)Xt(t,126);else if(ka(e)){Xt(t,117),Ue(t,e.length);for(let n=0;n0&&Ue(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const C6=t=>{t.count>0&&(Z3(t.encoder,t.count===1?t.s:-t.s),t.count>1&&Ue(t.encoder,t.count-2))};class Xf{constructor(){this.encoder=new $u,this.s=0,this.count=0}write(e){this.s===e?this.count++:(C6(this),this.count=1,this.s=e)}toUint8Array(){return C6(this),Ur(this.encoder)}}const w6=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);Z3(t.encoder,e),t.count>1&&Ue(t.encoder,t.count-2)}};class P0{constructor(){this.encoder=new $u,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(w6(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return w6(this),Ur(this.encoder)}}class rq{constructor(){this.sarr=[],this.s="",this.lensE=new Xf}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new $u;return this.sarr.push(this.s),this.s="",ca(e,this.sarr.join("")),l1(e,this.lensE.toUint8Array()),Ur(e)}}const fi=t=>new Error(t),Nr=()=>{throw fi("Method unimplemented")},En=()=>{throw fi("Unexpected case")},ek=fi("Unexpected end of array"),tk=fi("Integer out of Range");class a1{constructor(e){this.arr=e,this.pos=0}}const G3=t=>new a1(t),iq=t=>t.pos!==t.arr.length,oq=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Sr=t=>oq(t,vt(t)),wu=t=>t.arr[t.pos++],vt=t=>{let e=0,n=1;const r=t.arr.length;for(;t.posrp)throw tk}throw ek},Y3=t=>{let e=t.arr[t.pos++],n=e&X2,r=64;const i=(e&Gi)>0?-1:1;if((e&Dn)===0)return i*n;const o=t.arr.length;for(;t.posrp)throw tk}throw ek},sq=t=>{let e=vt(t);if(e===0)return"";{let n=String.fromCodePoint(wu(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(wu(t));else for(;e>0;){const r=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(n))}},lq=t=>ru.decode(Sr(t)),ty=ru?lq:sq,W3=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},aq=t=>W3(t,4).getFloat32(0,!1),cq=t=>W3(t,8).getFloat64(0,!1),uq=t=>W3(t,8).getBigInt64(0,!1),dq=[t=>{},t=>null,Y3,aq,cq,uq,t=>!1,t=>!0,ty,t=>{const e=vt(t),n={};for(let r=0;r{const e=vt(t),n=[];for(let r=0;rdq[127-wu(t)](t);class x6 extends a1{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),iq(this)?this.count=vt(this)+1:this.count=-1),this.count--,this.s}}class Qf extends a1{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Y3(this);const e=XT(this.s);this.count=1,e&&(this.s=-this.s,this.count=vt(this)+2)}return this.count--,this.s}}class F0 extends a1{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=Y3(this),n=e&1;this.diff=Zr(e/2),this.count=1,n&&(this.count=vt(this)+2)}return this.s+=this.diff,this.count--,this.s}}class fq{constructor(e){this.decoder=new Qf(e),this.str=ty(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const hq=crypto.getRandomValues.bind(crypto),pq=Math.random,nk=()=>hq(new Uint32Array(1))[0],mq=t=>t[Zr(pq()*t.length)],gq="10000000-1000-4000-8000"+-1e11,yq=()=>gq.replace(/[018]/g,t=>(t^nk()&15>>t/4).toString(16)),vq=Date.now,S6=t=>new Promise(t);Promise.all.bind(Promise);const T6=t=>t===void 0?null:t;class bq{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let rk=new bq,Cq=!0;try{typeof localStorage<"u"&&localStorage&&(rk=localStorage,Cq=!1)}catch{}const wq=rk,xu=Symbol("Equality"),ik=(t,e)=>t===e||!!t?.[xu]?.(e)||!1,xq=t=>typeof t=="object",Sq=Object.assign,ok=Object.keys,Tq=(t,e)=>{for(const n in t)e(t[n],n)},op=t=>ok(t).length,kq=t=>{for(const e in t)return!1;return!0},Ha=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},J3=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Eq=(t,e)=>t===e||op(t)===op(e)&&Ha(t,(n,r)=>(n!==void 0||J3(e,r))&&ik(e[r],n)),Mq=Object.freeze,sk=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&sk(t[e])}return Mq(t)},X3=(t,e,n=0)=>{try{for(;n{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[xu]!=null)return t[xu](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;ne.includes(t);var lk={};const Aa=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",ak=typeof window<"u"&&typeof document<"u"&&!Aa;let ii;const Nq=()=>{if(ii===void 0)if(Aa){ii=Fr();const t=process.argv;let e=null;for(let n=0;n{if(t.length!==0){const[e,n]=t.split("=");ii.set(`--${y6(e,"-")}`,n),ii.set(`-${y6(e,"-")}`,n)}})):ii=Fr();return ii},ny=t=>Nq().has(t),sp=t=>T6(Aa?lk[t.toUpperCase().replaceAll("-","_")]:wq.getItem(t)),ck=t=>ny("--"+t)||sp(t)!==null,Rq=ck("production"),Oq=Aa&&Aq(lk.FORCE_COLOR,["true","1","2"]),Dq=Oq||!ny("--no-colors")&&!ck("no-color")&&(!Aa||process.stdout.isTTY)&&(!Aa||ny("--color")||sp("COLORTERM")!==null||(sp("TERM")||"").includes("color")),Lq=t=>{let e="";for(let n=0;nBuffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),Hq=ak?Lq:_q,Iq=t=>K$(e=>Ma(e,t));class zq{constructor(e,n){this.left=e,this.right=n}}const zi=(t,e)=>new zq(t,e),k6=t=>t.next()>=.5,$0=(t,e,n)=>Zr(t.next()*(n+1-e)+e),uk=(t,e,n)=>Zr(t.next()*(n+1-e)+e),Q3=(t,e,n)=>uk(t,e,n),Bq=t=>QT(Q3(t,97,122)),jq=(t,e=0,n=20)=>{const r=Q3(t,e,n);let i="";for(let o=0;oe[Q3(t,0,e.length-1)],Vq=Symbol("0schema");class Uq{constructor(){this._rerrs=[]}extend(e,n,r,i=null){this._rerrs.push({path:e,expected:n,has:r,message:i})}toString(){const e=[];for(let n=this._rerrs.length-1;n>0;n--){const r=this._rerrs[n];e.push(Z$(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(` +`}),m}var ZB=qB,QS=st.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:BB,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:i}=jB(t,this.options.cellMinWidth),o=e.style;function l(){return o||(r?`width: ${r}`:`min-width: ${i}`)}const c=["table",Fe(this.options.HTMLAttributes,e,{style:l()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},c]:c},parseMarkdown:(t,e)=>{const n=[];if(t.header){const r=[];t.header.forEach(i=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(r=>{const i=[];r.forEach(o=>{i.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(o.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>ZB(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:o})=>{const l=UB(o.schema,t,e,n);if(i){const c=r.selection.from+1;r.replaceSelectionWith(l).scrollIntoView().setSelection(ue.near(r.doc.resolve(c)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>Qz(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>eB(t,e),deleteColumn:()=>({state:t,dispatch:e})=>nB(t,e),addRowBefore:()=>({state:t,dispatch:e})=>iB(t,e),addRowAfter:()=>({state:t,dispatch:e})=>oB(t,e),deleteRow:()=>({state:t,dispatch:e})=>lB(t,e),deleteTable:()=>({state:t,dispatch:e})=>pB(t,e),mergeCells:()=>({state:t,dispatch:e})=>o5(t,e),splitCell:()=>({state:t,dispatch:e})=>s5(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>yu("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>yu("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>fB(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>o5(t,e)?!0:s5(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>uB(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>a5(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>a5(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&GS(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=dt.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Mf,"Mod-Backspace":Mf,Delete:Mf,"Mod-Delete":Mf}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[TB({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],_B({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:Ye(be(t,"tableRole",e))}}}),KB=Ke.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(QS.configure(this.options.table)),this.options.tableCell!==!1&&t.push(HB.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(IB.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(zB.configure(this.options.tableRow)),t}});let GB=1;const Ui=()=>`folioTiptapNode-${GB++}`,j2=(t,e)=>{window.parent.postMessage({type:"f-tiptap-node:click",attrs:t,uniqueId:e},"*")},e8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[S.jsx("rect",{width:"10",height:"20",x:"2",y:"2",rx:"2"}),S.jsx("path",{d:"M21.593 11.998H15.19M18.39 15.201V8.8"})]}));e8.displayName="AddColumnAfter";const t8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:S.jsxs("g",{transform:"rotate(180 12 12)",children:[S.jsx("rect",{width:"10",height:"20",x:"2",y:"2",rx:"2"}),S.jsx("path",{d:"M21.593 11.998H15.19M18.39 15.201V8.8"})]})}));t8.displayName="AddColumnBefore";const n8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2ZM4 12C4 7.58172 7.58172 4 12 4C16.4183 4 20 7.58172 20 12C20 16.4183 16.4183 20 12 20C7.58172 20 4 16.4183 4 12Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 7C12.5523 7 13 7.44772 13 8V12C13 12.5523 12.5523 13 12 13C11.4477 13 11 12.5523 11 12V8C11 7.44772 11.4477 7 12 7Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 15C12.5523 15 13 15.4477 13 16C13 16.5523 12.5523 17 12 17C11.4477 17 11 16.5523 11 16C11 15.4477 11.4477 15 12 15Z",fill:"currentColor"})]}));n8.displayName="AlertCircleIcon";const r8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 12C6 11.4477 6.44772 11 7 11H17C17.5523 11 18 11.4477 18 12C18 12.5523 17.5523 13 17 13H7C6.44772 13 6 12.5523 6 12Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 18C4 17.4477 4.44772 17 5 17H19C19.5523 17 20 17.4477 20 18C20 18.5523 19.5523 19 19 19H5C4.44772 19 4 18.5523 4 18Z",fill:"currentColor"})]}));r8.displayName="AlignCenterIcon";const YB=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));YB.displayName="AlignJustifyIcon";const h3=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H15C15.5523 11 16 11.4477 16 12C16 12.5523 15.5523 13 15 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H17C17.5523 17 18 17.4477 18 18C18 18.5523 17.5523 19 17 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));h3.displayName="AlignLeftIcon";const i8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 18C6 17.4477 6.44772 17 7 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H7C6.44772 19 6 18.5523 6 18Z",fill:"currentColor"})]}));i8.displayName="AlignRightIcon";const o8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M11.92 19.92L4 12L11.92 4.08L13.33 5.5L7.83 11H22V13H7.83L13.34 18.5L11.92 19.92ZM4 12V2H2V22H4V12Z",fill:"currentColor"})}));o8.displayName="ArrowCollapseLeft";const s8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M12.08 4.08L20 12L12.08 19.92L10.67 18.5L16.17 13H2V11H16.17L10.67 5.5L12.08 4.08ZM20 12V22H22V2H20V12Z",fill:"currentColor"})}));s8.displayName="ArrowCollapseRight";const p3=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M11.0001 4H13.0001V16L18.5001 10.5L19.9201 11.92L12.0001 19.84L4.08008 11.92L5.50008 10.5L11.0001 16V4Z",fill:"currentColor"})}));p3.displayName="ArrowDownIcon";const WB=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M12.7071 5.70711C13.0976 5.31658 13.0976 4.68342 12.7071 4.29289C12.3166 3.90237 11.6834 3.90237 11.2929 4.29289L4.29289 11.2929C3.90237 11.6834 3.90237 12.3166 4.29289 12.7071L11.2929 19.7071C11.6834 20.0976 12.3166 20.0976 12.7071 19.7071C13.0976 19.3166 13.0976 18.6834 12.7071 18.2929L7.41421 13L19 13C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11L7.41421 11L12.7071 5.70711Z",fill:"currentColor"})}));WB.displayName="ArrowLeftIcon";const l8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M18 16V13H15V22H13V2H15V11H18V8L22 12L18 16ZM2 12L6 16V13H9V22H11V2H9V11H6V8L2 12Z",fill:"currentColor"})}));l8.displayName="ArrowSplitVerticalIcon";const m3=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M13.0001 20H11.0001V8.00003L5.50008 13.5L4.08008 12.08L12.0001 4.16003L19.9201 12.08L18.5001 13.5L13.0001 8.00003V20Z",fill:"currentColor"})}));m3.displayName="ArrowUpIcon";const JB=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.43471 4.01458C4.34773 4.06032 4.26607 4.11977 4.19292 4.19292C4.11977 4.26607 4.06032 4.34773 4.01458 4.43471C2.14611 6.40628 1 9.0693 1 12C1 18.0751 5.92487 23 12 23C14.9306 23 17.5936 21.854 19.5651 19.9856C19.6522 19.9398 19.7339 19.8803 19.8071 19.8071C19.8803 19.7339 19.9398 19.6522 19.9856 19.5651C21.854 17.5936 23 14.9306 23 12C23 5.92487 18.0751 1 12 1C9.0693 1 6.40628 2.14611 4.43471 4.01458ZM6.38231 4.9681C7.92199 3.73647 9.87499 3 12 3C16.9706 3 21 7.02944 21 12C21 14.125 20.2635 16.078 19.0319 17.6177L6.38231 4.9681ZM17.6177 19.0319C16.078 20.2635 14.125 21 12 21C7.02944 21 3 16.9706 3 12C3 9.87499 3.73647 7.92199 4.9681 6.38231L17.6177 19.0319Z",fill:"currentColor"})}));JB.displayName="BanIcon";const XB=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 6C8 5.44772 8.44772 5 9 5H16C16.5523 5 17 5.44772 17 6C17 6.55228 16.5523 7 16 7H9C8.44772 7 8 6.55228 8 6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 3C4.55228 3 5 3.44772 5 4L5 20C5 20.5523 4.55229 21 4 21C3.44772 21 3 20.5523 3 20L3 4C3 3.44772 3.44772 3 4 3Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H20C20.5523 11 21 11.4477 21 12C21 12.5523 20.5523 13 20 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 18C8 17.4477 8.44772 17 9 17H16C16.5523 17 17 17.4477 17 18C17 18.5523 16.5523 19 16 19H9C8.44772 19 8 18.5523 8 18Z",fill:"currentColor"})]}));XB.displayName="BlockQuoteIcon";const a8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 2.5C5.17157 2.5 4.5 3.17157 4.5 4V20C4.5 20.8284 5.17157 21.5 6 21.5H15C16.4587 21.5 17.8576 20.9205 18.8891 19.8891C19.9205 18.8576 20.5 17.4587 20.5 16C20.5 14.5413 19.9205 13.1424 18.8891 12.1109C18.6781 11.9 18.4518 11.7079 18.2128 11.5359C19.041 10.5492 19.5 9.29829 19.5 8C19.5 6.54131 18.9205 5.14236 17.8891 4.11091C16.8576 3.07946 15.4587 2.5 14 2.5H6ZM14 10.5C14.663 10.5 15.2989 10.2366 15.7678 9.76777C16.2366 9.29893 16.5 8.66304 16.5 8C16.5 7.33696 16.2366 6.70107 15.7678 6.23223C15.2989 5.76339 14.663 5.5 14 5.5H7.5V10.5H14ZM7.5 18.5V13.5H15C15.663 13.5 16.2989 13.7634 16.7678 14.2322C17.2366 14.7011 17.5 15.337 17.5 16C17.5 16.663 17.2366 17.2989 16.7678 17.7678C16.2989 18.2366 15.663 18.5 15 18.5H7.5Z",fill:"currentColor"})}));a8.displayName="BoldIcon";const QB=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.7071 6.29289C21.0976 6.68342 21.0976 7.31658 20.7071 7.70711L10.7071 17.7071C10.3166 18.0976 9.68342 18.0976 9.29289 17.7071L4.29289 12.7071C3.90237 12.3166 3.90237 11.6834 4.29289 11.2929C4.68342 10.9024 5.31658 10.9024 5.70711 11.2929L10 15.5858L19.2929 6.29289C19.6834 5.90237 20.3166 5.90237 20.7071 6.29289Z",fill:"currentColor"})}));QB.displayName="CheckIcon";const g3=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.29289 8.29289C5.68342 7.90237 6.31658 7.90237 6.70711 8.29289L12 13.5858L17.2929 8.29289C17.6834 7.90237 18.3166 7.90237 18.7071 8.29289C19.0976 8.68342 19.0976 9.31658 18.7071 9.70711L12.7071 15.7071C12.3166 16.0976 11.6834 16.0976 11.2929 15.7071L5.29289 9.70711C4.90237 9.31658 4.90237 8.68342 5.29289 8.29289Z",fill:"currentColor"})}));g3.displayName="ChevronDownIcon";const zp=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12L19 6.41Z",fill:"currentColor"})}));zp.displayName="CloseIcon";const ej=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.70711 2.29289C7.09763 2.68342 7.09763 3.31658 6.70711 3.70711L4.41421 6L6.70711 8.29289C7.09763 8.68342 7.09763 9.31658 6.70711 9.70711C6.31658 10.0976 5.68342 10.0976 5.29289 9.70711L2.29289 6.70711C1.90237 6.31658 1.90237 5.68342 2.29289 5.29289L5.29289 2.29289C5.68342 1.90237 6.31658 1.90237 6.70711 2.29289Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.2929 2.29289C10.6834 1.90237 11.3166 1.90237 11.7071 2.29289L14.7071 5.29289C15.0976 5.68342 15.0976 6.31658 14.7071 6.70711L11.7071 9.70711C11.3166 10.0976 10.6834 10.0976 10.2929 9.70711C9.90237 9.31658 9.90237 8.68342 10.2929 8.29289L12.5858 6L10.2929 3.70711C9.90237 3.31658 9.90237 2.68342 10.2929 2.29289Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17 4C17 3.44772 17.4477 3 18 3H19C20.6569 3 22 4.34315 22 6V18C22 19.6569 20.6569 21 19 21H5C3.34315 21 2 19.6569 2 18V12C2 11.4477 2.44772 11 3 11C3.55228 11 4 11.4477 4 12V18C4 18.5523 4.44772 19 5 19H19C19.5523 19 20 18.5523 20 18V6C20 5.44772 19.5523 5 19 5H18C17.4477 5 17 4.55228 17 4Z",fill:"currentColor"})]}));ej.displayName="CodeBlockIcon";const c8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M15.4545 4.2983C15.6192 3.77115 15.3254 3.21028 14.7983 3.04554C14.2712 2.88081 13.7103 3.1746 13.5455 3.70175L8.54554 19.7017C8.38081 20.2289 8.6746 20.7898 9.20175 20.9545C9.72889 21.1192 10.2898 20.8254 10.4545 20.2983L15.4545 4.2983Z",fill:"currentColor"}),S.jsx("path",{d:"M6.70711 7.29289C7.09763 7.68342 7.09763 8.31658 6.70711 8.70711L3.41421 12L6.70711 15.2929C7.09763 15.6834 7.09763 16.3166 6.70711 16.7071C6.31658 17.0976 5.68342 17.0976 5.29289 16.7071L1.29289 12.7071C0.902369 12.3166 0.902369 11.6834 1.29289 11.2929L5.29289 7.29289C5.68342 6.90237 6.31658 6.90237 6.70711 7.29289Z",fill:"currentColor"}),S.jsx("path",{d:"M17.2929 7.29289C17.6834 6.90237 18.3166 6.90237 18.7071 7.29289L22.7071 11.2929C23.0976 11.6834 23.0976 12.3166 22.7071 12.7071L18.7071 16.7071C18.3166 17.0976 17.6834 17.0976 17.2929 16.7071C16.9024 16.3166 16.9024 15.6834 17.2929 15.2929L20.5858 12L17.2929 8.70711C16.9024 8.31658 16.9024 7.68342 17.2929 7.29289Z",fill:"currentColor"})]}));c8.displayName="Code2Icon";const u8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21 4C21 3.44772 20.5523 3 20 3C19.4477 3 19 3.44772 19 4V11C19 11.7956 18.6839 12.5587 18.1213 13.1213C17.5587 13.6839 16.7956 14 16 14H6.41421L9.70711 10.7071C10.0976 10.3166 10.0976 9.68342 9.70711 9.29289C9.31658 8.90237 8.68342 8.90237 8.29289 9.29289L3.29289 14.2929C2.90237 14.6834 2.90237 15.3166 3.29289 15.7071L8.29289 20.7071C8.68342 21.0976 9.31658 21.0976 9.70711 20.7071C10.0976 20.3166 10.0976 19.6834 9.70711 19.2929L6.41421 16H16C17.3261 16 18.5979 15.4732 19.5355 14.5355C20.4732 13.5979 21 12.3261 21 11V4Z",fill:"currentColor"})}));u8.displayName="CornerDownLeftIcon";const d8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M20.71 7.04006C21.1 6.65006 21.1 6.00006 20.71 5.63006L18.37 3.29006C18 2.90006 17.35 2.90006 16.96 3.29006L15.12 5.12006L18.87 8.87006M3 17.2501V21.0001H6.75L17.81 9.93006L14.06 6.18006L3 17.2501Z",fill:"currentColor"})}));d8.displayName="EditIcon";const f8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M14 3C14 2.44772 14.4477 2 15 2H21C21.5523 2 22 2.44772 22 3V9C22 9.55228 21.5523 10 21 10C20.4477 10 20 9.55228 20 9V5.41421L10.7071 14.7071C10.3166 15.0976 9.68342 15.0976 9.29289 14.7071C8.90237 14.3166 8.90237 13.6834 9.29289 13.2929L18.5858 4H15C14.4477 4 14 3.55228 14 3Z",fill:"currentColor"}),S.jsx("path",{d:"M4.29289 7.29289C4.48043 7.10536 4.73478 7 5 7H11C11.5523 7 12 6.55228 12 6C12 5.44772 11.5523 5 11 5H5C4.20435 5 3.44129 5.31607 2.87868 5.87868C2.31607 6.44129 2 7.20435 2 8V19C2 19.7957 2.31607 20.5587 2.87868 21.1213C3.44129 21.6839 4.20435 22 5 22H16C16.7957 22 17.5587 21.6839 18.1213 21.1213C18.6839 20.5587 19 19.7957 19 19V13C19 12.4477 18.5523 12 18 12C17.4477 12 17 12.4477 17 13V19C17 19.2652 16.8946 19.5196 16.7071 19.7071C16.5196 19.8946 16.2652 20 16 20H5C4.73478 20 4.48043 19.8946 4.29289 19.7071C4.10536 19.5196 4 19.2652 4 19V8C4 7.73478 4.10536 7.48043 4.29289 7.29289Z",fill:"currentColor"})]}));f8.displayName="ExternalLinkIcon";const h8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"17",height:"16",className:t,viewBox:"0 0 17 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M16.1789 8.32686L11.616 3.76343C11.4016 3.54914 11.1109 3.42877 10.8077 3.42877C10.5046 3.42877 10.2139 3.54914 9.99944 3.76343L6.93773 6.82514L4.50001 0H3.35715L0.5 8H1.64286L2.21372 6.28571H5.64229L6.10115 7.66171L1.97772 11.7851C1.87154 11.8913 1.78732 12.0173 1.72986 12.156C1.67239 12.2947 1.64282 12.4433 1.64282 12.5934C1.64282 12.7435 1.67239 12.8922 1.72986 13.0309C1.78732 13.1696 1.87154 13.2956 1.97772 13.4017L4.57544 16H10.0554L16.1789 9.876C16.2807 9.77427 16.3614 9.65348 16.4165 9.52052C16.4716 9.38757 16.5 9.24506 16.5 9.10114C16.5 8.95722 16.4716 8.81472 16.4165 8.68176C16.3614 8.54881 16.2807 8.42859 16.1789 8.32686ZM2.59429 5.14286L3.92629 1.14286L5.26115 5.14286H2.59429ZM9.58287 14.8571H5.04858L2.78572 12.5931L6.39258 8.98686L10.9229 13.5166L9.58287 14.8571ZM11.7314 12.7086L7.20115 8.17886L10.808 4.57143L15.3377 9.10114L11.7314 12.7086Z",fill:"currentColor"})}));h8.displayName="FormatEraseIcon";const p8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 -960 960 960",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M120-280v-400h400v400H120Zm80-80h240v-240H200v240Zm-80-400v-80h720v80H120Zm480 160v-80h240v80H600Zm0 160v-80h240v80H600Zm0 160v-80h240v80H600ZM120-120v-80h720v80H120Z",fill:"currentColor"})}));p8.displayName="FormatImageLeft";const m8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),S.jsx("path",{d:"M16 10C16 9.44772 16.4477 9 17 9H21C21.5523 9 22 9.44772 22 10C22 10.5523 21.5523 11 21 11H18V12H18.3C20.2754 12 22 13.4739 22 15.5C22 17.5261 20.2754 19 18.3 19C17.6457 19 17.0925 18.8643 16.5528 18.5944C16.0588 18.3474 15.8586 17.7468 16.1055 17.2528C16.3525 16.7588 16.9532 16.5586 17.4472 16.8056C17.7074 16.9357 17.9542 17 18.3 17C19.3246 17 20 16.2739 20 15.5C20 14.7261 19.3246 14 18.3 14H17C16.4477 14 16 13.5523 16 13L16 12.9928V10Z",fill:"currentColor"})]}));m8.displayName="HeadingFiveIcon";const y3=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",fill:"currentColor"}),S.jsx("path",{d:"M17 9C17.5523 9 18 9.44772 18 10V13H20V10C20 9.44772 20.4477 9 21 9C21.5523 9 22 9.44772 22 10V18C22 18.5523 21.5523 19 21 19C20.4477 19 20 18.5523 20 18V15H17C16.4477 15 16 14.5523 16 14V10C16 9.44772 16.4477 9 17 9Z",fill:"currentColor"})]}));y3.displayName="HeadingFourIcon";const g8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M6 3C6.55228 3 7 3.44772 7 4V11H17V4C17 3.44772 17.4477 3 18 3C18.5523 3 19 3.44772 19 4V20C19 20.5523 18.5523 21 18 21C17.4477 21 17 20.5523 17 20V13H7V20C7 20.5523 6.55228 21 6 21C5.44772 21 5 20.5523 5 20V4C5 3.44772 5.44772 3 6 3Z",fill:"currentColor"})}));g8.displayName="HeadingIcon";const y8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),S.jsx("path",{d:"M21.0001 10C21.0001 9.63121 20.7971 9.29235 20.472 9.11833C20.1468 8.94431 19.7523 8.96338 19.4454 9.16795L16.4454 11.168C15.9859 11.4743 15.8617 12.0952 16.1681 12.5547C16.4744 13.0142 17.0953 13.1384 17.5548 12.8321L19.0001 11.8685V18C19.0001 18.5523 19.4478 19 20.0001 19C20.5524 19 21.0001 18.5523 21.0001 18V10Z",fill:"currentColor"})]}));y8.displayName="HeadingOneIcon";const v8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.7071 9.29289C21.0976 9.68342 21.0976 10.3166 20.7071 10.7071C19.8392 11.575 19.2179 12.2949 18.7889 13.0073C18.8587 13.0025 18.929 13 19 13C20.6569 13 22 14.3431 22 16C22 17.6569 20.6569 19 19 19C17.3431 19 16 17.6569 16 16C16 14.6007 16.2837 13.4368 16.8676 12.3419C17.4384 11.2717 18.2728 10.3129 19.2929 9.29289C19.6834 8.90237 20.3166 8.90237 20.7071 9.29289ZM19 17C18.4477 17 18 16.5523 18 16C18 15.4477 18.4477 15 19 15C19.5523 15 20 15.4477 20 16C20 16.5523 19.5523 17 19 17Z",fill:"currentColor"})]}));v8.displayName="HeadingSixIcon";const v3=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.4608 11.2169C19.1135 11.0531 18.5876 11.0204 18.0069 11.3619C17.5309 11.642 16.918 11.4831 16.638 11.007C16.358 10.531 16.5169 9.91809 16.9929 9.63807C18.1123 8.97962 19.3364 8.94691 20.314 9.40808C21.2839 9.86558 21.9999 10.818 21.9999 12C21.9999 12.7957 21.6838 13.5587 21.1212 14.1213C20.5586 14.6839 19.7956 15 18.9999 15C18.4476 15 17.9999 14.5523 17.9999 14C17.9999 13.4477 18.4476 13 18.9999 13C19.2651 13 19.5195 12.8947 19.707 12.7071C19.8946 12.5196 19.9999 12.2652 19.9999 12C19.9999 11.6821 19.8159 11.3844 19.4608 11.2169Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.0001 14C18.0001 13.4477 18.4478 13 19.0001 13C19.7957 13 20.5588 13.3161 21.1214 13.8787C21.684 14.4413 22.0001 15.2043 22.0001 16C22.0001 17.2853 21.2767 18.3971 20.1604 18.8994C19.0257 19.41 17.642 19.2315 16.4001 18.3C15.9582 17.9686 15.8687 17.3418 16.2001 16.9C16.5314 16.4582 17.1582 16.3686 17.6001 16.7C18.3581 17.2685 18.9744 17.24 19.3397 17.0756C19.7234 16.9029 20.0001 16.5147 20.0001 16C20.0001 15.7348 19.8947 15.4804 19.7072 15.2929C19.5196 15.1054 19.2653 15 19.0001 15C18.4478 15 18.0001 14.5523 18.0001 14Z",fill:"currentColor"})]}));v3.displayName="HeadingThreeIcon";const b3=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),S.jsx("path",{d:"M22.0001 12C22.0001 10.7611 21.1663 9.79297 20.0663 9.42632C18.9547 9.05578 17.6171 9.28724 16.4001 10.2C15.9582 10.5314 15.8687 11.1582 16.2001 11.6C16.5314 12.0418 17.1582 12.1314 17.6001 11.8C18.383 11.2128 19.0455 11.1942 19.4338 11.3237C19.8339 11.457 20.0001 11.7389 20.0001 12C20.0001 12.4839 19.8554 12.7379 19.6537 12.9481C19.4275 13.1837 19.1378 13.363 18.7055 13.6307C18.6313 13.6767 18.553 13.7252 18.4701 13.777C17.9572 14.0975 17.3128 14.5261 16.8163 15.2087C16.3007 15.9177 16.0001 16.8183 16.0001 18C16.0001 18.5523 16.4478 19 17.0001 19H21.0001C21.5523 19 22.0001 18.5523 22.0001 18C22.0001 17.4477 21.5523 17 21.0001 17H18.131C18.21 16.742 18.3176 16.5448 18.4338 16.385C18.6873 16.0364 19.0429 15.7775 19.5301 15.473C19.5898 15.4357 19.6536 15.3966 19.7205 15.3556C20.139 15.0992 20.6783 14.7687 21.0964 14.3332C21.6447 13.7621 22.0001 13.0161 22.0001 12Z",fill:"currentColor"})]}));b3.displayName="HeadingTwoIcon";const tj=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.7072 4.70711C15.0977 4.31658 15.0977 3.68342 14.7072 3.29289C14.3167 2.90237 13.6835 2.90237 13.293 3.29289L8.69294 7.89286L8.68594 7.9C8.13626 8.46079 7.82837 9.21474 7.82837 10C7.82837 10.2306 7.85491 10.4584 7.90631 10.6795L2.29289 16.2929C2.10536 16.4804 2 16.7348 2 17V20C2 20.5523 2.44772 21 3 21H12C12.2652 21 12.5196 20.8946 12.7071 20.7071L15.3205 18.0937C15.5416 18.1452 15.7695 18.1717 16.0001 18.1717C16.7853 18.1717 17.5393 17.8639 18.1001 17.3142L22.7072 12.7071C23.0977 12.3166 23.0977 11.6834 22.7072 11.2929C22.3167 10.9024 21.6835 10.9024 21.293 11.2929L16.6971 15.8887C16.5105 16.0702 16.2605 16.1717 16.0001 16.1717C15.7397 16.1717 15.4897 16.0702 15.303 15.8887L10.1113 10.697C9.92992 10.5104 9.82837 10.2604 9.82837 10C9.82837 9.73963 9.92992 9.48958 10.1113 9.30297L14.7072 4.70711ZM13.5858 17L9.00004 12.4142L4 17.4142V19H11.5858L13.5858 17Z",fill:"currentColor"})}));tj.displayName="HighlighterIcon";const nj=E.memo(({className:t,...e})=>S.jsx("svg",{width:"17",height:"16",className:t,viewBox:"0 0 17 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M13.8333 1.33317C13.8333 0.964984 13.5348 0.666504 13.1666 0.666504C12.7984 0.666504 12.4999 0.964984 12.4999 1.33317V2.6665H11.1666C10.7984 2.6665 10.4999 2.96498 10.4999 3.33317C10.4999 3.70136 10.7984 3.99984 11.1666 3.99984H12.4999V5.33317C12.4999 5.70136 12.7984 5.99984 13.1666 5.99984C13.5348 5.99984 13.8333 5.70136 13.8333 5.33317V3.99984H15.1666C15.5348 3.99984 15.8333 3.70136 15.8333 3.33317C15.8333 2.96498 15.5348 2.6665 15.1666 2.6665H13.8333V1.33317ZM3.83325 2.6665C3.65644 2.6665 3.48687 2.73674 3.36185 2.86176C3.23683 2.98679 3.16659 3.15636 3.16659 3.33317V12.6665C3.16659 12.8433 3.23683 13.0129 3.36185 13.1379C3.48687 13.2629 3.65644 13.3332 3.83325 13.3332H4.22378L10.0859 7.47104C10.461 7.0961 10.9696 6.88544 11.4999 6.88544C12.0303 6.88544 12.5389 7.0961 12.9139 7.47104L13.8333 8.39037V7.99984C13.8333 7.63164 14.1317 7.33317 14.4999 7.33317C14.8681 7.33317 15.1666 7.63164 15.1666 7.99984V9.9985V10.0012V12.6665C15.1666 13.197 14.9559 13.7056 14.5808 14.0807C14.2057 14.4558 13.6971 14.6665 13.1666 14.6665H4.50138H4.49846H3.83325C3.30282 14.6665 2.79411 14.4558 2.41904 14.0807C2.04397 13.7056 1.83325 13.197 1.83325 12.6665V3.33317C1.83325 2.80274 2.04397 2.29403 2.41904 1.91896C2.79411 1.54388 3.30282 1.33317 3.83325 1.33317H8.49992C8.86812 1.33317 9.16659 1.63165 9.16659 1.99984C9.16659 2.36802 8.86812 2.6665 8.49992 2.6665H3.83325ZM6.1094 13.3332H13.1666C13.3434 13.3332 13.513 13.2629 13.638 13.1379C13.763 13.0129 13.8333 12.8433 13.8333 12.6665V10.276L11.9713 8.41397C11.8463 8.28904 11.6767 8.21877 11.4999 8.21877C11.3232 8.21877 11.1537 8.28897 11.0287 8.4139L6.1094 13.3332ZM5.08571 4.58562C5.46078 4.21055 5.96949 3.99984 6.49992 3.99984C7.03035 3.99984 7.53905 4.21055 7.91412 4.58562C8.28919 4.9607 8.49992 5.4694 8.49992 5.99984C8.49992 6.53027 8.28919 7.03897 7.91412 7.41404C7.53905 7.7891 7.03035 7.99984 6.49992 7.99984C5.96949 7.99984 5.46078 7.7891 5.08571 7.41404C4.71063 7.03897 4.49992 6.53027 4.49992 5.99984C4.49992 5.4694 4.71063 4.9607 5.08571 4.58562ZM6.49992 5.33317C6.32311 5.33317 6.15354 5.40341 6.02851 5.52843C5.90349 5.65346 5.83325 5.82302 5.83325 5.99984C5.83325 6.17665 5.90349 6.34622 6.02851 6.47124C6.15354 6.59626 6.32311 6.6665 6.49992 6.6665C6.67673 6.6665 6.8463 6.59626 6.97133 6.47124C7.09635 6.34622 7.16659 6.17665 7.16659 5.99984C7.16659 5.82302 7.09635 5.65346 6.97133 5.52843C6.8463 5.40341 6.67673 5.33317 6.49992 5.33317Z",fill:"currentColor"})}));nj.displayName="ImageIcon";const Bp=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M15.0222 3H19C19.5523 3 20 3.44772 20 4C20 4.55228 19.5523 5 19 5H15.693L10.443 19H14C14.5523 19 15 19.4477 15 20C15 20.5523 14.5523 21 14 21H9.02418C9.00802 21.0004 8.99181 21.0004 8.97557 21H5C4.44772 21 4 20.5523 4 20C4 19.4477 4.44772 19 5 19H8.30704L13.557 5H10C9.44772 5 9 4.55228 9 4C9 3.44772 9.44772 3 10 3H14.9782C14.9928 2.99968 15.0075 2.99967 15.0222 3Z",fill:"currentColor"})}));Bp.displayName="ItalicIcon";const b8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M16.9958 1.06669C15.4226 1.05302 13.907 1.65779 12.7753 2.75074L12.765 2.76086L11.045 4.47086C10.6534 4.86024 10.6515 5.49341 11.0409 5.88507C11.4303 6.27673 12.0634 6.27858 12.4551 5.88919L14.1697 4.18456C14.9236 3.45893 15.9319 3.05752 16.9784 3.06662C18.0272 3.07573 19.0304 3.49641 19.772 4.23804C20.5137 4.97967 20.9344 5.98292 20.9435 7.03171C20.9526 8.07776 20.5515 9.08563 19.8265 9.83941L16.833 12.8329C16.4274 13.2386 15.9393 13.5524 15.4019 13.7529C14.8645 13.9533 14.2903 14.0359 13.7181 13.9949C13.146 13.9539 12.5894 13.7904 12.0861 13.5154C11.5827 13.2404 11.1444 12.8604 10.8008 12.401C10.47 11.9588 9.84333 11.8685 9.40108 12.1993C8.95883 12.5301 8.86849 13.1568 9.1993 13.599C9.71464 14.288 10.3721 14.858 11.1272 15.2705C11.8822 15.683 12.7171 15.9283 13.5753 15.9898C14.4334 16.0513 15.2948 15.9274 16.1009 15.6267C16.907 15.326 17.639 14.8555 18.2473 14.247L21.2472 11.2471L21.2593 11.2347C22.3523 10.1031 22.9571 8.58751 22.9434 7.01433C22.9297 5.44115 22.2987 3.93628 21.1863 2.82383C20.0738 1.71138 18.5689 1.08036 16.9958 1.06669Z",fill:"currentColor"}),S.jsx("path",{d:"M10.4247 8.0102C9.56657 7.94874 8.70522 8.07256 7.89911 8.37326C7.09305 8.67395 6.36096 9.14458 5.75272 9.753L2.75285 12.7529L2.74067 12.7653C1.64772 13.8969 1.04295 15.4125 1.05662 16.9857C1.07029 18.5589 1.70131 20.0637 2.81376 21.1762C3.9262 22.2886 5.43108 22.9196 7.00426 22.9333C8.57744 22.947 10.0931 22.3422 11.2247 21.2493L11.2371 21.2371L12.9471 19.5271C13.3376 19.1366 13.3376 18.5034 12.9471 18.1129C12.5565 17.7223 11.9234 17.7223 11.5328 18.1129L9.82932 19.8164C9.07555 20.5414 8.06768 20.9425 7.02164 20.9334C5.97285 20.9243 4.9696 20.5036 4.22797 19.762C3.48634 19.0203 3.06566 18.0171 3.05655 16.9683C3.04746 15.9222 3.44851 14.9144 4.17355 14.1606L7.16719 11.167C7.5727 10.7613 8.06071 10.4476 8.59811 10.2471C9.13552 10.0467 9.70976 9.96412 10.2819 10.0051C10.854 10.0461 11.4106 10.2096 11.9139 10.4846C12.4173 10.7596 12.8556 11.1397 13.1992 11.599C13.53 12.0412 14.1567 12.1316 14.5989 11.8007C15.0412 11.4699 15.1315 10.8433 14.8007 10.401C14.2854 9.71205 13.6279 9.14198 12.8729 8.72948C12.1178 8.31697 11.2829 8.07166 10.4247 8.0102Z",fill:"currentColor"})]}));b8.displayName="LinkIcon";const C3=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 6C7 5.44772 7.44772 5 8 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H8C7.44772 7 7 6.55228 7 6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12C7 11.4477 7.44772 11 8 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H8C7.44772 13 7 12.5523 7 12Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 18C7 17.4477 7.44772 17 8 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H8C7.44772 19 7 18.5523 7 18Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H3.01C3.56228 5 4.01 5.44772 4.01 6C4.01 6.55228 3.56228 7 3.01 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H3.01C3.56228 11 4.01 11.4477 4.01 12C4.01 12.5523 3.56228 13 3.01 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H3.01C3.56228 17 4.01 17.4477 4.01 18C4.01 18.5523 3.56228 19 3.01 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));C3.displayName="ListIcon";const C8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 6C9 5.44772 9.44772 5 10 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H10C9.44772 7 9 6.55228 9 6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 12C9 11.4477 9.44772 11 10 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H10C9.44772 13 9 12.5523 9 12Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 18C9 17.4477 9.44772 17 10 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H10C9.44772 19 9 18.5523 9 18Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 6C3 5.44772 3.44772 5 4 5H5C5.55228 5 6 5.44772 6 6V10C6 10.5523 5.55228 11 5 11C4.44772 11 4 10.5523 4 10V7C3.44772 7 3 6.55228 3 6Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 10C3 9.44772 3.44772 9 4 9H6C6.55228 9 7 9.44772 7 10C7 10.5523 6.55228 11 6 11H4C3.44772 11 3 10.5523 3 10Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.82219 13.0431C6.54543 13.4047 6.99997 14.1319 6.99997 15C6.99997 15.5763 6.71806 16.0426 6.48747 16.35C6.31395 16.5814 6.1052 16.8044 5.91309 17H5.99997C6.55226 17 6.99997 17.4477 6.99997 18C6.99997 18.5523 6.55226 19 5.99997 19H3.99997C3.44769 19 2.99997 18.5523 2.99997 18C2.99997 17.4237 3.28189 16.9575 3.51247 16.65C3.74323 16.3424 4.03626 16.0494 4.26965 15.8161C4.27745 15.8083 4.2852 15.8006 4.29287 15.7929C4.55594 15.5298 4.75095 15.3321 4.88748 15.15C4.96287 15.0495 4.99021 14.9922 4.99911 14.9714C4.99535 14.9112 4.9803 14.882 4.9739 14.8715C4.96613 14.8588 4.95382 14.845 4.92776 14.8319C4.87723 14.8067 4.71156 14.7623 4.44719 14.8944C3.95321 15.1414 3.35254 14.9412 3.10555 14.4472C2.85856 13.9533 3.05878 13.3526 3.55276 13.1056C4.28839 12.7378 5.12272 12.6934 5.82219 13.0431Z",fill:"currentColor"})]}));C8.displayName="ListOrderedIcon";const rj=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C12.5523 2 13 2.44772 13 3V6C13 6.55228 12.5523 7 12 7C11.4477 7 11 6.55228 11 6V3C11 2.44772 11.4477 2 12 2Z",fill:"currentColor",opacity:"0.2"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.9497 4.22183C17.3402 4.61236 17.3402 5.24552 16.9497 5.63604L14.8284 7.75736C14.4379 8.14789 13.8047 8.14789 13.4142 7.75736C13.0237 7.36684 13.0237 6.73367 13.4142 6.34315L15.5355 4.22183C15.926 3.8313 16.5592 3.8313 16.9497 4.22183Z",fill:"currentColor",opacity:"0.3"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22 12C22 12.5523 21.5523 13 21 13H18C17.4477 13 17 12.5523 17 12C17 11.4477 17.4477 11 18 11H21C21.5523 11 22 11.4477 22 12Z",fill:"currentColor",opacity:"0.4"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.7782 16.9497C20.1687 16.5592 20.1687 15.926 19.7782 15.5355L17.6569 13.4142C17.2663 13.0237 16.6332 13.0237 16.2426 13.4142C15.8521 13.8047 15.8521 14.4379 16.2426 14.8284L18.364 16.9497C18.7545 17.3402 19.3876 17.3402 19.7782 16.9497Z",fill:"currentColor",opacity:"0.5"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 17C12.5523 17 13 17.4477 13 18V21C13 21.5523 12.5523 22 12 22C11.4477 22 11 21.5523 11 21V18C11 17.4477 11.4477 17 12 17Z",fill:"currentColor",opacity:"0.6"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.05025 19.7782C7.44078 20.1687 7.44078 20.8019 7.05025 21.1924C6.65973 21.5829 6.02656 21.5829 5.63604 21.1924L3.51472 19.0711C3.12419 18.6805 3.12419 18.0474 3.51472 17.6569C3.90524 17.2663 4.53841 17.2663 4.92893 17.6569L7.05025 19.7782Z",fill:"currentColor",opacity:"0.7"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12C7 12.5523 6.55228 13 6 13H3C2.44772 13 2 12.5523 2 12C2 11.4477 2.44772 11 3 11H6C6.55228 11 7 11.4477 7 12Z",fill:"currentColor",opacity:"0.8"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.22183 7.05025C4.61236 7.44078 5.24552 7.44078 5.63604 7.05025L7.75736 4.92893C8.14789 4.53841 8.14789 3.90524 7.75736 3.51472C7.36684 3.12419 6.73367 3.12419 6.34315 3.51472L4.22183 5.63604C3.8313 6.02656 3.8313 6.65973 4.22183 7.05025Z",fill:"currentColor",opacity:"0.9"})]}));rj.displayName="LoaderIcon";const w8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M7 10L12 15L17 10H7Z",fill:"currentColor"})}));w8.displayName="MenuDownIcon";const x8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M7 15L12 10L17 15H7Z",fill:"currentColor"})}));x8.displayName="MenuUpIcon";const S8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"16",height:"16",className:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.66669 2.66634C2.2985 2.66634 2.00002 2.96482 2.00002 3.33301V9.99967C2.00002 10.3679 2.2985 10.6663 2.66669 10.6663H13.3334C13.7015 10.6663 14 10.3679 14 9.99967V3.33301C14 2.96482 13.7015 2.66634 13.3334 2.66634H2.66669ZM0.666687 3.33301C0.666687 2.22844 1.56212 1.33301 2.66669 1.33301H13.3334C14.4379 1.33301 15.3334 2.22844 15.3334 3.33301V9.99967C15.3334 11.1042 14.4379 11.9997 13.3334 11.9997H2.66669C1.56212 11.9997 0.666687 11.1042 0.666687 9.99967V3.33301Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.66669 13.9997C4.66669 13.6315 4.96516 13.333 5.33335 13.333H10.6667C11.0349 13.333 11.3334 13.6315 11.3334 13.9997C11.3334 14.3679 11.0349 14.6663 10.6667 14.6663H5.33335C4.96516 14.6663 4.66669 14.3679 4.66669 13.9997Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.99998 10.667C8.36817 10.667 8.66665 10.9655 8.66665 11.3337V14.0003C8.66665 14.3685 8.36817 14.667 7.99998 14.667C7.63179 14.667 7.33331 14.3685 7.33331 14.0003V11.3337C7.33331 10.9655 7.63179 10.667 7.99998 10.667Z",fill:"currentColor"})]}));S8.displayName="MonitorIcon";const ij=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C10.0222 2 8.08879 2.58649 6.4443 3.6853C4.79981 4.78412 3.51809 6.3459 2.76121 8.17317C2.00433 10.0004 1.8063 12.0111 2.19215 13.9509C2.578 15.8907 3.53041 17.6725 4.92894 19.0711C6.32746 20.4696 8.10929 21.422 10.0491 21.8079C11.9889 22.1937 13.9996 21.9957 15.8268 21.2388C17.6541 20.4819 19.2159 19.2002 20.3147 17.5557C21.4135 15.9112 22 13.9778 22 12C22 11.5955 21.7564 11.2309 21.3827 11.0761C21.009 10.9213 20.5789 11.0069 20.2929 11.2929C19.287 12.2988 17.9226 12.864 16.5 12.864C15.0774 12.864 13.713 12.2988 12.7071 11.2929C11.7012 10.287 11.136 8.92261 11.136 7.5C11.136 6.07739 11.7012 4.71304 12.7071 3.70711C12.9931 3.42111 13.0787 2.99099 12.9239 2.61732C12.7691 2.24364 12.4045 2 12 2ZM7.55544 5.34824C8.27036 4.87055 9.05353 4.51389 9.87357 4.28778C9.39271 5.27979 9.13604 6.37666 9.13604 7.5C9.13604 9.45304 9.91189 11.3261 11.2929 12.7071C12.6739 14.0881 14.547 14.864 16.5 14.864C17.6233 14.864 18.7202 14.6073 19.7122 14.1264C19.4861 14.9465 19.1295 15.7296 18.6518 16.4446C17.7727 17.7602 16.5233 18.7855 15.0615 19.391C13.5997 19.9965 11.9911 20.155 10.4393 19.8463C8.88743 19.5376 7.46197 18.7757 6.34315 17.6569C5.22433 16.538 4.4624 15.1126 4.15372 13.5607C3.84504 12.0089 4.00347 10.4003 4.60897 8.93853C5.21447 7.47672 6.23985 6.22729 7.55544 5.34824Z",fill:"currentColor"}),S.jsx("path",{d:"M19 2C19.5523 2 20 2.44772 20 3V4H21C21.5523 4 22 4.44772 22 5C22 5.55228 21.5523 6 21 6H20V7C20 7.55228 19.5523 8 19 8C18.4477 8 18 7.55228 18 7V6H17C16.4477 6 16 5.55228 16 5C16 4.44772 16.4477 4 17 4H18V3C18 2.44772 18.4477 2 19 2Z",fill:"currentColor"})]}));ij.displayName="MoonStarIcon";const T8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M13 14L11 14L11 17L8 17L8 19L11 19L11 22L13 22L13 19L16 19L16 17L13 17L13 14Z",fill:"currentColor"}),S.jsx("path",{d:"M2.58579 10.4142C2.21071 10.0391 2 9.53043 2 9L2 3L4 3L4 9L20 9L20 3L22 3L22 9C22 9.53043 21.7893 10.0391 21.4142 10.4142C21.0391 10.7893 20.5304 11 20 11L4 11C3.46957 11 2.96086 10.7893 2.58579 10.4142Z",fill:"currentColor"})]}));T8.displayName="PaginatedPlusAfterIcon";const k8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M11 10H13V7H16V5H13V2H11V5H8V7H11V10Z",fill:"currentColor"}),S.jsx("path",{d:"M21.4142 13.5858C21.7893 13.9609 22 14.4696 22 15V21H20V15H4V21H2V15C2 14.4696 2.21071 13.9609 2.58579 13.5858C2.96086 13.2107 3.46957 13 4 13H20C20.5304 13 21.0391 13.2107 21.4142 13.5858Z",fill:"currentColor"})]}));k8.displayName="PaginatedPlusBeforeIcon";const E8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,...e,children:S.jsx("path",{d:"M12.6667 2C13.0203 2 13.3594 2.14048 13.6095 2.39052C13.8595 2.64057 14 2.97971 14 3.33333V12.6667C14 13.4067 13.4 14 12.6667 14H3.33333C2.97971 14 2.64057 13.8595 2.39052 13.6095C2.14048 13.3594 2 13.0203 2 12.6667V3.33333C2 2.97971 2.14048 2.64057 2.39052 2.39052C2.64057 2.14048 2.97971 2 3.33333 2H12.6667ZM11.1333 6.23333C11.28 6.09333 11.28 5.86 11.1333 5.72L10.28 4.86667C10.14 4.72 9.90667 4.72 9.76667 4.86667L9.1 5.53333L10.4667 6.9L11.1333 6.23333ZM4.66667 9.96V11.3333H6.04L10.08 7.29333L8.70667 5.92L4.66667 9.96Z",fill:"currentColor"})}));E8.displayName="PencilBoxIcon";const M8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.7071 2.29289C15.3166 1.90237 14.6834 1.90237 14.2929 2.29289C13.9024 2.68342 13.9024 3.31658 14.2929 3.70711L17.5858 7H9.5C7.77609 7 6.12279 7.68482 4.90381 8.90381C3.68482 10.1228 3 11.7761 3 13.5C3 14.3536 3.16813 15.1988 3.49478 15.9874C3.82144 16.7761 4.30023 17.4926 4.90381 18.0962C6.12279 19.3152 7.77609 20 9.5 20H13C13.5523 20 14 19.5523 14 19C14 18.4477 13.5523 18 13 18H9.5C8.30653 18 7.16193 17.5259 6.31802 16.682C5.90016 16.2641 5.56869 15.768 5.34254 15.2221C5.1164 14.6761 5 14.0909 5 13.5C5 12.3065 5.47411 11.1619 6.31802 10.318C7.16193 9.47411 8.30653 9 9.5 9H17.5858L14.2929 12.2929C13.9024 12.6834 13.9024 13.3166 14.2929 13.7071C14.6834 14.0976 15.3166 14.0976 15.7071 13.7071L20.7071 8.70711C21.0976 8.31658 21.0976 7.68342 20.7071 7.29289L15.7071 2.29289Z",fill:"currentColor"})}));M8.displayName="Redo2Icon";const oj=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.8159 21H11.1841C10.9072 21 10.6478 20.8616 10.4969 20.6343C10.346 20.407 10.3244 20.1188 10.4394 19.8708L10.8045 19.0156C11.0696 18.4636 11.0186 17.8184 10.6683 17.3164C10.3181 16.8145 9.72183 16.5364 9.09901 16.5734C8.476 16.6104 7.91775 16.9571 7.63604 17.4938L7.36396 18.0062C7.24896 18.2542 6.98962 18.4221 6.70219 18.4518C6.41477 18.4815 6.12535 18.3695 5.94721 18.1514L4.84869 16.8486C4.67054 16.6305 4.62917 16.3367 4.73916 16.0797C4.84915 15.8227 5.09135 15.6422 5.36827 15.6062L6.24173 15.4938C6.86455 15.4071 7.40265 14.9929 7.68436 14.4062C7.96608 13.8196 7.94604 13.1304 7.63604 12.5562C7.32604 11.9821 6.76392 11.6105 6.14099 11.5734C5.518 11.5364 4.91871 11.8428 4.63604 12.3438L4.30396 12.9062C4.18896 13.1542 3.92962 13.3221 3.64219 13.3518C3.35477 13.3815 3.06535 13.2695 2.88721 13.0514L1.94869 11.8486C1.77054 11.6305 1.72917 11.3367 1.83916 11.0797C1.94915 10.8227 2.19135 10.6422 2.46827 10.6062L3.34173 10.4938C3.96455 10.4071 4.50265 9.99294 4.78436 9.40625C5.06608 8.81956 5.04604 8.13044 4.73604 7.55625C4.42604 6.98206 3.86392 6.61044 3.24099 6.57344C2.618 6.53644 2.01871 6.84279 1.73604 7.34375L1.46396 7.85625C1.34896 8.10425 1.08962 8.27213 0.802186 8.30181C0.514754 8.33148 0.225332 8.21948 0.0471854 8.00135L-0.85134 6.69865C-1.02949 6.48052 -1.07086 6.18669 -1.03916 5.92972C-1.00747 5.67274 -0.826704 5.49213 -0.549206 5.45622L0.324236 5.34375C0.947054 5.257 1.48516 4.84283 1.76687 4.25614C2.04858 3.66945 2.02854 2.98033 1.71854 2.40614C1.40854 1.83195 0.846424 1.46033 0.223493 1.42333C-0.399496 1.38633 -0.998788 1.69268 -1.28146 2.19364L-1.5533 2.70614C-1.6683 2.95414 -1.92764 3.122 -2.21507 3.15168C-2.5025 3.18135 -2.79192 3.06935 -2.97006 2.85122L-3.86858 1.54849C-4.04673 1.33036 -4.0881 1.03653 -4.0564 0.779558C-4.02471 0.522582 -3.84931 0.341969 -3.57182 0.305993L-2.69838 0.193524C-2.07556 0.106778 -1.53746 -0.307387 -1.25574 -0.894082C-0.974032 -1.48078 -0.994072 -2.1699 -1.30407 -2.74408C-1.61407 -3.31827 -2.17619 -3.68989 -2.79912 -3.72689C-3.42211 -3.76389 -4.0214 -3.45754 -4.30407 -2.95658L-4.57595 -2.44408C-4.69095 -2.19608 -4.95029 -2.0282 -5.23772 -1.99852C-5.52515 -1.96885 -5.81457 -2.08085 -5.99272 -2.29898L-6.89124 -3.60171C-7.06939 -3.81984 -7.11076 -4.11366 -7.07906 -4.37064C-7.04737 -4.62762 -6.87197 -4.80823 -6.59448 -4.84421L-5.72104 -4.95668C-5.09822 -5.04343 -4.56012 -5.4576 -4.2784 -6.04429C-3.99669 -6.63098 -4.01673 -7.3201 -4.32673 -7.89429C-4.63673 -8.46848 -5.19885 -8.8401 -5.82178 -8.8771C-6.44477 -8.9141 -7.04406 -8.60775 -7.32673 -8.10679L-7.59861 -7.59429C-7.71361 -7.34629 -7.97295 -7.17841 -8.26038 -7.14873C-8.54781 -7.11906 -8.83723 -7.23106 -9.01538 -7.44919L-9.9139 -8.75192C-10.091 -8.97005 -10.1324 -9.26388 -10.1007 -9.52085C-10.069 -9.77783 -9.89363 -9.95844 -9.61614 -9.99442L-8.7427 -10.1069C-8.11988 -10.1936 -7.58178 -10.6078 -7.30006 -11.1945C-7.01835 -11.7812 -7.03839 -12.4703 -7.34839 -13.0445C-7.65839 -13.6187 -8.22051 -13.9903 -8.84344 -14.0273C-9.46643 -14.0643 -10.0657 -13.758 -10.3484 -13.2571L-10.6203 -12.7446C-10.7353 -12.4966 -10.9946 -12.3287 -11.282 -12.299C-11.5695 -12.2693 -11.8589 -12.3813 -12.037 -12.5995L-12.9356 -13.9022C-13.1137 -14.1203 -13.1551 -14.4142 -13.1234 -14.6711C-13.0917 -14.9281 -12.9163 -15.1087 -12.6388 -15.1447L-11.7654 -15.2572C-11.1425 -15.3439 -10.6044 -15.7581 -10.3227 -16.3448C-10.041 -16.9315 -10.061 -17.6206 -10.371 -18.1948C-10.681 -18.769 -11.2432 -19.1406 -11.8661 -19.1776C-12.4891 -19.2146 -13.0884 -18.9083 -13.371 -18.4073L-13.6429 -17.8948C-13.7579 -17.6468 -14.0173 -17.4789 -14.3047 -17.4492C-14.5921 -17.4195 -14.8815 -17.5315 -15.0597 -17.7497L-15.9582 -19.0524C-16.1363 -19.2705 -16.1777 -19.5644 -16.146 -19.8213C-16.1143 -20.0783 -15.9389 -20.2589 -15.6614 -20.2949L-14.788 -20.4074C-14.1651 -20.4941 -13.627 -20.9083 -13.3453 -21.495C-13.0636 -22.0817 -13.0836 -22.7708 -13.3936 -23.345C-13.7036 -23.9192 -14.2657 -24.2908 -14.8887 -24.3278C-15.5117 -24.3648 -16.111 -24.0585 -16.3936 -23.5575L-16.6655 -23.045C-16.7805 -22.797 -17.0398 -22.6291 -17.3273 -22.5994C-17.6147 -22.5697 -17.9041 -22.6817 -18.0823 -22.8999L-18.9808 -24.2026C-19.1589 -24.4207 -19.2003 -24.7145 -19.1686 -24.9715C-19.1369 -25.2285 -18.9615 -25.4091 -18.684 -25.4451L-17.8106 -25.5576C-17.1877 -25.6443 -16.6496 -26.0585 -16.3679 -26.6452C-16.0862 -27.2319 -16.1062 -27.921 -16.4162 -28.4952C-16.7262 -29.0694 -17.2883 -29.441 -17.9113 -29.478C-18.5343 -29.515 -19.1336 -29.2087 -19.4162 -28.7077L-19.6881 -28.1952C-19.8031 -27.9472 -20.0624 -27.7793 -20.3499 -27.7496C-20.6373 -27.7199 -20.9267 -27.8319 -21.1049 -28.0501L-22.0034 -29.3528C-22.1815 -29.5709 -22.2229 -29.8647 -22.1912 -30.1217C-22.1595 -30.3787 -21.9841 -30.5593 -21.7066 -30.5953L-20.8332 -30.7078Z",fill:"currentColor"}),S.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor"})]}));oj.displayName="SettingsIcon";const A8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M9 7V17H15V15H11V7H9Z",fill:"currentColor"})}));A8.displayName="SizeLIcon";const N8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M9 7C7.9 7 7 7.9 7 9V17H9V9H11V16H13V9H15V17H17V9C17 7.9 16.11 7 15 7H9Z",fill:"currentColor"})}));N8.displayName="SizeMIcon";const R8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M11 7C9.9 7 9 7.9 9 9V11C9 12.11 9.9 13 11 13H13V15H9V17H13C14.11 17 15 16.11 15 15V13C15 11.9 14.11 11 13 11H11V9H15V7H11Z",fill:"currentColor"})}));R8.displayName="SizeSIcon";const O8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"16",height:"16",className:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.66669 2.00033C4.2985 2.00033 4.00002 2.2988 4.00002 2.66699V13.3337C4.00002 13.7018 4.2985 14.0003 4.66669 14.0003H11.3334C11.7015 14.0003 12 13.7018 12 13.3337V2.66699C12 2.2988 11.7015 2.00033 11.3334 2.00033H4.66669ZM2.66669 2.66699C2.66669 1.56242 3.56212 0.666992 4.66669 0.666992H11.3334C12.4379 0.666992 13.3334 1.56242 13.3334 2.66699V13.3337C13.3334 14.4382 12.4379 15.3337 11.3334 15.3337H4.66669C3.56212 15.3337 2.66669 14.4382 2.66669 13.3337V2.66699Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.33331 11.9997C7.33331 11.6315 7.63179 11.333 7.99998 11.333H8.00665C8.37484 11.333 8.67331 11.6315 8.67331 11.9997C8.67331 12.3679 8.37484 12.6663 8.00665 12.6663H7.99998C7.63179 12.6663 7.33331 12.3679 7.33331 11.9997Z",fill:"currentColor"})]}));O8.displayName="SmartphoneIcon";const w3=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M9.00039 3H16.0001C16.5524 3 17.0001 3.44772 17.0001 4C17.0001 4.55229 16.5524 5 16.0001 5H9.00011C8.68006 4.99983 8.36412 5.07648 8.07983 5.22349C7.79555 5.37051 7.55069 5.5836 7.36585 5.84487C7.181 6.10614 7.06155 6.40796 7.01754 6.72497C6.97352 7.04198 7.00623 7.36492 7.11292 7.66667C7.29701 8.18737 7.02414 8.75872 6.50344 8.94281C5.98274 9.1269 5.4114 8.85403 5.2273 8.33333C5.01393 7.72984 4.94851 7.08396 5.03654 6.44994C5.12456 5.81592 5.36346 5.21229 5.73316 4.68974C6.10285 4.1672 6.59256 3.74101 7.16113 3.44698C7.72955 3.15303 8.36047 2.99975 9.00039 3Z",fill:"currentColor"}),S.jsx("path",{d:"M18 13H20C20.5523 13 21 12.5523 21 12C21 11.4477 20.5523 11 20 11H4C3.44772 11 3 11.4477 3 12C3 12.5523 3.44772 13 4 13H14C14.7956 13 15.5587 13.3161 16.1213 13.8787C16.6839 14.4413 17 15.2044 17 16C17 16.7956 16.6839 17.5587 16.1213 18.1213C15.5587 18.6839 14.7956 19 14 19H6C5.44772 19 5 19.4477 5 20C5 20.5523 5.44772 21 6 21H14C15.3261 21 16.5979 20.4732 17.5355 19.5355C18.4732 18.5979 19 17.3261 19 16C19 14.9119 18.6453 13.8604 18 13Z",fill:"currentColor"})]}));w3.displayName="StrikeIcon";const x3=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.29289 7.29289C3.68342 6.90237 4.31658 6.90237 4.70711 7.29289L12.7071 15.2929C13.0976 15.6834 13.0976 16.3166 12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L3.29289 8.70711C2.90237 8.31658 2.90237 7.68342 3.29289 7.29289Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 7.29289C13.0976 7.68342 13.0976 8.31658 12.7071 8.70711L4.70711 16.7071C4.31658 17.0976 3.68342 17.0976 3.29289 16.7071C2.90237 16.3166 2.90237 15.6834 3.29289 15.2929L11.2929 7.29289C11.6834 6.90237 12.3166 6.90237 12.7071 7.29289Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.4079 14.3995C18.0284 14.0487 18.7506 13.9217 19.4536 14.0397C20.1566 14.1578 20.7977 14.5138 21.2696 15.0481L21.2779 15.0574L21.2778 15.0575C21.7439 15.5988 22 16.2903 22 17C22 18.0823 21.3962 18.8401 20.7744 19.3404C20.194 19.8073 19.4858 20.141 18.9828 20.378C18.9638 20.387 18.9451 20.3958 18.9266 20.4045C18.4473 20.6306 18.2804 20.7817 18.1922 20.918C18.1773 20.9412 18.1619 20.9681 18.1467 21H21C21.5523 21 22 21.4477 22 22C22 22.5523 21.5523 23 21 23H17C16.4477 23 16 22.5523 16 22C16 21.1708 16.1176 20.4431 16.5128 19.832C16.9096 19.2184 17.4928 18.8695 18.0734 18.5956C18.6279 18.334 19.138 18.0901 19.5207 17.7821C19.8838 17.49 20 17.2477 20 17C20 16.7718 19.9176 16.5452 19.7663 16.3672C19.5983 16.1792 19.3712 16.0539 19.1224 16.0121C18.8722 15.9701 18.6152 16.015 18.3942 16.1394C18.1794 16.2628 18.0205 16.4549 17.9422 16.675C17.7572 17.1954 17.1854 17.4673 16.665 17.2822C16.1446 17.0972 15.8728 16.5254 16.0578 16.005C16.2993 15.3259 16.7797 14.7584 17.4039 14.4018L17.4079 14.3995L17.4079 14.3995Z",fill:"currentColor"})]}));x3.displayName="SubscriptIcon";const sj=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{d:"M12 1C12.5523 1 13 1.44772 13 2V4C13 4.55228 12.5523 5 12 5C11.4477 5 11 4.55228 11 4V2C11 1.44772 11.4477 1 12 1Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12C7 9.23858 9.23858 7 12 7C14.7614 7 17 9.23858 17 12C17 14.7614 14.7614 17 12 17C9.23858 17 7 14.7614 7 12ZM12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9Z",fill:"currentColor"}),S.jsx("path",{d:"M13 20C13 19.4477 12.5523 19 12 19C11.4477 19 11 19.4477 11 20V22C11 22.5523 11.4477 23 12 23C12.5523 23 13 22.5523 13 22V20Z",fill:"currentColor"}),S.jsx("path",{d:"M4.22282 4.22289C4.61335 3.83236 5.24651 3.83236 5.63704 4.22289L7.04704 5.63289C7.43756 6.02341 7.43756 6.65658 7.04704 7.0471C6.65651 7.43762 6.02335 7.43762 5.63283 7.0471L4.22282 5.6371C3.8323 5.24658 3.8323 4.61341 4.22282 4.22289Z",fill:"currentColor"}),S.jsx("path",{d:"M18.367 16.9529C17.9765 16.5623 17.3433 16.5623 16.9528 16.9529C16.5623 17.3434 16.5623 17.9766 16.9528 18.3671L18.3628 19.7771C18.7533 20.1676 19.3865 20.1676 19.777 19.7771C20.1675 19.3866 20.1675 18.7534 19.777 18.3629L18.367 16.9529Z",fill:"currentColor"}),S.jsx("path",{d:"M1 12C1 11.4477 1.44772 11 2 11H4C4.55228 11 5 11.4477 5 12C5 12.5523 4.55228 13 4 13H2C1.44772 13 1 12.5523 1 12Z",fill:"currentColor"}),S.jsx("path",{d:"M20 11C19.4477 11 19 11.4477 19 12C19 12.5523 19.4477 13 20 13H22C22.5523 13 23 12.5523 23 12C23 11.4477 22.5523 11 22 11H20Z",fill:"currentColor"}),S.jsx("path",{d:"M7.04704 16.9529C7.43756 17.3434 7.43756 17.9766 7.04704 18.3671L5.63704 19.7771C5.24651 20.1676 4.61335 20.1676 4.22282 19.7771C3.8323 19.3866 3.8323 18.7534 4.22283 18.3629L5.63283 16.9529C6.02335 16.5623 6.65651 16.5623 7.04704 16.9529Z",fill:"currentColor"}),S.jsx("path",{d:"M19.777 5.6371C20.1675 5.24657 20.1675 4.61341 19.777 4.22289C19.3865 3.83236 18.7533 3.83236 18.3628 4.22289L16.9528 5.63289C16.5623 6.02341 16.5623 6.65658 16.9528 7.0471C17.3433 7.43762 17.9765 7.43762 18.367 7.0471L19.777 5.6371Z",fill:"currentColor"})]}));sj.displayName="SunIcon";const S3=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 7.29289C13.0976 7.68342 13.0976 8.31658 12.7071 8.70711L4.70711 16.7071C4.31658 17.0976 3.68342 17.0976 3.29289 16.7071C2.90237 16.3166 2.90237 15.6834 3.29289 15.2929L11.2929 7.29289C11.6834 6.90237 12.3166 6.90237 12.7071 7.29289Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.29289 7.29289C3.68342 6.90237 4.31658 6.90237 4.70711 7.29289L12.7071 15.2929C13.0976 15.6834 13.0976 16.3166 12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L3.29289 8.70711C2.90237 8.31658 2.90237 7.68342 3.29289 7.29289Z",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.405 1.40657C18.0246 1.05456 18.7463 0.92634 19.4492 1.04344C20.1521 1.16054 20.7933 1.51583 21.2652 2.0497L21.2697 2.05469L21.2696 2.05471C21.7431 2.5975 22 3.28922 22 4.00203C22 5.08579 21.3952 5.84326 20.7727 6.34289C20.1966 6.80531 19.4941 7.13675 18.9941 7.37261C18.9714 7.38332 18.9491 7.39383 18.9273 7.40415C18.4487 7.63034 18.2814 7.78152 18.1927 7.91844C18.1778 7.94155 18.1625 7.96834 18.1473 8.00003H21C21.5523 8.00003 22 8.44774 22 9.00003C22 9.55231 21.5523 10 21 10H17C16.4477 10 16 9.55231 16 9.00003C16 8.17007 16.1183 7.44255 16.5138 6.83161C16.9107 6.21854 17.4934 5.86971 18.0728 5.59591C18.6281 5.33347 19.1376 5.09075 19.5208 4.78316C19.8838 4.49179 20 4.25026 20 4.00203C20 3.77192 19.9178 3.54865 19.7646 3.37182C19.5968 3.18324 19.3696 3.05774 19.1205 3.01625C18.8705 2.97459 18.6137 3.02017 18.3933 3.14533C18.1762 3.26898 18.0191 3.45826 17.9406 3.67557C17.7531 4.19504 17.18 4.46414 16.6605 4.27662C16.141 4.0891 15.8719 3.51596 16.0594 2.99649C16.303 2.3219 16.7817 1.76125 17.4045 1.40689L17.405 1.40657Z",fill:"currentColor"})]}));S3.displayName="SuperscriptIcon";const D8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,...e,children:S.jsx("path",{d:"M11 2C11.5304 2 12.0391 2.21071 12.4142 2.58579C12.7893 2.96086 13 3.46957 13 4V20C13 20.5304 12.7893 21.0391 12.4142 21.4142C12.0391 21.7893 11.5304 22 11 22H2V2H11ZM4 10V14H11V10H4ZM4 16V20H11V16H4ZM4 4V8H11V4H4ZM15 11H18V8H20V11H23V13H20V16H18V13H15V11Z",fill:"currentColor"})}));D8.displayName="TableAddColumnAfter";const L8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,...e,children:S.jsx("path",{d:"M13 2C12.4696 2 11.9609 2.21071 11.5858 2.58579C11.2107 2.96086 11 3.46957 11 4V20C11 20.5304 11.2107 21.0391 11.5858 21.4142C11.9609 21.7893 12.4696 22 13 22H22V2H13ZM20 10V14H13V10H20ZM20 16V20H13V16H20ZM20 4V8H13V4H20ZM9 11H6V8H4V11H1V13H4V16H6V13H9V11Z",fill:"currentColor"})}));L8.displayName="TableAddColumnBefore";const _8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M22 10C22 10.5304 21.7893 11.0391 21.4142 11.4142C21.0391 11.7893 20.5304 12 20 12H4C3.46957 12 2.96086 11.7893 2.58579 11.4142C2.21071 11.0391 2 10.5304 2 10V3H4V5H8V3H10V5H14V3H16V5H20V3H22V10ZM4 10H8V7H4V10ZM10 10H14V7H10V10ZM20 10V7H16V10H20ZM11 14H13V17H16V19H13V22H11V19H8V17H11V14Z",fill:"currentColor"})}));_8.displayName="TableAddRowAfter";const H8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,...e,children:S.jsx("path",{d:"M22 14C22 13.4696 21.7893 12.9609 21.4142 12.5858C21.0391 12.2107 20.5304 12 20 12H4C3.46957 12 2.96086 12.2107 2.58579 12.5858C2.21071 12.9609 2 13.4696 2 14V21H4V19H8V21H10V19H14V21H16V19H20V21H22V14ZM4 14H8V17H4V14ZM10 14H14V17H10V14ZM20 14V17H16V14H20ZM11 10H13V7H16V5H13V2H11V5H8V7H11V10Z",fill:"currentColor"})}));H8.displayName="TableAddRowBefore";const I8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M4 2H11C11.5304 2 12.0391 2.21071 12.4142 2.58579C12.7893 2.96086 13 3.46957 13 4V20C13 20.5304 12.7893 21.0391 12.4142 21.4142C12.0391 21.7893 11.5304 22 11 22H4C3.46957 22 2.96086 21.7893 2.58579 21.4142C2.21071 21.0391 2 20.5304 2 20V4C2 3.46957 2.21071 2.96086 2.58579 2.58579C2.96086 2.21071 3.46957 2 4 2ZM4 10V14H11V10H4ZM4 16V20H11V16H4ZM4 4V8H11V4H4ZM17.59 12L15 9.41L16.41 8L19 10.59L21.59 8L23 9.41L20.41 12L23 14.59L21.59 16L19 13.41L16.41 16L15 14.59L17.59 12Z",fill:"currentColor"})}));I8.displayName="TableDeleteColumn";const z8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,...e,children:S.jsx("path",{d:"M9.41 13L12 15.59L14.59 13L16 14.41L13.41 17L16 19.59L14.59 21L12 18.41L9.41 21L8 19.59L10.59 17L8 14.41L9.41 13ZM22 9C22 9.53043 21.7893 10.0391 21.4142 10.4142C21.0391 10.7893 20.5304 11 20 11H4C3.46957 11 2.96086 10.7893 2.58579 10.4142C2.21071 10.0391 2 9.53043 2 9V6C2 5.46957 2.21071 4.96086 2.58579 4.58579C2.96086 4.21071 3.46957 4 4 4H20C20.5304 4 21.0391 4.21071 21.4142 4.58579C21.7893 4.96086 22 5.46957 22 6V9ZM4 9H8V6H4V9ZM10 9H14V6H10V9ZM16 9H20V6H16V9Z",fill:"currentColor"})}));z8.displayName="TableDeleteRow";const B8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M15.46 15.88L16.88 14.46L19 16.59L21.12 14.46L22.54 15.88L20.41 18L22.54 20.12L21.12 21.54L19 19.41L16.88 21.54L15.46 20.12L17.59 18L15.46 15.88ZM4 3H18C18.5304 3 19.0391 3.21071 19.4142 3.58579C19.7893 3.96086 20 4.46957 20 5V12.08C18.45 11.82 16.92 12.18 15.68 13H12V17H13.08C12.97 17.68 12.97 18.35 13.08 19H4C3.46957 19 2.96086 18.7893 2.58579 18.4142C2.21071 18.0391 2 17.5304 2 17V5C2 4.46957 2.21071 3.96086 2.58579 3.58579C2.96086 3.21071 3.46957 3 4 3ZM4 7V11H10V7H4ZM12 7V11H18V7H12ZM4 13V17H10V13H4Z",fill:"currentColor"})}));B8.displayName="TableDeleteTable";const T3=E.memo(({className:t,...e})=>S.jsx("svg",{width:"17",height:"16",className:t,viewBox:"0 0 17 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{d:"M13.8333 8.66683H9.16659V13.3335H13.1666C13.5348 13.3335 13.8333 13.035 13.8333 12.6668V8.66683ZM3.16659 12.6668C3.16659 13.035 3.46506 13.3335 3.83325 13.3335H7.83325V8.66683H3.16659V12.6668ZM13.8333 3.3335C13.8333 2.96531 13.5348 2.66683 13.1666 2.66683H9.16659V7.3335H13.8333V3.3335ZM3.16659 7.3335H7.83325V2.66683H3.83325C3.46506 2.66683 3.16659 2.96531 3.16659 3.3335V7.3335ZM15.1666 12.6668C15.1666 13.7714 14.2712 14.6668 13.1666 14.6668H3.83325C2.72868 14.6668 1.83325 13.7714 1.83325 12.6668V3.3335C1.83325 2.22893 2.72868 1.3335 3.83325 1.3335H13.1666C14.2712 1.3335 15.1666 2.22893 15.1666 3.3335V12.6668Z",fill:"currentColor"})}));T3.displayName="TableIcon";const j8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,...e,children:S.jsx("path",{d:"M5 10H3V4H11V6H5V10ZM19 18H13V20H21V14H19V18ZM5 18V14H3V20H11V18H5ZM21 4H13V6H19V10H21V4ZM8 13V15L11 12L8 9V11H3V13H8ZM16 11V9L13 12L16 15V13H21V11H16Z",fill:"currentColor"})}));j8.displayName="TableMergeCells";const V8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,...e,children:S.jsx("path",{d:"M19 14H21V20H3V14H5V18H19V14ZM3 4V10H5V6H19V10H21V4H3ZM11 11V13H8V15L5 12L8 9V11H11ZM16 11V9L19 12L16 15V13H13V11H16Z",fill:"currentColor"})}));V8.displayName="TableSplitCell";const U8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[S.jsx("rect",{x:"6",y:"7",width:"4",height:"3",fill:"currentColor"}),S.jsx("path",{d:"M19 4C20.1046 4 21 4.89543 21 6V18C21 19.0357 20.2128 19.887 19.2041 19.9893L19 20H5L4.7959 19.9893C3.78722 19.887 3 19.0357 3 18V6C3 4.89543 3.89543 4 5 4H19ZM5 18H11V13H5V18ZM13 18H19V13H13V18ZM5 11H11V6H5V11ZM13 11H19V6H13V11Z",fill:"currentColor"})]}));U8.displayName="TableToggleHeaderCell";const P8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,...e,children:[S.jsx("rect",{x:"6",y:"7",width:"4",height:"3",fill:"currentColor"}),S.jsx("rect",{x:"6",y:"14",width:"4",height:"3",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 4C20.1046 4 21 4.89543 21 6V18C21 19.0357 20.2128 19.887 19.2041 19.9893L19 20H5L4.7959 19.9893C3.78722 19.887 3 19.0357 3 18V6C3 4.89543 3.89543 4 5 4H19ZM5 18H11V13H5V18ZM13 13V18H19V13H13ZM13 11H19V6H13V11ZM5 11H11V6H5V11Z",fill:"currentColor"})]}));P8.displayName="TableToggleHeaderColumn";const F8=E.memo(({className:t,...e})=>S.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,...e,children:[S.jsx("rect",{x:"6",y:"7",width:"4",height:"3",fill:"currentColor"}),S.jsx("rect",{x:"14",y:"7",width:"4",height:"3",fill:"currentColor"}),S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 4C20.1046 4 21 4.89543 21 6V18C21 19.0357 20.2128 19.887 19.2041 19.9893L19 20H5L4.7959 19.9893C3.78722 19.887 3 19.0357 3 18V6C3 4.89543 3.89543 4 5 4H19ZM5 18H11V13H5V18ZM13 13V18H19V13H13ZM13 11H19V6H13V11ZM5 11H11V6H5V11Z",fill:"currentColor"})]}));F8.displayName="TableToggleHeaderRow";const $8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 5V4C7 3.17477 7.40255 2.43324 7.91789 1.91789C8.43324 1.40255 9.17477 1 10 1H14C14.8252 1 15.5668 1.40255 16.0821 1.91789C16.5975 2.43324 17 3.17477 17 4V5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H20V20C20 20.8252 19.5975 21.5668 19.0821 22.0821C18.5668 22.5975 17.8252 23 17 23H7C6.17477 23 5.43324 22.5975 4.91789 22.0821C4.40255 21.5668 4 20.8252 4 20V7H3C2.44772 7 2 6.55228 2 6C2 5.44772 2.44772 5 3 5H7ZM9 4C9 3.82523 9.09745 3.56676 9.33211 3.33211C9.56676 3.09745 9.82523 3 10 3H14C14.1748 3 14.4332 3.09745 14.6679 3.33211C14.9025 3.56676 15 3.82523 15 4V5H9V4ZM6 7V20C6 20.1748 6.09745 20.4332 6.33211 20.6679C6.56676 20.9025 6.82523 21 7 21H17C17.1748 21 17.4332 20.9025 17.6679 20.6679C17.9025 20.4332 18 20.1748 18 20V7H6Z",fill:"currentColor"})}));$8.displayName="TrashIcon";const k3=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4V10C5 11.8565 5.7375 13.637 7.05025 14.9497C8.36301 16.2625 10.1435 17 12 17C13.8565 17 15.637 16.2625 16.9497 14.9497C18.2625 13.637 19 11.8565 19 10V4C19 3.44772 18.5523 3 18 3C17.4477 3 17 3.44772 17 4V10C17 11.3261 16.4732 12.5979 15.5355 13.5355C14.5979 14.4732 13.3261 15 12 15C10.6739 15 9.40215 14.4732 8.46447 13.5355C7.52678 12.5979 7 11.3261 7 10V4ZM4 19C3.44772 19 3 19.4477 3 20C3 20.5523 3.44772 21 4 21H20C20.5523 21 21 20.5523 21 20C21 19.4477 20.5523 19 20 19H4Z",fill:"currentColor"})}));k3.displayName="UnderlineIcon";const q8=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.70711 3.70711C10.0976 3.31658 10.0976 2.68342 9.70711 2.29289C9.31658 1.90237 8.68342 1.90237 8.29289 2.29289L3.29289 7.29289C2.90237 7.68342 2.90237 8.31658 3.29289 8.70711L8.29289 13.7071C8.68342 14.0976 9.31658 14.0976 9.70711 13.7071C10.0976 13.3166 10.0976 12.6834 9.70711 12.2929L6.41421 9H14.5C15.0909 9 15.6761 9.1164 16.2221 9.34254C16.768 9.56869 17.2641 9.90016 17.682 10.318C18.0998 10.7359 18.4313 11.232 18.6575 11.7779C18.8836 12.3239 19 12.9091 19 13.5C19 14.0909 18.8836 14.6761 18.6575 15.2221C18.4313 15.768 18.0998 16.2641 17.682 16.682C17.2641 17.0998 16.768 17.4313 16.2221 17.6575C15.6761 17.8836 15.0909 18 14.5 18H11C10.4477 18 10 18.4477 10 19C10 19.5523 10.4477 20 11 20H14.5C15.3536 20 16.1988 19.8319 16.9874 19.5052C17.7761 19.1786 18.4926 18.6998 19.0962 18.0962C19.6998 17.4926 20.1786 16.7761 20.5052 15.9874C20.8319 15.1988 21 14.3536 21 13.5C21 12.6464 20.8319 11.8012 20.5052 11.0126C20.1786 10.2239 19.6998 9.50739 19.0962 8.90381C18.4926 8.30022 17.7761 7.82144 16.9874 7.49478C16.1988 7.16813 15.3536 7 14.5 7H6.41421L9.70711 3.70711Z",fill:"currentColor"})}));q8.displayName="Undo2Icon";const lj=E.memo(({className:t,...e})=>S.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:S.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.7071 5.29289C19.0976 5.68342 19.0976 6.31658 18.7071 6.70711L13.4142 12L18.7071 17.2929C19.0976 17.6834 19.0976 18.3166 18.7071 18.7071C18.3166 19.0976 17.6834 19.0976 17.2929 18.7071L12 13.4142L6.70711 18.7071C6.31658 19.0976 5.68342 19.0976 5.29289 18.7071C4.90237 18.3166 4.90237 17.6834 5.29289 17.2929L10.5858 12L5.29289 6.70711C4.90237 6.31658 4.90237 5.68342 5.29289 5.29289C5.68342 4.90237 6.31658 4.90237 6.70711 5.29289L12 10.5858L17.2929 5.29289C17.6834 4.90237 18.3166 4.90237 18.7071 5.29289Z",fill:"currentColor"})}));lj.displayName="XIcon";const pe=(t,e)=>(t[document.documentElement.lang]||t.en)[e]||e,Ic="f-tiptap-invalid-node-indicator",v5={cs:{title:"Nevalidní obsah",errorMessageHint:"Chyba"},en:{title:"Invalid content",errorMessageHint:"Error"}},aj={type:"Unknown type"},E3=({invalidNodeHash:t,message:e,errorMessage:n})=>S.jsxs("div",{className:Ic,children:[S.jsxs("h4",{className:`${Ic}__title`,children:[S.jsx(n8,{}),pe(v5,"title")]}),e&&S.jsx("p",{className:`${Ic}__message`,children:e}),n&&S.jsxs("p",{className:`${Ic}__message`,children:[S.jsxs("strong",{children:[pe(v5,"errorMessageHint"),":"]})," ",n]}),S.jsx("pre",{className:`${Ic}__pre`,children:S.jsx("code",{children:JSON.stringify(t||aj,null,2)})})]});E3.displayName="InvalidNodeIndicator";const cj={cs:{remove:"Odstranit",edit:"Upravit",errorMessage:"Tento obsah nebude veřejně zobrazen, protože při jeho zobrazení došlo k chybě. Můžete ho zkusit upravit nebo odstranit.",invalidMessage:"Tento obsah nebude veřejně zobrazen. Můžete ho upravit nebo odstranit."},en:{remove:"Remove",edit:"Edit",errorMessage:"This content will not be publicly displayed because an error occurred while rendering it. You can try to edit or remove it.",invalidMessage:"This content will not be publicly displayed. You can edit or remove it."}};let V2=[];const Z8=({html:t,serializedAttrs:e})=>{V2=[{html:t,serializedAttrs:e},...V2.slice(0,9)]},uj=t=>V2.find(n=>n.serializedAttrs===t)?.html,dj=t=>{try{const e=sessionStorage.getItem(`f-tiptap-node-height:${t}`);return e?parseInt(e,10):null}catch{return null}},fj=(t,e)=>{try{sessionStorage.setItem(`f-tiptap-node-height:${t}`,e.toString())}catch{}},hj=t=>{const{uniqueId:e,...n}=t.node.attrs,{updateAttributes:r}=t,i=E.useCallback(w=>r(w),[r]),[o,l]=E.useState("initial"),[c,d]=E.useState({}),f=E.useRef(null),h=E.useRef(null),m=E.useCallback(w=>{w.defaultPrevented||j2(n,e)},[n,e]),g=E.useCallback(()=>{const w=t.getPos();if(typeof w!="number")return;const{state:x,dispatch:k}=t.editor.view,A=me.create(x.doc,w);k(x.tr.setSelection(A))},[t]),y=E.useCallback(()=>{j2(n,e)},[n,e]);E.useEffect(()=>{e||i({uniqueId:Ui()})},[e,i]),E.useEffect(()=>{if(o==="initial"&&e){const w=JSON.stringify(n),x=uj(w);if(x){l("loaded"),d({html:x});return}else l("loading"),window.parent.postMessage({type:"f-tiptap-node:render",uniqueId:e,attrs:n},"*")}},[o,e,n]),E.useEffect(()=>{if(f&&f.current){const w=f.current;return w.addEventListener("f-tiptap-node:edit",y),()=>{w.removeEventListener("f-tiptap-node:edit",y)}}},[f,y]),E.useEffect(()=>{const w=x=>{x.origin===window.origin&&(x.data.type==="f-input-tiptap:render-nodes"?x.data.nodes.forEach(k=>{if(k.unique_id===e)if(k.html){const A=JSON.stringify(n);Z8({html:k.html,serializedAttrs:A}),d({html:k.html}),l("loaded")}else d({invalid:!0,errorMessage:k.error_message}),l("loaded")}):x.data&&x.data.type==="f-c-tiptap-overlay:saved"&&x.data.uniqueId===e&&x.data.node&&x.data.node.attrs&&(d({}),l("initial"),i(x.data.node.attrs)))};return window.addEventListener("message",w),()=>{window.removeEventListener("message",w)}},[e,n,o,i]),E.useEffect(()=>{if(c.html&&h.current){const w=JSON.stringify(n),x=h.current.offsetHeight;x>0&&fj(w,x)}},[c.html,n]);const C=E.useMemo(()=>{if(c.html)return{__html:c.html}},[c.html]);return e?S.jsx(Qi,{className:"f-tiptap-node",tabIndex:0,"data-drag-handle":"","data-folio-tiptap-node-version":t.node.attrs.version,"data-folio-tiptap-node-type":t.node.attrs.type,"data-folio-tiptap-node-data":JSON.stringify(t.node.attrs.data),"data-folio-tiptap-node-unique-id":t.node.attrs.uniqueId,onClick:g,onDoubleClick:m,ref:f,children:c.html?S.jsx("div",{ref:h,className:"f-tiptap-node__html",dangerouslySetInnerHTML:C}):c.invalid?S.jsx(E3,{invalidNodeHash:t.node.toJSON(),message:pe(cj,c.errorMessage?"errorMessage":"invalidMessage"),errorMessage:c.errorMessage}):S.jsx("div",{className:"f-tiptap-node__loader-wrap rounded",style:(()=>{const w=JSON.stringify(n),x=dj(w);return x?{height:`${x}px`}:void 0})(),children:S.jsx("span",{className:"folio-loader"})})}):null},b5=({direction:t,state:e,dispatch:n})=>{if(e.selection.from!==e.selection.to-1)return!1;const r=e.selection.node;if(!r||r.type.name!=="folioTiptapNode")return!1;let i;if(t==="up"){const o=e.doc.resolve(e.selection.from).nodeBefore;if(!o)return!1;i=e.selection.from-o.nodeSize}else{const o=e.doc.resolve(e.selection.to).nodeAfter;if(!o)return!1;i=e.selection.to+o.nodeSize-1}if(n){const o=e.tr;o.deleteRange(e.selection.from,e.selection.to),o.insert(i,r),o.setSelection(ue.near(o.doc.resolve(i))),n(o)}return!0};function K8(t,e){try{t.setSelection(ue.create(t.doc,e))}catch{t.setSelection(ue.near(t.doc.resolve(e)))}}function pj(t,e,n){const r=e.nodes.paragraph.create();t.insert(n,r),K8(t,n+1)}function T0(t,e,n){const i=t.doc.resolve(n).nodeAfter;!i||i.type.name==="folioTiptapNode"?pj(t,e,n):K8(t,n+1)}const G8=({node:t,pos:e,tr:n,schema:r})=>{const i=n.doc.resolve(e);if(n.doc.nodeAt(e)?.isBlock===!0){n.replaceWith(e,e+1,t);const c=e+t.nodeSize;T0(n,r,c)}else{const c=i.start(i.depth)-1,d=i.end(i.depth)+1,f=i.parent;if(f.content.size===0||f.textContent.trim().length===0){n.replaceWith(c,d,t);const m=c+t.nodeSize;T0(n,r,m)}else{n.insert(d,t);const m=d+t.nodeSize;T0(n,r,m)}}n.scrollIntoView()},mj="^https://(?:www\\.)?instagram\\.com/(?:p|reel)/([a-zA-Z0-9\\-_]+)/?",gj="^https://(?:\\w+\\.)?pinterest\\.com/pin/([a-zA-Z0-9\\-_]+)/?",yj="^https://(?:www\\.)?(?:twitter\\.com|x\\.com)/([a-zA-Z0-9\\-_]+)(?:/.*)?/?",vj="^https://(?:www\\.youtube\\.com/(?:watch\\?v=|shorts/)|youtu\\.be/)([a-zA-Z0-9\\-_]+)/?",bj={instagram:mj,pinterest:gj,twitter:yj,youtube:vj},Cj=Object.entries(bj).reduce((t,[e,n])=>(t[e]=new RegExp(n),t),{});function wj(t){for(const[e,n]of Object.entries(Cj))if(n.test(t))return e;return null}function C5(t){return/]*src="https:\/\/www\.facebook\.com\/plugins\/[^"]*"[^>]*>/.test(t)}const Y8=st.create({name:"folioTiptapNode",group:"block",draggable:!0,selectable:!0,atom:!0,addAttributes(){return{version:{default:1,parseHTML:t=>{let e;try{const n=t.dataset.folioTiptapNodeVersion||"1";e=parseInt(n,10)}catch(n){console.error("Error parsing folioTiptapNode version:",n),e=1}return e}},type:{default:"",parseHTML:t=>t.dataset.folioTiptapNodeType||""},data:{default:{},parseHTML:t=>{const e=t.dataset.folioTiptapNodeData||"{}";try{return JSON.parse(e)}catch(n){return console.error("Error parsing folioTiptapNode data:",n),{}}}},uniqueId:{default:"",parseHTML:()=>Ui()}}},parseHTML(){return[{tag:"div.f-tiptap-node",getAttrs:t=>{if(typeof t=="string")return!1;const e=t.dataset.folioTiptapNodeType||"";return this.options.nodes&&this.options.nodes.length>0&&!this.options.nodes.map(r=>r.type).includes(e)?!1:{version:parseInt(t.dataset.folioTiptapNodeVersion||"1",10),type:e,data:(()=>{try{return JSON.parse(t.dataset.folioTiptapNodeData||"{}")}catch(n){return console.error("Error parsing folioTiptapNode data:",n),{}}})(),uniqueId:Ui()}}}]},renderHTML({HTMLAttributes:t}){return["div",{class:"f-tiptap-node","data-folio-tiptap-node-version":t.version,"data-folio-tiptap-node-type":t.type,"data-folio-tiptap-node-data":JSON.stringify(t.data)}]},addNodeView(){return eo(hj,{stopEvent:()=>!1})},addProseMirrorPlugins(){const t={transformPastedHTML:n=>{if(!this.options.nodes||this.options.nodes.length===0)return n;const r=this.options.nodes.map(l=>l.type),i=document.createElement("div");return i.innerHTML=n,i.querySelectorAll("div.f-tiptap-node").forEach(l=>{const c=l.getAttribute("data-folio-tiptap-node-type")||"";r.includes(c)||l.remove()}),i.innerHTML}},e=[];return this.options.nodes&&this.options.nodes.forEach(n=>{if(n.config?.paste?.pattern)try{let r=n.config.paste.pattern;r=r.replace(/\\A/g,"^").replace(/\\z/g,"$");const i=new RegExp(r);e.push({type:n.type,pattern:i})}catch(r){console.error(`Failed to create RegExp for node ${n.type}:`,r)}}),(e.length>0||this.options.embedNodeClassName)&&(t.handlePaste=(n,r,i)=>{const o=r.clipboardData?.getData("text/plain"),l=r.clipboardData?.getData("text/html");if(e.length>0){const c=o?.trim()||l?.trim();if(c){for(const d of e)if(d.pattern.test(c)){const f=n.state.schema.nodes.folioTiptapNodePastePlaceholder.create({pasted_string:c,target_node_type:d.type,uniqueId:Ui()});return n.dispatch(n.state.tr.replaceSelectionWith(f)),!0}}}if(this.options.embedNodeClassName){if(o){const c=o.trim(),d=wj(c);if(d)return n.dispatch(n.state.tr.replaceSelectionWith(this.type.create({type:this.options.embedNodeClassName,version:1,uniqueId:Ui(),data:{folio_embed_data:{active:!0,type:d,url:c}}}))),!0;if(C5(c))return n.dispatch(n.state.tr.replaceSelectionWith(this.type.create({type:this.options.embedNodeClassName,version:1,uniqueId:Ui(),data:{folio_embed_data:{active:!0,html:c}}}))),!0}if(l&&C5(l))return n.dispatch(n.state.tr.replaceSelectionWith(this.type.create({type:this.options.embedNodeClassName,version:1,uniqueId:Ui(),data:{folio_embed_data:{active:!0,html:l}}}))),!0}return!1}),[new Ue({props:t})]},addCommands(){return{insertFolioTiptapNode:t=>({tr:e,dispatch:n,editor:r})=>{const i=r.schema.nodes.folioTiptapNode.createChecked({...t.attrs,uniqueId:t.attrs.uniqueId||Ui()},null);if(n){r.view.dom.focus();const l=e.selection.anchor;G8({node:i,pos:l,tr:e,schema:r.schema}),n(e)}return!0},moveFolioTiptapNodeDown:()=>({state:t,dispatch:e})=>b5({direction:"down",state:t,dispatch:e}),moveFolioTiptapNodeUp:()=>({state:t,dispatch:e})=>b5({direction:"up",state:t,dispatch:e}),editFolioTipapNode:()=>({state:t})=>{const e=t.selection.node;if(!e||e.type.name!==this.name)return!1;const{uniqueId:n,...r}=e.attrs;return j2(r,n),!0},removeFolioTiptapNode:()=>({state:t,dispatch:e})=>{const n=t.selection.node;if(!n||n.type.name!==this.name)return!1;const r=t.tr;return r.deleteRange(t.selection.from,t.selection.to),e(r),!0}}}}),w5="f-tiptap-node-paste-placeholder",xj=t=>{const{node:e,editor:n,getPos:r}=t,{pasted_string:i,target_node_type:o,uniqueId:l}=e.attrs;return E.useEffect(()=>{if(!l||!i||!o)return;window.parent.postMessage({type:"f-tiptap-node:paste",uniqueId:l,pasted_string:i,tiptap_node_type:o},"*");const c=d=>{if(d.origin===window.origin&&d.data.type==="f-input-tiptap:paste-node"&&d.data.unique_id===l){const f=r();if(typeof f!="number")return;if(d.data.tiptap_node){const{state:h}=n.view,{tr:m}=h,g={...d.data.tiptap_node.attrs,uniqueId:l};if(d.data.html){const{uniqueId:C,...w}=g,x=JSON.stringify(w);Z8({html:d.data.html,serializedAttrs:x})}const y=n.schema.nodes.folioTiptapNode.createChecked(g,null);G8({node:y,pos:f,tr:m,schema:n.schema}),n.view.dispatch(m)}else if(d.data.error){const{state:h}=n.view,{tr:m}=h;m.delete(f,f+1),n.view.dispatch(m),window.alert(d.data.error)}window.removeEventListener("message",c)}};return window.addEventListener("message",c),()=>{window.removeEventListener("message",c)}},[l,i,o,n,r]),S.jsx(Qi,{className:w5,"data-pasted-string":i,"data-target-node-type":o,"data-unique-id":l,children:S.jsx("div",{className:`${w5}__loader-wrap rounded`,children:S.jsx("span",{className:"folio-loader"})})})},x5="f-tiptap-node-paste-placeholder",Sj=st.create({name:"folioTiptapNodePastePlaceholder",group:"block",draggable:!0,selectable:!0,atom:!0,isolating:!0,renderHTML({HTMLAttributes:t}){return["div",{...t,class:x5},0]},addAttributes(){return{pasted_string:{default:"",parseHTML:t=>t.getAttribute("data-pasted-string")||"",renderHTML:t=>({"data-pasted-string":t.pasted_string})},target_node_type:{default:"",parseHTML:t=>t.getAttribute("data-target-node-type")||"",renderHTML:t=>({"data-target-node-type":t.target_node_type})},uniqueId:{default:"",parseHTML:t=>t.getAttribute("data-unique-id")||"",renderHTML:t=>({"data-unique-id":t.uniqueId})}}},addNodeView(){return eo(xj,{stopEvent:()=>!1})},parseHTML(){return[{tag:`div.${x5}`,getAttrs:t=>typeof t=="string"?!1:{pasted_string:t.getAttribute("data-pasted-string")||"",target_node_type:t.getAttribute("data-target-node-type")||"",uniqueId:t.getAttribute("data-unique-id")||""}}]}}),Af={cs:{moveFolioTiptapNodeUp:"Posunout nahoru",moveFolioTiptapNodeDown:"Posunout dolů",editFolioTipapNode:"Upravit",removeFolioTiptapNode:"Odstranit"},en:{moveFolioTiptapNodeUp:"Move up",moveFolioTiptapNodeDown:"Move down",editFolioTipapNode:"Edit",removeFolioTiptapNode:"Remove"}},Tj={pluginKey:"folioTiptapNodeBubbleMenu",priority:1,offset:({rects:t})=>-t.reference.height/2-t.floating.height/2,shouldShow:({editor:t})=>t.isActive(Y8.name),disabledKeys:({state:t})=>{const e=[];return t.doc.resolve(t.selection.from).nodeBefore||e.push("moveFolioTiptapNodeUp"),t.doc.resolve(t.selection.to).nodeAfter||e.push("moveFolioTiptapNodeDown"),e},items:[[{key:"moveFolioTiptapNodeUp",title:pe(Af,"moveFolioTiptapNodeUp"),icon:m3,command:({editor:t})=>{t.chain().focus().moveFolioTiptapNodeUp().run()}},{key:"moveFolioTiptapNodeDown",title:pe(Af,"moveFolioTiptapNodeDown"),icon:p3,command:({editor:t})=>{t.chain().focus().moveFolioTiptapNodeDown().run()}},{key:"editFolioTipapNode",title:pe(Af,"editFolioTipapNode"),icon:d8,command:({editor:t})=>{t.chain().focus().editFolioTipapNode().run()}},{key:"removeFolioTiptapNode",title:pe(Af,"removeFolioTiptapNode"),icon:zp,command:({editor:t})=>{t.chain().focus().removeFolioTiptapNode().run()}}]]},W8=t=>{const e={...t};return e.type==="folioTiptapNode"&&(e.attrs={...e.attrs,uniqueId:Ui()}),e.content&&Array.isArray(e.content)&&(e.content=e.content.map(n=>W8(n))),e},M3=t=>{const e={...t};return e.type==="folioTiptapNode"&&(e.attrs={...e.attrs},delete e.attrs.uniqueId),e.content&&Array.isArray(e.content)&&(e.content=e.content.map(n=>M3(n))),e},kj=Ke.create({name:"folioTiptapColumnsExtension"});function Ej(t,e=null){return e?t.createChecked({},e):t.createAndFill({})}function Mj(t){if(t.cached.columnsNodeTypes)return t.cached.columnsNodeTypes;const e={columns:t.nodes.folioTiptapColumns,column:t.nodes.folioTiptapColumn};return t.cached.columnsNodeTypes=e,e}function Aj(t,e,n=null){const r=Mj(t),i=[];for(let o=0;oo.type.name===o1.name)(t.selection),i=At(o=>o.type.name===tp.name)(t.selection);if(!r||!i)return!1;if(e){const o=r.node;let l=null;if(o.content.forEach((g,y,C)=>{if(l===null&&g===i.node){l=C;return}}),l===null)return console.warn("Current page not found in cols node"),!1;const c=o.toJSON();let d=l;if(n==="delete"){if(c.content.length<=2){const x=[];c.content.forEach(A=>{A.content&&A.content.length>0&&x.push(...A.content)}),x.length===0&&x.push({type:"paragraph"});const k=t.tr;return k.replaceWith(r.pos,r.pos+r.node.nodeSize,x.map(A=>Gn.fromJSON(t.schema,A))),k.setSelection(ue.near(k.doc.resolve(r.pos+1))),e(k),!0}const y=c.content[l].content||[],C=l>0?l-1:l+1,w=c.content[C];y.length>0&&(w.content||(w.content=[]),w.content.push(...y)),c.content.splice(l,1),d=l>0?l-1:0}else d=n==="addBefore"?l:l+1,c.content.splice(d,0,{type:tp.name,content:[{type:"paragraph"}]});const f=Gn.fromJSON(t.schema,c);let h=r.pos;f.content.forEach((g,y,C)=>{Co.type.name===o1.name)(t.selection),i=At(o=>o.type.name===tp.name)(t.selection);if(e&&r&&i){const o=r.node,l=i.node;let c=null;if(o.content.forEach((m,g,y)=>{if(c===null&&m===l){c=y;return}}),c===null)return console.warn("Current col not found in cols node"),!1;let d=0;n==="before"?d=(c-1+o.childCount)%o.childCount:d=(c+1)%o.childCount;let f=r.pos;o.content.forEach((m,g,y)=>{y"u"?!1:t instanceof ShadowRoot||t instanceof Jn(t).ShadowRoot}const Nj=new Set(["inline","contents"]);function zu(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=Rr(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!Nj.has(i)}const Rj=new Set(["table","td","th"]);function Oj(t){return Rj.has(ss(t))}const Dj=[":popover-open",":modal"];function Vp(t){return Dj.some(e=>{try{return t.matches(e)}catch{return!1}})}const Lj=["transform","translate","scale","rotate","perspective"],_j=["transform","translate","scale","rotate","perspective","filter"],Hj=["paint","layout","strict","content"];function N3(t){const e=Up(),n=yt(t)?Rr(t):t;return Lj.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||_j.some(r=>(n.willChange||"").includes(r))||Hj.some(r=>(n.contain||"").includes(r))}function Ij(t){let e=Wi(t);for(;_t(e)&&!Ki(e);){if(N3(e))return e;if(Vp(e))return null;e=Wi(e)}return null}function Up(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const zj=new Set(["html","body","#document"]);function Ki(t){return zj.has(ss(t))}function Rr(t){return Jn(t).getComputedStyle(t)}function Pp(t){return yt(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Wi(t){if(ss(t)==="html")return t;const e=t.assignedSlot||t.parentNode||U2(t)&&t.host||pi(t);return U2(e)?e.host:e}function J8(t){const e=Wi(t);return Ki(e)?t.ownerDocument?t.ownerDocument.body:t.body:_t(e)&&zu(e)?e:J8(e)}function Yo(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=J8(t),o=i===((r=t.ownerDocument)==null?void 0:r.body),l=Jn(i);if(o){const c=P2(l);return e.concat(l,l.visualViewport||[],zu(i)?i:[],c&&n?Yo(c):[])}return e.concat(i,Yo(i,[],n))}function P2(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}const X8=["top","right","bottom","left"],T5=["start","end"],k5=X8.reduce((t,e)=>t.concat(e,e+"-"+T5[0],e+"-"+T5[1]),[]),$r=Math.min,wn=Math.max,qh=Math.round,ia=Math.floor,ai=t=>({x:t,y:t}),Bj={left:"right",right:"left",bottom:"top",top:"bottom"},jj={start:"end",end:"start"};function F2(t,e,n){return wn(t,$r(e,n))}function qr(t,e){return typeof t=="function"?t(e):t}function cr(t){return t.split("-")[0]}function Pr(t){return t.split("-")[1]}function R3(t){return t==="x"?"y":"x"}function O3(t){return t==="y"?"height":"width"}const Vj=new Set(["top","bottom"]);function Vr(t){return Vj.has(cr(t))?"y":"x"}function D3(t){return R3(Vr(t))}function Q8(t,e,n){n===void 0&&(n=!1);const r=Pr(t),i=D3(t),o=O3(i);let l=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(l=Kh(l)),[l,Kh(l)]}function Uj(t){const e=Kh(t);return[Zh(t),e,Zh(e)]}function Zh(t){return t.replace(/start|end/g,e=>jj[e])}const E5=["left","right"],M5=["right","left"],Pj=["top","bottom"],Fj=["bottom","top"];function $j(t,e,n){switch(t){case"top":case"bottom":return n?e?M5:E5:e?E5:M5;case"left":case"right":return e?Pj:Fj;default:return[]}}function qj(t,e,n,r){const i=Pr(t);let o=$j(cr(t),n==="start",r);return i&&(o=o.map(l=>l+"-"+i),e&&(o=o.concat(o.map(Zh)))),o}function Kh(t){return t.replace(/left|right|bottom|top/g,e=>Bj[e])}function Zj(t){return{top:0,right:0,bottom:0,left:0,...t}}function L3(t){return typeof t!="number"?Zj(t):{top:t,right:t,bottom:t,left:t}}function wa(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}var Kj=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],Gh=Kj.join(","),eT=typeof Element>"u",xa=eT?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Yh=!eT&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t?.ownerDocument},Wh=function(e,n){var r;n===void 0&&(n=!0);var i=e==null||(r=e.getAttribute)===null||r===void 0?void 0:r.call(e,"inert"),o=i===""||i==="true",l=o||n&&e&&(typeof e.closest=="function"?e.closest("[inert]"):Wh(e.parentNode));return l},Gj=function(e){var n,r=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"contenteditable");return r===""||r==="true"},tT=function(e,n,r){if(Wh(e))return[];var i=Array.prototype.slice.apply(e.querySelectorAll(Gh));return n&&xa.call(e,Gh)&&i.unshift(e),i=i.filter(r),i},Jh=function(e,n,r){for(var i=[],o=Array.from(e);o.length;){var l=o.shift();if(!Wh(l,!1))if(l.tagName==="SLOT"){var c=l.assignedElements(),d=c.length?c:l.children,f=Jh(d,!0,r);r.flatten?i.push.apply(i,f):i.push({scopeParent:l,candidates:f})}else{var h=xa.call(l,Gh);h&&r.filter(l)&&(n||!e.includes(l))&&i.push(l);var m=l.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(l),g=!Wh(m,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(l));if(m&&g){var y=Jh(m===!0?l.children:m.children,!0,r);r.flatten?i.push.apply(i,y):i.push({scopeParent:l,candidates:y})}else o.unshift.apply(o,l.children)}}return i},nT=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},rT=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||Gj(e))&&!nT(e)?0:e.tabIndex},Yj=function(e,n){var r=rT(e);return r<0&&n&&!nT(e)?0:r},Wj=function(e,n){return e.tabIndex===n.tabIndex?e.documentOrder-n.documentOrder:e.tabIndex-n.tabIndex},iT=function(e){return e.tagName==="INPUT"},Jj=function(e){return iT(e)&&e.type==="hidden"},Xj=function(e){var n=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(r){return r.tagName==="SUMMARY"});return n},Qj=function(e,n){for(var r=0;rsummary:first-of-type"),c=l?e.parentElement:e;if(xa.call(c,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof i=="function"){for(var d=e;e;){var f=e.parentElement,h=Yh(e);if(f&&!f.shadowRoot&&i(f)===!0)return A5(e);e.assignedSlot?e=e.assignedSlot:!f&&h!==e.ownerDocument?e=h.host:e=f}e=d}if(rV(e))return!e.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return A5(e);return!1},oV=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var n=e.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r=0)},oT=function(e){var n=[],r=[];return e.forEach(function(i,o){var l=!!i.scopeParent,c=l?i.scopeParent:i,d=Yj(c,l),f=l?oT(i.candidates):c;d===0?l?n.push.apply(n,f):n.push(c):r.push({documentOrder:o,tabIndex:d,item:i,isScope:l,content:f})}),r.sort(Wj).reduce(function(i,o){return o.isScope?i.push.apply(i,o.content):i.push(o.content),i},[]).concat(n)},Fp=function(e,n){n=n||{};var r;return n.getShadowRoot?r=Jh([e],n.includeContainer,{filter:q2.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:sV}):r=tT(e,n.includeContainer,q2.bind(null,n)),oT(r)},lV=function(e,n){n=n||{};var r;return n.getShadowRoot?r=Jh([e],n.includeContainer,{filter:$2.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=tT(e,n.includeContainer,$2.bind(null,n)),r},sT=function(e,n){if(n=n||{},!e)throw new Error("No node provided");return xa.call(e,Gh)===!1?!1:q2(n,e)};function lT(){const t=navigator.userAgentData;return t!=null&&t.platform?t.platform:navigator.platform}function aT(){const t=navigator.userAgentData;return t&&Array.isArray(t.brands)?t.brands.map(e=>{let{brand:n,version:r}=e;return n+"/"+r}).join(" "):navigator.userAgent}function cT(){return/apple/i.test(navigator.vendor)}function Z2(){const t=/android/i;return t.test(lT())||t.test(aT())}function aV(){return lT().toLowerCase().startsWith("mac")&&!navigator.maxTouchPoints}function uT(){return aT().includes("jsdom/")}const N5="data-floating-ui-focusable",cV="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",E0="ArrowLeft",M0="ArrowRight",uV="ArrowUp",dV="ArrowDown";function li(t){let e=t.activeElement;for(;((n=e)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;e=e.shadowRoot.activeElement}return e}function fn(t,e){if(!t||!e)return!1;const n=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(n&&U2(n)){let r=e;for(;r;){if(t===r)return!0;r=r.parentNode||r.host}}return!1}function Pi(t){return"composedPath"in t?t.composedPath()[0]:t.target}function A0(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const n=t;return n.target!=null&&e.contains(n.target)}function fV(t){return t.matches("html,body")}function gn(t){return t?.ownerDocument||document}function _3(t){return _t(t)&&t.matches(cV)}function K2(t){return t?t.getAttribute("role")==="combobox"&&_3(t):!1}function hV(t){if(!t||uT())return!0;try{return t.matches(":focus-visible")}catch{return!0}}function Xh(t){return t?t.hasAttribute(N5)?t:t.querySelector("["+N5+"]")||t:null}function Us(t,e,n){return n===void 0&&(n=!0),t.filter(i=>{var o;return i.parentId===e&&(!n||((o=i.context)==null?void 0:o.open))}).flatMap(i=>[i,...Us(t,i.id,n)])}function pV(t,e){let n,r=-1;function i(o,l){l>r&&(n=o,r=l),Us(t,o).forEach(d=>{i(d.id,l+1)})}return i(e,0),t.find(o=>o.id===n)}function R5(t,e){var n;let r=[],i=(n=t.find(o=>o.id===e))==null?void 0:n.parentId;for(;i;){const o=t.find(l=>l.id===i);i=o?.parentId,o&&(r=r.concat(o))}return r}function hn(t){t.preventDefault(),t.stopPropagation()}function mV(t){return"nativeEvent"in t}function dT(t){return t.mozInputSource===0&&t.isTrusted?!0:Z2()&&t.pointerType?t.type==="click"&&t.buttons===1:t.detail===0&&!t.pointerType}function fT(t){return uT()?!1:!Z2()&&t.width===0&&t.height===0||Z2()&&t.width===1&&t.height===1&&t.pressure===0&&t.detail===0&&t.pointerType==="mouse"||t.width<1&&t.height<1&&t.pressure===0&&t.detail===0&&t.pointerType==="touch"}function vu(t,e){const n=["mouse","pen"];return e||n.push("",void 0),n.includes(t)}var gV=typeof document<"u",yV=function(){},ft=gV?E.useLayoutEffect:yV;const vV={...n9};function Zn(t){const e=E.useRef(t);return ft(()=>{e.current=t}),e}const bV=vV.useInsertionEffect,CV=bV||(t=>t());function Ht(t){const e=E.useRef(()=>{});return CV(()=>{e.current=t}),E.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i=t.current.length}function N0(t,e){return Cn(t,{disabledIndices:e})}function O5(t,e){return Cn(t,{decrement:!0,startingIndex:t.current.length,disabledIndices:e})}function Cn(t,e){let{startingIndex:n=-1,decrement:r=!1,disabledIndices:i,amount:o=1}=e===void 0?{}:e,l=n;do l+=r?-o:o;while(l>=0&&l<=t.current.length-1&&Gf(t,l,i));return l}function wV(t,e){let{event:n,orientation:r,loop:i,rtl:o,cols:l,disabledIndices:c,minIndex:d,maxIndex:f,prevIndex:h,stopEvent:m=!1}=e,g=h;if(n.key===uV){if(m&&hn(n),h===-1)g=f;else if(g=Cn(t,{startingIndex:g,amount:l,decrement:!0,disabledIndices:c}),i&&(h-ly?w:w-l}tu(t,g)&&(g=h)}if(n.key===dV&&(m&&hn(n),h===-1?g=d:(g=Cn(t,{startingIndex:h,amount:l,disabledIndices:c}),i&&h+l>f&&(g=Cn(t,{startingIndex:h%l-l,amount:l,disabledIndices:c}))),tu(t,g)&&(g=h)),r==="both"){const y=ia(h/l);n.key===(o?E0:M0)&&(m&&hn(n),h%l!==l-1?(g=Cn(t,{startingIndex:h,disabledIndices:c}),i&&Nf(g,l,y)&&(g=Cn(t,{startingIndex:h-h%l-1,disabledIndices:c}))):i&&(g=Cn(t,{startingIndex:h-h%l-1,disabledIndices:c})),Nf(g,l,y)&&(g=h)),n.key===(o?M0:E0)&&(m&&hn(n),h%l!==0?(g=Cn(t,{startingIndex:h,decrement:!0,disabledIndices:c}),i&&Nf(g,l,y)&&(g=Cn(t,{startingIndex:h+(l-h%l),decrement:!0,disabledIndices:c}))):i&&(g=Cn(t,{startingIndex:h+(l-h%l),decrement:!0,disabledIndices:c})),Nf(g,l,y)&&(g=h));const C=ia(f/l)===y;tu(t,g)&&(i&&C?g=n.key===(o?M0:E0)?f:Cn(t,{startingIndex:h-h%l-1,disabledIndices:c}):g=h)}return g}function xV(t,e,n){const r=[];let i=0;return t.forEach((o,l)=>{let{width:c,height:d}=o,f=!1;for(n&&(i=0);!f;){const h=[];for(let m=0;mr[m]==null)?(h.forEach(m=>{r[m]=l}),f=!0):i++}}),[...r]}function SV(t,e,n,r,i){if(t===-1)return-1;const o=n.indexOf(t),l=e[t];switch(i){case"tl":return o;case"tr":return l?o+l.width-1:o;case"bl":return l?o+(l.height-1)*r:o;case"br":return n.lastIndexOf(t)}}function TV(t,e){return e.flatMap((n,r)=>t.includes(n)?[r]:[])}function Gf(t,e,n){if(typeof n=="function")return n(e);if(n)return n.includes(e);const r=t.current[e];return r==null||r.hasAttribute("disabled")||r.getAttribute("aria-disabled")==="true"}const Bu=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function hT(t,e){const n=Fp(t,Bu()),r=n.length;if(r===0)return;const i=li(gn(t)),o=n.indexOf(i),l=o===-1?e===1?0:r-1:o+e;return n[l]}function pT(t){return hT(gn(t).body,1)||t}function mT(t){return hT(gn(t).body,-1)||t}function nu(t,e){const n=e||t.currentTarget,r=t.relatedTarget;return!r||!fn(n,r)}function kV(t){Fp(t,Bu()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function D5(t){t.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}function L5(t,e,n){let{reference:r,floating:i}=t;const o=Vr(e),l=D3(e),c=O3(l),d=cr(e),f=o==="y",h=r.x+r.width/2-i.width/2,m=r.y+r.height/2-i.height/2,g=r[c]/2-i[c]/2;let y;switch(d){case"top":y={x:h,y:r.y-i.height};break;case"bottom":y={x:h,y:r.y+r.height};break;case"right":y={x:r.x+r.width,y:m};break;case"left":y={x:r.x-i.width,y:m};break;default:y={x:r.x,y:r.y}}switch(Pr(e)){case"start":y[l]-=g*(n&&f?-1:1);break;case"end":y[l]+=g*(n&&f?-1:1);break}return y}const EV=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:l}=n,c=o.filter(Boolean),d=await(l.isRTL==null?void 0:l.isRTL(e));let f=await l.getElementRects({reference:t,floating:e,strategy:i}),{x:h,y:m}=L5(f,r,d),g=r,y={},C=0;for(let w=0;w({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:i,rects:o,platform:l,elements:c,middlewareData:d}=e,{element:f,padding:h=0}=qr(t,e)||{};if(f==null)return{};const m=L3(h),g={x:n,y:r},y=D3(i),C=O3(y),w=await l.getDimensions(f),x=y==="y",k=x?"top":"left",A=x?"bottom":"right",N=x?"clientHeight":"clientWidth",R=o.reference[C]+o.reference[y]-g[y]-o.floating[C],L=g[y]-o.reference[y],z=await(l.getOffsetParent==null?void 0:l.getOffsetParent(f));let _=z?z[N]:0;(!_||!await(l.isElement==null?void 0:l.isElement(z)))&&(_=c.floating[N]||o.floating[C]);const $=R/2-L/2,J=_/2-w[C]/2-1,U=$r(m[k],J),ne=$r(m[A],J),se=U,oe=_-w[C]-ne,G=_/2-w[C]/2+$,P=F2(se,G,oe),H=!d.arrow&&Pr(i)!=null&&G!==P&&o.reference[C]/2-(GPr(i)===t),...n.filter(i=>Pr(i)!==t)]:n.filter(i=>cr(i)===i)).filter(i=>t?Pr(i)===t||(e?Zh(i)!==i:!1):!0)}const NV=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,r,i;const{rects:o,middlewareData:l,placement:c,platform:d,elements:f}=e,{crossAxis:h=!1,alignment:m,allowedPlacements:g=k5,autoAlignment:y=!0,...C}=qr(t,e),w=m!==void 0||g===k5?AV(m||null,y,g):g,x=await Sa(e,C),k=((n=l.autoPlacement)==null?void 0:n.index)||0,A=w[k];if(A==null)return{};const N=Q8(A,o,await(d.isRTL==null?void 0:d.isRTL(f.floating)));if(c!==A)return{reset:{placement:w[0]}};const R=[x[cr(A)],x[N[0]],x[N[1]]],L=[...((r=l.autoPlacement)==null?void 0:r.overflows)||[],{placement:A,overflows:R}],z=w[k+1];if(z)return{data:{index:k+1,overflows:L},reset:{placement:z}};const _=L.map(U=>{const ne=Pr(U.placement);return[U.placement,ne&&h?U.overflows.slice(0,2).reduce((se,oe)=>se+oe,0):U.overflows[0],U.overflows]}).sort((U,ne)=>U[1]-ne[1]),J=((i=_.filter(U=>U[2].slice(0,Pr(U[0])?2:3).every(ne=>ne<=0))[0])==null?void 0:i[0])||_[0][0];return J!==c?{data:{index:k+1,overflows:L},reset:{placement:J}}:{}}}},RV=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:o,rects:l,initialPlacement:c,platform:d,elements:f}=e,{mainAxis:h=!0,crossAxis:m=!0,fallbackPlacements:g,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:C="none",flipAlignment:w=!0,...x}=qr(t,e);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const k=cr(i),A=Vr(c),N=cr(c)===c,R=await(d.isRTL==null?void 0:d.isRTL(f.floating)),L=g||(N||!w?[Kh(c)]:Uj(c)),z=C!=="none";!g&&z&&L.push(...qj(c,w,C,R));const _=[c,...L],$=await Sa(e,x),J=[];let U=((r=o.flip)==null?void 0:r.overflows)||[];if(h&&J.push($[k]),m){const G=Q8(i,l,R);J.push($[G[0]],$[G[1]])}if(U=[...U,{placement:i,overflows:J}],!J.every(G=>G<=0)){var ne,se;const G=(((ne=o.flip)==null?void 0:ne.index)||0)+1,P=_[G];if(P&&(!(m==="alignment"?A!==Vr(P):!1)||U.every(B=>Vr(B.placement)===A?B.overflows[0]>0:!0)))return{data:{index:G,overflows:U},reset:{placement:P}};let H=(se=U.filter(j=>j.overflows[0]<=0).sort((j,B)=>j.overflows[1]-B.overflows[1])[0])==null?void 0:se.placement;if(!H)switch(y){case"bestFit":{var oe;const j=(oe=U.filter(B=>{if(z){const re=Vr(B.placement);return re===A||re==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(re=>re>0).reduce((re,ae)=>re+ae,0)]).sort((B,re)=>B[1]-re[1])[0])==null?void 0:oe[0];j&&(H=j);break}case"initialPlacement":H=c;break}if(i!==H)return{reset:{placement:H}}}return{}}}};function _5(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function H5(t){return X8.some(e=>t[e]>=0)}const OV=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...i}=qr(t,e);switch(r){case"referenceHidden":{const o=await Sa(e,{...i,elementContext:"reference"}),l=_5(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:H5(l)}}}case"escaped":{const o=await Sa(e,{...i,altBoundary:!0}),l=_5(o,n.floating);return{data:{escapedOffsets:l,escaped:H5(l)}}}default:return{}}}}};function gT(t){const e=$r(...t.map(o=>o.left)),n=$r(...t.map(o=>o.top)),r=wn(...t.map(o=>o.right)),i=wn(...t.map(o=>o.bottom));return{x:e,y:n,width:r-e,height:i-n}}function DV(t){const e=t.slice().sort((i,o)=>i.y-o.y),n=[];let r=null;for(let i=0;ir.height/2?n.push([o]):n[n.length-1].push(o),r=o}return n.map(i=>wa(gT(i)))}const LV=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:r,rects:i,platform:o,strategy:l}=e,{padding:c=2,x:d,y:f}=qr(t,e),h=Array.from(await(o.getClientRects==null?void 0:o.getClientRects(r.reference))||[]),m=DV(h),g=wa(gT(h)),y=L3(c);function C(){if(m.length===2&&m[0].left>m[1].right&&d!=null&&f!=null)return m.find(x=>d>x.left-y.left&&dx.top-y.top&&f=2){if(Vr(n)==="y"){const U=m[0],ne=m[m.length-1],se=cr(n)==="top",oe=U.top,G=ne.bottom,P=se?U.left:ne.left,H=se?U.right:ne.right,j=H-P,B=G-oe;return{top:oe,bottom:G,left:P,right:H,width:j,height:B,x:P,y:oe}}const x=cr(n)==="left",k=wn(...m.map(U=>U.right)),A=$r(...m.map(U=>U.left)),N=m.filter(U=>x?U.left===A:U.right===k),R=N[0].top,L=N[N.length-1].bottom,z=A,_=k,$=_-z,J=L-R;return{top:R,bottom:L,left:z,right:_,width:$,height:J,x:z,y:R}}return g}const w=await o.getElementRects({reference:{getBoundingClientRect:C},floating:r.floating,strategy:l});return i.reference.x!==w.reference.x||i.reference.y!==w.reference.y||i.reference.width!==w.reference.width||i.reference.height!==w.reference.height?{reset:{rects:w}}:{}}}},yT=new Set(["left","top"]);async function _V(t,e){const{placement:n,platform:r,elements:i}=t,o=await(r.isRTL==null?void 0:r.isRTL(i.floating)),l=cr(n),c=Pr(n),d=Vr(n)==="y",f=yT.has(l)?-1:1,h=o&&d?-1:1,m=qr(e,t);let{mainAxis:g,crossAxis:y,alignmentAxis:C}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof C=="number"&&(y=c==="end"?C*-1:C),d?{x:y*h,y:g*f}:{x:g*f,y:y*h}}const HV=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:o,placement:l,middlewareData:c}=e,d=await _V(e,t);return l===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:i+d.x,y:o+d.y,data:{...d,placement:l}}}}},IV=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i}=e,{mainAxis:o=!0,crossAxis:l=!1,limiter:c={fn:x=>{let{x:k,y:A}=x;return{x:k,y:A}}},...d}=qr(t,e),f={x:n,y:r},h=await Sa(e,d),m=Vr(cr(i)),g=R3(m);let y=f[g],C=f[m];if(o){const x=g==="y"?"top":"left",k=g==="y"?"bottom":"right",A=y+h[x],N=y-h[k];y=F2(A,y,N)}if(l){const x=m==="y"?"top":"left",k=m==="y"?"bottom":"right",A=C+h[x],N=C-h[k];C=F2(A,C,N)}const w=c.fn({...e,[g]:y,[m]:C});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[g]:o,[m]:l}}}}}},zV=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:i,rects:o,middlewareData:l}=e,{offset:c=0,mainAxis:d=!0,crossAxis:f=!0}=qr(t,e),h={x:n,y:r},m=Vr(i),g=R3(m);let y=h[g],C=h[m];const w=qr(c,e),x=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(d){const N=g==="y"?"height":"width",R=o.reference[g]-o.floating[N]+x.mainAxis,L=o.reference[g]+o.reference[N]-x.mainAxis;yL&&(y=L)}if(f){var k,A;const N=g==="y"?"width":"height",R=yT.has(cr(i)),L=o.reference[m]-o.floating[N]+(R&&((k=l.offset)==null?void 0:k[m])||0)+(R?0:x.crossAxis),z=o.reference[m]+o.reference[N]+(R?0:((A=l.offset)==null?void 0:A[m])||0)-(R?x.crossAxis:0);Cz&&(C=z)}return{[g]:y,[m]:C}}}},BV=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:i,rects:o,platform:l,elements:c}=e,{apply:d=()=>{},...f}=qr(t,e),h=await Sa(e,f),m=cr(i),g=Pr(i),y=Vr(i)==="y",{width:C,height:w}=o.floating;let x,k;m==="top"||m==="bottom"?(x=m,k=g===(await(l.isRTL==null?void 0:l.isRTL(c.floating))?"start":"end")?"left":"right"):(k=m,x=g==="end"?"top":"bottom");const A=w-h.top-h.bottom,N=C-h.left-h.right,R=$r(w-h[x],A),L=$r(C-h[k],N),z=!e.middlewareData.shift;let _=R,$=L;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&($=N),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(_=A),z&&!g){const U=wn(h.left,0),ne=wn(h.right,0),se=wn(h.top,0),oe=wn(h.bottom,0);y?$=C-2*(U!==0||ne!==0?U+ne:wn(h.left,h.right)):_=w-2*(se!==0||oe!==0?se+oe:wn(h.top,h.bottom))}await d({...e,availableWidth:$,availableHeight:_});const J=await l.getDimensions(c.floating);return C!==J.width||w!==J.height?{reset:{rects:!0}}:{}}}};function vT(t){const e=Rr(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=_t(t),o=i?t.offsetWidth:n,l=i?t.offsetHeight:r,c=qh(n)!==o||qh(r)!==l;return c&&(n=o,r=l),{width:n,height:r,$:c}}function H3(t){return yt(t)?t:t.contextElement}function la(t){const e=H3(t);if(!_t(e))return ai(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:o}=vT(e);let l=(o?qh(n.width):n.width)/r,c=(o?qh(n.height):n.height)/i;return(!l||!Number.isFinite(l))&&(l=1),(!c||!Number.isFinite(c))&&(c=1),{x:l,y:c}}const jV=ai(0);function bT(t){const e=Jn(t);return!Up()||!e.visualViewport?jV:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function VV(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Jn(t)?!1:e}function Ws(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),o=H3(t);let l=ai(1);e&&(r?yt(r)&&(l=la(r)):l=la(t));const c=VV(o,n,r)?bT(o):ai(0);let d=(i.left+c.x)/l.x,f=(i.top+c.y)/l.y,h=i.width/l.x,m=i.height/l.y;if(o){const g=Jn(o),y=r&&yt(r)?Jn(r):r;let C=g,w=P2(C);for(;w&&r&&y!==C;){const x=la(w),k=w.getBoundingClientRect(),A=Rr(w),N=k.left+(w.clientLeft+parseFloat(A.paddingLeft))*x.x,R=k.top+(w.clientTop+parseFloat(A.paddingTop))*x.y;d*=x.x,f*=x.y,h*=x.x,m*=x.y,d+=N,f+=R,C=Jn(w),w=P2(C)}}return wa({width:h,height:m,x:d,y:f})}function $p(t,e){const n=Pp(t).scrollLeft;return e?e.left+n:Ws(pi(t)).left+n}function CT(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-$p(t,n),i=n.top+e.scrollTop;return{x:r,y:i}}function UV(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const o=i==="fixed",l=pi(r),c=e?Vp(e.floating):!1;if(r===l||c&&o)return n;let d={scrollLeft:0,scrollTop:0},f=ai(1);const h=ai(0),m=_t(r);if((m||!m&&!o)&&((ss(r)!=="body"||zu(l))&&(d=Pp(r)),_t(r))){const y=Ws(r);f=la(r),h.x=y.x+r.clientLeft,h.y=y.y+r.clientTop}const g=l&&!m&&!o?CT(l,d):ai(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-d.scrollLeft*f.x+h.x+g.x,y:n.y*f.y-d.scrollTop*f.y+h.y+g.y}}function PV(t){return Array.from(t.getClientRects())}function FV(t){const e=pi(t),n=Pp(t),r=t.ownerDocument.body,i=wn(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),o=wn(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let l=-n.scrollLeft+$p(t);const c=-n.scrollTop;return Rr(r).direction==="rtl"&&(l+=wn(e.clientWidth,r.clientWidth)-i),{width:i,height:o,x:l,y:c}}const I5=25;function $V(t,e){const n=Jn(t),r=pi(t),i=n.visualViewport;let o=r.clientWidth,l=r.clientHeight,c=0,d=0;if(i){o=i.width,l=i.height;const h=Up();(!h||h&&e==="fixed")&&(c=i.offsetLeft,d=i.offsetTop)}const f=$p(r);if(f<=0){const h=r.ownerDocument,m=h.body,g=getComputedStyle(m),y=h.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,C=Math.abs(r.clientWidth-m.clientWidth-y);C<=I5&&(o-=C)}else f<=I5&&(o+=f);return{width:o,height:l,x:c,y:d}}const qV=new Set(["absolute","fixed"]);function ZV(t,e){const n=Ws(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,o=_t(t)?la(t):ai(1),l=t.clientWidth*o.x,c=t.clientHeight*o.y,d=i*o.x,f=r*o.y;return{width:l,height:c,x:d,y:f}}function z5(t,e,n){let r;if(e==="viewport")r=$V(t,n);else if(e==="document")r=FV(pi(t));else if(yt(e))r=ZV(e,n);else{const i=bT(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return wa(r)}function wT(t,e){const n=Wi(t);return n===e||!yt(n)||Ki(n)?!1:Rr(n).position==="fixed"||wT(n,e)}function KV(t,e){const n=e.get(t);if(n)return n;let r=Yo(t,[],!1).filter(c=>yt(c)&&ss(c)!=="body"),i=null;const o=Rr(t).position==="fixed";let l=o?Wi(t):t;for(;yt(l)&&!Ki(l);){const c=Rr(l),d=N3(l);!d&&c.position==="fixed"&&(i=null),(o?!d&&!i:!d&&c.position==="static"&&!!i&&qV.has(i.position)||zu(l)&&!d&&wT(t,l))?r=r.filter(h=>h!==l):i=c,l=Wi(l)}return e.set(t,r),r}function GV(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const l=[...n==="clippingAncestors"?Vp(e)?[]:KV(e,this._c):[].concat(n),r],c=l[0],d=l.reduce((f,h)=>{const m=z5(e,h,i);return f.top=wn(m.top,f.top),f.right=$r(m.right,f.right),f.bottom=$r(m.bottom,f.bottom),f.left=wn(m.left,f.left),f},z5(e,c,i));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function YV(t){const{width:e,height:n}=vT(t);return{width:e,height:n}}function WV(t,e,n){const r=_t(e),i=pi(e),o=n==="fixed",l=Ws(t,!0,o,e);let c={scrollLeft:0,scrollTop:0};const d=ai(0);function f(){d.x=$p(i)}if(r||!r&&!o)if((ss(e)!=="body"||zu(i))&&(c=Pp(e)),r){const y=Ws(e,!0,o,e);d.x=y.x+e.clientLeft,d.y=y.y+e.clientTop}else i&&f();o&&!r&&i&&f();const h=i&&!r&&!o?CT(i,c):ai(0),m=l.left+c.scrollLeft-d.x-h.x,g=l.top+c.scrollTop-d.y-h.y;return{x:m,y:g,width:l.width,height:l.height}}function R0(t){return Rr(t).position==="static"}function B5(t,e){if(!_t(t)||Rr(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return pi(t)===n&&(n=n.ownerDocument.body),n}function xT(t,e){const n=Jn(t);if(Vp(t))return n;if(!_t(t)){let i=Wi(t);for(;i&&!Ki(i);){if(yt(i)&&!R0(i))return i;i=Wi(i)}return n}let r=B5(t,e);for(;r&&Oj(r)&&R0(r);)r=B5(r,e);return r&&Ki(r)&&R0(r)&&!N3(r)?n:r||Ij(t)||n}const JV=async function(t){const e=this.getOffsetParent||xT,n=this.getDimensions,r=await n(t.floating);return{reference:WV(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function XV(t){return Rr(t).direction==="rtl"}const QV={convertOffsetParentRelativeRectToViewportRelativeRect:UV,getDocumentElement:pi,getClippingRect:GV,getOffsetParent:xT,getElementRects:JV,getClientRects:PV,getDimensions:YV,getScale:la,isElement:yt,isRTL:XV};function ST(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function eU(t,e){let n=null,r;const i=pi(t);function o(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function l(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),o();const f=t.getBoundingClientRect(),{left:h,top:m,width:g,height:y}=f;if(c||e(),!g||!y)return;const C=ia(m),w=ia(i.clientWidth-(h+g)),x=ia(i.clientHeight-(m+y)),k=ia(h),N={rootMargin:-C+"px "+-w+"px "+-x+"px "+-k+"px",threshold:wn(0,$r(1,d))||1};let R=!0;function L(z){const _=z[0].intersectionRatio;if(_!==d){if(!R)return l();_?l(!1,_):r=setTimeout(()=>{l(!1,1e-7)},1e3)}_===1&&!ST(f,t.getBoundingClientRect())&&l(),R=!1}try{n=new IntersectionObserver(L,{...N,root:i.ownerDocument})}catch{n=new IntersectionObserver(L,N)}n.observe(t)}return l(!0),o}function qp(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=r,f=H3(t),h=i||o?[...f?Yo(f):[],...Yo(e)]:[];h.forEach(k=>{i&&k.addEventListener("scroll",n,{passive:!0}),o&&k.addEventListener("resize",n)});const m=f&&c?eU(f,n):null;let g=-1,y=null;l&&(y=new ResizeObserver(k=>{let[A]=k;A&&A.target===f&&y&&(y.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var N;(N=y)==null||N.observe(e)})),n()}),f&&!d&&y.observe(f),y.observe(e));let C,w=d?Ws(t):null;d&&x();function x(){const k=Ws(t);w&&!ST(w,k)&&n(),w=k,C=requestAnimationFrame(x)}return n(),()=>{var k;h.forEach(A=>{i&&A.removeEventListener("scroll",n),o&&A.removeEventListener("resize",n)}),m?.(),(k=y)==null||k.disconnect(),y=null,d&&cancelAnimationFrame(C)}}const Zp=HV,TT=NV,I3=IV,Kp=RV,Gp=BV,kT=OV,ET=MV,MT=LV,tU=zV,ju=(t,e,n)=>{const r=new Map,i={platform:QV,...n},o={...i.platform,_c:r};return EV(t,e,{...i,platform:o})};var nU=typeof document<"u",rU=function(){},Yf=nU?E.useLayoutEffect:rU;function Qh(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,i;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!Qh(t[r],e[r]))return!1;return!0}if(i=Object.keys(t),n=i.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=n;r--!==0;){const o=i[r];if(!(o==="_owner"&&t.$$typeof)&&!Qh(t[o],e[o]))return!1}return!0}return t!==t&&e!==e}function AT(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function j5(t,e){const n=AT(t);return Math.round(e*n)/n}function O0(t){const e=E.useRef(t);return Yf(()=>{e.current=t}),e}function iU(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:o,floating:l}={},transform:c=!0,whileElementsMounted:d,open:f}=t,[h,m]=E.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[g,y]=E.useState(r);Qh(g,r)||y(r);const[C,w]=E.useState(null),[x,k]=E.useState(null),A=E.useCallback(B=>{B!==z.current&&(z.current=B,w(B))},[]),N=E.useCallback(B=>{B!==_.current&&(_.current=B,k(B))},[]),R=o||C,L=l||x,z=E.useRef(null),_=E.useRef(null),$=E.useRef(h),J=d!=null,U=O0(d),ne=O0(i),se=O0(f),oe=E.useCallback(()=>{if(!z.current||!_.current)return;const B={placement:e,strategy:n,middleware:g};ne.current&&(B.platform=ne.current),ju(z.current,_.current,B).then(re=>{const ae={...re,isPositioned:se.current!==!1};G.current&&!Qh($.current,ae)&&($.current=ae,Oa.flushSync(()=>{m(ae)}))})},[g,e,n,ne,se]);Yf(()=>{f===!1&&$.current.isPositioned&&($.current.isPositioned=!1,m(B=>({...B,isPositioned:!1})))},[f]);const G=E.useRef(!1);Yf(()=>(G.current=!0,()=>{G.current=!1}),[]),Yf(()=>{if(R&&(z.current=R),L&&(_.current=L),R&&L){if(U.current)return U.current(R,L,oe);oe()}},[R,L,oe,U,J]);const P=E.useMemo(()=>({reference:z,floating:_,setReference:A,setFloating:N}),[A,N]),H=E.useMemo(()=>({reference:R,floating:L}),[R,L]),j=E.useMemo(()=>{const B={position:n,left:0,top:0};if(!H.floating)return B;const re=j5(H.floating,h.x),ae=j5(H.floating,h.y);return c?{...B,transform:"translate("+re+"px, "+ae+"px)",...AT(H.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:re,top:ae}},[n,c,H.floating,h.x,h.y]);return E.useMemo(()=>({...h,update:oe,refs:P,elements:H,floatingStyles:j}),[h,oe,P,H,j])}const Yp=(t,e)=>({...Zp(t),options:[t,e]}),z3=(t,e)=>({...I3(t),options:[t,e]}),oU=(t,e)=>({...tU(t),options:[t,e]}),B3=(t,e)=>({...Kp(t),options:[t,e]}),NT=(t,e)=>({...Gp(t),options:[t,e]});function ol(t){const e=E.useRef(void 0),n=E.useCallback(r=>{const i=t.map(o=>{if(o!=null){if(typeof o=="function"){const l=o,c=l(r);return typeof c=="function"?c:()=>{l(null)}}return o.current=r,()=>{o.current=null}}});return()=>{i.forEach(o=>o?.())}},t);return E.useMemo(()=>t.every(r=>r==null)?null:r=>{e.current&&(e.current(),e.current=void 0),r!=null&&(e.current=n(r))},t)}function sU(t,e){const n=t.compareDocumentPosition(e);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const RT=E.createContext({register:()=>{},unregister:()=>{},map:new Map,elementsRef:{current:[]}});function lU(t){const{children:e,elementsRef:n,labelsRef:r}=t,[i,o]=E.useState(()=>new Set),l=E.useCallback(f=>{o(h=>new Set(h).add(f))},[]),c=E.useCallback(f=>{o(h=>{const m=new Set(h);return m.delete(f),m})},[]),d=E.useMemo(()=>{const f=new Map;return Array.from(i.keys()).sort(sU).forEach((m,g)=>{f.set(m,g)}),f},[i]);return S.jsx(RT.Provider,{value:E.useMemo(()=>({register:l,unregister:c,map:d,elementsRef:n,labelsRef:r}),[l,c,d,n,r]),children:e})}function aU(t){t===void 0&&(t={});const{label:e}=t,{register:n,unregister:r,map:i,elementsRef:o,labelsRef:l}=E.useContext(RT),[c,d]=E.useState(null),f=E.useRef(null),h=E.useCallback(m=>{if(f.current=m,c!==null&&(o.current[c]=m,l)){var g;const y=e!==void 0;l.current[c]=y?e:(g=m?.textContent)!=null?g:null}},[c,o,l,e]);return ft(()=>{const m=f.current;if(m)return n(m),()=>{r(m)}},[n,r]),ft(()=>{const m=f.current?i.get(f.current):null;m!=null&&d(m)},[i]),E.useMemo(()=>({ref:h,index:c??-1}),[c,h])}const cU="data-floating-ui-focusable",V5="active",U5="selected",Vu="ArrowLeft",Uu="ArrowRight",OT="ArrowUp",Wp="ArrowDown",uU={...n9};let P5=!1,dU=0;const F5=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+dU++;function fU(){const[t,e]=E.useState(()=>P5?F5():void 0);return ft(()=>{t==null&&e(F5())},[]),E.useEffect(()=>{P5=!0},[]),t}const hU=uU.useId,j3=hU||fU;function pU(){const t=new Map;return{emit(e,n){var r;(r=t.get(e))==null||r.forEach(i=>i(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var r;(r=t.get(e))==null||r.delete(n)}}}const mU=E.createContext(null),gU=E.createContext(null),Jp=()=>{var t;return((t=E.useContext(mU))==null?void 0:t.id)||null},Pu=()=>E.useContext(gU);function Js(t){return"data-floating-ui-"+t}function On(t){t.current!==-1&&(clearTimeout(t.current),t.current=-1)}const $5=Js("safe-polygon");function D0(t,e,n){if(n&&!vu(n))return 0;if(typeof t=="number")return t;if(typeof t=="function"){const r=t();return typeof r=="number"?r:r?.[e]}return t?.[e]}function L0(t){return typeof t=="function"?t():t}function yU(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,dataRef:i,events:o,elements:l}=t,{enabled:c=!0,delay:d=0,handleClose:f=null,mouseOnly:h=!1,restMs:m=0,move:g=!0}=e,y=Pu(),C=Jp(),w=Zn(f),x=Zn(d),k=Zn(n),A=Zn(m),N=E.useRef(),R=E.useRef(-1),L=E.useRef(),z=E.useRef(-1),_=E.useRef(!0),$=E.useRef(!1),J=E.useRef(()=>{}),U=E.useRef(!1),ne=Ht(()=>{var j;const B=(j=i.current.openEvent)==null?void 0:j.type;return B?.includes("mouse")&&B!=="mousedown"});E.useEffect(()=>{if(!c)return;function j(B){let{open:re}=B;re||(On(R),On(z),_.current=!0,U.current=!1)}return o.on("openchange",j),()=>{o.off("openchange",j)}},[c,o]),E.useEffect(()=>{if(!c||!w.current||!n)return;function j(re){ne()&&r(!1,re,"hover")}const B=gn(l.floating).documentElement;return B.addEventListener("mouseleave",j),()=>{B.removeEventListener("mouseleave",j)}},[l.floating,n,r,c,w,ne]);const se=E.useCallback(function(j,B,re){B===void 0&&(B=!0),re===void 0&&(re="hover");const ae=D0(x.current,"close",N.current);ae&&!L.current?(On(R),R.current=window.setTimeout(()=>r(!1,j,re),ae)):B&&(On(R),r(!1,j,re))},[x,r]),oe=Ht(()=>{J.current(),L.current=void 0}),G=Ht(()=>{if($.current){const j=gn(l.floating).body;j.style.pointerEvents="",j.removeAttribute($5),$.current=!1}}),P=Ht(()=>i.current.openEvent?["click","mousedown"].includes(i.current.openEvent.type):!1);E.useEffect(()=>{if(!c)return;function j(Z){if(On(R),_.current=!1,h&&!vu(N.current)||L0(A.current)>0&&!D0(x.current,"open"))return;const W=D0(x.current,"open",N.current);W?R.current=window.setTimeout(()=>{k.current||r(!0,Z,"hover")},W):n||r(!0,Z,"hover")}function B(Z){if(P()){G();return}J.current();const W=gn(l.floating);if(On(z),U.current=!1,w.current&&i.current.floatingContext){n||On(R),L.current=w.current({...i.current.floatingContext,tree:y,x:Z.clientX,y:Z.clientY,onClose(){G(),oe(),P()||se(Z,!0,"safe-polygon")}});const de=L.current;W.addEventListener("mousemove",de),J.current=()=>{W.removeEventListener("mousemove",de)};return}(N.current!=="touch"||!fn(l.floating,Z.relatedTarget))&&se(Z)}function re(Z){P()||i.current.floatingContext&&(w.current==null||w.current({...i.current.floatingContext,tree:y,x:Z.clientX,y:Z.clientY,onClose(){G(),oe(),P()||se(Z)}})(Z))}function ae(){On(R)}function D(Z){P()||se(Z,!1)}if(yt(l.domReference)){const Z=l.domReference,W=l.floating;return n&&Z.addEventListener("mouseleave",re),g&&Z.addEventListener("mousemove",j,{once:!0}),Z.addEventListener("mouseenter",j),Z.addEventListener("mouseleave",B),W&&(W.addEventListener("mouseleave",re),W.addEventListener("mouseenter",ae),W.addEventListener("mouseleave",D)),()=>{n&&Z.removeEventListener("mouseleave",re),g&&Z.removeEventListener("mousemove",j),Z.removeEventListener("mouseenter",j),Z.removeEventListener("mouseleave",B),W&&(W.removeEventListener("mouseleave",re),W.removeEventListener("mouseenter",ae),W.removeEventListener("mouseleave",D))}}},[l,c,t,h,g,se,oe,G,r,n,k,y,x,w,i,P,A]),ft(()=>{var j;if(c&&n&&(j=w.current)!=null&&(j=j.__options)!=null&&j.blockPointerEvents&&ne()){$.current=!0;const re=l.floating;if(yt(l.domReference)&&re){var B;const ae=gn(l.floating).body;ae.setAttribute($5,"");const D=l.domReference,Z=y==null||(B=y.nodesRef.current.find(W=>W.id===C))==null||(B=B.context)==null?void 0:B.elements.floating;return Z&&(Z.style.pointerEvents=""),ae.style.pointerEvents="none",D.style.pointerEvents="auto",re.style.pointerEvents="auto",()=>{ae.style.pointerEvents="",D.style.pointerEvents="",re.style.pointerEvents=""}}}},[c,n,C,l,y,w,ne]),ft(()=>{n||(N.current=void 0,U.current=!1,oe(),G())},[n,oe,G]),E.useEffect(()=>()=>{oe(),On(R),On(z),G()},[c,l.domReference,oe,G]);const H=E.useMemo(()=>{function j(B){N.current=B.pointerType}return{onPointerDown:j,onPointerEnter:j,onMouseMove(B){const{nativeEvent:re}=B;function ae(){!_.current&&!k.current&&r(!0,re,"hover")}h&&!vu(N.current)||n||L0(A.current)===0||U.current&&B.movementX**2+B.movementY**2<2||(On(z),N.current==="touch"?ae():(U.current=!0,z.current=window.setTimeout(ae,L0(A.current))))}}},[h,r,n,k,A]);return E.useMemo(()=>c?{reference:H}:{},[c,H])}const q5=()=>{},vU=E.createContext({delay:0,initialDelay:0,timeoutMs:0,currentId:null,setCurrentId:q5,setState:q5,isInstantPhase:!1});function bU(t){const{children:e,delay:n,timeoutMs:r=0}=t,[i,o]=E.useReducer((d,f)=>({...d,...f}),{delay:n,timeoutMs:r,initialDelay:n,currentId:null,isInstantPhase:!1}),l=E.useRef(null),c=E.useCallback(d=>{o({currentId:d})},[]);return ft(()=>{i.currentId?l.current===null?l.current=i.currentId:i.isInstantPhase||o({isInstantPhase:!0}):(i.isInstantPhase&&o({isInstantPhase:!1}),l.current=null)},[i.currentId,i.isInstantPhase]),S.jsx(vU.Provider,{value:E.useMemo(()=>({...i,setState:o,setCurrentId:c}),[i,c]),children:e})}let Z5=0;function Rs(t,e){e===void 0&&(e={});const{preventScroll:n=!1,cancelPrevious:r=!0,sync:i=!1}=e;r&&cancelAnimationFrame(Z5);const o=()=>t?.focus({preventScroll:n});i?o():Z5=requestAnimationFrame(o)}function CU(t){return t?.ownerDocument||document}const aa={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function K5(t){return t==="inert"?aa.inert:t==="aria-hidden"?aa["aria-hidden"]:aa.none}let Rf=new WeakSet,Of={},_0=0;const wU=()=>typeof HTMLElement<"u"&&"inert"in HTMLElement.prototype,DT=t=>t&&(t.host||DT(t.parentNode)),xU=(t,e)=>e.map(n=>{if(t.contains(n))return n;const r=DT(n);return t.contains(r)?r:null}).filter(n=>n!=null);function SU(t,e,n,r){const i="data-floating-ui-inert",o=r?"inert":n?"aria-hidden":null,l=xU(e,t),c=new Set,d=new Set(l),f=[];Of[i]||(Of[i]=new WeakMap);const h=Of[i];l.forEach(m),g(e),c.clear();function m(y){!y||c.has(y)||(c.add(y),y.parentNode&&m(y.parentNode))}function g(y){!y||d.has(y)||[].forEach.call(y.children,C=>{if(ss(C)!=="script")if(c.has(C))g(C);else{const w=o?C.getAttribute(o):null,x=w!==null&&w!=="false",k=K5(o),A=(k.get(C)||0)+1,N=(h.get(C)||0)+1;k.set(C,A),h.set(C,N),f.push(C),A===1&&x&&Rf.add(C),N===1&&C.setAttribute(i,""),!x&&o&&C.setAttribute(o,o==="inert"?"":"true")}})}return _0++,()=>{f.forEach(y=>{const C=K5(o),x=(C.get(y)||0)-1,k=(h.get(y)||0)-1;C.set(y,x),h.set(y,k),x||(!Rf.has(y)&&o&&y.removeAttribute(o),Rf.delete(y)),k||y.removeAttribute(i)}),_0--,_0||(aa.inert=new WeakMap,aa["aria-hidden"]=new WeakMap,aa.none=new WeakMap,Rf=new WeakSet,Of={})}}function G5(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);const r=CU(t[0]).body;return SU(t.concat(Array.from(r.querySelectorAll('[aria-live],[role="status"],output'))),r,e,n)}const Xp={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},ep=E.forwardRef(function(e,n){const[r,i]=E.useState();ft(()=>{cT()&&i("button")},[]);const o={ref:n,tabIndex:0,role:r,"aria-hidden":r?void 0:!0,[Js("focus-guard")]:"",style:Xp};return S.jsx("span",{...e,...o})}),LT=E.createContext(null),Y5=Js("portal");function TU(t){t===void 0&&(t={});const{id:e,root:n}=t,r=j3(),i=_T(),[o,l]=E.useState(null),c=E.useRef(null);return ft(()=>()=>{o?.remove(),queueMicrotask(()=>{c.current=null})},[o]),ft(()=>{if(!r||c.current)return;const d=e?document.getElementById(e):null;if(!d)return;const f=document.createElement("div");f.id=r,f.setAttribute(Y5,""),d.appendChild(f),c.current=f,l(f)},[e,r]),ft(()=>{if(n===null||!r||c.current)return;let d=n||i?.portalNode;d&&!A3(d)&&(d=d.current),d=d||document.body;let f=null;e&&(f=document.createElement("div"),f.id=e,d.appendChild(f));const h=document.createElement("div");h.id=r,h.setAttribute(Y5,""),d=f||d,d.appendChild(h),c.current=h,l(h)},[e,n,r,i]),o}function Qp(t){const{children:e,id:n,root:r,preserveTabOrder:i=!0}=t,o=TU({id:n,root:r}),[l,c]=E.useState(null),d=E.useRef(null),f=E.useRef(null),h=E.useRef(null),m=E.useRef(null),g=l?.modal,y=l?.open,C=!!l&&!l.modal&&l.open&&i&&!!(r||o);return E.useEffect(()=>{if(!o||!i||g)return;function w(x){o&&nu(x)&&(x.type==="focusin"?D5:kV)(o)}return o.addEventListener("focusin",w,!0),o.addEventListener("focusout",w,!0),()=>{o.removeEventListener("focusin",w,!0),o.removeEventListener("focusout",w,!0)}},[o,i,g]),E.useEffect(()=>{o&&(y||D5(o))},[y,o]),S.jsxs(LT.Provider,{value:E.useMemo(()=>({preserveTabOrder:i,beforeOutsideRef:d,afterOutsideRef:f,beforeInsideRef:h,afterInsideRef:m,portalNode:o,setFocusManagerState:c}),[i,o]),children:[C&&o&&S.jsx(ep,{"data-type":"outside",ref:d,onFocus:w=>{if(nu(w,o)){var x;(x=h.current)==null||x.focus()}else{const k=l?l.domReference:null,A=mT(k);A?.focus()}}}),C&&o&&S.jsx("span",{"aria-owns":o.id,style:Xp}),o&&Oa.createPortal(e,o),C&&o&&S.jsx(ep,{"data-type":"outside",ref:f,onFocus:w=>{if(nu(w,o)){var x;(x=m.current)==null||x.focus()}else{const k=l?l.domReference:null,A=pT(k);A?.focus(),l?.closeOnFocusOut&&l?.onOpenChange(!1,w.nativeEvent,"focus-out")}}})]})}const _T=()=>E.useContext(LT);function W5(t){return E.useMemo(()=>e=>{t.forEach(n=>{n&&(n.current=e)})},t)}const kU=20;let Fo=[];function V3(){Fo=Fo.filter(t=>t.isConnected)}function EU(t){V3(),t&&ss(t)!=="body"&&(Fo.push(t),Fo.length>kU&&(Fo=Fo.slice(-20)))}function J5(){return V3(),Fo[Fo.length-1]}function MU(t){const e=Bu();return sT(t,e)?t:Fp(t,e)[0]||t}function X5(t,e){var n;if(!e.current.includes("floating")&&!((n=t.getAttribute("role"))!=null&&n.includes("dialog")))return;const r=Bu(),o=lV(t,r).filter(c=>{const d=c.getAttribute("data-tabindex")||"";return sT(c,r)||c.hasAttribute("data-tabindex")&&!d.startsWith("-")}),l=t.getAttribute("tabindex");e.current.includes("floating")||o.length===0?l!=="0"&&t.setAttribute("tabindex","0"):(l!=="-1"||t.hasAttribute("data-tabindex")&&t.getAttribute("data-tabindex")!=="-1")&&(t.setAttribute("tabindex","-1"),t.setAttribute("data-tabindex","-1"))}const AU=E.forwardRef(function(e,n){return S.jsx("button",{...e,type:"button",ref:n,tabIndex:-1,style:Xp})});function HT(t){const{context:e,children:n,disabled:r=!1,order:i=["content"],guards:o=!0,initialFocus:l=0,returnFocus:c=!0,restoreFocus:d=!1,modal:f=!0,visuallyHiddenDismiss:h=!1,closeOnFocusOut:m=!0,outsideElementsInert:g=!1,getInsideElements:y=()=>[]}=t,{open:C,onOpenChange:w,events:x,dataRef:k,elements:{domReference:A,floating:N}}=e,R=Ht(()=>{var Me;return(Me=k.current.floatingContext)==null?void 0:Me.nodeId}),L=Ht(y),z=typeof l=="number"&&l<0,_=K2(A)&&z,$=wU(),J=$?o:!0,U=!J||$&&g,ne=Zn(i),se=Zn(l),oe=Zn(c),G=Pu(),P=_T(),H=E.useRef(null),j=E.useRef(null),B=E.useRef(!1),re=E.useRef(!1),ae=E.useRef(-1),D=E.useRef(-1),Z=P!=null,W=Xh(N),le=Ht(function(Me){return Me===void 0&&(Me=W),Me?Fp(Me,Bu()):[]}),de=Ht(Me=>{const He=le(Me);return ne.current.map(Te=>A&&Te==="reference"?A:W&&Te==="floating"?W:He).filter(Boolean).flat()});E.useEffect(()=>{if(r||!f)return;function Me(Te){if(Te.key==="Tab"){fn(W,li(gn(W)))&&le().length===0&&!_&&hn(Te);const nt=de(),ht=Pi(Te);ne.current[0]==="reference"&&ht===A&&(hn(Te),Te.shiftKey?Rs(nt[nt.length-1]):Rs(nt[1])),ne.current[1]==="floating"&&ht===W&&Te.shiftKey&&(hn(Te),Rs(nt[0]))}}const He=gn(W);return He.addEventListener("keydown",Me),()=>{He.removeEventListener("keydown",Me)}},[r,A,W,f,ne,_,le,de]),E.useEffect(()=>{if(r||!N)return;function Me(He){const Te=Pi(He),ht=le().indexOf(Te);ht!==-1&&(ae.current=ht)}return N.addEventListener("focusin",Me),()=>{N.removeEventListener("focusin",Me)}},[r,N,le]),E.useEffect(()=>{if(r||!m)return;function Me(){re.current=!0,setTimeout(()=>{re.current=!1})}function He(ht){const Be=ht.relatedTarget,Gt=ht.currentTarget,Ot=Pi(ht);queueMicrotask(()=>{const zt=R(),Hn=!(fn(A,Be)||fn(N,Be)||fn(Be,N)||fn(P?.portalNode,Be)||Be!=null&&Be.hasAttribute(Js("focus-guard"))||G&&(Us(G.nodesRef.current,zt).find(ve=>{var Re,fe;return fn((Re=ve.context)==null?void 0:Re.elements.floating,Be)||fn((fe=ve.context)==null?void 0:fe.elements.domReference,Be)})||R5(G.nodesRef.current,zt).find(ve=>{var Re,fe,We;return[(Re=ve.context)==null?void 0:Re.elements.floating,Xh((fe=ve.context)==null?void 0:fe.elements.floating)].includes(Be)||((We=ve.context)==null?void 0:We.elements.domReference)===Be})));if(Gt===A&&W&&X5(W,ne),d&&Gt!==A&&!(Ot!=null&&Ot.isConnected)&&li(gn(W))===gn(W).body){_t(W)&&W.focus();const ve=ae.current,Re=le(),fe=Re[ve]||Re[Re.length-1]||W;_t(fe)&&fe.focus()}if(k.current.insideReactTree){k.current.insideReactTree=!1;return}(_||!f)&&Be&&Hn&&!re.current&&Be!==J5()&&(B.current=!0,w(!1,ht,"focus-out"))})}const Te=!!(!G&&P);function nt(){On(D),k.current.insideReactTree=!0,D.current=window.setTimeout(()=>{k.current.insideReactTree=!1})}if(N&&_t(A))return A.addEventListener("focusout",He),A.addEventListener("pointerdown",Me),N.addEventListener("focusout",He),Te&&N.addEventListener("focusout",nt,!0),()=>{A.removeEventListener("focusout",He),A.removeEventListener("pointerdown",Me),N.removeEventListener("focusout",He),Te&&N.removeEventListener("focusout",nt,!0)}},[r,A,N,W,f,G,P,w,m,d,le,_,R,ne,k]);const ye=E.useRef(null),Ee=E.useRef(null),Rt=W5([ye,P?.beforeInsideRef]),tt=W5([Ee,P?.afterInsideRef]);E.useEffect(()=>{var Me,He;if(r||!N)return;const Te=Array.from((P==null||(Me=P.portalNode)==null?void 0:Me.querySelectorAll("["+Js("portal")+"]"))||[]),ht=(He=(G?R5(G.nodesRef.current,R()):[]).find(Ot=>{var zt;return K2(((zt=Ot.context)==null?void 0:zt.elements.domReference)||null)}))==null||(He=He.context)==null?void 0:He.elements.domReference,Be=[N,ht,...Te,...L(),H.current,j.current,ye.current,Ee.current,P?.beforeOutsideRef.current,P?.afterOutsideRef.current,ne.current.includes("reference")||_?A:null].filter(Ot=>Ot!=null),Gt=f||_?G5(Be,!U,U):G5(Be);return()=>{Gt()}},[r,A,N,f,ne,P,_,J,U,G,R,L]),ft(()=>{if(r||!_t(W))return;const Me=gn(W),He=li(Me);queueMicrotask(()=>{const Te=de(W),nt=se.current,ht=(typeof nt=="number"?Te[nt]:nt.current)||W,Be=fn(W,He);!z&&!Be&&C&&Rs(ht,{preventScroll:ht===W})})},[r,C,W,z,de,se]),ft(()=>{if(r||!W)return;const Me=gn(W),He=li(Me);EU(He);function Te(Be){let{reason:Gt,event:Ot,nested:zt}=Be;if(["hover","safe-polygon"].includes(Gt)&&Ot.type==="mouseleave"&&(B.current=!0),Gt==="outside-press")if(zt)B.current=!1;else if(dT(Ot)||fT(Ot))B.current=!1;else{let Hn=!1;document.createElement("div").focus({get preventScroll(){return Hn=!0,!1}}),Hn?B.current=!1:B.current=!0}}x.on("openchange",Te);const nt=Me.createElement("span");nt.setAttribute("tabindex","-1"),nt.setAttribute("aria-hidden","true"),Object.assign(nt.style,Xp),Z&&A&&A.insertAdjacentElement("afterend",nt);function ht(){if(typeof oe.current=="boolean"){const Be=A||J5();return Be&&Be.isConnected?Be:nt}return oe.current.current||nt}return()=>{x.off("openchange",Te);const Be=li(Me),Gt=fn(N,Be)||G&&Us(G.nodesRef.current,R(),!1).some(zt=>{var Hn;return fn((Hn=zt.context)==null?void 0:Hn.elements.floating,Be)}),Ot=ht();queueMicrotask(()=>{const zt=MU(Ot);oe.current&&!B.current&&_t(zt)&&(!(zt!==Be&&Be!==Me.body)||Gt)&&zt.focus({preventScroll:!0}),nt.remove()})}},[r,N,W,oe,k,x,G,Z,A,R]),E.useEffect(()=>(queueMicrotask(()=>{B.current=!1}),()=>{queueMicrotask(V3)}),[r]),ft(()=>{if(!r&&P)return P.setFocusManagerState({modal:f,closeOnFocusOut:m,open:C,onOpenChange:w,domReference:A}),()=>{P.setFocusManagerState(null)}},[r,P,f,C,w,m,A]),ft(()=>{r||W&&X5(W,ne)},[r,W,ne]);function Nn(Me){return r||!h||!f?null:S.jsx(AU,{ref:Me==="start"?H:j,onClick:He=>w(!1,He.nativeEvent),children:typeof h=="string"?h:"Dismiss"})}const Or=!r&&J&&(f?!_:!0)&&(Z||f);return S.jsxs(S.Fragment,{children:[Or&&S.jsx(ep,{"data-type":"inside",ref:Rt,onFocus:Me=>{if(f){const Te=de();Rs(i[0]==="reference"?Te[0]:Te[Te.length-1])}else if(P!=null&&P.preserveTabOrder&&P.portalNode)if(B.current=!1,nu(Me,P.portalNode)){const Te=pT(A);Te?.focus()}else{var He;(He=P.beforeOutsideRef.current)==null||He.focus()}}}),!_&&Nn("start"),n,Nn("end"),Or&&S.jsx(ep,{"data-type":"inside",ref:tt,onFocus:Me=>{if(f)Rs(de()[0]);else if(P!=null&&P.preserveTabOrder&&P.portalNode)if(m&&(B.current=!0),nu(Me,P.portalNode)){const Te=mT(A);Te?.focus()}else{var He;(He=P.afterOutsideRef.current)==null||He.focus()}}})]})}function Q5(t){return _t(t.target)&&t.target.tagName==="BUTTON"}function NU(t){return _t(t.target)&&t.target.tagName==="A"}function e6(t){return _3(t)}function IT(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,dataRef:i,elements:{domReference:o}}=t,{enabled:l=!0,event:c="click",toggle:d=!0,ignoreMouse:f=!1,keyboardHandlers:h=!0,stickIfOpen:m=!0}=e,g=E.useRef(),y=E.useRef(!1),C=E.useMemo(()=>({onPointerDown(w){g.current=w.pointerType},onMouseDown(w){const x=g.current;w.button===0&&c!=="click"&&(vu(x,!0)&&f||(n&&d&&(!(i.current.openEvent&&m)||i.current.openEvent.type==="mousedown")?r(!1,w.nativeEvent,"click"):(w.preventDefault(),r(!0,w.nativeEvent,"click"))))},onClick(w){const x=g.current;if(c==="mousedown"&&g.current){g.current=void 0;return}vu(x,!0)&&f||(n&&d&&(!(i.current.openEvent&&m)||i.current.openEvent.type==="click")?r(!1,w.nativeEvent,"click"):r(!0,w.nativeEvent,"click"))},onKeyDown(w){g.current=void 0,!(w.defaultPrevented||!h||Q5(w))&&(w.key===" "&&!e6(o)&&(w.preventDefault(),y.current=!0),!NU(w)&&w.key==="Enter"&&r(!(n&&d),w.nativeEvent,"click"))},onKeyUp(w){w.defaultPrevented||!h||Q5(w)||e6(o)||w.key===" "&&y.current&&(y.current=!1,r(!(n&&d),w.nativeEvent,"click"))}}),[i,o,c,f,h,r,n,m,d]);return E.useMemo(()=>l?{reference:C}:{},[l,C])}const RU={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},OU={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},t6=t=>{var e,n;return{escapeKey:typeof t=="boolean"?t:(e=t?.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(n=t?.outsidePress)!=null?n:!0}};function U3(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,elements:i,dataRef:o}=t,{enabled:l=!0,escapeKey:c=!0,outsidePress:d=!0,outsidePressEvent:f="pointerdown",referencePress:h=!1,referencePressEvent:m="pointerdown",ancestorScroll:g=!1,bubbles:y,capture:C}=e,w=Pu(),x=Ht(typeof d=="function"?d:()=>!1),k=typeof d=="function"?x:d,A=E.useRef(!1),{escapeKey:N,outsidePress:R}=t6(y),{escapeKey:L,outsidePress:z}=t6(C),_=E.useRef(!1),$=Ht(G=>{var P;if(!n||!l||!c||G.key!=="Escape"||_.current)return;const H=(P=o.current.floatingContext)==null?void 0:P.nodeId,j=w?Us(w.nodesRef.current,H):[];if(!N&&(G.stopPropagation(),j.length>0)){let B=!0;if(j.forEach(re=>{var ae;if((ae=re.context)!=null&&ae.open&&!re.context.dataRef.current.__escapeKeyBubbles){B=!1;return}}),!B)return}r(!1,mV(G)?G.nativeEvent:G,"escape-key")}),J=Ht(G=>{var P;const H=()=>{var j;$(G),(j=Pi(G))==null||j.removeEventListener("keydown",H)};(P=Pi(G))==null||P.addEventListener("keydown",H)}),U=Ht(G=>{var P;const H=o.current.insideReactTree;o.current.insideReactTree=!1;const j=A.current;if(A.current=!1,f==="click"&&j||H||typeof k=="function"&&!k(G))return;const B=Pi(G),re="["+Js("inert")+"]",ae=gn(i.floating).querySelectorAll(re);let D=yt(B)?B:null;for(;D&&!Ki(D);){const de=Wi(D);if(Ki(de)||!yt(de))break;D=de}if(ae.length&&yt(B)&&!fV(B)&&!fn(B,i.floating)&&Array.from(ae).every(de=>!fn(D,de)))return;if(_t(B)&&oe){const de=Ki(B),ye=Rr(B),Ee=/auto|scroll/,Rt=de||Ee.test(ye.overflowX),tt=de||Ee.test(ye.overflowY),Nn=Rt&&B.clientWidth>0&&B.scrollWidth>B.clientWidth,Or=tt&&B.clientHeight>0&&B.scrollHeight>B.clientHeight,Me=ye.direction==="rtl",He=Or&&(Me?G.offsetX<=B.offsetWidth-B.clientWidth:G.offsetX>B.clientWidth),Te=Nn&&G.offsetY>B.clientHeight;if(He||Te)return}const Z=(P=o.current.floatingContext)==null?void 0:P.nodeId,W=w&&Us(w.nodesRef.current,Z).some(de=>{var ye;return A0(G,(ye=de.context)==null?void 0:ye.elements.floating)});if(A0(G,i.floating)||A0(G,i.domReference)||W)return;const le=w?Us(w.nodesRef.current,Z):[];if(le.length>0){let de=!0;if(le.forEach(ye=>{var Ee;if((Ee=ye.context)!=null&&Ee.open&&!ye.context.dataRef.current.__outsidePressBubbles){de=!1;return}}),!de)return}r(!1,G,"outside-press")}),ne=Ht(G=>{var P;const H=()=>{var j;U(G),(j=Pi(G))==null||j.removeEventListener(f,H)};(P=Pi(G))==null||P.addEventListener(f,H)});E.useEffect(()=>{if(!n||!l)return;o.current.__escapeKeyBubbles=N,o.current.__outsidePressBubbles=R;let G=-1;function P(ae){r(!1,ae,"ancestor-scroll")}function H(){window.clearTimeout(G),_.current=!0}function j(){G=window.setTimeout(()=>{_.current=!1},Up()?5:0)}const B=gn(i.floating);c&&(B.addEventListener("keydown",L?J:$,L),B.addEventListener("compositionstart",H),B.addEventListener("compositionend",j)),k&&B.addEventListener(f,z?ne:U,z);let re=[];return g&&(yt(i.domReference)&&(re=Yo(i.domReference)),yt(i.floating)&&(re=re.concat(Yo(i.floating))),!yt(i.reference)&&i.reference&&i.reference.contextElement&&(re=re.concat(Yo(i.reference.contextElement)))),re=re.filter(ae=>{var D;return ae!==((D=B.defaultView)==null?void 0:D.visualViewport)}),re.forEach(ae=>{ae.addEventListener("scroll",P,{passive:!0})}),()=>{c&&(B.removeEventListener("keydown",L?J:$,L),B.removeEventListener("compositionstart",H),B.removeEventListener("compositionend",j)),k&&B.removeEventListener(f,z?ne:U,z),re.forEach(ae=>{ae.removeEventListener("scroll",P)}),window.clearTimeout(G)}},[o,i,c,k,f,n,r,g,l,N,R,$,L,J,U,z,ne]),E.useEffect(()=>{o.current.insideReactTree=!1},[o,k,f]);const se=E.useMemo(()=>({onKeyDown:$,...h&&{[RU[m]]:G=>{r(!1,G.nativeEvent,"reference-press")},...m!=="click"&&{onClick(G){r(!1,G.nativeEvent,"reference-press")}}}}),[$,r,h,m]),oe=E.useMemo(()=>({onKeyDown:$,onMouseDown(){A.current=!0},onMouseUp(){A.current=!0},[OU[f]]:()=>{o.current.insideReactTree=!0}}),[$,f,o]);return E.useMemo(()=>l?{reference:se,floating:oe}:{},[l,se,oe])}function DU(t){const{open:e=!1,onOpenChange:n,elements:r}=t,i=j3(),o=E.useRef({}),[l]=E.useState(()=>pU()),c=Jp()!=null,[d,f]=E.useState(r.reference),h=Ht((y,C,w)=>{o.current.openEvent=y?C:void 0,l.emit("openchange",{open:y,event:C,reason:w,nested:c}),n?.(y,C,w)}),m=E.useMemo(()=>({setPositionReference:f}),[]),g=E.useMemo(()=>({reference:d||r.reference||null,floating:r.floating||null,domReference:r.reference}),[d,r.reference,r.floating]);return E.useMemo(()=>({dataRef:o,open:e,onOpenChange:h,elements:g,events:l,floatingId:i,refs:m}),[e,h,g,l,i,m])}function e1(t){t===void 0&&(t={});const{nodeId:e}=t,n=DU({...t,elements:{reference:null,floating:null,...t.elements}}),r=t.rootContext||n,i=r.elements,[o,l]=E.useState(null),[c,d]=E.useState(null),h=i?.domReference||o,m=E.useRef(null),g=Pu();ft(()=>{h&&(m.current=h)},[h]);const y=iU({...t,elements:{...i,...c&&{reference:c}}}),C=E.useCallback(N=>{const R=yt(N)?{getBoundingClientRect:()=>N.getBoundingClientRect(),getClientRects:()=>N.getClientRects(),contextElement:N}:N;d(R),y.refs.setReference(R)},[y.refs]),w=E.useCallback(N=>{(yt(N)||N===null)&&(m.current=N,l(N)),(yt(y.refs.reference.current)||y.refs.reference.current===null||N!==null&&!yt(N))&&y.refs.setReference(N)},[y.refs]),x=E.useMemo(()=>({...y.refs,setReference:w,setPositionReference:C,domReference:m}),[y.refs,w,C]),k=E.useMemo(()=>({...y.elements,domReference:h}),[y.elements,h]),A=E.useMemo(()=>({...y,...r,refs:x,elements:k,nodeId:e}),[y,x,k,e,r]);return ft(()=>{r.dataRef.current.floatingContext=A;const N=g?.nodesRef.current.find(R=>R.id===e);N&&(N.context=A)}),E.useMemo(()=>({...y,context:A,refs:x,elements:k}),[y,x,k,A])}function H0(){return aV()&&cT()}function LU(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,events:i,dataRef:o,elements:l}=t,{enabled:c=!0,visibleOnly:d=!0}=e,f=E.useRef(!1),h=E.useRef(-1),m=E.useRef(!0);E.useEffect(()=>{if(!c)return;const y=Jn(l.domReference);function C(){!n&&_t(l.domReference)&&l.domReference===li(gn(l.domReference))&&(f.current=!0)}function w(){m.current=!0}function x(){m.current=!1}return y.addEventListener("blur",C),H0()&&(y.addEventListener("keydown",w,!0),y.addEventListener("pointerdown",x,!0)),()=>{y.removeEventListener("blur",C),H0()&&(y.removeEventListener("keydown",w,!0),y.removeEventListener("pointerdown",x,!0))}},[l.domReference,n,c]),E.useEffect(()=>{if(!c)return;function y(C){let{reason:w}=C;(w==="reference-press"||w==="escape-key")&&(f.current=!0)}return i.on("openchange",y),()=>{i.off("openchange",y)}},[i,c]),E.useEffect(()=>()=>{On(h)},[]);const g=E.useMemo(()=>({onMouseLeave(){f.current=!1},onFocus(y){if(f.current)return;const C=Pi(y.nativeEvent);if(d&&yt(C)){if(H0()&&!y.relatedTarget){if(!m.current&&!_3(C))return}else if(!hV(C))return}r(!0,y.nativeEvent,"focus")},onBlur(y){f.current=!1;const C=y.relatedTarget,w=y.nativeEvent,x=yt(C)&&C.hasAttribute(Js("focus-guard"))&&C.getAttribute("data-type")==="outside";h.current=window.setTimeout(()=>{var k;const A=li(l.domReference?l.domReference.ownerDocument:document);!C&&A===l.domReference||fn((k=o.current.floatingContext)==null?void 0:k.refs.floating.current,A)||fn(l.domReference,A)||x||r(!1,w,"focus")})}}),[o,l.domReference,r,d]);return E.useMemo(()=>c?{reference:g}:{},[c,g])}function I0(t,e,n){const r=new Map,i=n==="item";let o=t;if(i&&t){const{[V5]:l,[U5]:c,...d}=t;o=d}return{...n==="floating"&&{tabIndex:-1,[cU]:""},...o,...e.map(l=>{const c=l?l[n]:null;return typeof c=="function"?t?c(t):null:c}).concat(t).reduce((l,c)=>(c&&Object.entries(c).forEach(d=>{let[f,h]=d;if(!(i&&[V5,U5].includes(f)))if(f.indexOf("on")===0){if(r.has(f)||r.set(f,[]),typeof h=="function"){var m;(m=r.get(f))==null||m.push(h),l[f]=function(){for(var g,y=arguments.length,C=new Array(y),w=0;wx(...C)).find(x=>x!==void 0)}}}else l[f]=h}),l),{})}}function t1(t){t===void 0&&(t=[]);const e=t.map(c=>c?.reference),n=t.map(c=>c?.floating),r=t.map(c=>c?.item),i=E.useCallback(c=>I0(c,t,"reference"),e),o=E.useCallback(c=>I0(c,t,"floating"),n),l=E.useCallback(c=>I0(c,t,"item"),r);return E.useMemo(()=>({getReferenceProps:i,getFloatingProps:o,getItemProps:l}),[i,o,l])}const _U="Escape";function n1(t,e,n){switch(t){case"vertical":return e;case"horizontal":return n;default:return e||n}}function Df(t,e){return n1(e,t===OT||t===Wp,t===Vu||t===Uu)}function z0(t,e,n){return n1(e,t===Wp,n?t===Vu:t===Uu)||t==="Enter"||t===" "||t===""}function n6(t,e,n){return n1(e,n?t===Vu:t===Uu,t===Wp)}function r6(t,e,n,r){const i=n?t===Uu:t===Vu,o=t===OT;return e==="both"||e==="horizontal"&&r&&r>1?t===_U:n1(e,i,o)}function HU(t,e){const{open:n,onOpenChange:r,elements:i,floatingId:o}=t,{listRef:l,activeIndex:c,onNavigate:d=()=>{},enabled:f=!0,selectedIndex:h=null,allowEscape:m=!1,loop:g=!1,nested:y=!1,rtl:C=!1,virtual:w=!1,focusItemOnOpen:x="auto",focusItemOnHover:k=!0,openOnArrowKeyDown:A=!0,disabledIndices:N=void 0,orientation:R="vertical",parentOrientation:L,cols:z=1,scrollItemIntoView:_=!0,virtualItemRef:$,itemSizes:J,dense:U=!1}=e,ne=Xh(i.floating),se=Zn(ne),oe=Jp(),G=Pu();ft(()=>{t.dataRef.current.orientation=R},[t,R]);const P=Ht(()=>{d(B.current===-1?null:B.current)}),H=K2(i.domReference),j=E.useRef(x),B=E.useRef(h??-1),re=E.useRef(null),ae=E.useRef(!0),D=E.useRef(P),Z=E.useRef(!!i.floating),W=E.useRef(n),le=E.useRef(!1),de=E.useRef(!1),ye=Zn(N),Ee=Zn(n),Rt=Zn(_),tt=Zn(h),[Nn,Or]=E.useState(),[Me,He]=E.useState(),Te=Ht(()=>{function ve(lt){if(w){var wt;(wt=lt.id)!=null&&wt.endsWith("-fui-option")&&(lt.id=o+"-"+Math.random().toString(16).slice(2,10)),Or(lt.id),G?.events.emit("virtualfocus",lt),$&&($.current=lt)}else Rs(lt,{sync:le.current,preventScroll:!0})}const Re=l.current[B.current],fe=de.current;Re&&ve(Re),(le.current?lt=>lt():requestAnimationFrame)(()=>{const lt=l.current[B.current]||Re;if(!lt)return;Re||ve(lt);const wt=Rt.current;wt&&ht&&(fe||!ae.current)&&(lt.scrollIntoView==null||lt.scrollIntoView(typeof wt=="boolean"?{block:"nearest",inline:"nearest"}:wt))})});ft(()=>{f&&(n&&i.floating?j.current&&h!=null&&(de.current=!0,B.current=h,P()):Z.current&&(B.current=-1,D.current()))},[f,n,i.floating,h,P]),ft(()=>{if(f&&n&&i.floating)if(c==null){if(le.current=!1,tt.current!=null)return;if(Z.current&&(B.current=-1,Te()),(!W.current||!Z.current)&&j.current&&(re.current!=null||j.current===!0&&re.current==null)){let ve=0;const Re=()=>{l.current[0]==null?(ve<2&&(ve?requestAnimationFrame:queueMicrotask)(Re),ve++):(B.current=re.current==null||z0(re.current,R,C)||y?N0(l,ye.current):O5(l,ye.current),re.current=null,P())};Re()}}else tu(l,c)||(B.current=c,Te(),de.current=!1)},[f,n,i.floating,c,tt,y,l,R,C,P,Te,ye]),ft(()=>{var ve;if(!f||i.floating||!G||w||!Z.current)return;const Re=G.nodesRef.current,fe=(ve=Re.find(wt=>wt.id===oe))==null||(ve=ve.context)==null?void 0:ve.elements.floating,We=li(gn(i.floating)),lt=Re.some(wt=>wt.context&&fn(wt.context.elements.floating,We));fe&&!lt&&ae.current&&fe.focus({preventScroll:!0})},[f,i.floating,G,oe,w]),ft(()=>{if(!f||!G||!w||oe)return;function ve(Re){He(Re.id),$&&($.current=Re)}return G.events.on("virtualfocus",ve),()=>{G.events.off("virtualfocus",ve)}},[f,G,w,oe,$]),ft(()=>{D.current=P,W.current=n,Z.current=!!i.floating}),ft(()=>{n||(re.current=null,j.current=x)},[n,x]);const nt=c!=null,ht=E.useMemo(()=>{function ve(fe){if(!Ee.current)return;const We=l.current.indexOf(fe);We!==-1&&B.current!==We&&(B.current=We,P())}return{onFocus(fe){let{currentTarget:We}=fe;le.current=!0,ve(We)},onClick:fe=>{let{currentTarget:We}=fe;return We.focus({preventScroll:!0})},onMouseMove(fe){let{currentTarget:We}=fe;le.current=!0,de.current=!1,k&&ve(We)},onPointerLeave(fe){let{pointerType:We}=fe;if(!(!ae.current||We==="touch")&&(le.current=!0,!!k&&(B.current=-1,P(),!w))){var lt;(lt=se.current)==null||lt.focus({preventScroll:!0})}}}},[Ee,se,k,l,P,w]),Be=E.useCallback(()=>{var ve;return L??(G==null||(ve=G.nodesRef.current.find(Re=>Re.id===oe))==null||(ve=ve.context)==null||(ve=ve.dataRef)==null?void 0:ve.current.orientation)},[oe,G,L]),Gt=Ht(ve=>{if(ae.current=!1,le.current=!0,ve.which===229||!Ee.current&&ve.currentTarget===se.current)return;if(y&&r6(ve.key,R,C,z)){Df(ve.key,Be())||hn(ve),r(!1,ve.nativeEvent,"list-navigation"),_t(i.domReference)&&(w?G?.events.emit("virtualfocus",i.domReference):i.domReference.focus());return}const Re=B.current,fe=N0(l,N),We=O5(l,N);if(H||(ve.key==="Home"&&(hn(ve),B.current=fe,P()),ve.key==="End"&&(hn(ve),B.current=We,P())),z>1){const lt=J||Array.from({length:l.current.length},()=>({width:1,height:1})),wt=xV(lt,z,U),Jr=wt.findIndex(In=>In!=null&&!Gf(l,In,N)),al=wt.reduce((In,mi,Xr)=>mi!=null&&!Gf(l,mi,N)?Xr:In,-1),ro=wt[wV({current:wt.map(In=>In!=null?l.current[In]:null)},{event:ve,orientation:R,loop:g,rtl:C,cols:z,disabledIndices:TV([...(typeof N!="function"?N:null)||l.current.map((In,mi)=>Gf(l,mi,N)?mi:void 0),void 0],wt),minIndex:Jr,maxIndex:al,prevIndex:SV(B.current>We?fe:B.current,lt,wt,z,ve.key===Wp?"bl":ve.key===(C?Vu:Uu)?"tr":"tl"),stopEvent:!0})];if(ro!=null&&(B.current=ro,P()),R==="both")return}if(Df(ve.key,R)){if(hn(ve),n&&!w&&li(ve.currentTarget.ownerDocument)===ve.currentTarget){B.current=z0(ve.key,R,C)?fe:We,P();return}z0(ve.key,R,C)?g?B.current=Re>=We?m&&Re!==l.current.length?-1:fe:Cn(l,{startingIndex:Re,disabledIndices:N}):B.current=Math.min(We,Cn(l,{startingIndex:Re,disabledIndices:N})):g?B.current=Re<=fe?m&&Re!==-1?l.current.length:We:Cn(l,{startingIndex:Re,decrement:!0,disabledIndices:N}):B.current=Math.max(fe,Cn(l,{startingIndex:Re,decrement:!0,disabledIndices:N})),tu(l,B.current)&&(B.current=-1),P()}}),Ot=E.useMemo(()=>w&&n&&nt&&{"aria-activedescendant":Me||Nn},[w,n,nt,Me,Nn]),zt=E.useMemo(()=>({"aria-orientation":R==="both"?void 0:R,...H?{}:Ot,onKeyDown:Gt,onPointerMove(){ae.current=!0}}),[Ot,Gt,R,H]),Hn=E.useMemo(()=>{function ve(fe){x==="auto"&&dT(fe.nativeEvent)&&(j.current=!0)}function Re(fe){j.current=x,x==="auto"&&fT(fe.nativeEvent)&&(j.current=!0)}return{...Ot,onKeyDown(fe){ae.current=!1;const We=fe.key.startsWith("Arrow"),lt=["Home","End"].includes(fe.key),wt=We||lt,Jr=n6(fe.key,R,C),al=r6(fe.key,R,C,z),ro=n6(fe.key,Be(),C),In=Df(fe.key,R),mi=(y?ro:In)||fe.key==="Enter"||fe.key.trim()==="";if(w&&n){const Yt=G?.nodesRef.current.find(cl=>cl.parentId==null),Qr=G&&Yt?pV(G.nodesRef.current,Yt.id):null;if(wt&&Qr&&$){const cl=new KeyboardEvent("keydown",{key:fe.key,bubbles:!0});if(Jr||al){var Xr,yn;const E1=((Xr=Qr.context)==null?void 0:Xr.elements.domReference)===fe.currentTarget,ls=al&&!E1?(yn=Qr.context)==null?void 0:yn.elements.domReference:Jr?l.current.find(as=>as?.id===Nn):null;ls&&(hn(fe),ls.dispatchEvent(cl),He(void 0))}if((In||lt)&&Qr.context&&Qr.context.open&&Qr.parentId&&fe.currentTarget!==Qr.context.elements.domReference){var Dr;hn(fe),(Dr=Qr.context.elements.domReference)==null||Dr.dispatchEvent(cl);return}}return Gt(fe)}if(!(!n&&!A&&We)){if(mi){const Yt=Df(fe.key,Be());re.current=y&&Yt?null:fe.key}if(y){ro&&(hn(fe),n?(B.current=N0(l,ye.current),P()):r(!0,fe.nativeEvent,"list-navigation"));return}In&&(h!=null&&(B.current=h),hn(fe),!n&&A?r(!0,fe.nativeEvent,"list-navigation"):Gt(fe),n&&P())}},onFocus(){n&&!w&&(B.current=-1,P())},onPointerDown:Re,onPointerEnter:Re,onMouseDown:ve,onClick:ve}},[Nn,Ot,z,Gt,ye,x,l,y,P,r,n,A,R,Be,C,h,G,w,$]);return E.useMemo(()=>f?{reference:Hn,floating:zt,item:ht}:{},[f,Hn,zt,ht])}const IU=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function P3(t,e){var n,r;e===void 0&&(e={});const{open:i,elements:o,floatingId:l}=t,{enabled:c=!0,role:d="dialog"}=e,f=j3(),h=((n=o.domReference)==null?void 0:n.id)||f,m=E.useMemo(()=>{var A;return((A=Xh(o.floating))==null?void 0:A.id)||l},[o.floating,l]),g=(r=IU.get(d))!=null?r:d,C=Jp()!=null,w=E.useMemo(()=>g==="tooltip"||d==="label"?{["aria-"+(d==="label"?"labelledby":"describedby")]:i?m:void 0}:{"aria-expanded":i?"true":"false","aria-haspopup":g==="alertdialog"?"dialog":g,"aria-controls":i?m:void 0,...g==="listbox"&&{role:"combobox"},...g==="menu"&&{id:h},...g==="menu"&&C&&{role:"menuitem"},...d==="select"&&{"aria-autocomplete":"none"},...d==="combobox"&&{"aria-autocomplete":"list"}},[g,m,C,i,h,d]),x=E.useMemo(()=>{const A={id:m,...g&&{role:g}};return g==="tooltip"||d==="label"?A:{...A,...g==="menu"&&{"aria-labelledby":h}}},[g,m,h,d]),k=E.useCallback(A=>{let{active:N,selected:R}=A;const L={role:"option",...N&&{id:m+"-fui-option"}};switch(d){case"select":case"combobox":return{...L,"aria-selected":R}}return{}},[m,d]);return E.useMemo(()=>c?{reference:w,floating:x,item:k}:{},[c,w,x,k])}function zU(t,e){var n;const{open:r,dataRef:i}=t,{listRef:o,activeIndex:l,onMatch:c,onTypingChange:d,enabled:f=!0,findMatch:h=null,resetMs:m=750,ignoreKeys:g=[],selectedIndex:y=null}=e,C=E.useRef(-1),w=E.useRef(""),x=E.useRef((n=y??l)!=null?n:-1),k=E.useRef(null),A=Ht(c),N=Ht(d),R=Zn(h),L=Zn(g);ft(()=>{r&&(On(C),k.current=null,w.current="")},[r]),ft(()=>{if(r&&w.current===""){var U;x.current=(U=y??l)!=null?U:-1}},[r,y,l]);const z=Ht(U=>{U?i.current.typing||(i.current.typing=U,N(U)):i.current.typing&&(i.current.typing=U,N(U))}),_=Ht(U=>{function ne(H,j,B){const re=R.current?R.current(j,B):j.find(ae=>ae?.toLocaleLowerCase().indexOf(B.toLocaleLowerCase())===0);return re?H.indexOf(re):-1}const se=o.current;if(w.current.length>0&&w.current[0]!==" "&&(ne(se,se,w.current)===-1?z(!1):U.key===" "&&hn(U)),se==null||L.current.includes(U.key)||U.key.length!==1||U.ctrlKey||U.metaKey||U.altKey)return;r&&U.key!==" "&&(hn(U),z(!0)),se.every(H=>{var j,B;return H?((j=H[0])==null?void 0:j.toLocaleLowerCase())!==((B=H[1])==null?void 0:B.toLocaleLowerCase()):!0})&&w.current===U.key&&(w.current="",x.current=k.current),w.current+=U.key,On(C),C.current=window.setTimeout(()=>{w.current="",x.current=k.current,z(!1)},m);const G=x.current,P=ne(se,[...se.slice((G||0)+1),...se.slice(0,(G||0)+1)],w.current);P!==-1?(A(P),k.current=P):U.key!==" "&&(w.current="",z(!1))}),$=E.useMemo(()=>({onKeyDown:_}),[_]),J=E.useMemo(()=>({onKeyDown:_,onKeyUp(U){U.key===" "&&z(!1)}}),[_,z]);return E.useMemo(()=>f?{reference:$,floating:J}:{},[f,$,J])}const BU=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),jU=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),i6=t=>{const e=jU(t);return e.charAt(0).toUpperCase()+e.slice(1)},zT=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),VU=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UU={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const PU=E.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:o,iconNode:l,...c},d)=>E.createElement("svg",{ref:d,...UU,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:zT("lucide",i),...!o&&!VU(c)&&{"aria-hidden":"true"},...c},[...l.map(([f,h])=>E.createElement(f,h)),...Array.isArray(o)?o:[o]]));const we=(t,e)=>{const n=E.forwardRef(({className:r,...i},o)=>E.createElement(PU,{ref:o,iconNode:e,className:zT(`lucide-${BU(i6(t))}`,`lucide-${t}`,r),...i}));return n.displayName=i6(t),n};const FU=[["path",{d:"M3.5 13h6",key:"p1my2r"}],["path",{d:"m2 16 4.5-9 4.5 9",key:"ndf0b3"}],["path",{d:"M18 7v9",key:"pknjwm"}],["path",{d:"m14 12 4 4 4-4",key:"buelq4"}]],$U=we("a-arrow-down",FU);const qU=[["path",{d:"M3.5 13h6",key:"p1my2r"}],["path",{d:"m2 16 4.5-9 4.5 9",key:"ndf0b3"}],["path",{d:"M18 16V7",key:"ty0viw"}],["path",{d:"m14 11 4-4 4 4",key:"1pu57t"}]],ZU=we("a-arrow-up",qU);const KU=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],GU=we("align-left",KU);const YU=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],WU=we("arrow-right",YU);const JU=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M16 12h2",key:"7q9ll5"}],["path",{d:"M16 8h2",key:"msurwy"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}],["path",{d:"M6 12h2",key:"32wvfc"}],["path",{d:"M6 8h2",key:"30oboj"}]],XU=we("book-open-text",JU);const QU=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],eP=we("box",QU);const tP=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],nP=we("check",tP);const rP=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]],iP=we("clipboard-copy",rP);const oP=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],sP=we("clipboard-paste",oP);const lP=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],aP=we("code",lP);const cP=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],uP=we("columns-2",cP);const dP=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],fP=we("credit-card",dP);const hP=[["path",{d:"m21.12 6.4-6.05-4.06a2 2 0 0 0-2.17-.05L2.95 8.41a2 2 0 0 0-.95 1.7v5.82a2 2 0 0 0 .88 1.66l6.05 4.07a2 2 0 0 0 2.17.05l9.95-6.12a2 2 0 0 0 .95-1.7V8.06a2 2 0 0 0-.88-1.66Z",key:"1u2ovd"}],["path",{d:"M10 22v-8L2.25 9.15",key:"11pn4q"}],["path",{d:"m10 14 11.77-6.87",key:"1kt1wh"}]],Xs=we("cuboid",hP);const pP=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],mP=we("file-down",pP);const gP=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],G2=we("file-text",gP);const yP=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],vP=we("folder-open",yP);const bP=[["path",{d:"M3 2h18",key:"15qxfx"}],["rect",{width:"18",height:"12",x:"3",y:"6",rx:"2",key:"1439r6"}],["path",{d:"M3 22h18",key:"8prr45"}]],CP=we("gallery-vertical",bP);const wP=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],xP=we("grid-3x3",wP);const SP=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],TP=we("grip-vertical",SP);const kP=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],BT=we("heading",kP);const EP=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]],MP=we("house",EP);const AP=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],o6=we("image-plus",AP);const NP=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],RP=we("image",NP);const OP=[["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"m22 13-1.296-1.296a2.41 2.41 0 0 0-3.408 0L11 18",key:"nf6bnh"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["rect",{width:"16",height:"16",x:"6",y:"2",rx:"2",key:"12espp"}]],jT=we("images",OP);const DP=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],LP=we("layers",DP);const _P=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]],HP=we("layout-list",_P);const IP=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],zP=we("layout-grid",IP);const BP=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],jP=we("link",BP);const VP=[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]],VT=we("list",VP);const UP=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],PP=we("mail",UP);const FP=[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],$P=we("message-circle-question-mark",FP);const qP=[["path",{d:"M5 12h14",key:"1ays0h"}]],UT=we("minus",qP);const ZP=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],KP=we("monitor",ZP);const GP=[["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-4 0v-9a2 2 0 0 1 2-2h2",key:"39pd36"}],["rect",{width:"8",height:"4",x:"10",y:"6",rx:"1",key:"aywv1n"}]],s6=we("newspaper",GP);const YP=[["path",{d:"M13 4v16",key:"8vvj80"}],["path",{d:"M17 4v16",key:"7dpous"}],["path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13",key:"sh4n9v"}]],WP=we("pilcrow",YP);const JP=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],XP=we("play",JP);const QP=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],r1=we("plus",QP);const eF=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]],tF=we("quote",eF);const nF=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M7 12h.01",key:"eqddd0"}]],rF=we("rectangle-ellipsis",nF);const iF=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]],PT=we("rectangle-horizontal",iF);const oF=[["path",{d:"M13 13H8a1 1 0 0 0-1 1v7",key:"h8g396"}],["path",{d:"M14 8h1",key:"1lfen6"}],["path",{d:"M17 21v-4",key:"1yknxs"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20.41 20.41A2 2 0 0 1 19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 .59-1.41",key:"1t4vdl"}],["path",{d:"M29.5 11.5s5 5 4 5",key:"zzn4i6"}],["path",{d:"M9 3h6.2a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V15",key:"24cby9"}]],l6=we("save-off",oF);const sF=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],lF=we("save",sF);const aF=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],cF=we("send",aF);const uF=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],dF=we("settings",uF);const fF=[["path",{d:"M4 10c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"4i38lg"}],["path",{d:"M10 16c-1.1 0-2-.9-2-2v-4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"mlte4a"}],["rect",{width:"8",height:"8",x:"14",y:"14",rx:"2",key:"1fa9i4"}]],hF=we("square-stack",fF);const pF=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],mF=we("square",pF);const gF=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],FT=we("star",gF);const yF=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],vF=we("tag",yF);const bF=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],CF=we("triangle-alert",bF);const wF=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],xF=we("user",wF);const SF=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],TF=we("video",SF);const kF=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],i1=we("x",kF),EF={cs:{placeholder:"Klikněte pro přidání dalšího obsahu"},en:{placeholder:"Click to add more content"}},_a=({children:t,editor:e,getPos:n,target:r,wrapperRef:i})=>{const[o,l]=E.useState(!1),[c,d]=E.useState(!1),f=E.useRef(null),h=E.useRef(null),m=E.useCallback(()=>{if(!f.current||f.current.closest(".f-tiptap-page")?.classList.contains("f-tiptap-page--collapsed"))return!1;const R=f.current.querySelector("[data-node-view-content-react]")||f.current;if(!R)return!1;const L=R.lastElementChild;return L?L.tagName.toLowerCase()==="div":!1},[]),{refs:g,floatingStyles:y}=e1({open:c,placement:"bottom",middleware:[Yp({mainAxis:0}),NT({apply({rects:N,elements:R}){Object.assign(R.floating.style,{width:`${N.reference.width}px`})}})],whileElementsMounted:qp,strategy:"fixed"}),{getFloatingProps:C}=t1([]),w=E.useCallback(N=>{f.current?.contains(N.target)&&l(!0)},[]),x=E.useCallback(N=>{const R=N.relatedTarget;h.current&&R&&R instanceof Node&&(h.current.contains(R)||h.current===R)||l(!1)},[]),k=E.useCallback(()=>{l(!1)},[]);E.useEffect(()=>{if(!e||!o)return;const N=()=>{m()?(d(!0),f.current&&g.setReference(f.current)):d(!1)};return e.on("update",N),()=>{e.off("update",N)}},[e,o,m,g]),E.useEffect(()=>{o&&m()?(d(!0),f.current&&g.setReference(f.current)):d(!1)},[o,m,g]);const A=E.useCallback(()=>{if(d(!1),n){const N=n();if(typeof N=="number"){const R=e.state.doc.resolve(N+1),L=R.end(R.depth),z=e.schema.nodes.paragraph.create(),_=e.state.tr;_.insert(L,z);const $=L+1;_.setSelection(ue.create(_.doc,$)),e.view.dispatch(_),e.view.focus();return}}e.chain().focus().insertContent({type:"paragraph"}).run()},[e,n]);return!e||!e.isEditable?S.jsx(S.Fragment,{children:t}):S.jsxs(S.Fragment,{children:[S.jsx("div",{ref:N=>{f.current=N,i&&"current"in i&&(i.current=N)},onMouseEnter:w,onMouseLeave:x,onMouseOver:w,style:{position:"relative"},children:t}),c&&S.jsx(Qp,{children:S.jsx("div",{ref:N=>{h.current=N,g.setFloating(N)},onMouseEnter:()=>l(!0),onMouseLeave:k,style:{...y,marginTop:0},...C(),className:"f-tiptap-paragraph-placeholder",children:S.jsxs("div",{className:"f-tiptap-paragraph-placeholder__div",onClick:A,children:[S.jsx(r1,{className:"f-tiptap-paragraph-placeholder__icon"}),pe(EF,"placeholder")]})})})]})};_a.displayName="HasParagraphPlaceholder";const MF=({editor:t,getPos:e})=>t?S.jsx(Qi,{children:S.jsx(_a,{editor:t,getPos:e,target:"column",children:S.jsx(La,{})})}):null,tp=st.create({name:"folioTiptapColumn",content:"block+",isolating:!0,addOptions(){return{HTMLAttributes:{class:"f-tiptap-column"}}},parseHTML(){return[{tag:"div.f-tiptap-column"}]},renderHTML({HTMLAttributes:t}){return["div",Fe(this.options.HTMLAttributes,t),0]},addNodeView(){return eo(MF,{className:"node-folioTiptapColumn f-tiptap-column",stopEvent:()=>!1})}}),o1=st.create({name:"folioTiptapColumns",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,content:"folioTiptapColumn{1,}",draggable:!0,addOptions(){return{HTMLAttributes:{class:"f-tiptap-columns"}}},parseHTML(){return[{tag:"div.f-tiptap-columns"}]},renderHTML({HTMLAttributes:t}){return["div",Fe({class:"f-tiptap-columns f-tiptap-avoid-external-layout"},this.options.HTMLAttributes,t),0]},addCommands(){return{insertFolioTiptapColumns:()=>({tr:t,dispatch:e,editor:n})=>{const r=Aj(n.schema,2);if(e){const i=t.selection.anchor+1;t.replaceSelectionWith(r).scrollIntoView().setSelection(ue.near(t.doc.resolve(i)))}return!0},addFolioTiptapColumnBefore:()=>({dispatch:t,state:e})=>k0({dispatch:t,state:e,type:"addBefore"}),addFolioTiptapColumnAfter:()=>({dispatch:t,state:e})=>k0({dispatch:t,state:e,type:"addAfter"}),deleteFolioTiptapColumn:()=>({dispatch:t,state:e})=>k0({dispatch:t,state:e,type:"delete"})}},addKeyboardShortcuts(){return{Tab:()=>S5({state:this.editor.state,dispatch:this.editor.view.dispatch,type:"after"}),"Shift-Tab":()=>S5({state:this.editor.state,dispatch:this.editor.view.dispatch,type:"before"})}}});function AF(t,e=null,n=null){if(e)return t.createChecked({},e);if(n){const r=[n.nodes.heading.createChecked({level:2})];return t.createChecked({},r)}return t.createAndFill({})}function NF(t){if(t.cached.pagesNodeTypes)return t.cached.pagesNodeTypes;const e={pages:t.nodes.folioTiptapPages,page:t.nodes.folioTiptapPage};return t.cached.pagesNodeTypes=e,e}function RF(t,e,n=null){const r=NF(t),i=[];for(let o=0;oo.type.name===Fu.name)(t.selection),i=At(o=>o.type.name===Xo.name)(t.selection);if(!r||!i)return!1;if(e){const o=r.node;let l=null;if(o.content.forEach((g,y,C)=>{if(l===null&&g===i.node){l=C;return}}),l===null)return console.warn("Current page not found in pages node"),!1;const c=o.toJSON();let d=l;if(n==="delete"){if(c.content.length<=2){const x=[];c.content.forEach(A=>{A.content&&A.content.length>0&&x.push(...A.content)}),x.length===0&&x.push({type:"paragraph"});const k=t.tr;return k.replaceWith(r.pos,r.pos+r.node.nodeSize,x.map(A=>Gn.fromJSON(t.schema,A))),k.setSelection(ue.near(k.doc.resolve(r.pos+1))),e(k),!0}const y=c.content[l].content||[],C=l>0?l-1:l+1,w=c.content[C];y.length>0&&(w.content||(w.content=[]),w.content.push(...y)),c.content.splice(l,1),d=l>0?l-1:0}else d=n==="addBefore"?l:l+1,c.content.splice(d,0,{type:Xo.name,content:[{type:"heading",attrs:{level:2}}]});const f=Gn.fromJSON(t.schema,c);let h=r.pos;f.content.forEach((g,y,C)=>{Co.type.name===Fu.name)(t.selection),i=At(o=>o.type.name===Xo.name)(t.selection);if(r&&i){const o=r.node;let l=null;if(o.content.forEach((w,x,k)=>{if(l===null&&w===i.node){l=k;return}}),l===null)return console.warn("Current page not found in pages node"),!1;let c;if(n==="up"){if(l===0)return!1;c=l-1}else{if(l===o.childCount-1)return!1;c=l+1}const d=o.content.maybeChild(c);if(!d||d.type.name!==Xo.name)return!1;const f=o.toJSON(),h=f.content[l],m=f.content[c];f.content[l]=m,f.content[c]=h;const g=Gn.fromJSON(t.schema,f);let y=r.pos;g.content.forEach((w,x,k)=>{ko.type.name===Fu.name)(t.selection),i=At(o=>o.type.name===Xo.name)(t.selection);if(e&&r&&i){const o=r.node,l=i.node;let c=null;if(o.content.forEach((m,g,y)=>{if(c===null&&m===l){c=y;return}}),c===null)return console.warn("Current page not found in pages node"),!1;let d=0;n==="before"?d=(c-1+o.childCount)%o.childCount:d=(c+1)%o.childCount;let f=r.pos;o.content.forEach((m,g,y)=>{y{const n=e();if(typeof n!="number")return;const r=t.schema.nodes.heading.create({level:2}),i=n+1,o=t.state.tr;o.insert(i,r);const l=i+1;o.setSelection(ue.create(o.doc,l)),t.view.dispatch(o)},LF=({event:t,editor:e,getPos:n})=>{t.preventDefault(),t.stopPropagation();const r=n();if(typeof r!="number")return!1;const i=e.state.doc.resolve(r+1),o=i.end(i.depth),l=e.state.tr.setSelection(ue.create(e.state.doc,o-1));e.view.dispatch(l)},_F=({node:t,getPos:e,editor:n})=>{const r=E.useMemo(()=>Vx(t,h=>h.type.name==="heading"),[t]),i=E.useMemo(()=>r.find(h=>h.node.content.size>0),[r]);if(!n)return null;const o=()=>{$T({state:n.state,dispatch:n.view.dispatch,node:t,getPos:e})};let l="f-tiptap-page";const c=!i,d=r.length===0;c&&(l+=" f-tiptap-page--invalid"),t.attrs.collapsed&&(l+=" f-tiptap-page--collapsed");const f=t.attrs.collapsed?{"data-collapsed":"true"}:{};return S.jsxs(Qi,{className:l,...f,children:[S.jsx("div",{className:"f-tiptap-page__toggle-wrap",onClick:o,children:S.jsx("div",{className:"f-tiptap-page__toggle",children:t.attrs.collapsed?S.jsx(w8,{className:"f-tiptap-page__toggle-ico"}):S.jsx(x8,{className:"f-tiptap-page__toggle-ico"})})}),S.jsxs("div",{className:"f-tiptap-page__content",children:[d?S.jsx("h2",{className:"f-tiptap-page__title-placeholder is-empty","data-placeholder":pe(OF,"missingHeading"),onClick:()=>{DF({editor:n,getPos:e})},children:S.jsx("br",{className:"ProseMirror-trailingBreak"})}):null,S.jsx(_a,{editor:n,getPos:e,target:"page",children:S.jsx(La,{})})]}),S.jsx("span",{className:"f-tiptap-page__content-click-trigger",onClick:h=>LF({event:h,editor:n,getPos:e})})]})},Xo=st.create({name:"folioTiptapPage",content:"block+",isolating:!0,addAttributes(){return{collapsed:{default:!1,parseHTML:t=>t.getAttribute("data-collapsed")==="true",renderHTML:t=>t.collapsed?{"data-collapsed":"true"}:{}}}},addOptions(){return{HTMLAttributes:{class:"f-tiptap-page"}}},parseHTML(){return[{tag:"div.f-tiptap-page"}]},renderHTML({HTMLAttributes:t}){return["div",Fe(this.options.HTMLAttributes,t),0]},addNodeView(){return eo(_F,{stopEvent:()=>!1})}}),HF=({node:t,getPos:e,editor:n})=>(E.useEffect(()=>{if(!n)return;const r=()=>{const i=At(o=>o.type.name==="folioTiptapPage")(n.state.selection);i&&i.node.attrs.collapsed&&$T({state:n.state,dispatch:n.view.dispatch,node:i.node,getPos:()=>i.pos})};return n.on("selectionUpdate",r),()=>{n.off("selectionUpdate",r)}},[n,t,e]),n?S.jsx(Qi,{className:"f-tiptap-pages__view",children:S.jsx(La,{className:"f-tiptap-pages__content"})}):null),u6={cs:{label:"Stránkovaný obsah"},en:{label:"Paged content"}},Fu=st.create({name:"folioTiptapPages",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,content:"folioTiptapPage{2,}",draggable:!0,addOptions(){return{HTMLAttributes:{class:"f-tiptap-pages"}}},parseHTML(){return[{tag:"div.f-tiptap-pages"}]},renderHTML({HTMLAttributes:t}){return["div",Fe({class:"f-tiptap-pages"},this.options.HTMLAttributes,t),0]},addCommands(){return{insertFolioTiptapPages:()=>({tr:t,dispatch:e,editor:n})=>{const r=RF(n.schema,2);if(e){const i=t.selection.anchor+1;t.replaceSelectionWith(r).scrollIntoView().setSelection(ue.near(t.doc.resolve(i)))}return!0},addFolioTiptapPageBefore:()=>({dispatch:t,state:e})=>B0({dispatch:t,state:e,type:"addBefore"}),addFolioTiptapPageAfter:()=>({dispatch:t,state:e})=>B0({dispatch:t,state:e,type:"addAfter"}),deleteFolioTiptapPage:()=>({dispatch:t,state:e})=>B0({dispatch:t,state:e,type:"delete"}),moveFolioTiptapPageUp:()=>({dispatch:t,state:e})=>a6({state:e,dispatch:t,type:"up"}),moveFolioTiptapPageDown:()=>({dispatch:t,state:e})=>a6({state:e,dispatch:t,type:"down"})}},addNodeView(){return eo(HF,{className:"node-folioTiptapPages f-tiptap-pages",stopEvent:()=>!1})},addKeyboardShortcuts(){return{Tab:()=>c6({state:this.editor.state,dispatch:this.editor.view.dispatch,type:"after"}),"Shift-Tab":()=>c6({state:this.editor.state,dispatch:this.editor.view.dispatch,type:"before"})}}}),zc={cs:{addFolioTiptapPageBefore:"Přidat stránku před",moveFolioTiptapPageUp:"Posunout stránku nahoru",addFolioTiptapPageAfter:"Přidat stránku za",moveFolioTiptapPageDown:"Posunout stránku dolů",deleteFolioTiptapPage:"Odstranit stránku"},en:{addFolioTiptapPageBefore:"Add page before",moveFolioTiptapPageUp:"Move page up",addFolioTiptapPageAfter:"Add page after",moveFolioTiptapPageDown:"Move page down",deleteFolioTiptapPage:"Remove page"}},IF={pluginKey:"folioTiptapPagesBubbleMenu",priority:1,shouldShow:({editor:t})=>t.isActive(Fu.name),disabledKeys:({editor:t})=>{const e=[];return t.can().moveFolioTiptapPageUp()||e.push("moveFolioTiptapPageUp"),t.can().moveFolioTiptapPageDown()||e.push("moveFolioTiptapPageDown"),e},items:[[{key:"addFolioTiptapPageBefore",title:pe(zc,"addFolioTiptapPageBefore"),icon:k8,command:({editor:t})=>{t.chain().focus().addFolioTiptapPageBefore().run()}},{key:"moveFolioTiptapPageUp",title:pe(zc,"moveFolioTiptapPageUp"),icon:m3,command:({editor:t})=>{t.chain().focus().moveFolioTiptapPageUp().run()}}],[{key:"addFolioTiptapPageAfter",title:pe(zc,"addFolioTiptapPageAfter"),icon:T8,command:({editor:t})=>{t.chain().focus().addFolioTiptapPageAfter().run()}},{key:"moveFolioTiptapPageDown",title:pe(zc,"moveFolioTiptapPageDown"),icon:p3,command:({editor:t})=>{t.chain().focus().moveFolioTiptapPageDown().run()}}],[{key:"deleteFolioTiptapPage",title:pe(zc,"deleteFolioTiptapPage"),icon:i1,command:({editor:t})=>{t.chain().focus().deleteFolioTiptapPage().run()}}]]},zF=Ke.create({name:"folioTiptapPagesExtension"}),BF=t=>t?[{title:{cs:u6.cs.label,en:u6.en.label},icon:XU,key:"folioTiptapPages",command:({chain:n})=>{n.insertFolioTiptapPages()}}]:[],jF=II.extend({name:"folioTiptapStyledParagraph",parseHTML(){const t=this.options.variants||[],e=r=>typeof r=="string"?!1:{variant:r.getAttribute("data-f-tiptap-styled-paragraph-variant")||null},n=[{tag:"p.f-tiptap-styled-paragraph",getAttrs:e}];return t.forEach(r=>{r.tag&&r.tag!=="p"&&n.push({tag:`${r.tag}.f-tiptap-styled-paragraph`,getAttrs:e})}),n},renderHTML({HTMLAttributes:t}){const e=this.options.variants||[],n=t["data-f-tiptap-styled-paragraph-variant"],r=e.find(d=>d.variant===n),i=r?.tag||"p",o="f-tiptap-styled-paragraph",l=r?.class_name,c=l?`${o} ${l}`:o;return[i,{...t,class:c},0]},addOptions(){return{variants:[],variantCommands:[]}},addAttributes(){return{variant:{default:null,parseHTML:t=>t.getAttribute("data-f-tiptap-styled-paragraph-variant"),renderHTML:t=>({"data-f-tiptap-styled-paragraph-variant":t.variant})}}}}),VF=t=>{const e=(r,i)=>{switch(r){case"arrow-up":return ZU;case"arrow-down":return $U;case"heading":return BT;case"message-circle-question-mark":return $P}switch(i){case"h1":return y8;case"h2":return b3;case"h3":return v3;case"h4":return y3;case"h5":return m8;case"h6":return v8;default:return FT}},n=t.map(r=>({title:r.title,icon:e(r.icon,r.tag),key:`styledParagraphVariant-${r.variant}`,command:({chain:o})=>{const l={variant:r.variant};o.setNode("folioTiptapStyledParagraph",l)}}));return n.sort((r,i)=>{const o=r.title[document.documentElement.lang]||r.title.en,l=i.title[document.documentElement.lang]||i.title.en;return o.localeCompare(l)}),n},UF=({node:t,editor:e,getPos:n})=>{if(!e)return null;const r=t.attrs.variant,i="node-folioTiptapStyledWrap f-tiptap-styled-wrap f-tiptap-avoid-external-layout",o=r?{"data-f-tiptap-styled-wrap-variant":r}:{};return S.jsx(Qi,{className:i,...o,children:S.jsx(_a,{editor:e,getPos:n,target:"styled-wrap",children:S.jsx(La,{})})})},PF=st.create({name:"folioTiptapStyledWrap",defining:!1,isolating:!0,allowGapCursor:!1,content:"block+",group:"block",parseHTML(){return[{tag:"div.f-tiptap-styled-wrap",getAttrs:t=>typeof t=="string"?!1:{variant:t.getAttribute("data-f-tiptap-styled-wrap-variant")||null}}]},renderHTML({HTMLAttributes:t}){return["div",{...t,class:"f-tiptap-styled-wrap f-tiptap-avoid-external-layout"},0]},addOptions(){return{variantCommands:[]}},addAttributes(){return{variant:{default:null,parseHTML:t=>t.getAttribute("data-f-tiptap-styled-wrap-variant"),renderHTML:t=>({"data-f-tiptap-styled-wrap-variant":t.variant})}}},addNodeView(){return eo(UF,{stopEvent:()=>!1})}}),FF=t=>{const e=t.map(n=>({title:n.title,icon:eP,key:`styledWrapVariant-${n.variant}`,command:({chain:i})=>{i.insertContent({type:"folioTiptapStyledWrap",attrs:{variant:n.variant},content:[{type:"paragraph",content:[]}]})}}));return e.sort((n,r)=>{const i=n.title[document.documentElement.lang]||n.title.en,o=r.title[document.documentElement.lang]||r.title.en;return i.localeCompare(o)}),e},$F=({editor:t,getPos:e})=>t?S.jsx(Qi,{children:S.jsx(_a,{editor:t,getPos:e,target:"float-aside",children:S.jsx(La,{})})}):null,qT=st.create({name:"folioTiptapFloatAside",isolating:!0,content:"block+",addOptions(){return{HTMLAttributes:{class:"f-tiptap-float__aside"}}},parseHTML(){return[{tag:"aside.f-tiptap-float__aside"},{tag:"div.f-tiptap-float__aside"}]},renderHTML({HTMLAttributes:t}){return["aside",Fe({class:"f-tiptap-float__aside"},this.options.HTMLAttributes,t),0]},addNodeView(){return eo($F,{as:"aside",className:"node-folioTiptapFloatAside f-tiptap-float__aside",stopEvent:()=>!1})}}),qF=({tr:t,dispatch:e,editor:n})=>{const r=[n.schema.nodes.folioTiptapFloatAside.createAndFill({}),n.schema.nodes.folioTiptapFloatMain.createAndFill({})],i=n.schema.nodes.folioTiptapFloat.createChecked({},r);if(e){const o=t.selection.anchor+1;t.replaceSelectionWith(i).scrollIntoView().setSelection(ue.near(t.doc.resolve(o))),e(t)}return!0},ZF=({attrs:t,tr:e,dispatch:n,state:r})=>{const i=At(c=>c.type.name===Ta.name)(r.selection);if(!i)return!1;let o=!1;const l={side:i.node.attrs.side||"left",size:i.node.attrs.size||"medium"};return t.side&&t.side!==l.side&&["left","right"].includes(t.side)&&(l.side=t.side,o=!0),t.size&&t.size!==l.size&&["small","medium","large"].includes(t.size)&&(l.size=t.size,o=!0),o?(n&&(e.setNodeMarkup(i.pos,void 0,l),n(e)),!0):!1};function d6({state:t,dispatch:e}){const n=At(r=>r.type.name===Ta.name)(t.selection);if(e&&n){if(At(l=>l.type.name==="listItem")(t.selection))return!1;const i=At(l=>l.type.name===qT.name)(t.selection),o=t.tr;if(i){const l=i.pos+i.node.nodeSize;o.setSelection(ue.near(o.doc.resolve(l)))}else{const l=n.pos+1;o.setSelection(ue.near(o.doc.resolve(l)))}return e(o),!0}return!1}function KF({tr:t,dispatch:e,state:n}){const r=At(i=>i.type.name===Ta.name)(n.selection);if(!r)return!1;if(e){const i=[];r.node.toJSON().content.forEach(o=>{o.content&&o.content.length>0&&o.content.forEach(l=>{if(l){if(l.type==="paragraph"&&(!l.content||l.content.length===0))return;i.push(l)}})}),i.length===0&&i.push({type:"paragraph"}),t.replaceWith(r.pos,r.pos+r.node.nodeSize,i.map(o=>Gn.fromJSON(n.schema,o))),t.setSelection(ue.near(t.doc.resolve(r.pos+1))),e(t)}return!0}const Ta=st.create({name:"folioTiptapFloat",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,content:"folioTiptapFloatAside{1} folioTiptapFloatMain{1}",draggable:!1,addOptions(){return{HTMLAttributes:{class:"f-tiptap-float"}}},addAttributes(){return{side:{default:"left",parseHTML:t=>t.getAttribute("data-f-tiptap-float-side")||"left"},size:{default:"medium",parseHTML:t=>t.getAttribute("data-f-tiptap-float-size")||"medium"}}},parseHTML(){return[{tag:"div.f-tiptap-float",getAttrs:t=>typeof t=="string"?!1:{side:t.getAttribute("data-f-tiptap-float-side")||"left",size:t.getAttribute("data-f-tiptap-float-size")||"medium"}}]},renderHTML({HTMLAttributes:t}){return["div",Fe({class:"f-tiptap-float f-tiptap-avoid-external-layout","data-f-tiptap-float-side":t.side,"data-f-tiptap-float-size":t.size},this.options.HTMLAttributes,t),0]},addCommands(){return{insertFolioTiptapFloat:()=>({tr:t,dispatch:e,editor:n})=>qF({tr:t,dispatch:e,editor:n}),cancelFolioTiptapFloat:()=>({tr:t,dispatch:e,state:n,editor:r})=>KF({tr:t,dispatch:e,state:n}),setFolioTiptapFloatAttributes:t=>({tr:e,dispatch:n,state:r,editor:i})=>ZF({attrs:t,tr:e,dispatch:n,state:r})}},addKeyboardShortcuts(){return{Tab:()=>d6({state:this.editor.state,dispatch:this.editor.view.dispatch}),"Shift-Tab":()=>d6({state:this.editor.state,dispatch:this.editor.view.dispatch})}}}),GF=({editor:t,getPos:e})=>t?S.jsx(Qi,{children:S.jsx(_a,{editor:t,getPos:e,target:"float-main",children:S.jsx(La,{})})}):null,YF=st.create({name:"folioTiptapFloatMain",isolating:!0,content:"block+",addOptions(){return{HTMLAttributes:{class:"f-tiptap-float__main"}}},parseHTML(){return[{tag:"div.f-tiptap-float__main"}]},renderHTML({HTMLAttributes:t}){return["div",Fe({class:"f-tiptap-float__main"},this.options.HTMLAttributes,t),0]},addNodeView(){return eo(GF,{as:"main",className:"node-folioTiptapFloatMain f-tiptap-float__main",stopEvent:()=>!1})}}),Wl={cs:{setFloatSideToLeft:"Obtékaný obsah - vlevo",setFloatSideToRight:"Obtékaný obsah - vpravo",cancelFloat:"Zrušit obtékání obsahu",setFloatSizeToSmall:"Obtékaný obsah - úzký",setFloatSizeToMedium:"Obtékaný obsah - střední",setFloatSizeToLarge:"Obtékaný obsah - široký"},en:{setFloatSideToLeft:"Float content - left",setFloatSideToRight:"Float content - right",cancelFloat:"Cancel float content",setFloatSizeToSmall:"Float content - small",setFloatSizeToMedium:"Float content - medium",setFloatSizeToLarge:"Float content - large"}},WF={pluginKey:"folioTiptapFloatBubbleMenu",priority:1,shouldShow:({editor:t})=>t.isActive(Ta.name),activeKeys:({editor:t})=>{const e=At(r=>r.type.name===Ta.name)(t.state.selection);if(!e)return[];const n=[];return e.node.attrs.side==="right"?n.push("setFloatSideToRight"):n.push("setFloatSideToLeft"),e.node.attrs.size==="small"?n.push("setFloatSizeToSmall"):e.node.attrs.size==="large"?n.push("setFloatSizeToLarge"):n.push("setFloatSizeToMedium"),n},items:[[{key:"setFloatSideToLeft",title:pe(Wl,"setFloatSideToLeft"),icon:o8,command:({editor:t})=>{t.chain().focus().setFolioTiptapFloatAttributes({side:"left"}).run()}},{key:"cancelFloat",title:pe(Wl,"cancelFloat"),icon:zp,command:({editor:t})=>{t.chain().focus().cancelFolioTiptapFloat().run()}},{key:"setFloatSideToRight",title:pe(Wl,"setFloatSideToRight"),icon:s8,command:({editor:t})=>{t.chain().focus().setFolioTiptapFloatAttributes({side:"right"}).run()}}],[{key:"setFloatSizeToSmall",title:pe(Wl,"setFloatSizeToSmall"),icon:R8,command:({editor:t})=>{t.chain().focus().setFolioTiptapFloatAttributes({size:"small"}).run()}},{key:"setFloatSizeToMedium",title:pe(Wl,"setFloatSizeToMedium"),icon:N8,command:({editor:t})=>{t.chain().focus().setFolioTiptapFloatAttributes({size:"medium"}).run()}},{key:"setFloatSizeToLarge",title:pe(Wl,"setFloatSizeToLarge"),icon:A8,command:({editor:t})=>{t.chain().focus().setFolioTiptapFloatAttributes({size:"large"}).run()}}]]},Y2="f-tiptap-invalid-node",JF={cs:{message:"Tento obsah nebude veřejně zobrazen. Můžete ho odstranit."},en:{message:"This content will not be publicly displayed. You can remove it."}},XF=t=>{const{node:e}=t;return S.jsx(Qi,{className:Y2,"data-node-string":JSON.stringify(e.attrs.invalidNodeHash),children:S.jsx(E3,{invalidNodeHash:e&&e.attrs&&e.attrs.invalidNodeHash,message:pe(JF,"message")})})},QF=st.create({name:"folioTiptapInvalidNode",group:"block",draggable:!0,selectable:!0,atom:!0,code:!0,isolating:!0,renderHTML({HTMLAttributes:t}){return["div",{...t,class:Y2},0]},addAttributes(){return{invalidNodeHash:{default:{},parseHTML:t=>JSON.parse(t.getAttribute("data-node-string")||"{}"),renderHTML:t=>({"data-node-string":JSON.stringify(t.invalidNodeHash)})}}},addNodeView(){return eo(XF,{stopEvent:()=>!1})},parseHTML(){return[{tag:`div.${Y2}`,getAttrs:t=>typeof t=="string"?!1:{invalidNodeHash:(()=>{try{return JSON.parse(t.getAttribute("data-node-string")||"{}")}catch(e){return console.error("Error parsing invalidNodeHash:",e),{}}})()}}]}}),e$={title:{cs:"Bodový seznam",en:"Bullet List"},icon:C3,key:"bulletList",command:({chain:t})=>{t.toggleBulletList()}},t$={title:{cs:"Sloupce",en:"Columns"},icon:uP,key:"folioTiptapColumns",command:({chain:t})=>{t.insertFolioTiptapColumns({count:2})}},n$={title:{cs:"Obtékaný obsah",en:"Float content"},icon:p8,key:"folioTiptapFloat",command:({chain:t})=>{t.insertFolioTiptapFloat()}},r$={title:{cs:"Nadpis H4",en:"Heading H4"},icon:y3,key:"heading-4",keymap:"####",command:({chain:t})=>{t.setNode("heading",{level:4})}},i$={title:{cs:"Nadpis H3",en:"Heading H3"},icon:v3,key:"heading-3",keymap:"###",command:({chain:t})=>{t.setNode("heading",{level:3})}},o$={title:{cs:"Nadpis H2",en:"Heading H2"},icon:b3,key:"heading-2",keymap:"##",command:({chain:t})=>{t.setNode("heading",{level:2})}},ZT={title:{cs:"Oddělovač",en:"Delimiter"},icon:UT,key:"horizontalRule",hideInToolbarDropdown:!0,command:({chain:t})=>{t.insertContent({type:"horizontalRule"})}},s$={title:{cs:"Číslovaný seznam",en:"Ordered List"},icon:C8,key:"orderedList",command:({chain:t})=>{t.toggleOrderedList()}},l$={title:{cs:"Odstavec",en:"Paragraph"},icon:WP,key:"paragraph",dontShowAsActiveInCollapsedToolbar:!0,command:({chain:t})=>{t.setNode("paragraph")}},a$={title:{cs:"Tabulka",en:"Table"},icon:T3,key:"table",command:({chain:t})=>{t.insertTable({rows:2,cols:2,withHeaderRow:!0})}},c$={title:{cs:"Zarovnat doprostřed",en:"Align center"},icon:r8,key:"align-center",command:({chain:t})=>{t.setTextAlign("center")}},u$={title:{cs:"Zarovnat doleva",en:"Align left"},icon:h3,key:"align-left",command:({chain:t})=>{t.setTextAlign("left")}},d$={title:{cs:"Zarovnat doprava",en:"Align right"},icon:i8,key:"align-right",command:({chain:t})=>{t.setTextAlign("right")}},f$={title:{cs:"Kurzíva",en:"Italic"},icon:Bp,key:"italic",command:({chain:t})=>{t.toggleMark("italic")}},h$={title:{cs:"Podtržené",en:"Underline"},icon:k3,key:"underline",command:({chain:t})=>{t.toggleMark("underline")}},p$={title:{cs:"Horní index",en:"Superscript"},icon:S3,key:"superscript",command:({chain:t})=>{t.toggleMark("superscript")}},m$={title:{cs:"Dolní index",en:"Subscript"},icon:x3,key:"subscript",command:({chain:t})=>{t.toggleMark("subscript")}},g$={title:{cs:"Přeškrtnuté",en:"Strikethrough"},icon:w3,key:"strike",command:({chain:t})=>{t.toggleMark("strike")}},F3={title:{cs:"Seznamy",en:"Lists"},key:"lists",icon:C3,commands:[e$,s$]},y$={title:{cs:"Zarovnání",en:"Text align"},key:"textAlign",icon:h3,commands:[u$,c$,d$]},v$={title:{cs:"Dekorace textu",en:"Text Decorations"},key:"textDecorations",icon:Bp,commands:[f$,h$,g$,p$,m$]},np={image:RP,video:TF,newspaper:s6,plus:r1,content_text:G2,content_title:BT,content_lead:GU,quote:tF,content_divider:UT,content_documents:mP,file_text:G2,image_gallery:jT,image_grid:zP,image_masonry:xP,image_one_two:CP,image_with_text:o6,image_wrapping:o6,user:xF,rectangle_horizontal:PT,card_visual:fP,card_size:mF,card_full:hF,card_padded:LP,list:VT,listing_news:s6,listing_projects:vP,listing_project_card:HP,arrow_right:WU,hero_banner:KP,home:MP,tag:vF,contact_form:PP,link:jP,play:XP,form:rF,send:cF},W2={content:G2,images:jT,cards:PT,listings:VT,special:FT};let Lf=null;const KT=()=>(Lf!==null||(Lf=window.Folio?.Tiptap?.customIcons||{}),Lf),Wf=t=>{if(!t)return Xs;const e=KT();return e[t]?e[t]:np[t]?np[t]:(t&&console.warn(`Unknown icon string: ${t}, using Cuboid as fallback. Define custom icons in window.Folio.Tiptap.customIcons`),Xs)},b$=t=>W2[t]||Xs,f6=t=>{if(!t)return Xs;const e=KT();return e[t]?e[t]:np[t]?np[t]:W2[t]?W2[t]:Xs},C$=(t,e)=>{if(e&&e.length>0){const r={},i=[];t.forEach(c=>{const d=c.config?.group;d?(r[d]||(r[d]=[]),r[d].push(c)):i.push(c)});const o=Object.keys(r).sort((c,d)=>c.localeCompare(d)),l=[];if(o.forEach(c=>{const d=e.find(m=>m.key===c),f=document.documentElement.lang,h=r[c].map(m=>({title:m.title,icon:Wf(m.config?.icon),key:`folioTiptapNode-${m.type}`,command:()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),window.parent.postMessage({type:"f-tiptap-slash-command:selected",attrs:{type:m.type}},"*")}}));h.sort((m,g)=>{const y=m.title[f]||m.title.en,C=g.title[f]||g.title.en;return y.localeCompare(C)}),l.push({title:d?.title||{cs:c,en:c},key:`folioTiptapNodes-${c}`,icon:b$(c),commands:h})}),i.length>0){const c=document.documentElement.lang,d=i.map(f=>({title:f.title,icon:Wf(f.config?.icon),key:`folioTiptapNode-${f.type}`,command:()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),window.parent.postMessage({type:"f-tiptap-slash-command:selected",attrs:{type:f.type}},"*")}}));d.sort((f,h)=>{const m=f.title[c]||f.title.en,g=h.title[c]||h.title.en;return m.localeCompare(g)}),l.push({title:{cs:"Ostatní",en:"Other"},key:"folioTiptapNodes-other",icon:Xs,commands:d})}return l}const n=t.map(r=>({title:r.title,icon:Wf(r.config?.icon),key:`folioTiptapNode-${r.type}`,command:()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),window.parent.postMessage({type:"f-tiptap-slash-command:selected",attrs:{type:r.type}},"*")}}));return n.sort((r,i)=>{const o=r.title[document.documentElement.lang]||r.title.en,l=i.title[document.documentElement.lang]||i.title.en;return o.localeCompare(l)}),{title:{cs:"Bloky",en:"Blocks"},key:"folioTiptapNodes",icon:Xs,commands:n}},w$=({folioTiptapStyledWrapCommands:t,folioTiptapPagesCommands:e})=>({title:{cs:"Rozložení",en:"Layouts"},key:"layouts",icon:T3,commands:[a$,t$,n$,...t,...e,ZT]}),x$=({folioTiptapStyledParagraphCommands:t,folioTiptapHeadingLevels:e})=>{const n=[];return e&&(e.includes(2)&&n.push(o$),e.includes(3)&&n.push(i$),e.includes(4)&&n.push(r$)),e.length===1&&(n[0].title={cs:"Mezititulek",en:"Title"}),{title:{cs:"Formát textu",en:"Text format"},key:"textStyles",icon:g8,commands:[l$,...n,...t]}};function S$(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:o,startOfLine:l,$position:c}=t,d=r&&!i,f=v_(n),h=new RegExp(`\\s${f}$`),m=l?"^":"",g=i?"":f,y=d?new RegExp(`${m}${f}.*?(?=\\s${g}|$)`,"gm"):new RegExp(`${m}(?:^)?${f}[^\\s${g}]*`,"gm"),C=((e=c.nodeBefore)==null?void 0:e.isText)&&c.nodeBefore.text;if(!C)return null;const w=c.pos-C.length,x=Array.from(C.matchAll(y)).pop();if(!x||x.input===void 0||x.index===void 0)return null;const k=x.input.slice(Math.max(0,x.index-1),x.index),A=new RegExp(`^[${o?.join("")}\0]?$`).test(k);if(o!==null&&!A)return null;const N=w+x.index;let R=N+x[0].length;return d&&h.test(C.slice(R-1,R+1))&&(x[0]+=" ",R+=1),N=c.pos?{range:{from:N,to:R},query:x[0].slice(n.length),text:x[0]}:null}var T$=new Ze("suggestion");function k$({pluginKey:t=T$,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:o=[" "],startOfLine:l=!1,decorationTag:c="span",decorationClass:d="suggestion",decorationContent:f="",decorationEmptyClass:h="is-empty",command:m=()=>null,items:g=()=>[],render:y=()=>({}),allow:C=()=>!0,findSuggestionMatch:w=S$}){let x;const k=y?.(),A=()=>{const z=e.state.selection.$anchor.pos,_=e.view.coordsAtPos(z),{top:$,right:J,bottom:U,left:ne}=_;try{return new DOMRect(ne,$,J-ne,U-$)}catch{return null}},N=(z,_)=>_?()=>{const $=t.getState(e.state),J=$?.decorationId,U=z.dom.querySelector(`[data-decoration-id="${J}"]`);return U?.getBoundingClientRect()||null}:A;function R(z,_){var $;try{const U=t.getState(z.state),ne=U?.decorationId?z.dom.querySelector(`[data-decoration-id="${U.decorationId}"]`):null,se={editor:e,range:U?.range||{from:0,to:0},query:U?.query||null,text:U?.text||null,items:[],command:oe=>m({editor:e,range:U?.range||{from:0,to:0},props:oe}),decorationNode:ne,clientRect:N(z,ne)};($=k?.onExit)==null||$.call(k,se)}catch{}const J=z.state.tr.setMeta(_,{exit:!0});z.dispatch(J)}const L=new Ue({key:t,view(){return{update:async(z,_)=>{var $,J,U,ne,se,oe,G;const P=($=this.key)==null?void 0:$.getState(_),H=(J=this.key)==null?void 0:J.getState(z.state),j=P.active&&H.active&&P.range.from!==H.range.from,B=!P.active&&H.active,re=P.active&&!H.active,ae=!B&&!re&&P.query!==H.query,D=B||j&&ae,Z=ae||j,W=re||j&&ae;if(!D&&!Z&&!W)return;const le=W&&!D?P:H,de=z.dom.querySelector(`[data-decoration-id="${le.decorationId}"]`);x={editor:e,range:le.range,query:le.query,text:le.text,items:[],command:ye=>m({editor:e,range:le.range,props:ye}),decorationNode:de,clientRect:N(z,de)},D&&((U=k?.onBeforeStart)==null||U.call(k,x)),Z&&((ne=k?.onBeforeUpdate)==null||ne.call(k,x)),(Z||D)&&(x.items=await g({editor:e,query:le.query})),W&&((se=k?.onExit)==null||se.call(k,x)),Z&&((oe=k?.onUpdate)==null||oe.call(k,x)),D&&((G=k?.onStart)==null||G.call(k,x))},destroy:()=>{var z;x&&((z=k?.onExit)==null||z.call(k,x))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(z,_,$,J){const{isEditable:U}=e,{composing:ne}=e.view,{selection:se}=z,{empty:oe,from:G}=se,P={..._},H=z.getMeta(t);if(H&&H.exit)return P.active=!1,P.decorationId=null,P.range={from:0,to:0},P.query=null,P.text=null,P;if(P.composing=ne,U&&(oe||e.view.composing)){(G<_.range.from||G>_.range.to)&&!ne&&!_.composing&&(P.active=!1);const j=w({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:o,startOfLine:l,$position:se.$from}),B=`id_${Math.floor(Math.random()*4294967295)}`;j&&C({editor:e,state:J,range:j.range,isActive:_.active})?(P.active=!0,P.decorationId=_.decorationId?_.decorationId:B,P.range=j.range,P.query=j.query,P.text=j.text):P.active=!1}else P.active=!1;return P.active||(P.decorationId=null,P.range={from:0,to:0},P.query=null,P.text=null),P}},props:{handleKeyDown(z,_){var $,J,U,ne;const{active:se,range:oe}=L.getState(z.state);if(!se)return!1;if(_.key==="Escape"||_.key==="Esc"){const P=L.getState(z.state),H=($=x?.decorationNode)!=null?$:null,j=H??(P?.decorationId?z.dom.querySelector(`[data-decoration-id="${P.decorationId}"]`):null);if(((J=k?.onKeyDown)==null?void 0:J.call(k,{view:z,event:_,range:P.range}))||!1)return!0;const re={editor:e,range:P.range,query:P.query,text:P.text,items:[],command:ae=>m({editor:e,range:P.range,props:ae}),decorationNode:j,clientRect:j?()=>j.getBoundingClientRect()||null:null};return(U=k?.onExit)==null||U.call(k,re),R(z,t),!0}return((ne=k?.onKeyDown)==null?void 0:ne.call(k,{view:z,event:_,range:oe}))||!1},decorations(z){const{active:_,range:$,decorationId:J,query:U}=L.getState(z);if(!_)return null;const ne=!U?.length,se=[d];return ne&&se.push(h),Qe.create(z.doc,[Ft.inline($.from,$.to,{nodeName:c,class:se.join(" "),"data-decoration-id":J,"data-decoration-content":f})])}}});return L}var E$=k$;const M$=Ke.create({name:"folioTiptapCommands",addOptions(){return{suggestion:{char:"/",command:({editor:t,range:e,props:n})=>{const r=t.chain();r.focus(),r.deleteRange(e),n.command({chain:r}),r.run()}}}},addProseMirrorPlugins(){return[E$({editor:this.editor,...this.options.suggestion})]},addCommands(){return{triggerFolioTiptapCommand:t=>({state:e,dispatch:n})=>{const r=t||e.selection.$from;if(!r)return console.error("Invalid resolved position"),!1;let i=r.node(1);i||(t?i=e.doc.nodeAt(t.pos):e.selection instanceof me&&(i=e.selection.node));let o=!0,l;i&&i.isLeaf?l=r.after(1)+i.nodeSize:i&&i.type.name==="paragraph"&&i.content.size===0?(o=!1,l=r.start(1)):l=r.after(1);const c=e.tr;if(o){const f=e.schema.nodes.paragraph.create({},[e.schema.text("/")]);c.insert(l,f)}else{const f=e.schema.text("/");c.insert(l,f)}const d=l+1+(o?1:0);return c.setSelection(ue.create(c.doc,d)),n&&n(c),!0}}}}),h6={cs:{defaultAction:"Napsat /{query} do obsahu",defaultBlankAction:"Zavřít nabídku"},en:{defaultAction:"Type /{query} to content",defaultBlankAction:"Close menu"}};class A$ extends Ve.Component{constructor(e){super(e),this.state={selectedIndex:0}}onEscape(){this.props.command({title:"",normalizedTitle:"",icon:i1,key:"commandListEscape",command:({chain:e})=>{this.props.query&&e.insertContent(`/${this.props.query} `)}})}onKeyDown({event:e}){return e.key==="ArrowUp"?(this.upHandler(),!0):e.key==="ArrowDown"||e.key==="Tab"?(this.downHandler(),!0):e.key==="Enter"?(this.enterHandler(),!0):!1}setSelectedIndex(e){this.setState({selectedIndex:e})}upHandler(){let e=this.state.selectedIndex-1;if(e<0){let n=0;this.props.items.forEach(r=>{n+=r.commandsForSuggestion.length}),e=n-1}this.setSelectedIndex(e)}downHandler(){let e=0;this.props.items.forEach(r=>{e+=r.commandsForSuggestion.length});let n=this.state.selectedIndex+1;n>=e&&(n=0),this.setSelectedIndex(n)}enterHandler(){let e=-1,n=null;this.props.items.forEach(r=>{n||r.commandsForSuggestion.forEach(i=>{n||(e+=1,e===this.state.selectedIndex&&(n=i))})}),n&&this.selectItem(n)}selectItem(e){e&&this.props.command(e)}componentDidUpdate(e){let n=0;e.items.forEach(i=>{n+=i.commandsForSuggestion.length});let r=0;this.props.items.forEach(i=>{r+=i.commandsForSuggestion.length}),r!==n&&this.setState({selectedIndex:0})}render(){let e=-1;return S.jsxs("div",{className:"f-tiptap-commands-list",children:[this.props.items.length>0?S.jsx("div",{className:"f-tiptap-commands-list__section f-tiptap-commands-list__section--scroll",children:this.props.items.map(n=>S.jsxs(Ve.Fragment,{children:[S.jsx("div",{className:"f-tiptap-commands-list__section-heading",children:n.title}),S.jsx("ul",{className:"f-tiptap-commands-list__section-ul",children:n.commandsForSuggestion.map(r=>{e+=1;const i=r.icon,o=e;return S.jsx("li",{className:"f-tiptap-commands-list__section-li",children:S.jsx("button",{type:"button",className:"f-tiptap-commands-list__item f-tiptap-commands-list__item--active","data-selected":String(e===this.state.selectedIndex),onClick:()=>this.selectItem(r),onMouseOver:()=>this.setSelectedIndex(o),children:S.jsxs("span",{className:"f-tiptap-commands-list__item-inner",children:[i?S.jsx(i,{className:"f-tiptap-commands-list__item-icon"}):null,S.jsx("span",{className:"f-tiptap-commands-list__item-label",children:r.title}),S.jsx("span",{className:"f-tiptap-commands-list__item-keymap","data-keymap":r.keymap})]})})},`${n.title}-${r.title}`)})})]},n.title))}):null,S.jsx("div",{className:"f-tiptap-commands-list__section f-tiptap-commands-list__section--fallback",children:S.jsx("ul",{className:"f-tiptap-commands-list__section-ul",children:S.jsx("li",{className:"f-tiptap-commands-list__section-li",children:S.jsx("span",{className:"f-tiptap-commands-list__item f-tiptap-commands-list__item--fallback",children:S.jsxs("span",{className:"f-tiptap-commands-list__item-inner",children:[S.jsx("span",{className:"f-tiptap-commands-list__item-label",children:this.props.query?pe(h6,"defaultAction").replace("{query}",this.props.query):pe(h6,"defaultBlankAction")}),S.jsx("span",{className:"f-tiptap-commands-list__item-keymap",children:"esc"})]})})})})})]})}}class N$ extends Ve.Component{close(){console.log("close"),this.props.command({title:"",normalizedTitle:"",icon:i1,key:"commandListBackdrop",command:({chain:e})=>{console.log("commandListBackdrop",this.props.query),this.props.query&&(console.log("insertContent"),e.insertContent(" "))}})}render(){return S.jsx("div",{className:"f-tiptap-commands-list-backdrop",onClick:()=>this.close()})}}const GT=t=>t.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase(),YT=t=>({query:e})=>{const n=GT(e);return R$(t).map(r=>{const i=r.commandsForSuggestion.filter(o=>o.normalizedTitle.indexOf(n)!==-1);return i.length>0?{...r,commandsForSuggestion:i}:null}).filter(r=>r!==null)},R$=t=>{const e=document.documentElement.lang;return t.map(n=>{let r;return typeof n.title=="string"?r=n.title:r=n.title[e]||n.title.en,{title:r,key:n.key,commandsForSuggestion:n.commands.map(i=>{let o;return typeof i.title=="string"?o=i.title:o=i.title[e]||i.title.en,{...i,title:o,normalizedTitle:GT(o)}})}})},WT={allowSpaces:!1,render:()=>{let t=null,e=null;function n(r,i){if(!t||!t.element)return;const o={getBoundingClientRect(){return r}};let l="bottom-start";i==="update"&&t&&t.element&&t.element.dataset.placement&&(l=t.element.dataset.placement),ju(o,t.element,{placement:l,middleware:[Kp(),Zp(12),Gp({apply({availableWidth:c,availableHeight:d}){Object.assign(t.element.style,{maxWidth:`${Math.max(0,c)}px`,maxHeight:`${Math.max(0,d)}px`,pointerEvents:"none"})}})]}).then(c=>{t.element.dataset.placement=c.placement,Object.assign(t.element.style,{left:`${c.x}px`,top:`${c.y}px`,zIndex:"11",position:c.strategy==="fixed"?"fixed":"absolute",display:"flex",flexDirection:"column"}),Object.assign(e.element.style,{inset:0,position:c.strategy==="fixed"?"fixed":"absolute",zIndex:"10"})})}return{onStart:r=>{r.editor.chain().setMeta("hideDragHandle",!0).setMeta("lockDragHandle",!0).run(),e=new x2(N$,{props:{...r,query:r.query},editor:r.editor}),document.body.appendChild(e.element),t=new x2(A$,{props:{...r,query:r.query},editor:r.editor}),document.body.appendChild(t.element),n(r.clientRect(),"start")},onUpdate(r){t?.updateProps(r),n(r.clientRect(),"update")},onKeyDown(r){return r.event.key==="Escape"?(t?.ref&&typeof t.ref.onEscape=="function"&&t.ref.onEscape(),e?.element&&(e.element.remove(),e.destroy()),t?.element&&(t.element.remove(),t.destroy()),!0):t?.ref?.onKeyDown(r)},onExit(r){r.editor.chain().setMeta("hideDragHandle",!1).setMeta("lockDragHandle",!1).run(),t&&(e&&(e.element&&document.body.contains(e.element)&&document.body.removeChild(e.element),e.destroy()),t.element&&document.body.contains(t.element)&&document.body.removeChild(t.element),t.destroy())}}}},O$=({textStylesCommandGroup:t})=>({...WT,items:YT([t,F3])}),Fr=()=>new Map,J2=t=>{const e=Fr();return t.forEach((n,r)=>{e.set(r,n)}),e},to=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},D$=(t,e)=>{const n=[];for(const[r,i]of t)n.push(e(i,r));return n},L$=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},Qs=()=>new Set,j0=t=>t[t.length-1],_$=(t,e)=>{for(let n=0;n{for(let n=0;n{for(let n=0;n{const n=new Array(t);for(let r=0;r{this.off(e,r),n(...i)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return el((this._observers.get(e)||Fr()).values()).forEach(r=>r(...n))}destroy(){this._observers=Fr()}}const Zr=Math.floor,Jf=Math.abs,Ea=(t,e)=>tt>e?t:e,XT=t=>t!==0?t<0:1/t<0,p6=1,m6=2,V0=4,U0=8,bu=32,Gi=64,Dn=128,I$=1<<29,s1=31,X2=63,Ps=127,z$=2147483647,rp=Number.MAX_SAFE_INTEGER,g6=Number.MIN_SAFE_INTEGER,B$=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&Zr(t)===t),QT=String.fromCharCode,j$=t=>t.toLowerCase(),V$=/^\s*/g,U$=t=>t.replace(V$,""),P$=/([A-Z])/g,y6=(t,e)=>U$(t.replace(P$,n=>`${e}${j$(n)}`)),F$=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let i=0;iCu.encode(t),q$=Cu?$$:F$;let ru=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});ru&&ru.decode(new Uint8Array).length===1&&(ru=null);const Z$=(t,e)=>H$(e,()=>t).join("");class $u{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const qu=()=>new $u,K$=t=>{const e=qu();return t(e),Ur(e)},G$=t=>{let e=t.cpos;for(let n=0;n{const e=new Uint8Array(G$(t));let n=0;for(let r=0;r{const n=t.cbuf.length;n-t.cpos{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},Q2=Xt,Pe=(t,e)=>{for(;e>Ps;)Xt(t,Dn|Ps&e),e=Zr(e/128);Xt(t,Ps&e)},Z3=(t,e)=>{const n=XT(e);for(n&&(e=-e),Xt(t,(e>X2?Dn:0)|(n?Gi:0)|X2&e),e=Zr(e/64);e>0;)Xt(t,(e>Ps?Dn:0)|Ps&e),e=Zr(e/128)},ey=new Uint8Array(3e4),W$=ey.length/3,J$=(t,e)=>{if(e.length{const n=unescape(encodeURIComponent(e)),r=n.length;Pe(t,r);for(let i=0;i{const n=t.cbuf.length,r=t.cpos,i=Ea(n-r,e.length),o=e.length-i;t.cbuf.set(e.subarray(0,i),r),t.cpos+=i,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(Qo(n*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o)},sr=(t,e)=>{Pe(t,e.byteLength),l1(t,e)},K3=(t,e)=>{Y$(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},Q$=(t,e)=>K3(t,4).setFloat32(0,e,!1),eq=(t,e)=>K3(t,8).setFloat64(0,e,!1),tq=(t,e)=>K3(t,8).setBigInt64(0,e,!1),v6=new DataView(new ArrayBuffer(4)),nq=t=>(v6.setFloat32(0,t),v6.getFloat32(0)===t),Ma=(t,e)=>{switch(typeof e){case"string":Xt(t,119),ca(t,e);break;case"number":B$(e)&&Jf(e)<=z$?(Xt(t,125),Z3(t,e)):nq(e)?(Xt(t,124),Q$(t,e)):(Xt(t,123),eq(t,e));break;case"bigint":Xt(t,122),tq(t,e);break;case"object":if(e===null)Xt(t,126);else if(ka(e)){Xt(t,117),Pe(t,e.length);for(let n=0;n0&&Pe(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const C6=t=>{t.count>0&&(Z3(t.encoder,t.count===1?t.s:-t.s),t.count>1&&Pe(t.encoder,t.count-2))};class Xf{constructor(){this.encoder=new $u,this.s=0,this.count=0}write(e){this.s===e?this.count++:(C6(this),this.count=1,this.s=e)}toUint8Array(){return C6(this),Ur(this.encoder)}}const w6=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);Z3(t.encoder,e),t.count>1&&Pe(t.encoder,t.count-2)}};class P0{constructor(){this.encoder=new $u,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(w6(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return w6(this),Ur(this.encoder)}}class rq{constructor(){this.sarr=[],this.s="",this.lensE=new Xf}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new $u;return this.sarr.push(this.s),this.s="",ca(e,this.sarr.join("")),l1(e,this.lensE.toUint8Array()),Ur(e)}}const fi=t=>new Error(t),Nr=()=>{throw fi("Method unimplemented")},En=()=>{throw fi("Unexpected case")},ek=fi("Unexpected end of array"),tk=fi("Integer out of Range");class a1{constructor(e){this.arr=e,this.pos=0}}const G3=t=>new a1(t),iq=t=>t.pos!==t.arr.length,oq=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Sr=t=>oq(t,vt(t)),wu=t=>t.arr[t.pos++],vt=t=>{let e=0,n=1;const r=t.arr.length;for(;t.posrp)throw tk}throw ek},Y3=t=>{let e=t.arr[t.pos++],n=e&X2,r=64;const i=(e&Gi)>0?-1:1;if((e&Dn)===0)return i*n;const o=t.arr.length;for(;t.posrp)throw tk}throw ek},sq=t=>{let e=vt(t);if(e===0)return"";{let n=String.fromCodePoint(wu(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(wu(t));else for(;e>0;){const r=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(n))}},lq=t=>ru.decode(Sr(t)),ty=ru?lq:sq,W3=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},aq=t=>W3(t,4).getFloat32(0,!1),cq=t=>W3(t,8).getFloat64(0,!1),uq=t=>W3(t,8).getBigInt64(0,!1),dq=[t=>{},t=>null,Y3,aq,cq,uq,t=>!1,t=>!0,ty,t=>{const e=vt(t),n={};for(let r=0;r{const e=vt(t),n=[];for(let r=0;rdq[127-wu(t)](t);class x6 extends a1{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),iq(this)?this.count=vt(this)+1:this.count=-1),this.count--,this.s}}class Qf extends a1{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Y3(this);const e=XT(this.s);this.count=1,e&&(this.s=-this.s,this.count=vt(this)+2)}return this.count--,this.s}}class F0 extends a1{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=Y3(this),n=e&1;this.diff=Zr(e/2),this.count=1,n&&(this.count=vt(this)+2)}return this.s+=this.diff,this.count--,this.s}}class fq{constructor(e){this.decoder=new Qf(e),this.str=ty(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const hq=crypto.getRandomValues.bind(crypto),pq=Math.random,nk=()=>hq(new Uint32Array(1))[0],mq=t=>t[Zr(pq()*t.length)],gq="10000000-1000-4000-8000"+-1e11,yq=()=>gq.replace(/[018]/g,t=>(t^nk()&15>>t/4).toString(16)),vq=Date.now,S6=t=>new Promise(t);Promise.all.bind(Promise);const T6=t=>t===void 0?null:t;class bq{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let rk=new bq,Cq=!0;try{typeof localStorage<"u"&&localStorage&&(rk=localStorage,Cq=!1)}catch{}const wq=rk,xu=Symbol("Equality"),ik=(t,e)=>t===e||!!t?.[xu]?.(e)||!1,xq=t=>typeof t=="object",Sq=Object.assign,ok=Object.keys,Tq=(t,e)=>{for(const n in t)e(t[n],n)},op=t=>ok(t).length,kq=t=>{for(const e in t)return!1;return!0},Ha=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},J3=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Eq=(t,e)=>t===e||op(t)===op(e)&&Ha(t,(n,r)=>(n!==void 0||J3(e,r))&&ik(e[r],n)),Mq=Object.freeze,sk=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&sk(t[e])}return Mq(t)},X3=(t,e,n=0)=>{try{for(;n{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[xu]!=null)return t[xu](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;ne.includes(t);var lk={};const Aa=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",ak=typeof window<"u"&&typeof document<"u"&&!Aa;let ii;const Nq=()=>{if(ii===void 0)if(Aa){ii=Fr();const t=process.argv;let e=null;for(let n=0;n{if(t.length!==0){const[e,n]=t.split("=");ii.set(`--${y6(e,"-")}`,n),ii.set(`-${y6(e,"-")}`,n)}})):ii=Fr();return ii},ny=t=>Nq().has(t),sp=t=>T6(Aa?lk[t.toUpperCase().replaceAll("-","_")]:wq.getItem(t)),ck=t=>ny("--"+t)||sp(t)!==null,Rq=ck("production"),Oq=Aa&&Aq(lk.FORCE_COLOR,["true","1","2"]),Dq=Oq||!ny("--no-colors")&&!ck("no-color")&&(!Aa||process.stdout.isTTY)&&(!Aa||ny("--color")||sp("COLORTERM")!==null||(sp("TERM")||"").includes("color")),Lq=t=>{let e="";for(let n=0;nBuffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),Hq=ak?Lq:_q,Iq=t=>K$(e=>Ma(e,t));class zq{constructor(e,n){this.left=e,this.right=n}}const zi=(t,e)=>new zq(t,e),k6=t=>t.next()>=.5,$0=(t,e,n)=>Zr(t.next()*(n+1-e)+e),uk=(t,e,n)=>Zr(t.next()*(n+1-e)+e),Q3=(t,e,n)=>uk(t,e,n),Bq=t=>QT(Q3(t,97,122)),jq=(t,e=0,n=20)=>{const r=Q3(t,e,n);let i="";for(let o=0;oe[Q3(t,0,e.length-1)],Vq=Symbol("0schema");class Uq{constructor(){this._rerrs=[]}extend(e,n,r,i=null){this._rerrs.push({path:e,expected:n,has:r,message:i})}toString(){const e=[];for(let n=this._rerrs.length-1;n>0;n--){const r=this._rerrs[n];e.push(Z$(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(` `)}}const ry=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[xu]?ik(t,e):ka(t)?$3(t,n=>q3(e,r=>ry(n,r))):xq(t)?Ha(t,(n,r)=>ry(n,e[r])):!1;class An{extends(e){let[n,r]=[this.shape,e.shape];return this.constructor._dilutes&&([r,n]=[n,r]),ry(n,r)}equals(e){return this.constructor===e.constructor&&eh(this.shape,e.shape)}[Vq](){return!0}[xu](e){return this.equals(e)}validate(e){return this.check(e)}check(e,n){Nr()}get nullable(){return Ia(this,h1)}get optional(){return new hk(this)}cast(e){return E6(e,this),e}expect(e){return E6(e,this),e}}df(An,"_dilutes",!1);class ev extends An{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n=void 0){const r=e?.constructor===this.shape&&(this._c==null||this._c(e));return!r&&n?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?"Constructor match failed":"Check failed"),r}}const Zt=(t,e=null)=>new ev(t,e);Zt(ev);class tv extends An{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape(e);return!r&&n?.extend(null,"custom prop",e?.constructor.name,"failed to check custom prop"),r}}const on=t=>new tv(t);Zt(tv);class c1 extends An{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape.some(i=>i===e);return!r&&n?.extend(null,this.shape.join(" | "),e.toString()),r}}const u1=(...t)=>new c1(t),dk=Zt(c1),Pq=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),fk=t=>{if(Na.check(t))return[Pq(t)];if(dk.check(t))return t.shape.map(e=>e+"");if(xk.check(t))return["[+-]?\\d+.?\\d*"];if(Sk.check(t))return[".*"];if(ap.check(t))return t.shape.map(fk).flat(1);En()};class Fq extends An{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(fk).map(n=>`(${n.join("|")})`).join("")+"$")}check(e,n){const r=this._r.exec(e)!=null;return!r&&n?.extend(null,this._r.toString(),e.toString(),"String doesn't match string template."),r}}Zt(Fq);const $q=Symbol("optional");class hk extends An{constructor(e){super(),this.shape=e}check(e,n){const r=e===void 0||this.shape.check(e);return!r&&n?.extend(null,"undefined (optional)","()"),r}get[$q](){return!0}}const qq=Zt(hk);class Zq extends An{check(e,n){return n?.extend(null,"never",typeof e),!1}}Zt(Zq);const wp=class wp extends An{constructor(e,n=!1){super(),this.shape=e,this._isPartial=n}get partial(){return new wp(this.shape,!0)}check(e,n){return e==null?(n?.extend(null,"object","null"),!1):Ha(this.shape,(r,i)=>{const o=this._isPartial&&!J3(e,i)||r.check(e[i],n);return!o&&n?.extend(i.toString(),r.toString(),typeof e[i],"Object property does not match"),o})}};df(wp,"_dilutes",!0);let lp=wp;const Kq=t=>new lp(t),Gq=Zt(lp),Yq=on(t=>t!=null&&(t.constructor===Object||t.constructor==null));class pk extends An{constructor(e,n){super(),this.shape={keys:e,values:n}}check(e,n){return e!=null&&Ha(e,(r,i)=>{const o=this.shape.keys.check(i,n);return!o&&n?.extend(i+"","Record",typeof e,o?"Key doesn't match schema":"Value doesn't match value"),o&&this.shape.values.check(r,n)})}}const mk=(t,e)=>new pk(t,e),Wq=Zt(pk);class gk extends An{constructor(e){super(),this.shape=e}check(e,n){return e!=null&&Ha(this.shape,(r,i)=>{const o=r.check(e[i],n);return!o&&n?.extend(i.toString(),"Tuple",typeof r),o})}}const Jq=(...t)=>new gk(t);Zt(gk);class yk extends An{constructor(e){super(),this.shape=e.length===1?e[0]:new d1(e)}check(e,n){const r=ka(e)&&$3(e,i=>this.shape.check(i));return!r&&n?.extend(null,"Array",""),r}}const vk=(...t)=>new yk(t),Xq=Zt(yk),Qq=on(t=>ka(t));class bk extends An{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n){const r=e instanceof this.shape&&(this._c==null||this._c(e));return!r&&n?.extend(null,this.shape.name,e?.constructor.name),r}}const eZ=(t,e=null)=>new bk(t,e);Zt(bk);const tZ=eZ(An);class nZ extends An{constructor(e){super(),this.len=e.length-1,this.args=Jq(...e.slice(-1)),this.res=e[this.len]}check(e,n){const r=e.constructor===Function&&e.length<=this.len;return!r&&n?.extend(null,"function",typeof e),r}}const rZ=Zt(nZ),iZ=on(t=>typeof t=="function");class oZ extends An{constructor(e){super(),this.shape=e}check(e,n){const r=$3(this.shape,i=>i.check(e,n));return!r&&n?.extend(null,"Intersectinon",typeof e),r}}Zt(oZ,t=>t.shape.length>0);class d1 extends An{constructor(e){super(),this.shape=e}check(e,n){const r=q3(this.shape,i=>i.check(e,n));return n?.extend(null,"Union",typeof e),r}}df(d1,"_dilutes",!0);const Ia=(...t)=>t.findIndex(e=>ap.check(e))>=0?Ia(...t.map(e=>Su(e)).map(e=>ap.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new d1(t),ap=Zt(d1),Ck=()=>!0,cp=on(Ck),sZ=Zt(tv,t=>t.shape===Ck),nv=on(t=>typeof t=="bigint"),lZ=on(t=>t===nv),wk=on(t=>typeof t=="symbol");on(t=>t===wk);const ua=on(t=>typeof t=="number"),xk=on(t=>t===ua),Na=on(t=>typeof t=="string"),Sk=on(t=>t===Na),f1=on(t=>typeof t=="boolean"),aZ=on(t=>t===f1),Tk=u1(void 0);Zt(c1,t=>t.shape.length===1&&t.shape[0]===void 0);u1(void 0);const h1=u1(null),cZ=Zt(c1,t=>t.shape.length===1&&t.shape[0]===null);Zt(Uint8Array);Zt(ev,t=>t.shape===Uint8Array);const uZ=Ia(ua,Na,h1,Tk,nv,f1,wk);(()=>{const t=vk(cp),e=mk(Na,cp),n=Ia(ua,Na,h1,f1,t,e);return t.shape=n,e.shape.values=n,n})();const Su=t=>{if(tZ.check(t))return t;if(Yq.check(t)){const e={};for(const n in t)e[n]=Su(t[n]);return Kq(e)}else{if(Qq.check(t))return Ia(...t.map(Su));if(uZ.check(t))return u1(t);if(iZ.check(t))return Zt(t)}En()},E6=Rq?()=>{}:(t,e)=>{const n=new Uq;if(!e.check(t,n))throw fi(`Expected value to be of type ${e.constructor.name}. -${n.toString()}`)};class dZ{constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:Su(e),h:n}),this}else(e){return this.if(cp,e)}done(){return(e,n)=>{for(let r=0;rnew dZ(t),kk=fZ(cp).if(xk,(t,e)=>$0(e,g6,rp)).if(Sk,(t,e)=>jq(e)).if(aZ,(t,e)=>k6(e)).if(lZ,(t,e)=>BigInt($0(e,g6,rp))).if(ap,(t,e)=>Jl(e,q0(e,t.shape))).if(Gq,(t,e)=>{const n={};for(const r in t.shape){let i=t.shape[r];if(qq.check(i)){if(k6(e))continue;i=i.shape}n[r]=kk(i,e)}return n}).if(Xq,(t,e)=>{const n=[],r=uk(e,0,42);for(let i=0;iq0(e,t.shape)).if(cZ,(t,e)=>null).if(rZ,(t,e)=>{const n=Jl(e,t.res);return()=>n}).if(sZ,(t,e)=>Jl(e,q0(e,[ua,Na,h1,Tk,nv,f1,vk(ua),mk(Ia("a","b","c"),ua)]))).if(Wq,(t,e)=>{const n={},r=$0(e,0,3);for(let i=0;ikk(Su(e),t),Zu=typeof document<"u"?document:{};on(t=>t.nodeType===yZ);typeof DOMParser<"u"&&new DOMParser;on(t=>t.nodeType===pZ);on(t=>t.nodeType===mZ);const hZ=t=>D$(t,(e,n)=>`${n}:${e};`).join(""),pZ=Zu.ELEMENT_NODE,mZ=Zu.TEXT_NODE,gZ=Zu.DOCUMENT_NODE,yZ=Zu.DOCUMENT_FRAGMENT_NODE;on(t=>t.nodeType===gZ);const vZ=t=>class{constructor(n){this._=n}destroy(){t(this._)}},bZ=vZ(clearTimeout),Ek=(t,e)=>new bZ(setTimeout(e,t)),no=Symbol,Mk=no(),Ak=no(),CZ=no(),wZ=no(),xZ=no(),Nk=no(),SZ=no(),rv=no(),TZ=no(),kZ=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r0&&n.push(e.join(""));r{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[],r=Fr();let i=[],o=0;for(;o0||d.length>0?(e.push("%c"+l),n.push(d)):e.push(l)}else break}}for(o>0&&(i=n,i.unshift(e.join("")));o{console.log(...Rk(t)),Dk.forEach(e=>e.print(t))},Ok=(...t)=>{console.warn(...Rk(t)),t.unshift(rv),Dk.forEach(e=>e.print(t))},Dk=Qs(),Lk=t=>({[Symbol.iterator](){return this},next:t}),NZ=(t,e)=>Lk(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Z0=(t,e)=>Lk(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class iv{constructor(e,n){this.clock=e,this.len=n}}class za{constructor(){this.clients=new Map}}const es=(t,e,n)=>e.clients.forEach((r,i)=>{const o=t.doc.store.clients.get(i);if(o!=null){const l=o[o.length-1],c=l.id.clock+l.length;for(let d=0,f=r[d];d{let n=0,r=t.length-1;for(;n<=r;){const i=Zr((n+r)/2),o=t[i],l=o.clock;if(l<=e){if(e{const n=t.clients.get(e.client);return n!==void 0&&RZ(n,e.clock)!==null},ov=t=>{t.clients.forEach(e=>{e.sort((i,o)=>i.clock-o.clock);let n,r;for(n=1,r=1;n=o.clock?i.len=Qo(i.len,o.clock+o.len-i.clock):(r{const e=new za;for(let n=0;n{if(!e.clients.has(i)){const o=r.slice();for(let l=n+1;l{to(t.clients,e,()=>[]).push(new iv(n,r))},_k=()=>new za,OZ=t=>{const e=_k();return t.clients.forEach((n,r)=>{const i=[];for(let o=0;o0&&e.clients.set(r,i)}),e},sv=(t,e)=>{Ue(t.restEncoder,e.clients.size),el(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),Ue(t.restEncoder,n);const i=r.length;Ue(t.restEncoder,i);for(let o=0;o{const e=new za,n=vt(t.restDecoder);for(let r=0;r0){const l=to(e.clients,i,()=>[]);for(let c=0;c{const r=new za,i=vt(t.restDecoder);for(let o=0;o0){const o=new p1;return Ue(o.restEncoder,0),sv(o,r),o.toUint8Array()}return null},Hk=nk;class sl extends JT{constructor({guid:e=yq(),collectionid:n=null,gc:r=!0,gcFilter:i=()=>!0,meta:o=null,autoLoad:l=!1,shouldLoad:c=!0}={}){super(),this.gc=r,this.gcFilter=i,this.clientID=Hk(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new jk,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=l,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=S6(f=>{this.on("load",()=>{this.isLoaded=!0,f(this)})});const d=()=>S6(f=>{const h=m=>{(m===void 0||m===!0)&&(this.off("sync",h),f())};this.on("sync",h)});this.on("sync",f=>{f===!1&&this.isSynced&&(this.whenSynced=d()),this.isSynced=f===void 0||f===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=d()}load(){const e=this._item;e!==null&&!this.shouldLoad&&ct(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(el(this.subdocs).map(e=>e.guid))}transact(e,n=null){return ct(this,e,n)}get(e,n=rn){const r=to(this.share,e,()=>{const o=new n;return o._integrate(this,null),o}),i=r.constructor;if(n!==rn&&i!==n)if(i===rn){const o=new n;o._map=r._map,r._map.forEach(l=>{for(;l!==null;l=l.left)l.parent=o}),o._start=r._start;for(let l=o._start;l!==null;l=l.right)l.parent=o;return o._length=r._length,this.share.set(e,o),o._integrate(this,null),o}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,ha)}getText(e=""){return this.get(e,ts)}getMap(e=""){return this.get(e,Ra)}getXmlElement(e=""){return this.get(e,xn)}getXmlFragment(e=""){return this.get(e,tl)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,el(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new sl({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,ct(e.parent.doc,r=>{const i=n.doc;e.deleted||r.subdocsAdded.add(i),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class LZ{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=vt(this.restDecoder),this.dsCurrVal}readDsLen(){const e=vt(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class up extends LZ{constructor(e){super(e),this.keys=[],vt(e),this.keyClockDecoder=new F0(Sr(e)),this.clientDecoder=new Qf(Sr(e)),this.leftClockDecoder=new F0(Sr(e)),this.rightClockDecoder=new F0(Sr(e)),this.infoDecoder=new x6(Sr(e),wu),this.stringDecoder=new fq(Sr(e)),this.parentInfoDecoder=new x6(Sr(e),wu),this.typeRefDecoder=new Qf(Sr(e)),this.lenDecoder=new Qf(Sr(e))}readLeftID(){return new da(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new da(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return ip(this.restDecoder)}readBuf(){return Sr(this.restDecoder)}readJSON(){return ip(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e{r=Qo(r,e[0].id.clock);const i=Kr(e,r);Ue(t.restEncoder,e.length-i),t.writeClient(n),Ue(t.restEncoder,r);const o=e[i];o.write(t,r-o.id.clock);for(let l=i+1;l{const r=new Map;n.forEach((i,o)=>{It(e,o)>i&&r.set(o,i)}),m1(e).forEach((i,o)=>{n.has(o)||r.set(o,0)}),Ue(t.restEncoder,r.size),el(r.entries()).sort((i,o)=>o[0]-i[0]).forEach(([i,o])=>{zZ(t,e.clients.get(i),i,o)})},BZ=(t,e)=>{const n=Fr(),r=vt(t.restDecoder);for(let i=0;i{const r=[];let i=el(n.keys()).sort((y,C)=>y-C);if(i.length===0)return null;const o=()=>{if(i.length===0)return null;let y=n.get(i[i.length-1]);for(;y.refs.length===y.i;)if(i.pop(),i.length>0)y=n.get(i[i.length-1]);else return null;return y};let l=o();if(l===null)return null;const c=new jk,d=new Map,f=(y,C)=>{const w=d.get(y);(w==null||w>C)&&d.set(y,C)};let h=l.refs[l.i++];const m=new Map,g=()=>{for(const y of r){const C=y.id.client,w=n.get(C);w?(w.i--,c.clients.set(C,w.refs.slice(w.i)),n.delete(C),w.i=0,w.refs=[]):c.clients.set(C,[y]),i=i.filter(x=>x!==C)}r.length=0};for(;;){if(h.constructor!==Br){const C=to(m,h.id.client,()=>It(e,h.id.client))-h.id.clock;if(C<0)r.push(h),f(h.id.client,h.id.clock-1),g();else{const w=h.getMissing(t,e);if(w!==null){r.push(h);const x=n.get(w)||{refs:[],i:0};if(x.refs.length===x.i)f(w,It(e,w)),g();else{h=x.refs[x.i++];continue}}else(C===0||C0)h=r.pop();else if(l!==null&&l.i0){const y=new p1;return Ik(y,c,new Map),Ue(y.restEncoder,0),{missing:d,update:y.toUint8Array()}}return null},VZ=(t,e)=>Ik(t,e.doc.store,e.beforeState),UZ=(t,e,n,r=new up(t))=>ct(e,i=>{i.local=!1;let o=!1;const l=i.doc,c=l.store,d=BZ(r,l),f=jZ(i,c,d),h=c.pendingStructs;if(h){for(const[g,y]of h.missing)if(yy)&&h.missing.set(g,y)}h.update=I6([h.update,f.update])}}else c.pendingStructs=f;const m=M6(r,i,c);if(c.pendingDs){const g=new up(G3(c.pendingDs));vt(g.restDecoder);const y=M6(g,i,c);m&&y?c.pendingDs=I6([m,y]):c.pendingDs=m||y}else c.pendingDs=m;if(o){const g=c.pendingStructs.update;c.pendingStructs=null,oy(i.doc,g)}},n,!1),oy=(t,e,n,r=up)=>{const i=G3(e);UZ(i,t,n,new r(i))};class PZ{constructor(){this.l=[]}}const A6=()=>new PZ,N6=(t,e)=>t.l.push(e),R6=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(i=>e!==i),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},zk=(t,e,n)=>X3(t.l,[e,n]);class da{constructor(e,n){this.client=e,this.clock=n}}const _f=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,De=(t,e)=>new da(t,e),ku=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw En()},Eu=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class dp{constructor(e,n,r,i=0){this.type=e,this.tname=n,this.item=r,this.assoc=i}}class FZ{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const $Z=(t,e,n=0)=>new FZ(t,e,n),Hf=(t,e,n)=>{let r=null,i=null;return t._item===null?i=ku(t):r=De(t._item.id.client,t._item.id.clock),new dp(r,i,e,n)},K0=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return Hf(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Hf(t,De(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return Hf(t,r.lastId,n);r=r.right}return Hf(t,null,n)},qZ=(t,e)=>{const n=fa(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},ZZ=(t,e,n=!0)=>{const r=e.store,i=t.item,o=t.type,l=t.tname,c=t.assoc;let d=null,f=0;if(i!==null){if(It(r,i.client)<=i.clock)return null;const h=n?cy(r,i):qZ(r,i),m=h.item;if(!(m instanceof et))return null;if(d=m.parent,d._item===null||!d._item.deleted){f=m.deleted||!m.countable?0:h.diff+(c>=0?0:1);let g=m.left;for(;g!==null;)!g.deleted&&g.countable&&(f+=g.length),g=g.left}}else{if(l!==null)d=e.get(l);else if(o!==null){if(It(r,o.client)<=o.clock)return null;const{item:h}=n?cy(r,o):{item:fa(r,o)};if(h instanceof et&&h.content instanceof Wr)d=h.content.type;else return null}else throw En();c>=0?f=d._length:f=0}return $Z(d,f,t.assoc)};class lv{constructor(e,n){this.ds=e,this.sv=n}}const Bk=(t,e)=>new lv(t,e),G0=t=>Bk(OZ(t.store),m1(t.store)),Ds=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Ba(e.ds,t.id),sy=(t,e)=>{const n=to(t.meta,sy,Qs),r=t.doc.store;n.has(e)||(e.sv.forEach((i,o)=>{i{}),n.add(e))};class jk{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const m1=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const i=n[n.length-1];e.set(r,i.id.clock+i.length)}),e},It=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},Vk=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw En()}n.push(e)},Kr=(t,e)=>{let n=0,r=t.length-1,i=t[r],o=i.id.clock;if(o===e)return r;let l=Zr(e/(o+i.length-1)*r);for(;n<=r;){if(i=t[l],o=i.id.clock,o<=e){if(e{const n=t.clients.get(e.client);return n[Kr(n,e.clock)]},fa=KZ,ly=(t,e,n)=>{const r=Kr(e,n),i=e[r];return i.id.clock{const n=t.doc.store.clients.get(e.client);return n[ly(t,n,e.clock)]},O6=(t,e,n)=>{const r=e.clients.get(n.client),i=Kr(r,n.clock),o=r[i];return n.clock!==o.id.clock+o.length-1&&o.constructor!==Er&&r.splice(i+1,0,gp(t,o,n.clock-o.id.clock+1)),o},GZ=(t,e,n)=>{const r=t.clients.get(e.id.client);r[Kr(r,e.id.clock)]=n},Uk=(t,e,n,r,i)=>{if(r===0)return;const o=n+r;let l=ly(t,e,n),c;do c=e[l++],oe.deleteSet.clients.size===0&&!L$(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(ov(e.deleteSet),VZ(t,e),sv(t,e.deleteSet),!0),L6=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&to(t.changed,e,Qs).add(n)},th=(t,e)=>{let n=t[e],r=t[e-1],i=e;for(;i>0;n=r,r=t[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof et&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const o=e-i;return o&&t.splice(e+1-o,o),o},WZ=(t,e,n)=>{for(const[r,i]of t.clients.entries()){const o=e.clients.get(r);for(let l=i.length-1;l>=0;l--){const c=i[l],d=c.clock+c.len;for(let f=Kr(o,c.clock),h=o[f];f{t.clients.forEach((n,r)=>{const i=e.clients.get(r);for(let o=n.length-1;o>=0;o--){const l=n[o],c=Ea(i.length-1,1+Kr(i,l.clock+l.len-1));for(let d=c,f=i[d];d>0&&f.id.clock>=l.clock;f=i[d])d-=1+th(i,d)}})},Pk=(t,e)=>{if(ec.push(()=>{(f._item===null||!f._item.deleted)&&f._callObserver(n,d)})),c.push(()=>{n.changedParentTypes.forEach((d,f)=>{f._dEH.l.length>0&&(f._item===null||!f._item.deleted)&&(d=d.filter(h=>h.target._item===null||!h.target._item.deleted),d.forEach(h=>{h.currentTarget=f,h._path=null}),d.sort((h,m)=>h.path.length-m.path.length),c.push(()=>{zk(f._dEH,d,n)}))}),c.push(()=>r.emit("afterTransaction",[n,r])),c.push(()=>{n._needFormattingCleanup&&yK(n)})}),X3(c,[])}finally{r.gc&&WZ(o,i,r.gcFilter),JZ(o,i),n.afterState.forEach((h,m)=>{const g=n.beforeState.get(m)||0;if(g!==h){const y=i.clients.get(m),C=Qo(Kr(y,g),1);for(let w=y.length-1;w>=C;)w-=1+th(y,w)}});for(let h=l.length-1;h>=0;h--){const{client:m,clock:g}=l[h].id,y=i.clients.get(m),C=Kr(y,g);C+11||C>0&&th(y,C)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(AZ(rv,Mk,"[yjs] ",Ak,Nk,"Changed the client-id because another client seems to be using it."),r.clientID=Hk()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const h=new HZ;D6(h,n)&&r.emit("update",[h.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const h=new p1;D6(h,n)&&r.emit("updateV2",[h.toUint8Array(),n.origin,r,n])}const{subdocsAdded:c,subdocsLoaded:d,subdocsRemoved:f}=n;(c.size>0||f.size>0||d.size>0)&&(c.forEach(h=>{h.clientID=r.clientID,h.collectionid==null&&(h.collectionid=r.collectionid),r.subdocs.add(h)}),f.forEach(h=>r.subdocs.delete(h)),r.emit("subdocs",[{loaded:d,added:c,removed:f},r,n]),f.forEach(h=>h.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):Pk(t,e+1)}}},ct=(t,e,n=null,r=!0)=>{const i=t._transactionCleanups;let o=!1,l=null;t._transaction===null&&(o=!0,t._transaction=new YZ(t,n,r),i.push(t._transaction),i.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{l=e(t._transaction)}finally{if(o){const c=t._transaction===i[0];t._transaction=null,c&&Pk(i,0)}}return l};class XZ{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const _6=(t,e,n)=>{es(t,n.deletions,r=>{r instanceof et&&e.scope.some(i=>i===t.doc||Eu(i,r))&&fv(r,!1)})},H6=(t,e,n)=>{let r=null;const i=t.doc,o=t.scope;ct(i,c=>{for(;e.length>0&&t.currStackItem===null;){const d=i.store,f=e.pop(),h=new Set,m=[];let g=!1;es(c,f.insertions,y=>{if(y instanceof et){if(y.redone!==null){let{item:C,diff:w}=cy(d,y.id);w>0&&(C=Kn(c,De(C.id.client,C.id.clock+w))),y=C}!y.deleted&&o.some(C=>C===c.doc||Eu(C,y))&&m.push(y)}}),es(c,f.deletions,y=>{y instanceof et&&o.some(C=>C===c.doc||Eu(C,y))&&!Ba(f.insertions,y.id)&&h.add(y)}),h.forEach(y=>{g=aE(c,y,h,f.insertions,t.ignoreRemoteMapChanges,t)!==null||g});for(let y=m.length-1;y>=0;y--){const C=m[y];t.deleteFilter(C)&&(C.delete(c),g=!0)}t.currStackItem=g?f:null}c.changed.forEach((d,f)=>{d.has(null)&&f._searchMarker&&(f._searchMarker.length=0)}),r=c},t);const l=t.currStackItem;if(l!=null){const c=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:l,type:n,changedParentTypes:c,origin:t},t]),t.currStackItem=null}return l};class Fk extends JT{constructor(e,{captureTimeout:n=500,captureTransaction:r=d=>!0,deleteFilter:i=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:l=!1,doc:c=ka(e)?e[0].doc:e instanceof sl?e:e.doc}={}){super(),this.scope=[],this.doc=c,this.addToScope(e),this.deleteFilter=i,o.add(this),this.trackedOrigins=o,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=l,this.captureTimeout=n,this.afterTransactionHandler=d=>{if(!this.captureTransaction(d)||!this.scope.some(x=>d.changedParentTypes.has(x)||x===this.doc)||!this.trackedOrigins.has(d.origin)&&(!d.origin||!this.trackedOrigins.has(d.origin.constructor)))return;const f=this.undoing,h=this.redoing,m=f?this.redoStack:this.undoStack;f?this.stopCapturing():h||this.clear(!1,!0);const g=new za;d.afterState.forEach((x,k)=>{const A=d.beforeState.get(k)||0,N=x-A;N>0&&Tu(g,k,A,N)});const y=vq();let C=!1;if(this.lastChange>0&&y-this.lastChange0&&!f&&!h){const x=m[m.length-1];x.deletions=iy([x.deletions,d.deleteSet]),x.insertions=iy([x.insertions,g])}else m.push(new XZ(d.deleteSet,g)),C=!0;!f&&!h&&(this.lastChange=y),es(d,d.deleteSet,x=>{x instanceof et&&this.scope.some(k=>k===d.doc||Eu(k,x))&&fv(x,!0)});const w=[{stackItem:m[m.length-1],origin:d.origin,type:f?"redo":"undo",changedParentTypes:d.changedParentTypes},this];C?this.emit("stack-item-added",w):this.emit("stack-item-updated",w)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const n=new Set(this.scope);e=ka(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof rn?r.doc!==this.doc:r!==this.doc)&&Ok("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(i=>_6(r,this,i)),this.undoStack=[]),n&&(this.redoStack.forEach(i=>_6(r,this,i)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=H6(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=H6(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*QZ(t){const e=vt(t.restDecoder);for(let n=0;n{if(t.constructor===Er){const{client:n,clock:r}=t.id;return new Er(De(n,r+e),t.length-e)}else if(t.constructor===Br){const{client:n,clock:r}=t.id;return new Br(De(n,r+e),t.length-e)}else{const n=t,{client:r,clock:i}=n.id;return new et(De(r,i+e),null,De(r,i+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},I6=(t,e=up,n=p1)=>{if(t.length===1)return t[0];const r=t.map(h=>new e(G3(h)));let i=r.map(h=>new eK(h,!0)),o=null;const l=new n,c=new tK(l);for(;i=i.filter(g=>g.curr!==null),i.sort((g,y)=>{if(g.curr.id.client===y.curr.id.client){const C=g.curr.id.clock-y.curr.id.clock;return C===0?g.curr.constructor===y.curr.constructor?0:g.curr.constructor===Br?1:-1:C}else return y.curr.id.client-g.curr.id.client}),i.length!==0;){const h=i[0],m=h.curr.id.client;if(o!==null){let g=h.curr,y=!1;for(;g!==null&&g.id.clock+g.length<=o.struct.id.clock+o.struct.length&&g.id.client>=o.struct.id.client;)g=h.next(),y=!0;if(g===null||g.id.client!==m||y&&g.id.clock>o.struct.id.clock+o.struct.length)continue;if(m!==o.struct.id.client)Bc(c,o.struct,o.offset),o={struct:g,offset:0},h.next();else if(o.struct.id.clock+o.struct.length0&&(o.struct.constructor===Br?o.struct.length-=C:g=nK(g,C)),o.struct.mergeWith(g)||(Bc(c,o.struct,o.offset),o={struct:g,offset:0},h.next())}}else o={struct:h.curr,offset:0},h.next();for(let g=h.curr;g!==null&&g.id.client===m&&g.id.clock===o.struct.id.clock+o.struct.length&&g.constructor!==Br;g=h.next())Bc(c,o.struct,o.offset),o={struct:g,offset:0}}o!==null&&(Bc(c,o.struct,o.offset),o=null),rK(c);const d=r.map(h=>DZ(h)),f=iy(d);return sv(l,f),l.toUint8Array()},$k=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:Ur(t.encoder.restEncoder)}),t.encoder.restEncoder=qu(),t.written=0)},Bc=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&$k(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),Ue(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},rK=t=>{$k(t);const e=t.encoder.restEncoder;Ue(e,t.clientStructs.length);for(let n=0;n{if(i!==null){const o=n._map.get(i);let l,c;if(this.adds(o)){let d=o.left;for(;d!==null&&this.adds(d);)d=d.left;if(this.deletes(o))if(d!==null&&this.deletes(d))l="delete",c=j0(d.content.getContent());else return;else d!==null&&this.deletes(d)?(l="update",c=j0(d.content.getContent())):(l="add",c=void 0)}else if(this.deletes(o))l="delete",c=j0(o.content.getContent());else return;e.set(i,{action:l,oldValue:c})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw fi(z6);const n=this.target,r=Qs(),i=Qs(),o=[];if(e={added:r,deleted:i,delta:o,keys:this.keys},this.transaction.changed.get(n).has(null)){let c=null;const d=()=>{c&&o.push(c)};for(let f=n._start;f!==null;f=f.right)f.deleted?this.deletes(f)&&!this.adds(f)&&((c===null||c.delete===void 0)&&(d(),c={delete:0}),c.delete+=f.length,i.add(f)):this.adds(f)?((c===null||c.insert===void 0)&&(d(),c={insert:[]}),c.insert=c.insert.concat(f.content.getContent()),r.add(f)):((c===null||c.retain===void 0)&&(d(),c={retain:0}),c.retain+=f.length);c!==null&&c.retain===void 0&&d()}this._changes=e}return e}}const iK=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,i=e._item.parent._start;for(;i!==e._item&&i!==null;)!i.deleted&&i.countable&&(r+=i.length),i=i.right;n.unshift(r)}e=e._item.parent}return n},Sn=()=>{Ok("Invalid access: Add Yjs type to a document before reading data.")},qk=80;let av=0;class oK{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=av++}}const sK=t=>{t.timestamp=av++},Zk=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=av++},lK=(t,e,n)=>{if(t.length>=qk){const r=t.reduce((i,o)=>i.timestamp{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((o,l)=>Jf(e-o.index)e;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&Jf(n.index-i){for(let r=t.length-1;r>=0;r--){const i=t[r];if(n>0){let o=i.p;for(o.marker=!1;o&&(o.deleted||!o.countable);)o=o.left,o&&!o.deleted&&o.countable&&(i.index-=o.length);if(o===null||o.marker===!0){t.splice(r,1);continue}i.p=o,o.marker=!0}(e0&&e===i.index)&&(i.index=Qo(e,i.index+n))}},v1=(t,e,n)=>{const r=t,i=e.changedParentTypes;for(;to(i,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;zk(r._eH,n,e)};class rn{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=A6(),this._dEH=A6(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw Nr()}clone(){throw Nr()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){N6(this._eH,e)}observeDeep(e){N6(this._dEH,e)}unobserve(e){R6(this._eH,e)}unobserveDeep(e){R6(this._dEH,e)}toJSON(){}}const Kk=(t,e,n)=>{t.doc??Sn(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const i=[];let o=t._start;for(;o!==null&&r>0;){if(o.countable&&!o.deleted){const l=o.content.getContent();if(l.length<=e)e-=l.length;else{for(let c=e;c0;c++)i.push(l[c]),r--;e=0}}o=o.right}return i},Gk=t=>{t.doc??Sn();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let i=0;i{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&Ds(r,e)){const i=r.content.getContent();for(let o=0;o{let n=0,r=t._start;for(t.doc??Sn();r!==null;){if(r.countable&&!r.deleted){const i=r.content.getContent();for(let o=0;o{const n=[];return Au(t,(r,i)=>{n.push(e(r,i,t))}),n},aK=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const i=n[r++];return n.length<=r&&(n=null),{done:!1,value:i}}}},Jk=(t,e)=>{t.doc??Sn();const n=y1(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e{let i=n;const o=t.doc,l=o.clientID,c=o.store,d=n===null?e._start:n.right;let f=[];const h=()=>{f.length>0&&(i=new et(De(l,It(c,l)),i,i&&i.lastId,d,d&&d.id,e,null,new nl(f)),i.integrate(t,0),f=[])};r.forEach(m=>{if(m===null)f.push(m);else switch(m.constructor){case Number:case Object:case Boolean:case Array:case String:f.push(m);break;default:switch(h(),m.constructor){case Uint8Array:case ArrayBuffer:i=new et(De(l,It(c,l)),i,i&&i.lastId,d,d&&d.id,e,null,new Ku(new Uint8Array(m))),i.integrate(t,0);break;case sl:i=new et(De(l,It(c,l)),i,i&&i.lastId,d,d&&d.id,e,null,new Gu(m)),i.integrate(t,0);break;default:if(m instanceof rn)i=new et(De(l,It(c,l)),i,i&&i.lastId,d,d&&d.id,e,null,new Wr(m)),i.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),h()},Xk=()=>fi("Length exceeded!"),Qk=(t,e,n,r)=>{if(n>e._length)throw Xk();if(n===0)return e._searchMarker&&Mu(e._searchMarker,n,r.length),fp(t,e,null,r);const i=n,o=y1(e,n);let l=e._start;for(o!==null&&(l=o.p,n-=o.index,n===0&&(l=l.prev,n+=l&&l.countable&&!l.deleted?l.length:0));l!==null;l=l.right)if(!l.deleted&&l.countable){if(n<=l.length){n{let i=(e._searchMarker||[]).reduce((o,l)=>l.index>o.index?l:o,{index:0,p:e._start}).p;if(i)for(;i.right;)i=i.right;return fp(t,e,i,n)},eE=(t,e,n,r)=>{if(r===0)return;const i=n,o=r,l=y1(e,n);let c=e._start;for(l!==null&&(c=l.p,n-=l.index);c!==null&&n>0;c=c.right)!c.deleted&&c.countable&&(n0&&c!==null;)c.deleted||(r0)throw Xk();e._searchMarker&&Mu(e._searchMarker,i,-o+r)},hp=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},cv=(t,e,n,r)=>{const i=e._map.get(n)||null,o=t.doc,l=o.clientID;let c;if(r==null)c=new nl([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new nl([r]);break;case Uint8Array:c=new Ku(r);break;case sl:c=new Gu(r);break;default:if(r instanceof rn)c=new Wr(r);else throw new Error("Unexpected content type")}new et(De(l,It(o.store,l)),i,i&&i.lastId,null,null,e,n,c).integrate(t,0)},uv=(t,e)=>{t.doc??Sn();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},tE=t=>{const e={};return t.doc??Sn(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},nE=(t,e)=>{t.doc??Sn();const n=t._map.get(e);return n!==void 0&&!n.deleted},uK=(t,e)=>{const n={};return t._map.forEach((r,i)=>{let o=r;for(;o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0));)o=o.left;o!==null&&Ds(o,e)&&(n[i]=o.content.getContent()[o.length-1])}),n},If=t=>(t.doc??Sn(),NZ(t._map.entries(),e=>!e[1].deleted));class dK extends g1{}class ha extends rn{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new ha;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ha}clone(){const e=new ha;return e.insert(0,this.toArray().map(n=>n instanceof rn?n.clone():n)),e}get length(){return this.doc??Sn(),this._length}_callObserver(e,n){super._callObserver(e,n),v1(this,e,new dK(this,e))}insert(e,n){this.doc!==null?ct(this.doc,r=>{Qk(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?ct(this.doc,n=>{cK(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?ct(this.doc,r=>{eE(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return Jk(this,e)}toArray(){return Gk(this)}slice(e=0,n=this.length){return Kk(this,e,n)}toJSON(){return this.map(e=>e instanceof rn?e.toJSON():e)}map(e){return Wk(this,e)}forEach(e){Au(this,e)}[Symbol.iterator](){return aK(this)}_write(e){e.writeTypeRef(IK)}}const fK=t=>new ha;class hK extends g1{constructor(e,n,r){super(e,n),this.keysChanged=r}}class Ra extends rn{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,i)=>{this.set(i,r)}),this._prelimContent=null}_copy(){return new Ra}clone(){const e=new Ra;return this.forEach((n,r)=>{e.set(r,n instanceof rn?n.clone():n)}),e}_callObserver(e,n){v1(this,e,new hK(this,e,n))}toJSON(){this.doc??Sn();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const i=n.content.getContent()[n.length-1];e[r]=i instanceof rn?i.toJSON():i}}),e}get size(){return[...If(this)].length}keys(){return Z0(If(this),e=>e[0])}values(){return Z0(If(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Z0(If(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Sn(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?ct(this.doc,n=>{hp(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?ct(this.doc,r=>{cv(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return uv(this,e)}has(e){return nE(this,e)}clear(){this.doc!==null?ct(this.doc,e=>{this.forEach(function(n,r,i){hp(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(zK)}}const pK=t=>new Ra,$o=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&Eq(t,e);class ay{constructor(e,n,r,i){this.left=e,this.right=n,this.index=r,this.currentAttributes=i}forward(){this.right===null&&En(),this.right.content.constructor===qt?this.right.deleted||ja(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}const B6=(t,e,n)=>{for(;e.right!==null&&n>0;)e.right.content.constructor===qt?e.right.deleted||ja(e.currentAttributes,e.right.content):e.right.deleted||(n{const i=new Map,o=r?y1(e,n):null;if(o){const l=new ay(o.p.left,o.p,o.index,i);return B6(t,l,n-o.index)}else{const l=new ay(null,e._start,0,i);return B6(t,l,n)}},rE=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===qt&&$o(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const i=t.doc,o=i.clientID;r.forEach((l,c)=>{const d=n.left,f=n.right,h=new et(De(o,It(i.store,o)),d,d&&d.lastId,f,f&&f.id,e,null,new qt(c,l));h.integrate(t,0),n.right=h,n.forward()})},ja=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},iE=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===qt&&$o(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},oE=(t,e,n,r)=>{const i=t.doc,o=i.clientID,l=new Map;for(const c in r){const d=r[c],f=n.currentAttributes.get(c)??null;if(!$o(f,d)){l.set(c,f);const{left:h,right:m}=n;n.right=new et(De(o,It(i.store,o)),h,h&&h.lastId,m,m&&m.id,e,null,new qt(c,d)),n.right.integrate(t,0),n.forward()}}return l},Y0=(t,e,n,r,i)=>{n.currentAttributes.forEach((g,y)=>{i[y]===void 0&&(i[y]=null)});const o=t.doc,l=o.clientID;iE(n,i);const c=oE(t,e,n,i),d=r.constructor===String?new Gr(r):r instanceof rn?new Wr(r):new ll(r);let{left:f,right:h,index:m}=n;e._searchMarker&&Mu(e._searchMarker,n.index,d.getLength()),h=new et(De(l,It(o.store,l)),f,f&&f.lastId,h,h&&h.id,e,null,d),h.integrate(t,0),n.right=h,n.index=m,n.forward(),rE(t,e,n,c)},j6=(t,e,n,r,i)=>{const o=t.doc,l=o.clientID;iE(n,i);const c=oE(t,e,n,i);e:for(;n.right!==null&&(r>0||c.size>0&&(n.right.deleted||n.right.content.constructor===qt));){if(!n.right.deleted)switch(n.right.content.constructor){case qt:{const{key:d,value:f}=n.right.content,h=i[d];if(h!==void 0){if($o(h,f))c.delete(d);else{if(r===0)break e;c.set(d,f)}n.right.delete(t)}else n.currentAttributes.set(d,f);break}default:r0){let d="";for(;r>0;r--)d+=` +${n.toString()}`)};class dZ{constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:Su(e),h:n}),this}else(e){return this.if(cp,e)}done(){return(e,n)=>{for(let r=0;rnew dZ(t),kk=fZ(cp).if(xk,(t,e)=>$0(e,g6,rp)).if(Sk,(t,e)=>jq(e)).if(aZ,(t,e)=>k6(e)).if(lZ,(t,e)=>BigInt($0(e,g6,rp))).if(ap,(t,e)=>Jl(e,q0(e,t.shape))).if(Gq,(t,e)=>{const n={};for(const r in t.shape){let i=t.shape[r];if(qq.check(i)){if(k6(e))continue;i=i.shape}n[r]=kk(i,e)}return n}).if(Xq,(t,e)=>{const n=[],r=uk(e,0,42);for(let i=0;iq0(e,t.shape)).if(cZ,(t,e)=>null).if(rZ,(t,e)=>{const n=Jl(e,t.res);return()=>n}).if(sZ,(t,e)=>Jl(e,q0(e,[ua,Na,h1,Tk,nv,f1,vk(ua),mk(Ia("a","b","c"),ua)]))).if(Wq,(t,e)=>{const n={},r=$0(e,0,3);for(let i=0;ikk(Su(e),t),Zu=typeof document<"u"?document:{};on(t=>t.nodeType===yZ);typeof DOMParser<"u"&&new DOMParser;on(t=>t.nodeType===pZ);on(t=>t.nodeType===mZ);const hZ=t=>D$(t,(e,n)=>`${n}:${e};`).join(""),pZ=Zu.ELEMENT_NODE,mZ=Zu.TEXT_NODE,gZ=Zu.DOCUMENT_NODE,yZ=Zu.DOCUMENT_FRAGMENT_NODE;on(t=>t.nodeType===gZ);const vZ=t=>class{constructor(n){this._=n}destroy(){t(this._)}},bZ=vZ(clearTimeout),Ek=(t,e)=>new bZ(setTimeout(e,t)),no=Symbol,Mk=no(),Ak=no(),CZ=no(),wZ=no(),xZ=no(),Nk=no(),SZ=no(),rv=no(),TZ=no(),kZ=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r0&&n.push(e.join(""));r{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[],r=Fr();let i=[],o=0;for(;o0||d.length>0?(e.push("%c"+l),n.push(d)):e.push(l)}else break}}for(o>0&&(i=n,i.unshift(e.join("")));o{console.log(...Rk(t)),Dk.forEach(e=>e.print(t))},Ok=(...t)=>{console.warn(...Rk(t)),t.unshift(rv),Dk.forEach(e=>e.print(t))},Dk=Qs(),Lk=t=>({[Symbol.iterator](){return this},next:t}),NZ=(t,e)=>Lk(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Z0=(t,e)=>Lk(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class iv{constructor(e,n){this.clock=e,this.len=n}}class za{constructor(){this.clients=new Map}}const es=(t,e,n)=>e.clients.forEach((r,i)=>{const o=t.doc.store.clients.get(i);if(o!=null){const l=o[o.length-1],c=l.id.clock+l.length;for(let d=0,f=r[d];d{let n=0,r=t.length-1;for(;n<=r;){const i=Zr((n+r)/2),o=t[i],l=o.clock;if(l<=e){if(e{const n=t.clients.get(e.client);return n!==void 0&&RZ(n,e.clock)!==null},ov=t=>{t.clients.forEach(e=>{e.sort((i,o)=>i.clock-o.clock);let n,r;for(n=1,r=1;n=o.clock?i.len=Qo(i.len,o.clock+o.len-i.clock):(r{const e=new za;for(let n=0;n{if(!e.clients.has(i)){const o=r.slice();for(let l=n+1;l{to(t.clients,e,()=>[]).push(new iv(n,r))},_k=()=>new za,OZ=t=>{const e=_k();return t.clients.forEach((n,r)=>{const i=[];for(let o=0;o0&&e.clients.set(r,i)}),e},sv=(t,e)=>{Pe(t.restEncoder,e.clients.size),el(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),Pe(t.restEncoder,n);const i=r.length;Pe(t.restEncoder,i);for(let o=0;o{const e=new za,n=vt(t.restDecoder);for(let r=0;r0){const l=to(e.clients,i,()=>[]);for(let c=0;c{const r=new za,i=vt(t.restDecoder);for(let o=0;o0){const o=new p1;return Pe(o.restEncoder,0),sv(o,r),o.toUint8Array()}return null},Hk=nk;class sl extends JT{constructor({guid:e=yq(),collectionid:n=null,gc:r=!0,gcFilter:i=()=>!0,meta:o=null,autoLoad:l=!1,shouldLoad:c=!0}={}){super(),this.gc=r,this.gcFilter=i,this.clientID=Hk(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new jk,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=l,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=S6(f=>{this.on("load",()=>{this.isLoaded=!0,f(this)})});const d=()=>S6(f=>{const h=m=>{(m===void 0||m===!0)&&(this.off("sync",h),f())};this.on("sync",h)});this.on("sync",f=>{f===!1&&this.isSynced&&(this.whenSynced=d()),this.isSynced=f===void 0||f===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=d()}load(){const e=this._item;e!==null&&!this.shouldLoad&&ct(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(el(this.subdocs).map(e=>e.guid))}transact(e,n=null){return ct(this,e,n)}get(e,n=rn){const r=to(this.share,e,()=>{const o=new n;return o._integrate(this,null),o}),i=r.constructor;if(n!==rn&&i!==n)if(i===rn){const o=new n;o._map=r._map,r._map.forEach(l=>{for(;l!==null;l=l.left)l.parent=o}),o._start=r._start;for(let l=o._start;l!==null;l=l.right)l.parent=o;return o._length=r._length,this.share.set(e,o),o._integrate(this,null),o}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,ha)}getText(e=""){return this.get(e,ts)}getMap(e=""){return this.get(e,Ra)}getXmlElement(e=""){return this.get(e,xn)}getXmlFragment(e=""){return this.get(e,tl)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,el(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new sl({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,ct(e.parent.doc,r=>{const i=n.doc;e.deleted||r.subdocsAdded.add(i),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class LZ{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=vt(this.restDecoder),this.dsCurrVal}readDsLen(){const e=vt(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class up extends LZ{constructor(e){super(e),this.keys=[],vt(e),this.keyClockDecoder=new F0(Sr(e)),this.clientDecoder=new Qf(Sr(e)),this.leftClockDecoder=new F0(Sr(e)),this.rightClockDecoder=new F0(Sr(e)),this.infoDecoder=new x6(Sr(e),wu),this.stringDecoder=new fq(Sr(e)),this.parentInfoDecoder=new x6(Sr(e),wu),this.typeRefDecoder=new Qf(Sr(e)),this.lenDecoder=new Qf(Sr(e))}readLeftID(){return new da(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new da(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return ip(this.restDecoder)}readBuf(){return Sr(this.restDecoder)}readJSON(){return ip(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e{r=Qo(r,e[0].id.clock);const i=Kr(e,r);Pe(t.restEncoder,e.length-i),t.writeClient(n),Pe(t.restEncoder,r);const o=e[i];o.write(t,r-o.id.clock);for(let l=i+1;l{const r=new Map;n.forEach((i,o)=>{It(e,o)>i&&r.set(o,i)}),m1(e).forEach((i,o)=>{n.has(o)||r.set(o,0)}),Pe(t.restEncoder,r.size),el(r.entries()).sort((i,o)=>o[0]-i[0]).forEach(([i,o])=>{zZ(t,e.clients.get(i),i,o)})},BZ=(t,e)=>{const n=Fr(),r=vt(t.restDecoder);for(let i=0;i{const r=[];let i=el(n.keys()).sort((y,C)=>y-C);if(i.length===0)return null;const o=()=>{if(i.length===0)return null;let y=n.get(i[i.length-1]);for(;y.refs.length===y.i;)if(i.pop(),i.length>0)y=n.get(i[i.length-1]);else return null;return y};let l=o();if(l===null)return null;const c=new jk,d=new Map,f=(y,C)=>{const w=d.get(y);(w==null||w>C)&&d.set(y,C)};let h=l.refs[l.i++];const m=new Map,g=()=>{for(const y of r){const C=y.id.client,w=n.get(C);w?(w.i--,c.clients.set(C,w.refs.slice(w.i)),n.delete(C),w.i=0,w.refs=[]):c.clients.set(C,[y]),i=i.filter(x=>x!==C)}r.length=0};for(;;){if(h.constructor!==Br){const C=to(m,h.id.client,()=>It(e,h.id.client))-h.id.clock;if(C<0)r.push(h),f(h.id.client,h.id.clock-1),g();else{const w=h.getMissing(t,e);if(w!==null){r.push(h);const x=n.get(w)||{refs:[],i:0};if(x.refs.length===x.i)f(w,It(e,w)),g();else{h=x.refs[x.i++];continue}}else(C===0||C0)h=r.pop();else if(l!==null&&l.i0){const y=new p1;return Ik(y,c,new Map),Pe(y.restEncoder,0),{missing:d,update:y.toUint8Array()}}return null},VZ=(t,e)=>Ik(t,e.doc.store,e.beforeState),UZ=(t,e,n,r=new up(t))=>ct(e,i=>{i.local=!1;let o=!1;const l=i.doc,c=l.store,d=BZ(r,l),f=jZ(i,c,d),h=c.pendingStructs;if(h){for(const[g,y]of h.missing)if(yy)&&h.missing.set(g,y)}h.update=I6([h.update,f.update])}}else c.pendingStructs=f;const m=M6(r,i,c);if(c.pendingDs){const g=new up(G3(c.pendingDs));vt(g.restDecoder);const y=M6(g,i,c);m&&y?c.pendingDs=I6([m,y]):c.pendingDs=m||y}else c.pendingDs=m;if(o){const g=c.pendingStructs.update;c.pendingStructs=null,oy(i.doc,g)}},n,!1),oy=(t,e,n,r=up)=>{const i=G3(e);UZ(i,t,n,new r(i))};class PZ{constructor(){this.l=[]}}const A6=()=>new PZ,N6=(t,e)=>t.l.push(e),R6=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(i=>e!==i),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},zk=(t,e,n)=>X3(t.l,[e,n]);class da{constructor(e,n){this.client=e,this.clock=n}}const _f=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,De=(t,e)=>new da(t,e),ku=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw En()},Eu=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class dp{constructor(e,n,r,i=0){this.type=e,this.tname=n,this.item=r,this.assoc=i}}class FZ{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const $Z=(t,e,n=0)=>new FZ(t,e,n),Hf=(t,e,n)=>{let r=null,i=null;return t._item===null?i=ku(t):r=De(t._item.id.client,t._item.id.clock),new dp(r,i,e,n)},K0=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return Hf(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Hf(t,De(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return Hf(t,r.lastId,n);r=r.right}return Hf(t,null,n)},qZ=(t,e)=>{const n=fa(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},ZZ=(t,e,n=!0)=>{const r=e.store,i=t.item,o=t.type,l=t.tname,c=t.assoc;let d=null,f=0;if(i!==null){if(It(r,i.client)<=i.clock)return null;const h=n?cy(r,i):qZ(r,i),m=h.item;if(!(m instanceof et))return null;if(d=m.parent,d._item===null||!d._item.deleted){f=m.deleted||!m.countable?0:h.diff+(c>=0?0:1);let g=m.left;for(;g!==null;)!g.deleted&&g.countable&&(f+=g.length),g=g.left}}else{if(l!==null)d=e.get(l);else if(o!==null){if(It(r,o.client)<=o.clock)return null;const{item:h}=n?cy(r,o):{item:fa(r,o)};if(h instanceof et&&h.content instanceof Wr)d=h.content.type;else return null}else throw En();c>=0?f=d._length:f=0}return $Z(d,f,t.assoc)};class lv{constructor(e,n){this.ds=e,this.sv=n}}const Bk=(t,e)=>new lv(t,e),G0=t=>Bk(OZ(t.store),m1(t.store)),Ds=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Ba(e.ds,t.id),sy=(t,e)=>{const n=to(t.meta,sy,Qs),r=t.doc.store;n.has(e)||(e.sv.forEach((i,o)=>{i{}),n.add(e))};class jk{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const m1=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const i=n[n.length-1];e.set(r,i.id.clock+i.length)}),e},It=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},Vk=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw En()}n.push(e)},Kr=(t,e)=>{let n=0,r=t.length-1,i=t[r],o=i.id.clock;if(o===e)return r;let l=Zr(e/(o+i.length-1)*r);for(;n<=r;){if(i=t[l],o=i.id.clock,o<=e){if(e{const n=t.clients.get(e.client);return n[Kr(n,e.clock)]},fa=KZ,ly=(t,e,n)=>{const r=Kr(e,n),i=e[r];return i.id.clock{const n=t.doc.store.clients.get(e.client);return n[ly(t,n,e.clock)]},O6=(t,e,n)=>{const r=e.clients.get(n.client),i=Kr(r,n.clock),o=r[i];return n.clock!==o.id.clock+o.length-1&&o.constructor!==Er&&r.splice(i+1,0,gp(t,o,n.clock-o.id.clock+1)),o},GZ=(t,e,n)=>{const r=t.clients.get(e.id.client);r[Kr(r,e.id.clock)]=n},Uk=(t,e,n,r,i)=>{if(r===0)return;const o=n+r;let l=ly(t,e,n),c;do c=e[l++],oe.deleteSet.clients.size===0&&!L$(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(ov(e.deleteSet),VZ(t,e),sv(t,e.deleteSet),!0),L6=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&to(t.changed,e,Qs).add(n)},th=(t,e)=>{let n=t[e],r=t[e-1],i=e;for(;i>0;n=r,r=t[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof et&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const o=e-i;return o&&t.splice(e+1-o,o),o},WZ=(t,e,n)=>{for(const[r,i]of t.clients.entries()){const o=e.clients.get(r);for(let l=i.length-1;l>=0;l--){const c=i[l],d=c.clock+c.len;for(let f=Kr(o,c.clock),h=o[f];f{t.clients.forEach((n,r)=>{const i=e.clients.get(r);for(let o=n.length-1;o>=0;o--){const l=n[o],c=Ea(i.length-1,1+Kr(i,l.clock+l.len-1));for(let d=c,f=i[d];d>0&&f.id.clock>=l.clock;f=i[d])d-=1+th(i,d)}})},Pk=(t,e)=>{if(ec.push(()=>{(f._item===null||!f._item.deleted)&&f._callObserver(n,d)})),c.push(()=>{n.changedParentTypes.forEach((d,f)=>{f._dEH.l.length>0&&(f._item===null||!f._item.deleted)&&(d=d.filter(h=>h.target._item===null||!h.target._item.deleted),d.forEach(h=>{h.currentTarget=f,h._path=null}),d.sort((h,m)=>h.path.length-m.path.length),c.push(()=>{zk(f._dEH,d,n)}))}),c.push(()=>r.emit("afterTransaction",[n,r])),c.push(()=>{n._needFormattingCleanup&&yK(n)})}),X3(c,[])}finally{r.gc&&WZ(o,i,r.gcFilter),JZ(o,i),n.afterState.forEach((h,m)=>{const g=n.beforeState.get(m)||0;if(g!==h){const y=i.clients.get(m),C=Qo(Kr(y,g),1);for(let w=y.length-1;w>=C;)w-=1+th(y,w)}});for(let h=l.length-1;h>=0;h--){const{client:m,clock:g}=l[h].id,y=i.clients.get(m),C=Kr(y,g);C+11||C>0&&th(y,C)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(AZ(rv,Mk,"[yjs] ",Ak,Nk,"Changed the client-id because another client seems to be using it."),r.clientID=Hk()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const h=new HZ;D6(h,n)&&r.emit("update",[h.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const h=new p1;D6(h,n)&&r.emit("updateV2",[h.toUint8Array(),n.origin,r,n])}const{subdocsAdded:c,subdocsLoaded:d,subdocsRemoved:f}=n;(c.size>0||f.size>0||d.size>0)&&(c.forEach(h=>{h.clientID=r.clientID,h.collectionid==null&&(h.collectionid=r.collectionid),r.subdocs.add(h)}),f.forEach(h=>r.subdocs.delete(h)),r.emit("subdocs",[{loaded:d,added:c,removed:f},r,n]),f.forEach(h=>h.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):Pk(t,e+1)}}},ct=(t,e,n=null,r=!0)=>{const i=t._transactionCleanups;let o=!1,l=null;t._transaction===null&&(o=!0,t._transaction=new YZ(t,n,r),i.push(t._transaction),i.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{l=e(t._transaction)}finally{if(o){const c=t._transaction===i[0];t._transaction=null,c&&Pk(i,0)}}return l};class XZ{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const _6=(t,e,n)=>{es(t,n.deletions,r=>{r instanceof et&&e.scope.some(i=>i===t.doc||Eu(i,r))&&fv(r,!1)})},H6=(t,e,n)=>{let r=null;const i=t.doc,o=t.scope;ct(i,c=>{for(;e.length>0&&t.currStackItem===null;){const d=i.store,f=e.pop(),h=new Set,m=[];let g=!1;es(c,f.insertions,y=>{if(y instanceof et){if(y.redone!==null){let{item:C,diff:w}=cy(d,y.id);w>0&&(C=Kn(c,De(C.id.client,C.id.clock+w))),y=C}!y.deleted&&o.some(C=>C===c.doc||Eu(C,y))&&m.push(y)}}),es(c,f.deletions,y=>{y instanceof et&&o.some(C=>C===c.doc||Eu(C,y))&&!Ba(f.insertions,y.id)&&h.add(y)}),h.forEach(y=>{g=aE(c,y,h,f.insertions,t.ignoreRemoteMapChanges,t)!==null||g});for(let y=m.length-1;y>=0;y--){const C=m[y];t.deleteFilter(C)&&(C.delete(c),g=!0)}t.currStackItem=g?f:null}c.changed.forEach((d,f)=>{d.has(null)&&f._searchMarker&&(f._searchMarker.length=0)}),r=c},t);const l=t.currStackItem;if(l!=null){const c=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:l,type:n,changedParentTypes:c,origin:t},t]),t.currStackItem=null}return l};class Fk extends JT{constructor(e,{captureTimeout:n=500,captureTransaction:r=d=>!0,deleteFilter:i=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:l=!1,doc:c=ka(e)?e[0].doc:e instanceof sl?e:e.doc}={}){super(),this.scope=[],this.doc=c,this.addToScope(e),this.deleteFilter=i,o.add(this),this.trackedOrigins=o,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=l,this.captureTimeout=n,this.afterTransactionHandler=d=>{if(!this.captureTransaction(d)||!this.scope.some(x=>d.changedParentTypes.has(x)||x===this.doc)||!this.trackedOrigins.has(d.origin)&&(!d.origin||!this.trackedOrigins.has(d.origin.constructor)))return;const f=this.undoing,h=this.redoing,m=f?this.redoStack:this.undoStack;f?this.stopCapturing():h||this.clear(!1,!0);const g=new za;d.afterState.forEach((x,k)=>{const A=d.beforeState.get(k)||0,N=x-A;N>0&&Tu(g,k,A,N)});const y=vq();let C=!1;if(this.lastChange>0&&y-this.lastChange0&&!f&&!h){const x=m[m.length-1];x.deletions=iy([x.deletions,d.deleteSet]),x.insertions=iy([x.insertions,g])}else m.push(new XZ(d.deleteSet,g)),C=!0;!f&&!h&&(this.lastChange=y),es(d,d.deleteSet,x=>{x instanceof et&&this.scope.some(k=>k===d.doc||Eu(k,x))&&fv(x,!0)});const w=[{stackItem:m[m.length-1],origin:d.origin,type:f?"redo":"undo",changedParentTypes:d.changedParentTypes},this];C?this.emit("stack-item-added",w):this.emit("stack-item-updated",w)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const n=new Set(this.scope);e=ka(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof rn?r.doc!==this.doc:r!==this.doc)&&Ok("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(i=>_6(r,this,i)),this.undoStack=[]),n&&(this.redoStack.forEach(i=>_6(r,this,i)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=H6(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=H6(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*QZ(t){const e=vt(t.restDecoder);for(let n=0;n{if(t.constructor===Er){const{client:n,clock:r}=t.id;return new Er(De(n,r+e),t.length-e)}else if(t.constructor===Br){const{client:n,clock:r}=t.id;return new Br(De(n,r+e),t.length-e)}else{const n=t,{client:r,clock:i}=n.id;return new et(De(r,i+e),null,De(r,i+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},I6=(t,e=up,n=p1)=>{if(t.length===1)return t[0];const r=t.map(h=>new e(G3(h)));let i=r.map(h=>new eK(h,!0)),o=null;const l=new n,c=new tK(l);for(;i=i.filter(g=>g.curr!==null),i.sort((g,y)=>{if(g.curr.id.client===y.curr.id.client){const C=g.curr.id.clock-y.curr.id.clock;return C===0?g.curr.constructor===y.curr.constructor?0:g.curr.constructor===Br?1:-1:C}else return y.curr.id.client-g.curr.id.client}),i.length!==0;){const h=i[0],m=h.curr.id.client;if(o!==null){let g=h.curr,y=!1;for(;g!==null&&g.id.clock+g.length<=o.struct.id.clock+o.struct.length&&g.id.client>=o.struct.id.client;)g=h.next(),y=!0;if(g===null||g.id.client!==m||y&&g.id.clock>o.struct.id.clock+o.struct.length)continue;if(m!==o.struct.id.client)Bc(c,o.struct,o.offset),o={struct:g,offset:0},h.next();else if(o.struct.id.clock+o.struct.length0&&(o.struct.constructor===Br?o.struct.length-=C:g=nK(g,C)),o.struct.mergeWith(g)||(Bc(c,o.struct,o.offset),o={struct:g,offset:0},h.next())}}else o={struct:h.curr,offset:0},h.next();for(let g=h.curr;g!==null&&g.id.client===m&&g.id.clock===o.struct.id.clock+o.struct.length&&g.constructor!==Br;g=h.next())Bc(c,o.struct,o.offset),o={struct:g,offset:0}}o!==null&&(Bc(c,o.struct,o.offset),o=null),rK(c);const d=r.map(h=>DZ(h)),f=iy(d);return sv(l,f),l.toUint8Array()},$k=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:Ur(t.encoder.restEncoder)}),t.encoder.restEncoder=qu(),t.written=0)},Bc=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&$k(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),Pe(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},rK=t=>{$k(t);const e=t.encoder.restEncoder;Pe(e,t.clientStructs.length);for(let n=0;n{if(i!==null){const o=n._map.get(i);let l,c;if(this.adds(o)){let d=o.left;for(;d!==null&&this.adds(d);)d=d.left;if(this.deletes(o))if(d!==null&&this.deletes(d))l="delete",c=j0(d.content.getContent());else return;else d!==null&&this.deletes(d)?(l="update",c=j0(d.content.getContent())):(l="add",c=void 0)}else if(this.deletes(o))l="delete",c=j0(o.content.getContent());else return;e.set(i,{action:l,oldValue:c})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw fi(z6);const n=this.target,r=Qs(),i=Qs(),o=[];if(e={added:r,deleted:i,delta:o,keys:this.keys},this.transaction.changed.get(n).has(null)){let c=null;const d=()=>{c&&o.push(c)};for(let f=n._start;f!==null;f=f.right)f.deleted?this.deletes(f)&&!this.adds(f)&&((c===null||c.delete===void 0)&&(d(),c={delete:0}),c.delete+=f.length,i.add(f)):this.adds(f)?((c===null||c.insert===void 0)&&(d(),c={insert:[]}),c.insert=c.insert.concat(f.content.getContent()),r.add(f)):((c===null||c.retain===void 0)&&(d(),c={retain:0}),c.retain+=f.length);c!==null&&c.retain===void 0&&d()}this._changes=e}return e}}const iK=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,i=e._item.parent._start;for(;i!==e._item&&i!==null;)!i.deleted&&i.countable&&(r+=i.length),i=i.right;n.unshift(r)}e=e._item.parent}return n},Sn=()=>{Ok("Invalid access: Add Yjs type to a document before reading data.")},qk=80;let av=0;class oK{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=av++}}const sK=t=>{t.timestamp=av++},Zk=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=av++},lK=(t,e,n)=>{if(t.length>=qk){const r=t.reduce((i,o)=>i.timestamp{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((o,l)=>Jf(e-o.index)e;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&Jf(n.index-i){for(let r=t.length-1;r>=0;r--){const i=t[r];if(n>0){let o=i.p;for(o.marker=!1;o&&(o.deleted||!o.countable);)o=o.left,o&&!o.deleted&&o.countable&&(i.index-=o.length);if(o===null||o.marker===!0){t.splice(r,1);continue}i.p=o,o.marker=!0}(e0&&e===i.index)&&(i.index=Qo(e,i.index+n))}},v1=(t,e,n)=>{const r=t,i=e.changedParentTypes;for(;to(i,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;zk(r._eH,n,e)};class rn{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=A6(),this._dEH=A6(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw Nr()}clone(){throw Nr()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){N6(this._eH,e)}observeDeep(e){N6(this._dEH,e)}unobserve(e){R6(this._eH,e)}unobserveDeep(e){R6(this._dEH,e)}toJSON(){}}const Kk=(t,e,n)=>{t.doc??Sn(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const i=[];let o=t._start;for(;o!==null&&r>0;){if(o.countable&&!o.deleted){const l=o.content.getContent();if(l.length<=e)e-=l.length;else{for(let c=e;c0;c++)i.push(l[c]),r--;e=0}}o=o.right}return i},Gk=t=>{t.doc??Sn();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let i=0;i{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&Ds(r,e)){const i=r.content.getContent();for(let o=0;o{let n=0,r=t._start;for(t.doc??Sn();r!==null;){if(r.countable&&!r.deleted){const i=r.content.getContent();for(let o=0;o{const n=[];return Au(t,(r,i)=>{n.push(e(r,i,t))}),n},aK=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const i=n[r++];return n.length<=r&&(n=null),{done:!1,value:i}}}},Jk=(t,e)=>{t.doc??Sn();const n=y1(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e{let i=n;const o=t.doc,l=o.clientID,c=o.store,d=n===null?e._start:n.right;let f=[];const h=()=>{f.length>0&&(i=new et(De(l,It(c,l)),i,i&&i.lastId,d,d&&d.id,e,null,new nl(f)),i.integrate(t,0),f=[])};r.forEach(m=>{if(m===null)f.push(m);else switch(m.constructor){case Number:case Object:case Boolean:case Array:case String:f.push(m);break;default:switch(h(),m.constructor){case Uint8Array:case ArrayBuffer:i=new et(De(l,It(c,l)),i,i&&i.lastId,d,d&&d.id,e,null,new Ku(new Uint8Array(m))),i.integrate(t,0);break;case sl:i=new et(De(l,It(c,l)),i,i&&i.lastId,d,d&&d.id,e,null,new Gu(m)),i.integrate(t,0);break;default:if(m instanceof rn)i=new et(De(l,It(c,l)),i,i&&i.lastId,d,d&&d.id,e,null,new Wr(m)),i.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),h()},Xk=()=>fi("Length exceeded!"),Qk=(t,e,n,r)=>{if(n>e._length)throw Xk();if(n===0)return e._searchMarker&&Mu(e._searchMarker,n,r.length),fp(t,e,null,r);const i=n,o=y1(e,n);let l=e._start;for(o!==null&&(l=o.p,n-=o.index,n===0&&(l=l.prev,n+=l&&l.countable&&!l.deleted?l.length:0));l!==null;l=l.right)if(!l.deleted&&l.countable){if(n<=l.length){n{let i=(e._searchMarker||[]).reduce((o,l)=>l.index>o.index?l:o,{index:0,p:e._start}).p;if(i)for(;i.right;)i=i.right;return fp(t,e,i,n)},eE=(t,e,n,r)=>{if(r===0)return;const i=n,o=r,l=y1(e,n);let c=e._start;for(l!==null&&(c=l.p,n-=l.index);c!==null&&n>0;c=c.right)!c.deleted&&c.countable&&(n0&&c!==null;)c.deleted||(r0)throw Xk();e._searchMarker&&Mu(e._searchMarker,i,-o+r)},hp=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},cv=(t,e,n,r)=>{const i=e._map.get(n)||null,o=t.doc,l=o.clientID;let c;if(r==null)c=new nl([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new nl([r]);break;case Uint8Array:c=new Ku(r);break;case sl:c=new Gu(r);break;default:if(r instanceof rn)c=new Wr(r);else throw new Error("Unexpected content type")}new et(De(l,It(o.store,l)),i,i&&i.lastId,null,null,e,n,c).integrate(t,0)},uv=(t,e)=>{t.doc??Sn();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},tE=t=>{const e={};return t.doc??Sn(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},nE=(t,e)=>{t.doc??Sn();const n=t._map.get(e);return n!==void 0&&!n.deleted},uK=(t,e)=>{const n={};return t._map.forEach((r,i)=>{let o=r;for(;o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0));)o=o.left;o!==null&&Ds(o,e)&&(n[i]=o.content.getContent()[o.length-1])}),n},If=t=>(t.doc??Sn(),NZ(t._map.entries(),e=>!e[1].deleted));class dK extends g1{}class ha extends rn{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new ha;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ha}clone(){const e=new ha;return e.insert(0,this.toArray().map(n=>n instanceof rn?n.clone():n)),e}get length(){return this.doc??Sn(),this._length}_callObserver(e,n){super._callObserver(e,n),v1(this,e,new dK(this,e))}insert(e,n){this.doc!==null?ct(this.doc,r=>{Qk(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?ct(this.doc,n=>{cK(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?ct(this.doc,r=>{eE(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return Jk(this,e)}toArray(){return Gk(this)}slice(e=0,n=this.length){return Kk(this,e,n)}toJSON(){return this.map(e=>e instanceof rn?e.toJSON():e)}map(e){return Wk(this,e)}forEach(e){Au(this,e)}[Symbol.iterator](){return aK(this)}_write(e){e.writeTypeRef(IK)}}const fK=t=>new ha;class hK extends g1{constructor(e,n,r){super(e,n),this.keysChanged=r}}class Ra extends rn{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,i)=>{this.set(i,r)}),this._prelimContent=null}_copy(){return new Ra}clone(){const e=new Ra;return this.forEach((n,r)=>{e.set(r,n instanceof rn?n.clone():n)}),e}_callObserver(e,n){v1(this,e,new hK(this,e,n))}toJSON(){this.doc??Sn();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const i=n.content.getContent()[n.length-1];e[r]=i instanceof rn?i.toJSON():i}}),e}get size(){return[...If(this)].length}keys(){return Z0(If(this),e=>e[0])}values(){return Z0(If(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Z0(If(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Sn(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?ct(this.doc,n=>{hp(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?ct(this.doc,r=>{cv(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return uv(this,e)}has(e){return nE(this,e)}clear(){this.doc!==null?ct(this.doc,e=>{this.forEach(function(n,r,i){hp(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(zK)}}const pK=t=>new Ra,$o=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&Eq(t,e);class ay{constructor(e,n,r,i){this.left=e,this.right=n,this.index=r,this.currentAttributes=i}forward(){this.right===null&&En(),this.right.content.constructor===qt?this.right.deleted||ja(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}const B6=(t,e,n)=>{for(;e.right!==null&&n>0;)e.right.content.constructor===qt?e.right.deleted||ja(e.currentAttributes,e.right.content):e.right.deleted||(n{const i=new Map,o=r?y1(e,n):null;if(o){const l=new ay(o.p.left,o.p,o.index,i);return B6(t,l,n-o.index)}else{const l=new ay(null,e._start,0,i);return B6(t,l,n)}},rE=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===qt&&$o(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const i=t.doc,o=i.clientID;r.forEach((l,c)=>{const d=n.left,f=n.right,h=new et(De(o,It(i.store,o)),d,d&&d.lastId,f,f&&f.id,e,null,new qt(c,l));h.integrate(t,0),n.right=h,n.forward()})},ja=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},iE=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===qt&&$o(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},oE=(t,e,n,r)=>{const i=t.doc,o=i.clientID,l=new Map;for(const c in r){const d=r[c],f=n.currentAttributes.get(c)??null;if(!$o(f,d)){l.set(c,f);const{left:h,right:m}=n;n.right=new et(De(o,It(i.store,o)),h,h&&h.lastId,m,m&&m.id,e,null,new qt(c,d)),n.right.integrate(t,0),n.forward()}}return l},Y0=(t,e,n,r,i)=>{n.currentAttributes.forEach((g,y)=>{i[y]===void 0&&(i[y]=null)});const o=t.doc,l=o.clientID;iE(n,i);const c=oE(t,e,n,i),d=r.constructor===String?new Gr(r):r instanceof rn?new Wr(r):new ll(r);let{left:f,right:h,index:m}=n;e._searchMarker&&Mu(e._searchMarker,n.index,d.getLength()),h=new et(De(l,It(o.store,l)),f,f&&f.lastId,h,h&&h.id,e,null,d),h.integrate(t,0),n.right=h,n.index=m,n.forward(),rE(t,e,n,c)},j6=(t,e,n,r,i)=>{const o=t.doc,l=o.clientID;iE(n,i);const c=oE(t,e,n,i);e:for(;n.right!==null&&(r>0||c.size>0&&(n.right.deleted||n.right.content.constructor===qt));){if(!n.right.deleted)switch(n.right.content.constructor){case qt:{const{key:d,value:f}=n.right.content,h=i[d];if(h!==void 0){if($o(h,f))c.delete(d);else{if(r===0)break e;c.set(d,f)}n.right.delete(t)}else n.currentAttributes.set(d,f);break}default:r0){let d="";for(;r>0;r--)d+=` `;n.right=new et(De(l,It(o.store,l)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new Gr(d)),n.right.integrate(t,0),n.forward()}rE(t,e,n,c)},sE=(t,e,n,r,i)=>{let o=e;const l=Fr();for(;o&&(!o.countable||o.deleted);){if(!o.deleted&&o.content.constructor===qt){const f=o.content;l.set(f.key,f)}o=o.right}let c=0,d=!1;for(;e!==o;){if(n===e&&(d=!0),!e.deleted){const f=e.content;if(f.constructor===qt){const{key:h,value:m}=f,g=r.get(h)??null;(l.get(h)!==f||g===m)&&(e.delete(t),c++,!d&&(i.get(h)??null)===m&&g!==m&&(g===null?i.delete(h):i.set(h,g))),!d&&!e.deleted&&ja(i,f)}}e=e.right}return c},mK=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===qt){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},gK=t=>{let e=0;return ct(t.doc,n=>{let r=t._start,i=t._start,o=Fr();const l=J2(o);for(;i;)i.deleted===!1&&(i.content.constructor===qt?ja(l,i.content):(e+=sE(n,r,i,o,l),o=J2(l),r=i)),i=i.right}),e},yK=t=>{const e=new Set,n=t.doc;for(const[r,i]of t.afterState.entries()){const o=t.beforeState.get(r)||0;i!==o&&Uk(t,n.store.clients.get(r),o,i,l=>{!l.deleted&&l.content.constructor===qt&&l.constructor!==Er&&e.add(l.parent)})}ct(n,r=>{es(t,t.deleteSet,i=>{if(i instanceof Er||!i.parent._hasFormatting||e.has(i.parent))return;const o=i.parent;i.content.constructor===qt?e.add(o):mK(r,i)});for(const i of e)gK(i)})},V6=(t,e,n)=>{const r=n,i=J2(e.currentAttributes),o=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Wr:case ll:case Gr:n{i===null?this.childListChanged=!0:this.keysChanged.add(i)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,n=[];ct(e,r=>{const i=new Map,o=new Map;let l=this.target._start,c=null;const d={};let f="",h=0,m=0;const g=()=>{if(c!==null){let y=null;switch(c){case"delete":m>0&&(y={delete:m}),m=0;break;case"insert":(typeof f=="object"||f.length>0)&&(y={insert:f},i.size>0&&(y.attributes={},i.forEach((C,w)=>{C!==null&&(y.attributes[w]=C)}))),f="";break;case"retain":h>0&&(y={retain:h},kq(d)||(y.attributes=Sq({},d))),h=0;break}y&&n.push(y),c=null}};for(;l!==null;){switch(l.content.constructor){case Wr:case ll:this.adds(l)?this.deletes(l)||(g(),c="insert",f=l.content.getContent()[0],g()):this.deletes(l)?(c!=="delete"&&(g(),c="delete"),m+=1):l.deleted||(c!=="retain"&&(g(),c="retain"),h+=1);break;case Gr:this.adds(l)?this.deletes(l)||(c!=="insert"&&(g(),c="insert"),f+=l.content.str):this.deletes(l)?(c!=="delete"&&(g(),c="delete"),m+=l.length):l.deleted||(c!=="retain"&&(g(),c="retain"),h+=l.length);break;case qt:{const{key:y,value:C}=l.content;if(this.adds(l)){if(!this.deletes(l)){const w=i.get(y)??null;$o(w,C)?C!==null&&l.delete(r):(c==="retain"&&g(),$o(C,o.get(y)??null)?delete d[y]:d[y]=C)}}else if(this.deletes(l)){o.set(y,C);const w=i.get(y)??null;$o(w,C)||(c==="retain"&&g(),d[y]=w)}else if(!l.deleted){o.set(y,C);const w=d[y];w!==void 0&&($o(w,C)?w!==null&&l.delete(r):(c==="retain"&&g(),C===null?delete d[y]:d[y]=C))}l.deleted||(c==="insert"&&g(),ja(i,l.content));break}}l=l.right}for(g();n.length>0;){const y=n[n.length-1];if(y.retain!==void 0&&y.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class ts extends rn{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Sn(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new ts}clone(){const e=new ts;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new vK(this,e,n);v1(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Sn();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===Gr&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?ct(this.doc,r=>{const i=new ay(null,this._start,0,new Map);for(let o=0;o0)&&Y0(r,this,i,c,l.attributes||{})}else l.retain!==void 0?j6(r,this,i,l.retain,l.attributes||{}):l.delete!==void 0&&V6(r,i,l.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??Sn();const i=[],o=new Map,l=this.doc;let c="",d=this._start;function f(){if(c.length>0){const m={};let g=!1;o.forEach((C,w)=>{g=!0,m[w]=C});const y={insert:c};g&&(y.attributes=m),i.push(y),c=""}}const h=()=>{for(;d!==null;){if(Ds(d,e)||n!==void 0&&Ds(d,n))switch(d.content.constructor){case Gr:{const m=o.get("ychange");e!==void 0&&!Ds(d,e)?(m===void 0||m.user!==d.id.client||m.type!=="removed")&&(f(),o.set("ychange",r?r("removed",d.id):{type:"removed"})):n!==void 0&&!Ds(d,n)?(m===void 0||m.user!==d.id.client||m.type!=="added")&&(f(),o.set("ychange",r?r("added",d.id):{type:"added"})):m!==void 0&&(f(),o.delete("ychange")),c+=d.content.str;break}case Wr:case ll:{f();const m={insert:d.content.getContent()[0]};if(o.size>0){const g={};m.attributes=g,o.forEach((y,C)=>{g[C]=y})}i.push(m);break}case qt:Ds(d,e)&&(f(),ja(o,d.content));break}d=d.right}f()};return e||n?ct(l,m=>{e&&sy(m,e),n&&sy(m,n),h()},"cleanup"):h(),i}insert(e,n,r){if(n.length<=0)return;const i=this.doc;i!==null?ct(i,o=>{const l=zf(o,this,e,!r);r||(r={},l.currentAttributes.forEach((c,d)=>{r[d]=c})),Y0(o,this,l,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const i=this.doc;i!==null?ct(i,o=>{const l=zf(o,this,e,!r);Y0(o,this,l,n,r||{})}):this._pending.push(()=>this.insertEmbed(e,n,r||{}))}delete(e,n){if(n===0)return;const r=this.doc;r!==null?ct(r,i=>{V6(i,zf(i,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const i=this.doc;i!==null?ct(i,o=>{const l=zf(o,this,e,!1);l.right!==null&&j6(o,this,l,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?ct(this.doc,n=>{hp(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?ct(this.doc,r=>{cv(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return uv(this,e)}getAttributes(){return tE(this)}_write(e){e.writeTypeRef(BK)}}const bK=t=>new ts;class W0{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Sn()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===xn||n.constructor===tl)&&n._start!==null)e=n._start;else for(;e!==null;){const r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class tl extends rn{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new tl}clone(){const e=new tl;return e.insert(0,this.toArray().map(n=>n instanceof rn?n.clone():n)),e}get length(){return this.doc??Sn(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new W0(this,e)}querySelector(e){e=e.toUpperCase();const r=new W0(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),el(new W0(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){v1(this,e,new xK(this,n,e))}toString(){return Wk(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const i=e.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),Au(this,o=>{i.insertBefore(o.toDOM(e,n,r),null)}),i}insert(e,n){this.doc!==null?ct(this.doc,r=>{Qk(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)ct(this.doc,r=>{const i=e&&e instanceof rn?e._item:e;fp(r,this,i,n)});else{const r=this._prelimContent,i=e===null?0:r.findIndex(o=>o===e)+1;if(i===0&&e!==null)throw fi("Reference item not found");r.splice(i,0,...n)}}delete(e,n=1){this.doc!==null?ct(this.doc,r=>{eE(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return Gk(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Jk(this,e)}slice(e=0,n=this.length){return Kk(this,e,n)}forEach(e){Au(this,e)}_write(e){e.writeTypeRef(VK)}}const CK=t=>new tl;class xn extends tl{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((r,i)=>{this.setAttribute(i,r)}),this._prelimAttrs=null}_copy(){return new xn(this.nodeName)}clone(){const e=new xn(this.nodeName),n=this.getAttributes();return Tq(n,(r,i)=>{e.setAttribute(i,r)}),e.insert(0,this.toArray().map(r=>r instanceof rn?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],r=[];for(const c in e)r.push(c);r.sort();const i=r.length;for(let c=0;c0?" "+n.join(" "):"";return`<${o}${l}>${super.toString()}`}removeAttribute(e){this.doc!==null?ct(this.doc,n=>{hp(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?ct(this.doc,r=>{cv(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return uv(this,e)}hasAttribute(e){return nE(this,e)}getAttributes(e){return e?uK(this,e):tE(this)}toDOM(e=document,n={},r){const i=e.createElement(this.nodeName),o=this.getAttributes();for(const l in o){const c=o[l];typeof c=="string"&&i.setAttribute(l,c)}return Au(this,l=>{i.appendChild(l.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(jK),e.writeKey(this.nodeName)}}const wK=t=>new xn(t.readKey());class xK extends g1{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(i=>{i===null?this.childListChanged=!0:this.attributesChanged.add(i)})}}class pp extends Ra{constructor(e){super(),this.hookName=e}_copy(){return new pp(this.hookName)}clone(){const e=new pp(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const i=n[this.hookName];let o;return i!==void 0?o=i.createDom(this):o=document.createElement(this.hookName),o.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(o,this),o}_write(e){e.writeTypeRef(UK),e.writeKey(this.hookName)}}const SK=t=>new pp(t.readKey());class Xn extends ts{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new Xn}clone(){const e=new Xn;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const i=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(i,this),i}toString(){return this.toDelta().map(e=>{const n=[];for(const i in e.attributes){const o=[];for(const l in e.attributes[i])o.push({key:l,value:e.attributes[i][l]});o.sort((l,c)=>l.keyi.nodeName=0;i--)r+=``;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(PK)}}const TK=t=>new Xn;class dv{constructor(e,n){this.id=e,this.length=n}get deleted(){throw Nr()}mergeWith(e){return!1}write(e,n,r){throw Nr()}integrate(e,n){throw Nr()}}const kK=0;class Er extends dv{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),Vk(e.doc.store,this)}write(e,n){e.writeInfo(kK),e.writeLen(this.length-n)}getMissing(e,n){return null}}class Ku{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Ku(this.content)}splice(e){throw Nr()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const EK=t=>new Ku(t.readBuf());class Nu{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Nu(this.len)}splice(e){const n=new Nu(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){Tu(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const MK=t=>new Nu(t.readLen()),lE=(t,e)=>new sl({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Gu{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Gu(lE(this.doc.guid,this.opts))}splice(e){throw Nr()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const AK=t=>new Gu(lE(t.readString(),t.readAny()));class ll{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ll(this.embed)}splice(e){throw Nr()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const NK=t=>new ll(t.readJSON());class qt{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new qt(this.key,this.value)}splice(e){throw Nr()}mergeWith(e){return!1}integrate(e,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const RK=t=>new qt(t.readKey(),t.readJSON());class mp{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new mp(this.arr)}splice(e){const n=new mp(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let i=n;i{const e=t.readLen(),n=[];for(let r=0;r{const e=t.readLen(),n=[];for(let r=0;r=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const _K=t=>new Gr(t.readString()),HK=[fK,pK,bK,wK,CK,SK,TK],IK=0,zK=1,BK=2,jK=3,VK=4,UK=5,PK=6;class Wr{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Wr(this.type._copy())}splice(e){throw Nr()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}}const FK=t=>new Wr(HK[t.readTypeRef()](t)),cy=(t,e)=>{let n=e,r=0,i;do r>0&&(n=De(n.client,n.clock+r)),i=fa(t,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof et);return{item:i,diff:r}},fv=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},gp=(t,e,n)=>{const{client:r,clock:i}=e.id,o=new et(De(r,i+n),e,De(r,i+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&o.markDeleted(),e.keep&&(o.keep=!0),e.redone!==null&&(o.redone=De(e.redone.client,e.redone.clock+n)),e.right=o,o.right!==null&&(o.right.left=o),t._mergeStructs.push(o),o.parentSub!==null&&o.right===null&&o.parent._map.set(o.parentSub,o),e.length=n,o},U6=(t,e)=>q3(t,n=>Ba(n.deletions,e)),aE=(t,e,n,r,i,o)=>{const l=t.doc,c=l.store,d=l.clientID,f=e.redone;if(f!==null)return Kn(t,f);let h=e.parent._item,m=null,g;if(h!==null&&h.deleted===!0){if(h.redone===null&&(!n.has(h)||aE(t,h,n,r,i,o)===null))return null;for(;h.redone!==null;)h=Kn(t,h.redone)}const y=h===null?e.parent:h.content.type;if(e.parentSub===null){for(m=e.left,g=e;m!==null;){let k=m;for(;k!==null&&k.parent._item!==h;)k=k.redone===null?null:Kn(t,k.redone);if(k!==null&&k.parent._item===h){m=k;break}m=m.left}for(;g!==null;){let k=g;for(;k!==null&&k.parent._item!==h;)k=k.redone===null?null:Kn(t,k.redone);if(k!==null&&k.parent._item===h){g=k;break}g=g.right}}else if(g=null,e.right&&!i){for(m=e;m!==null&&m.right!==null&&(m.right.redone||Ba(r,m.right.id)||U6(o.undoStack,m.right.id)||U6(o.redoStack,m.right.id));)for(m=m.right;m.redone;)m=Kn(t,m.redone);if(m&&m.right!==null)return null}else m=y._map.get(e.parentSub)||null;const C=It(c,d),w=De(d,C),x=new et(w,m,m&&m.lastId,g,g&&g.id,y,e.parentSub,e.content.copy());return e.redone=w,fv(x,!0),x.integrate(t,0),x};class et extends dv{constructor(e,n,r,i,o,l,c,d){super(e,d.getLength()),this.origin=r,this.left=n,this.right=i,this.rightOrigin=o,this.parent=l,this.parentSub=c,this.redone=null,this.content=d,this.info=this.content.isCountable()?m6:0}set marker(e){(this.info&U0)>0!==e&&(this.info^=U0)}get marker(){return(this.info&U0)>0}get keep(){return(this.info&p6)>0}set keep(e){this.keep!==e&&(this.info^=p6)}get countable(){return(this.info&m6)>0}get deleted(){return(this.info&V0)>0}set deleted(e){this.deleted!==e&&(this.info^=V0)}markDeleted(){this.info|=V0}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=It(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=It(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===da&&this.id.client!==this.parent.client&&this.parent.clock>=It(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=O6(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Kn(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Er||this.right&&this.right.constructor===Er)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===et?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===et&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===da){const r=fa(n,this.parent);r.constructor===Er?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=O6(e,e.doc.store,De(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,i;if(r!==null)i=r.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;const o=new Set,l=new Set;for(;i!==null&&i!==this.right;){if(l.add(i),o.add(i),_f(this.origin,i.origin)){if(i.id.client{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Tu(e.deleteSet,this.id.client,this.id.clock,this.length),L6(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw En();this.content.gc(e),n?GZ(e,this,new Er(this.id,this.length)):this.content=new Nu(this.length)}write(e,n){const r=n>0?De(this.id.client,this.id.clock+n-1):this.origin,i=this.rightOrigin,o=this.parentSub,l=this.content.getRef()&s1|(r===null?0:Dn)|(i===null?0:Gi)|(o===null?0:bu);if(e.writeInfo(l),r!==null&&e.writeLeftID(r),i!==null&&e.writeRightID(i),r===null&&i===null){const c=this.parent;if(c._item!==void 0){const d=c._item;if(d===null){const f=ku(c);e.writeParentInfo(!0),e.writeString(f)}else e.writeParentInfo(!1),e.writeLeftID(d.id)}else c.constructor===String?(e.writeParentInfo(!0),e.writeString(c)):c.constructor===da?(e.writeParentInfo(!1),e.writeLeftID(c)):En();o!==null&&e.writeString(o)}this.content.write(e,n)}}const cE=(t,e)=>$K[e&s1](t),$K=[()=>{En()},MK,OK,EK,_K,NK,RK,FK,LK,AK,()=>{En()}],qK=10;class Br extends dv{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){En()}write(e,n){e.writeInfo(qK),Ue(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const uE=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},dE="__ $YJS$ __";uE[dE]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");uE[dE]=!0;const ZK=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},KK=/[\uD800-\uDBFF]/,GK=/[\uDC00-\uDFFF]/,YK=(t,e)=>{let n=0,r=0;for(;n0&&KK.test(t[n-1])&&n--;r+n0&&GK.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},WK=YK,ci=(t,e)=>t>>>e|t<<32-e,JK=t=>ci(t,2)^ci(t,13)^ci(t,22),XK=t=>ci(t,6)^ci(t,11)^ci(t,25),QK=t=>ci(t,7)^ci(t,18)^t>>>3,eG=t=>ci(t,17)^ci(t,19)^t>>>10,tG=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),nG=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class rG{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(nG),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let m=16;m<64;m++)n[m]=eG(n[m-2])+n[m-7]+QK(n[m-15])+n[m-16];let r=e[0],i=e[1],o=e[2],l=e[3],c=e[4],d=e[5],f=e[6],h=e[7];for(let m=0,g,y;m<64;m++)g=h+XK(c)+(c&d^~c&f)+tG[m]+n[m]>>>0,y=JK(r)+(r&i^r&o^i&o)>>>0,h=f,f=d,d=c,c=l+g>>>0,l=o,o=i,i=r,r=g+y>>>0;e[0]+=r,e[1]+=i,e[2]+=o,e[3]+=l,e[4]+=c,e[5]+=d,e[6]+=f,e[7]+=h}digest(e){let n=0;for(;n+56<=e.length;){let l=0;for(;l<16&&n+3=0&&n>>(3-c)*8;return o}}const iG=t=>new rG().digest(t),Ct=new qe("y-sync"),Yi=new qe("y-undo");new qe("yjs-cursor");const oG=t=>{for(let n=6;nHq(oG(iG(Iq(t)))),yp=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!Ba(e.ds,t.id),lG=[{light:"#ecd44433",dark:"#ecd444"}],aG=(t,e,n)=>{if(!t.has(n)){if(t.sizer.add(i)),e=e.filter(i=>!r.has(i))}t.set(n,mq(e))}return t.get(n)},cG=(t,{colors:e=lG,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:o}={})=>{let l=!1;const c=new fG(t,o),d=new Ve({props:{editable:f=>{const h=Ct.getState(f);return h.snapshot==null&&h.prevSnapshot==null}},key:Ct,state:{init:(f,h)=>({type:t,doc:t.doc,binding:c,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(f,h)=>{const m=f.getMeta(Ct);if(m!==void 0){h=Object.assign({},h);for(const g in m)h[g]=m[g]}return h.addToHistory=f.getMeta("addToHistory")!==!1,h.isChangeOrigin=m!==void 0&&!!m.isChangeOrigin,h.isUndoRedoOperation=m!==void 0&&!!m.isChangeOrigin&&!!m.isUndoRedoOperation,c.prosemirrorView!==null&&m!==void 0&&(m.snapshot!=null||m.prevSnapshot!=null)&&Ek(0,()=>{c.prosemirrorView!=null&&(m.restore==null?c._renderSnapshot(m.snapshot,m.prevSnapshot,h):(c._renderSnapshot(m.snapshot,m.snapshot,h),delete h.restore,delete h.snapshot,delete h.prevSnapshot,c.mux(()=>{c._prosemirrorChanged(c.prosemirrorView.state.doc)})))}),h}},view:f=>(c.initView(f),o==null&&c._forceRerender(),i(),{update:()=>{const h=d.getState(f.state);if(h.snapshot==null&&h.prevSnapshot==null&&(l||f.state.doc.content.findDiffStart(f.state.doc.type.createAndFill().content)!==null)){if(l=!0,h.addToHistory===!1&&!h.isChangeOrigin){const m=Yi.getState(f.state),g=m&&m.undoManager;g&&g.stopCapturing()}c.mux(()=>{h.doc.transact(m=>{m.meta.set("addToHistory",h.addToHistory),c._prosemirrorChanged(f.state.doc)},Ct)})}},destroy:()=>{c.destroy()}})});return d},uG=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")t.setSelection(new Yn(t.doc));else if(e.type==="node"){const r=iu(n.doc,n.type,e.anchor,n.mapping);t.setSelection(dG(t,r))}else{const r=iu(n.doc,n.type,e.anchor,n.mapping),i=iu(n.doc,n.type,e.head,n.mapping);r!==null&&i!==null&&t.setSelection(ue.between(t.doc.resolve(r),t.doc.resolve(i)))}},dG=(t,e)=>{const n=t.doc.resolve(e);return n.nodeAfter?me.create(t.doc,e):ue.near(n)},uy=(t,e)=>({type:e.selection.jsonID,anchor:bp(e.selection.anchor,t.type,t.mapping),head:bp(e.selection.head,t.type,t.mapping)});class fG{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=ZK(),this.mapping=n,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=uy(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(ak&&this._domSelectionInView===null&&(Ek(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;const n=this.prosemirrorView._root.createRange();n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const i=n.getBoundingClientRect(),o=Zu.documentElement;return i.bottom>=0&&i.right>=0&&i.left<=(window.innerWidth||o.clientWidth||0)&&i.top<=(window.innerHeight||o.clientHeight||0)}renderSnapshot(e,n){n||(n=Bk(_k(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Ct,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>nh(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ce(te.from(e),0,0));n.setMeta(Ct,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(i=>nh(i,this.prosemirrorView.state.schema,this)).filter(i=>i!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ce(te.from(n),0,0));if(e){const i=Ea(Qo(e.anchor,0),r.doc.content.size),o=Ea(Qo(e.head,0),r.doc.content.size);r.setSelection(ue.create(r.doc,i,o))}this.prosemirrorView.dispatch(r.setMeta(Ct,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let i=this.doc,o=this.type;if(e||(e=G0(this.doc)),e instanceof Uint8Array||n instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&En(),i=new sl({gc:!1}),oy(i,n),n=G0(i),oy(i,e),e=G0(i),o._item===null){const l=Array.from(this.doc.share.keys()).find(c=>this.doc.share.get(c)===this.type);o=i.getXmlFragment(l)}else{const l=i.store.clients.get(o._item.id.client)??[],c=Kr(l,o._item.id.clock);o=l[c].content.type}this.mapping.clear(),this.mux(()=>{i.transact(l=>{const c=r.permanentUserData;c&&c.dss.forEach(m=>{es(l,m,g=>{})});const d=(m,g)=>{const y=m==="added"?c.getUserByClientId(g.client):c.getUserByDeletedId(g);return{user:y,type:m,color:aG(r.colorMapping,r.colors,y)}},f=Yk(o,new lv(n.ds,e.sv)).map(m=>!m._item.deleted||yp(m._item,e)||yp(m._item,n)?nh(m,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,n,d):null).filter(m=>m!==null),h=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ce(te.from(f),0,0));this.prosemirrorView.dispatch(h.setMeta(Ct,{isChangeOrigin:!0}))},Ct)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=Ct.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const i=(c,d)=>this.mapping.delete(d);es(n,n.deleteSet,c=>{if(c.constructor===et){const d=c.content.type;d&&this.mapping.delete(d)}}),n.changed.forEach(i),n.changedParentTypes.forEach(i);const o=this.type.toArray().map(c=>fE(c,this.prosemirrorView.state.schema,this)).filter(c=>c!==null);let l=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ce(te.from(o),0,0));uG(l,this.beforeTransactionSelection,this),l=l.setMeta(Ct,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof Fk}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&l.scrollIntoView(),this.prosemirrorView.dispatch(l)})}_prosemirrorChanged(e){this.doc.transact(()=>{fy(this.doc,this.type,e,this),this.beforeTransactionSelection=uy(this,this.prosemirrorView.state)},Ct)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const fE=(t,e,n,r,i,o)=>{const l=n.mapping.get(t);if(l===void 0){if(t instanceof xn)return nh(t,e,n,r,i,o);throw Nr()}return l},nh=(t,e,n,r,i,o)=>{const l=[],c=d=>{if(d instanceof xn){const f=fE(d,e,n,r,i,o);f!==null&&l.push(f)}else{const f=d._item.right?.content?.type;f instanceof ts&&!f._item.deleted&&f._item.id.client===f.doc.clientID&&(d.applyDelta([{retain:d.length},...f.toDelta()]),f.doc.transact(m=>{f._item.delete(m)}));const h=hG(d,e,n,r,i,o);h!==null&&h.forEach(m=>{m!==null&&l.push(m)})}};r===void 0||i===void 0?t.toArray().forEach(c):Yk(t,new lv(i.ds,r.sv)).forEach(c);try{const d=t.getAttributes(r);r!==void 0&&(yp(t._item,r)?yp(t._item,i)||(d.ychange=o?o("added",t._item.id):{type:"added"}):d.ychange=o?o("removed",t._item.id):{type:"removed"});const f=e.node(t.nodeName,d,l);return n.mapping.set(t,f),f}catch{return t.doc.transact(f=>{t._item.delete(f)},Ct),n.mapping.delete(t),null}},hG=(t,e,n,r,i,o)=>{const l=[],c=t.toDelta(r,i,o);try{for(let d=0;d{t._item.delete(f)},Ct),null}return l},pG=(t,e)=>{const n=new Xn,r=t.map(i=>({insert:i.text,attributes:pE(i.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n},mG=(t,e)=>{const n=new xn(t.type.name);for(const r in t.attrs){const i=t.attrs[r];i!==null&&r!=="ychange"&&n.setAttribute(r,i)}return n.insert(0,b1(t).map(r=>dy(r,e))),e.mapping.set(n,t),n},dy=(t,e)=>t instanceof Array?pG(t,e):mG(t,e),P6=t=>typeof t=="object"&&t!==null,hv=(t,e)=>{const n=Object.keys(t).filter(i=>t[i]!==null);let r=n.length===Object.keys(e).filter(i=>e[i]!==null).length;for(let i=0;i{const e=t.content.content,n=[];for(let r=0;r{const n=t.toDelta();return n.length===e.length&&n.every((r,i)=>r.insert===e[i].text&&ok(r.attributes||{}).length===e[i].marks.length&&Ha(r.attributes,(o,l)=>{const c=pv(l),d=e[i].marks;return d.find(h=>h.type.name===c)?hv(o,d.find(h=>h.type.name===c)?.attrs):!1}))},Ru=(t,e)=>{if(t instanceof xn&&!(e instanceof Array)&&hy(t,e)){const n=b1(e);return t._length===n.length&&hv(t.getAttributes(),e.attrs)&&t.toArray().every((r,i)=>Ru(r,n[i]))}return t instanceof Xn&&e instanceof Array&&hE(t,e)},vp=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),F6=(t,e,n)=>{const r=t.toArray(),i=b1(e),o=i.length,l=r.length,c=Ea(l,o);let d=0,f=0,h=!1;for(;d{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof Gr?e+=n.content.str:n.content instanceof qt&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},yG=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:i}=gG(t),o=e.map(f=>({insert:f.text,attributes:Object.assign({},r,pE(f.marks,n))})),{insert:l,remove:c,index:d}=WK(i,o.map(f=>f.insert).join(""));t.delete(d,c),t.insert(d,l),t.applyDelta(o.map(f=>({retain:f.insert.length,attributes:f.attributes})))},vG=/(.*)(--[a-zA-Z0-9+/=]{8})$/,pv=t=>vG.exec(t)?.[1]??t,bG=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(pv(r),t[r]));return n},pE=(t,e)=>{const n={};return t.forEach(r=>{if(r.type.name!=="ychange"){const i=to(e.isOMark,r.type,()=>!r.type.excludes(r.type));n[i?`${r.type.name}--${sG(r.toJSON())}`:r.type.name]=r.attrs}}),n},fy=(t,e,n,r)=>{if(e instanceof xn&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof xn){const m=e.getAttributes(),g=n.attrs;for(const y in g)g[y]!==null?m[y]!==g[y]&&y!=="ychange"&&e.setAttribute(y,g[y]):e.removeAttribute(y);for(const y in m)g[y]===void 0&&e.removeAttribute(y)}const i=b1(n),o=i.length,l=e.toArray(),c=l.length,d=Ea(o,c);let f=0,h=0;for(;f{for(;c-f-h>0&&o-f-h>0;){const g=l[f],y=i[f],C=l[c-h-1],w=i[o-h-1];if(g instanceof Xn&&y instanceof Array)hE(g,y)||yG(g,y,r),f+=1;else{let x=g instanceof xn&&hy(g,y),k=C instanceof xn&&hy(C,w);if(x&&k){const A=F6(g,y,r),N=F6(C,w,r);A.foundMappedChild&&!N.foundMappedChild?k=!1:!A.foundMappedChild&&N.foundMappedChild||A.equalityFactor0&&(e.slice(f,f+m).forEach(g=>r.mapping.delete(g)),e.delete(f,m)),f+h!(e instanceof Array)&&t.nodeName===e.type.name,bp=(t,e,n)=>{if(t===0)return K0(e,0,-1);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof Xn){if(r._length>=t)return K0(r,t,-1);if(t-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,t--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const i=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&t1)return new dp(r._item===null?null:r._item.id,r._item===null?ku(r):null,null);if(t-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(t===0)return r=r._item===null?r:r._item.parent,new dp(r._item===null?null:r._item.id,r._item===null?ku(r):null,null);do r=r._item.parent,t--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw En();if(t===0&&r.constructor!==Xn&&r!==e)return CG(r._item.parent,r._item)}return K0(e,e._length,-1)},CG=(t,e)=>{let n=null,r=null;return t._item===null?r=ku(t):n=De(t._item.id.client,t._item.id.clock),new dp(n,r,e.id)},iu=(t,e,n,r)=>{const i=ZZ(n,t);if(i===null||i.type!==e&&!Eu(e,i.type._item))return null;let o=i.type,l=0;if(o.constructor===Xn)l=i.index;else if(o._item===null||!o._item.deleted){let c=o._first,d=0;for(;d{let i;if(r instanceof Xn)i=r.toDelta().map(l=>{const c={type:"text",text:l.insert};return l.attributes&&(c.marks=Object.keys(l.attributes).map(d=>{const f=l.attributes[d],m={type:pv(d)};return Object.keys(f)&&(m.attrs=f),m})),c});else if(r instanceof xn){i={type:r.nodeName};const o=r.getAttributes();Object.keys(o).length&&(i.attrs=o);const l=r.toArray();l.length&&(i.content=l.map(n).flat())}else En();return i};return{type:"doc",content:e.map(n)}}const xG=t=>{const e=Yi.getState(t).undoManager;if(e!=null)return e.undo(),!0},SG=t=>{const e=Yi.getState(t).undoManager;if(e!=null)return e.redo(),!0},TG=new Set(["paragraph"]),kG=(t,e)=>!(t instanceof et)||!(t.content instanceof Wr)||!(t.content.type instanceof ts||t.content.type instanceof xn&&e.has(t.content.type.nodeName))||t.content.type._length===0,EG=({protectedNodes:t=TG,trackedOrigins:e=[],undoManager:n=null}={})=>new Ve({key:Yi,state:{init:(r,i)=>{const o=Ct.getState(i),l=n||new Fk(o.type,{trackedOrigins:new Set([Ct].concat(e)),deleteFilter:c=>kG(c,t),captureTransaction:c=>c.meta.get("addToHistory")!==!1});return{undoManager:l,prevSel:null,hasUndoOps:l.undoStack.length>0,hasRedoOps:l.redoStack.length>0}},apply:(r,i,o,l)=>{const c=Ct.getState(l).binding,d=i.undoManager,f=d.undoStack.length>0,h=d.redoStack.length>0;return c?{undoManager:d,prevSel:uy(c,o),hasUndoOps:f,hasRedoOps:h}:f!==i.hasUndoOps||h!==i.hasRedoOps?Object.assign({},i,{hasUndoOps:d.undoStack.length>0,hasRedoOps:d.redoStack.length>0}):i}},view:r=>{const i=Ct.getState(r.state),o=Yi.getState(r.state).undoManager;return o.on("stack-item-added",({stackItem:l})=>{const c=i.binding;c&&l.meta.set(c,Yi.getState(r.state).prevSel)}),o.on("stack-item-popped",({stackItem:l})=>{const c=i.binding;c&&(c.beforeTransactionSelection=l.meta.get(c)||c.beforeTransactionSelection)}),{destroy:()=>{o.destroy()}}}});function mE(t){return!!t.getMeta(Ct)}function MG(t,e){const n=Ct.getState(t);return iu(n.doc,n.type,e,n.binding.mapping)||0}function gE(t,e){const n=Ct.getState(t);return bp(e,n.type,n.binding.mapping)}var rh=class yE extends Gy{constructor(e,n){super(e),this.yRelativePosition=n}static fromJSON(e){return new yE(e.position,e.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};function AG(t,e){const n=gE(e,t);return new rh(t,n)}function NG(t,e,n){const r=t instanceof rh?t.yRelativePosition:null;if(mE(e)&&r){const l=MG(n,r);return{position:new rh(l,r),mapResult:null}}const i=Wx(t,e),o=i.position.position;return{position:new rh(o,r??gE(n,o)),mapResult:i.mapResult}}Ze.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(t=>t.name==="undoRedo")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".')},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(t,e)=>NG(t,e,this.editor.state),this.editor.utils.createMappablePosition=t=>AG(t,this.editor.state)},addCommands(){return{undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Yi.getState(e).undoManager.undoStack.length===0?!1:n?xG(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Yi.getState(e).undoManager.redoStack.length===0?!1:n?SG(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){var t;const e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),n=EG(this.options.yUndoOptions),r=n.spec.view;n.spec.view=l=>{const{undoManager:c}=Yi.getState(l.state);c.restore&&(c.restore(),c.restore=()=>{});const d=r?r(l):void 0;return{destroy:()=>{const f=c.trackedOrigins.has(c),h=c._observers;c.restore=()=>{f&&c.trackedOrigins.add(c),c.doc.on("afterTransaction",c.afterTransactionHandler),c._observers=h},d?.destroy&&d.destroy()}}};const i={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender},o=cG(e,i);return this.editor.options.enableContentCheck&&((t=e.doc)==null||t.on("beforeTransaction",()=>{try{const l=wG(e);if(l.content.length===0)return;this.editor.schema.nodeFromJSON(l).check()}catch(l){return this.editor.emit("contentError",{error:l,editor:this.editor,disableCollaboration:()=>{var c;(c=e.doc)==null||c.destroy(),this.storage.isDisabled=!0}}),!1}})),[o,n,this.editor.options.enableContentCheck&&new Ve({key:new qe("filterInvalidContent"),filterTransaction:()=>{var l;return this.storage.isDisabled!==!1&&((l=e.doc)==null||l.destroy()),!0}})].filter(Boolean)}});function $6(t){if(!t.length)return Xe.empty;const e=[],n=t[0].$from.node(0);return t.forEach(r=>{const i=r.$from.pos,o=r.$from.nodeAfter;o&&e.push(Ft.node(i,i+o.nodeSize,{class:"ProseMirror-selectednoderange"}))}),Xe.create(n,e)}function C1(t,e,n){const r=[],i=t.node(0);typeof n=="number"&&n>=0||(t.sameParent(e)?n=Math.max(0,t.sharedDepth(e.pos)-1):n=t.sharedDepth(e.pos));const o=new su(t,e,n),l=o.depth===0?0:i.resolve(o.start).posAtIndex(0);return o.parent.forEach((c,d)=>{const f=l+d,h=f+c.nodeSize;if(f=o.end)return;const m=new wy(i.resolve(f),i.resolve(h));r.push(m)}),r}var RG=class vE{constructor(e,n){this.anchor=e,this.head=n}map(e){return new vE(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return new qo(n,r)}},qo=class Do extends Se{constructor(e,n,r,i=1){const{doc:o}=e,l=e===n,c=e.pos===o.content.size&&n.pos===o.content.size,d=l&&!c?o.resolve(n.pos+(i>0?1:-1)):n,f=l&&c?o.resolve(e.pos-(i>0?1:-1)):e,h=C1(f.min(d),f.max(d),r),m=d.pos>=e.pos?h[0].$from:h[h.length-1].$to,g=d.pos>=e.pos?h[h.length-1].$to:h[0].$from;super(m,g,h),this.depth=r}get $to(){return this.ranges[this.ranges.length-1].$to}eq(e){return e instanceof Do&&e.$from.pos===this.$from.pos&&e.$to.pos===this.$to.pos}map(e,n){const r=e.resolve(n.map(this.anchor)),i=e.resolve(n.map(this.head));return new Do(r,i)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:e}=this.$from;if(this.isForwards&&this.ranges.length>1){const i=this.ranges.slice(0,-1),o=i[0].$from,l=i[i.length-1].$to;return new Do(o,l,this.depth)}const n=this.ranges[0],r=e.resolve(Math.max(0,n.$from.pos-1));return new Do(this.$anchor,r,this.depth)}extendForwards(){const{doc:e}=this.$from;if(this.isBackwards&&this.ranges.length>1){const i=this.ranges.slice(1),o=i[0].$from,l=i[i.length-1].$to;return new Do(l,o,this.depth)}const n=this.ranges[this.ranges.length-1],r=e.resolve(Math.min(e.content.size,n.$to.pos+1));return new Do(this.$anchor,r,this.depth)}static fromJSON(e,n){return new Do(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r,i,o=1){return new this(e.resolve(n),e.resolve(r),i,o)}getBookmark(){return new RG(this.anchor,this.head)}};qo.prototype.visible=!1;function Bf(t){return t instanceof qo}Ze.create({name:"nodeRange",addOptions(){return{depth:void 0,key:"Mod"}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:i,selection:o,tr:l}=r,{anchor:c,head:d}=o;if(!Bf(o)){const h=qo.create(i,c,d,e,-1);return l.setSelection(h),n.dispatch(l),!0}const f=o.extendBackwards();return l.setSelection(f),n.dispatch(l),!0},"Shift-ArrowDown":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:i,selection:o,tr:l}=r,{anchor:c,head:d}=o;if(!Bf(o)){const h=qo.create(i,c,d,e);return l.setSelection(h),n.dispatch(l),!0}const f=o.extendForwards();return l.setSelection(f),n.dispatch(l),!0},"Mod-a":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:i,tr:o}=r,l=qo.create(i,0,i.content.size,e);return o.setSelection(l),n.dispatch(o),!0}}},onSelectionUpdate(){const{selection:t}=this.editor.state;Bf(t)&&this.editor.view.dom.classList.add("ProseMirror-noderangeselection")},addProseMirrorPlugins(){let t=!1,e=!1;return[new Ve({key:new qe("nodeRange"),props:{attributes:()=>t?{class:"ProseMirror-noderangeselection"}:{class:""},handleDOMEvents:{mousedown:(n,r)=>{const{key:i}=this.options,o=/Mac/.test(navigator.platform),l=!!r.shiftKey,c=!!r.ctrlKey,d=!!r.altKey,f=!!r.metaKey,h=o?f:c;return(i==null||i==="Shift"&&l||i==="Control"&&c||i==="Alt"&&d||i==="Meta"&&f||i==="Mod"&&h)&&(e=!0),e&&document.addEventListener("mouseup",()=>{e=!1;const{state:m}=n,{doc:g,selection:y,tr:C}=m,{$anchor:w,$head:x}=y;if(w.sameParent(x))return;const k=qo.create(g,w.pos,x.pos,this.options.depth);C.setSelection(k),n.dispatch(C)},{once:!0}),!1}},decorations:n=>{const{selection:r}=n,i=Bf(r);if(t=!1,!e)return i?(t=!0,$6(r.ranges)):null;const{$from:o,$to:l}=r;if(!i&&o.sameParent(l))return null;const c=C1(o,l,this.options.depth);return c.length?(t=!0,$6(c)):null}}})]}});function OG(t){let e="";const n=getComputedStyle(t);for(let r=0;r{r[o].style.cssText=OG(i)}),e}function LG(t,e){let n=t;for(;n?.parentElement&&n.parentElement!==e.dom;)n=n.parentElement;return n?.parentElement===e.dom?n:void 0}function _G(t,e,n,r=5){const i=t.dom,o=i.firstElementChild,l=i.lastElementChild;if(!o||!l)return{x:e,y:n};const c=o.getBoundingClientRect(),d=l.getBoundingClientRect(),f=Math.min(Math.max(c.top+r,n),d.bottom-r),h=.5,m=Math.abs(c.left-d.left){const{x:e,y:n,editor:r}=t,{view:i,state:o}=r,{x:l,y:c}=_G(i,e,n,5),d=i.root.elementsFromPoint(l,c);let f;if(Array.prototype.some.call(d,g=>{if(!i.dom.contains(g))return!1;const y=LG(g,i);return y?(f=y,!0):!1}),!f)return{resultElement:null,resultNode:null,pos:null};let h;try{h=i.posAtDOM(f,0)}catch{return{resultElement:null,resultNode:null,pos:null}}const m=o.doc.nodeAt(h);if(!m){const g=o.doc.resolve(h),y=g.parent;return{resultElement:f,resultNode:y,pos:g.start()}}return{resultElement:f,resultNode:m,pos:h}};function jf(t,e){return window.getComputedStyle(t)[e]}function HG(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function IG(t,e,n){const r=parseInt(jf(t.dom,"paddingLeft"),10),i=parseInt(jf(t.dom,"paddingRight"),10),o=parseInt(jf(t.dom,"borderLeftWidth"),10),l=parseInt(jf(t.dom,"borderLeftWidth"),10),c=t.dom.getBoundingClientRect();return{left:HG(e,c.left+r+o,c.right-i-l),top:n}}function CE(t){var e;(e=t.parentNode)==null||e.removeChild(t)}function zG(t,e){const{doc:n}=e.view.state,r=bE({editor:e,x:t.clientX,y:t.clientY});if(!r.resultNode||r.pos===null)return[];const i=t.clientX,o=IG(e.view,i,t.clientY),l=e.view.posAtCoords(o);if(!l)return[];const{pos:c}=l;if(!n.resolve(c).parent)return[];const f=n.resolve(r.pos),h=n.resolve(r.pos+1);return C1(f,h,0)}function BG(t,e){const{view:n}=e;if(!t.dataTransfer)return;const{empty:r,$from:i,$to:o}=n.state.selection,l=zG(t,e),c=C1(i,o,0),d=c.some(x=>l.find(k=>k.$from===x.$from&&k.$to===x.$to)),f=r||!d?l:c;if(!f.length)return;const{tr:h}=n.state,m=document.createElement("div"),g=f[0].$from.pos,y=f[f.length-1].$to.pos,C=qo.create(n.state.doc,g,y),w=C.content();f.forEach(x=>{const k=n.nodeDOM(x.$from.pos),A=DG(k);m.append(A)}),m.style.position="absolute",m.style.top="-10000px",document.body.append(m),t.dataTransfer.clearData(),t.dataTransfer.setDragImage(m,0,0),n.dragging={slice:w,move:!0},h.setSelection(C),n.dispatch(h),document.addEventListener("drop",()=>CE(m),{once:!0})}var q6=(t,e)=>{const n=t.resolve(e),{depth:r}=n;return r===0?e:n.pos-n.parentOffset-1},Z6=(t,e)=>{const n=t.nodeAt(e),r=t.resolve(e);let{depth:i}=r,o=n;for(;i>0;){const l=r.node(i);i-=1,i===0&&(o=l)}return o},J0=(t,e)=>{const n=Ct.getState(t);return n?bp(e,n.type,n.binding.mapping):null},jG=(t,e)=>{const n=Ct.getState(t);return n?iu(n.doc,n.type,e,n.binding.mapping)||0:-1},K6=(t,e)=>{let n=e;for(;n?.parentNode&&n.parentNode!==t.dom;)n=n.parentNode;return n},wE=new qe("dragHandle"),xE=({pluginKey:t=wE,element:e,editor:n,computePositionConfig:r,getReferencedVirtualElement:i,onNodeChange:o,onElementDragStart:l,onElementDragEnd:c})=>{const d=document.createElement("div");let f=!1,h=null,m=-1,g,y=null,C=null;function w(){e&&(e.style.visibility="hidden",e.style.pointerEvents="none")}function x(){if(e){if(!n.isEditable){w();return}e.style.visibility="",e.style.pointerEvents="auto"}}function k(R){const L=i?.()||{getBoundingClientRect:()=>R.getBoundingClientRect()};ju(L,e,r).then(z=>{Object.assign(e.style,{position:z.strategy,left:`${z.x}px`,top:`${z.y}px`})})}function A(R){l?.(R),BG(R,n),e&&(e.dataset.dragging="true"),setTimeout(()=>{e&&(e.style.pointerEvents="none")},0)}function N(R){c?.(R),w(),e&&(e.style.pointerEvents="auto",e.dataset.dragging="false")}return e.addEventListener("dragstart",A),e.addEventListener("dragend",N),d.appendChild(e),{unbind(){e.removeEventListener("dragstart",A),e.removeEventListener("dragend",N),y&&(cancelAnimationFrame(y),y=null,C=null)},plugin:new Ve({key:typeof t=="string"?new qe(t):t,state:{init(){return{locked:!1}},apply(R,L,z,_){const q=R.getMeta("lockDragHandle"),J=R.getMeta("hideDragHandle");if(q!==void 0&&(f=q),J)return w(),f=!1,h=null,m=-1,o?.({editor:n,node:null,pos:-1}),L;if(R.docChanged&&m!==-1&&e)if(mE(R)){const U=jG(_,g);U!==m&&(m=U)}else{const U=R.mapping.map(m);U!==m&&(m=U,g=J0(_,m))}return L}},view:R=>{var L;return e.draggable=!0,e.style.pointerEvents="auto",e.dataset.dragging="false",(L=n.view.dom.parentElement)==null||L.appendChild(d),d.style.pointerEvents="none",d.style.position="absolute",d.style.top="0",d.style.left="0",{update(z,_){if(!e)return;if(!n.isEditable){w();return}if(f?e.draggable=!1:e.draggable=!0,R.state.doc.eq(_.doc)||m===-1)return;let q=R.nodeDOM(m);if(q=K6(R,q),q===R.dom||q?.nodeType!==1)return;const J=R.posAtDOM(q,0),U=Z6(n.state.doc,J),ne=q6(n.state.doc,J);h=U,m=ne,g=J0(R.state,m),o?.({editor:n,node:h,pos:m}),k(q)},destroy(){y&&(cancelAnimationFrame(y),y=null,C=null),e&&CE(d)}}},props:{handleDOMEvents:{keydown(R){return!e||f||R.hasFocus()&&(w(),h=null,m=-1,o?.({editor:n,node:null,pos:-1})),!1},mouseleave(R,L){return f||L.target&&!d.contains(L.relatedTarget)&&(w(),h=null,m=-1,o?.({editor:n,node:null,pos:-1})),!1},mousemove(R,L){return!e||f||(C={x:L.clientX,y:L.clientY},y)||(y=requestAnimationFrame(()=>{if(y=null,!C)return;const{x:z,y:_}=C;C=null;const q=bE({x:z,y:_,editor:n});if(!q.resultElement)return;let J=q.resultElement;if(J=K6(R,J),J===R.dom||J?.nodeType!==1)return;const U=R.posAtDOM(J,0),ne=Z6(n.state.doc,U);if(ne!==h){const le=q6(n.state.doc,U);h=ne,m=le,g=J0(R.state,m),o?.({editor:n,node:h,pos:m}),k(J),x()}})),!1}}}})}},py={placement:"left-start",strategy:"absolute"};Ze.create({name:"dragHandle",addOptions(){return{render(){const t=document.createElement("div");return t.classList.add("drag-handle"),t},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0}},addCommands(){return{lockDragHandle:()=>({editor:t})=>(this.options.locked=!0,t.commands.setMeta("lockDragHandle",this.options.locked)),unlockDragHandle:()=>({editor:t})=>(this.options.locked=!1,t.commands.setMeta("lockDragHandle",this.options.locked)),toggleDragHandle:()=>({editor:t})=>(this.options.locked=!this.options.locked,t.commands.setMeta("lockDragHandle",this.options.locked))}},addProseMirrorPlugins(){const t=this.options.render();return[xE({computePositionConfig:{...py,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:t,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd}).plugin]}});var VG=t=>{const{className:e="drag-handle",children:n,editor:r,pluginKey:i=wE,onNodeChange:o,onElementDragStart:l,onElementDragEnd:c,computePositionConfig:d=py}=t,[f,h]=E.useState(null),m=E.useRef(null);return E.useEffect(()=>{let g=null;return f?r.isDestroyed?()=>{m.current=null}:(m.current||(g=xE({editor:r,element:f,pluginKey:i,computePositionConfig:{...py,...d},onElementDragStart:l,onElementDragEnd:c,onNodeChange:o}),m.current=g.plugin,r.registerPlugin(m.current)),()=>{r.unregisterPlugin(i),m.current=null,g&&(g.unbind(),g=null)}):()=>{m.current=null}},[f,r,o,i,d,l,c]),S.jsx("div",{className:e,style:{visibility:"hidden",position:"absolute"},"data-dragging":"false",ref:h,children:n})},UG=VG;function PG({initialOpen:t=!1,placement:e="top",open:n,onOpenChange:r,delay:i=600,closeDelay:o=0}={}){const[l,c]=E.useState(t),d=n??l,f=r??c,h=e1({placement:e,open:d,onOpenChange:f,whileElementsMounted:qp,middleware:[Yp(4),B3({crossAxis:e.includes("-"),fallbackAxisSideDirection:"start",padding:4}),z3({padding:4})]}),m=h.context,g=yU(m,{mouseOnly:!0,move:!1,restMs:i,enabled:n==null,delay:{close:o}}),y=LU(m,{enabled:n==null}),C=U3(m),w=P3(m,{role:"tooltip"}),x=t1([g,y,C,w]);return E.useMemo(()=>({open:d,setOpen:f,...x,...h}),[d,f,x,h])}const my=E.createContext(null);function SE(){const t=E.useContext(my);if(t==null)throw new Error("Tooltip components must be wrapped in ");return t}function TE({children:t,...e}){const n=PG(e);return e.useDelayGroup?S.jsx(bU,{delay:{open:e.delay??0,close:e.closeDelay??0},timeoutMs:e.timeout,children:S.jsx(my.Provider,{value:n,children:t})}):S.jsx(my.Provider,{value:n,children:t})}const kE=E.forwardRef(function({children:e,asChild:n=!1,...r},i){const o=SE(),l=E.isValidElement(e)?parseInt(E.version,10)>=19?e.props.ref:e.ref:void 0,c=ol([o.refs.setReference,i,l]);if(n&&E.isValidElement(e)){const d={"data-tooltip-state":o.open?"open":"closed"};return E.cloneElement(e,o.getReferenceProps({ref:c,...r,...typeof e.props=="object"?e.props:{},...d}))}return S.jsx("button",{ref:c,"data-tooltip-state":o.open?"open":"closed",...o.getReferenceProps(r),children:e})}),EE=E.forwardRef(function({style:e,children:n,portal:r=!0,portalProps:i={},...o},l){const c=SE(),d=ol([c.refs.setFloating,l]);if(!c.open)return null;const f=S.jsx("div",{ref:d,style:{...c.floatingStyles,...e},...c.getFloatingProps(o),className:"tiptap-tooltip",children:n});return r?S.jsx(Qp,{...i,children:f}):f});TE.displayName="Tooltip";kE.displayName="TooltipTrigger";EE.displayName="TooltipContent";const FG={ctrl:"⌘",alt:"⌥",shift:"⇧"},$G=(t,e)=>{if(e){const n=t.toLowerCase();return FG[n]||t.toUpperCase()}return t.charAt(0).toUpperCase()+t.slice(1)},qG=(t,e)=>t?t.split("-").map(n=>n.trim()).map(n=>$G(n,e)):[],ZG=({shortcuts:t})=>t.length===0?null:S.jsx("div",{children:t.map((e,n)=>S.jsxs(E.Fragment,{children:[n>0&&S.jsx("kbd",{children:"+"}),S.jsx("kbd",{children:e})]},n))}),xt=E.forwardRef(({className:t="",spanTag:e,children:n,tooltip:r,showTooltip:i=!0,shortcutKeys:o,"aria-label":l,...c},d)=>{const f=E.useMemo(()=>typeof navigator<"u"&&navigator.platform.toLowerCase().includes("mac"),[]),h=E.useMemo(()=>qG(o,f),[o,f]);return!r||!i?e?S.jsx("span",{className:`tiptap-button ${t}`.trim(),ref:d,"aria-label":l,...c,children:n}):S.jsx("button",{className:`tiptap-button ${t}`.trim(),ref:d,"aria-label":l,...c,children:n}):S.jsxs(TE,{delay:200,children:[S.jsx(kE,{className:`tiptap-button ${t}`.trim(),ref:d,"aria-label":l,...c,children:n}),S.jsxs(EE,{children:[r,S.jsx(ZG,{shortcuts:h})]})]})});xt.displayName="Button";const Yu=E.forwardRef(({decorative:t,orientation:e="vertical",className:n="",...r},i)=>{const l=t?{role:"none"}:{"aria-orientation":e==="vertical"?e:void 0,role:"separator"};return S.jsx("div",{className:`tiptap-separator ${n}`.trim(),"data-orientation":e,...l,...r,ref:i})});Yu.displayName="Separator";const ME=E.createContext(null);function w1(){const t=E.useContext(ME);if(!t)throw new Error("DropdownMenu components must be wrapped in ");return t}function KG({initialOpen:t=!1,open:e,onOpenChange:n,side:r="bottom",align:i="start"}){const[o,l]=E.useState(t),[c,d]=E.useState(`${r}-${i}`),[f,h]=E.useState(null),[m,g]=E.useState(null),y=e??o,C=n??l,w=E.useRef([]),x=E.useRef([]),k=e1({open:y,onOpenChange:C,placement:c,middleware:[Yp({mainAxis:4}),B3(),z3({padding:4}),NT({apply({availableHeight:L}){const z=L-16;g(z)}})],whileElementsMounted:qp}),{context:A}=k,N=t1([IT(A,{event:"click",toggle:!0,ignoreMouse:!1}),P3(A,{role:"menu"}),U3(A,{outsidePress:!0,outsidePressEvent:"mousedown"}),HU(A,{listRef:w,activeIndex:f,onNavigate:h,loop:!0}),zU(A,{listRef:x,onMatch:y?h:void 0,activeIndex:f})]),R=E.useCallback((L,z)=>{d(`${L}-${z}`)},[]);return E.useMemo(()=>({open:y,setOpen:C,activeIndex:f,setActiveIndex:h,elementsRef:w,labelsRef:x,updatePosition:R,maxHeight:m,...N,...k}),[y,C,f,N,k,R,m])}function mv({children:t,...e}){const n=KG(e);return S.jsx(ME.Provider,{value:n,children:S.jsx(lU,{elementsRef:n.elementsRef,labelsRef:n.labelsRef,children:t})})}const x1=E.forwardRef(({children:t,asChild:e=!1,...n},r)=>{const i=w1(),o=E.isValidElement(t)?parseInt(E.version,10)>=19?t.props.ref:t.ref:void 0,l=ol([i.refs.setReference,r,o]);if(e&&E.isValidElement(t)){const c={"data-state":i.open?"open":"closed"};return E.cloneElement(t,i.getReferenceProps({ref:l,...n,...typeof t.props=="object"?t.props:{},"aria-expanded":i.open,"aria-haspopup":"menu",...c}))}return S.jsx("button",{ref:l,"aria-expanded":i.open,"aria-haspopup":"menu","data-state":i.open?"open":"closed",...i.getReferenceProps(n),children:t})});x1.displayName="DropdownMenuTrigger";const S1=E.forwardRef(({style:t,className:e,orientation:n="vertical",side:r="bottom",align:i="start",portal:o=!0,portalProps:l={},...c},d)=>{const f=w1(),h=ol([f.refs.setFloating,d]);if(E.useEffect(()=>{f.updatePosition(r,i)},[f,r,i]),!f.open)return null;const m=S.jsx(HT,{context:f.context,modal:!1,initialFocus:0,returnFocus:!0,children:S.jsx("div",{ref:h,className:`tiptap-dropdown-menu ${e||""}`,style:{position:f.strategy,top:f.y??0,left:f.x??0,outline:"none",...t},"aria-orientation":n,"data-orientation":n,"data-state":f.open?"open":"closed","data-side":r,"data-align":i,...f.getFloatingProps(c),children:c.children})});return o?S.jsx(Qp,{...l,children:m}):m});S1.displayName="DropdownMenuContent";const T1=E.forwardRef(({children:t,disabled:e,asChild:n=!1,onSelect:r,className:i,...o},l)=>{const c=w1(),d=aU({label:e?null:t?.toString()}),f=c.activeIndex===d.index,h=E.useCallback(g=>{e||(r?.(),o.onClick?.(g),c.setOpen(!1))},[c,e,r,o]),m={ref:ol([d.ref,l]),role:"menuitem",className:i,tabIndex:f?0:-1,"data-highlighted":f,"aria-disabled":e,...c.getItemProps({...o,onClick:h})};if(n&&E.isValidElement(t)){const g=t.props,y={...m,...typeof t.props=="object"?t.props:{}},C={onClick:w=>{h(w),g.onClick?.(w)}};return E.cloneElement(t,{...y,...C})}return S.jsx("div",{...m,children:t})});T1.displayName="DropdownMenuItem";const k1=E.forwardRef(({children:t,label:e,className:n,...r},i)=>{const o=w1(),l={};return o.maxHeight&&(l.maxHeight=`${o.maxHeight}px`),S.jsx("div",{...r,ref:i,role:"group","aria-label":e,className:`tiptap-button-group ${n||""}`,style:l,children:t})});k1.displayName="DropdownMenuGroup";const GG=E.forwardRef(({className:t,...e},n)=>S.jsx(Yu,{ref:n,className:`tiptap-dropdown-menu-separator ${t||""}`,...e}));GG.displayName=Yu.displayName;function AE(t){const{x:e,y:n,direction:r,editor:i}=t;let o=null,l=null,c=null,d=e,f=null;for(;l===null&&d0;){const h=document.elementsFromPoint(d,n),m=h.findIndex(y=>y.classList.contains("ProseMirror")),g=h.slice(0,m);if(g.length>0){let y=g[0],C=y,w=100;for(;w>0&&C.parentElement&&!C.parentElement.classList.contains("f-tiptap-editor__tiptap-editor");)C=C.parentElement,w--;if(C&&(y=C),o=y,c=i.view.posAtDOM(y,0),c>=0){f=i.state.doc.resolve(c),f.depth>=1&&(l=f.node(1)),l||(l=i.state.doc.nodeAt(Math.max(c-1,0)),l||(l=i.state.doc.nodeAt(Math.max(c,0))));break}}r==="left"?d-=1:d+=1}return{resultElement:o,resultNode:l,pos:c!==null?c:null,resolvedPos:f}}const YG=({event:t,editor:e})=>{const n=t.target.closest(".drag-handle").getBoundingClientRect(),r=AE({x:n.left,y:n.top+16,direction:"right",editor:e});if(!r||r.resolvedPos===null){console.error("No node found at the clicked position");return}e.chain().focus().triggerFolioTiptapCommand(r.resolvedPos).run()},WG=()=>{},NE=(t,e)=>{if(!e.resultNode||e.pos===null)throw new Error("Invalid target node");const n=t.state.doc.resolve(e.pos);let r,i;return e.resultNode.isLeaf||e.resultNode.content.size===0?(r=e.pos,i=e.pos+e.resultNode.nodeSize):(r=n.before(1),i=n.after(1)),{startPos:r,endPos:i}},JG=async(t,e,n)=>{try{if(e&&e.resultElement){const r=e.resultElement.outerHTML,i=e.resultElement.textContent||"";try{await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:"text/html"}),"text/plain":new Blob([i],{type:"text/plain"})})])}catch(o){console.error("Failed to write to clipboard:",o)}return{success:!0,data:{html:r}}}return console.error("No target node found for copying"),{success:!1}}catch(r){return console.error("Error copying node:",r),{success:!1}}},XG=(t,e,n)=>{try{if(!n.html)return{success:!1};const{startPos:r,endPos:i}=NE(t,e);return e.resultNode?.type.name==="paragraph"&&e.resultNode.content.size===0?t.commands.insertContentAt(r,n.html):t.commands.insertContentAt(i,n.html),{success:!0}}catch(r){return console.error("Error pasting node:",r),{success:!1}}},QG=(t,e,n)=>{try{const{startPos:r,endPos:i}=NE(t,e);if(typeof r=="number"&&typeof i=="number"){const o=t.state.tr;return o.delete(r,i),t.view.dispatch(o),{success:!0}}else return console.error("Error removing node"),{success:!1}}catch(r){return console.error("Error removing node:",r),{success:!1}}},eY=(t,e,n)=>{if(!e.resultNode||e.pos===null)return console.error("Invalid target node"),{success:!1};if(e.resultElement){const r=new CustomEvent("f-tiptap-node:edit");return e.resultElement.dispatchEvent(r),{success:!0}}return{success:!1}},G6={cs:{copyNode:"Kopírovat",pasteNode:"Vložit",removeNode:"Odstranit",editFolioTiptapNode:"Upravit"},en:{copyNode:"Copy",pasteNode:"Paste",removeNode:"Remove",editFolioTiptapNode:"Edit"}},X0=[{type:"copyNode",icon:iP,command:JG},{type:"removeNode",icon:zp,command:QG}],tY={type:"pasteNode",icon:sP,command:XG},nY={type:"editFolioTiptapNode",icon:E8,command:eY},rY=(t,e,n,r,i)=>async()=>{const o=document.querySelector(".f-tiptap-smart-drag-handle__button--drag").getBoundingClientRect(),l=AE({x:o.left,y:o.top+16,direction:"right",editor:t});if(l&&l.resultNode&&l.pos!==null){const{success:c,data:d}=await e.command(t,l,r);c&&(n(null),e.type==="copyNode"&&d&&d.html&&i({at:Date.now(),html:d.html}))}else n(null)},Y6=1e3;function iY({editor:t,selectedNodeData:e,clipboardData:n,setClipboardData:r}){const[i,o]=E.useState(null),[,l]=Qe.useReducer(m=>m+1,0),c=Qe.useRef(null),[d]=Qe.useState(void 0);if(Qe.useEffect(()=>{if(n.at){const m=setTimeout(()=>{l()},Y6);return()=>clearTimeout(m)}},[n.at]),!t)return null;let f;n.at?f=[...X0.slice(0,1),tY,...X0.slice(1)]:f=X0;const h=[...e&&e.type==="folioTiptapNode"?[...f.slice(0,f.length-1),nY,f[f.length-1]]:f];return S.jsx("div",{className:"f-tiptap-smart-drag-handle-content",style:d,ref:c,children:S.jsxs("div",{className:"f-tiptap-smart-drag-handle-content__flex",children:[S.jsx(xt,{type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":"Plus",onClick:m=>{YG({event:m,editor:t})},className:"f-tiptap-smart-drag-handle__button f-tiptap-smart-drag-handle__button--plus",children:S.jsx(r1,{className:"tiptap-button-icon"})}),S.jsxs(mv,{open:i==="drag",onOpenChange:m=>{o(m?"drag":null)},children:[S.jsx(x1,{asChild:!0,children:S.jsx(xt,{spanTag:!0,type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":"Drag",onClick:WG,className:"f-tiptap-smart-drag-handle__button f-tiptap-smart-drag-handle__button--drag",children:n.at&&Date.now()-n.atS.jsx(T1,{asChild:!0,children:S.jsxs(xt,{type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":pe(G6,m.type),className:"f-tiptap-smart-drag-handle__dropdown-button",onClick:rY(t,m,o,n,r),children:[E.createElement(m.icon,{className:"tiptap-button-icon"}),pe(G6,m.type)]})},m.type))})})]})]})})}function oY({editor:t}){const[e,n]=Qe.useState(null),r=Qe.useRef(-1),[i,o]=Qe.useState({at:null,html:null});return S.jsx(UG,{editor:t,onElementDragStart:l=>{const c=r.current;if(!t.view.dragging&&c>=0){if(!t.state.doc.nodeAt(c))return;const f=me.create(t.state.doc,c),h=f.content();t.view.dragging={slice:h,move:!0};const m=t.state.tr.setSelection(f);if(t.view.dispatch(m),l.dataTransfer){l.dataTransfer.effectAllowed="move";const g=t.view.nodeDOM(c);if(g instanceof HTMLElement){const y=document.createElement("div");y.appendChild(g.cloneNode(!0)),y.style.position="absolute",y.style.top="-10000px",document.body.appendChild(y),l.dataTransfer.setDragImage(y,0,0),document.addEventListener("drop",()=>y.remove(),{once:!0})}}}},onNodeChange:({node:l,pos:c})=>{if(r.current=c,l){const d=document.querySelector(".drag-handle");if(d){const f=d.getBoundingClientRect(),h={type:l.type.name,x:f.x,y:f.y};if(e&&e.type===h.type&&e.x===h.x&&e.y===h.y)return;n(h);return}}n(null)},children:S.jsx(iY,{editor:t,selectedNodeData:e,clipboardData:i,setClipboardData:o})})}const RE=({content:t,schema:e,allowedNodeTypes:n})=>{if(!t)return t;if(t.type&&!e.nodes[t.type])return console.error(`Removed unsupported node type: ${t.type}`),{type:"folioTiptapInvalidNode",attrs:{invalidNodeHash:t}};if(t.type==="folioTiptapNode"&&n&&n.length>0){const r=t.attrs?.type;if(r&&!n.includes(r))return console.error(`Removed disallowed folioTiptapNode type: ${r}`),{type:"folioTiptapInvalidNode",attrs:{invalidNodeHash:t}}}if(Array.isArray(t.content)){const r=[];return t.content.forEach(i=>{const o=RE({content:i,schema:e,allowedNodeTypes:n});o&&r.push(o)}),{...t,content:r}}return t},sY=({content:t,editor:e,allowedFolioTiptapNodeTypes:n})=>{if(!t)return t;const r=n?.map(i=>i.type);return RE({content:t,schema:e.schema,allowedNodeTypes:r})},lY=t=>t.type==="paragraph"&&(!t.content||t.content.length===0),OE=t=>{if(!t.content||!Array.isArray(t.content)||t.content.length===0)return t;const e=t.content.map(n=>OE(n));return e.length>1&&lY(e[e.length-1])?{...t,content:e.slice(0,-1)}:{...t,content:e}},DE=t=>OE(t),aY={commandPlaceholder:'Začněte psát, nebo stiskněte "/" pro příkazy…',defaultPlaceholder:"Začněte psát…",headingInPagesPlaceholder:"Napište titulek stránky",h2Placeholder:'Napište H2 titulek, nebo "/" pro příkazy',h3Placeholder:'Napište H3 titulek, nebo "/" pro příkazy',h4Placeholder:'Napište H4 titulek, nebo "/" pro příkazy',singleHeadingPlaceholder:'Napište mezititulek, nebo "/" pro příkazy'},cY={commandPlaceholder:'Start writing, or press "/" for commands…',defaultPlaceholder:"Start writing…",headingInPagesPlaceholder:"Write page title",h2Placeholder:'Write H2 heading or "/" for commands',h3Placeholder:'Write H3 heading or "/" for commands',h4Placeholder:'Write H4 heading or "/" for commands',singleHeadingPlaceholder:'Write title or "/" for commands'},W6={cs:aY,en:cY};function uY(t,e){const n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),i=Math.min(t.left,e.left),l=Math.max(t.right,e.right)-i,c=r-n,d=i,f=n;return new DOMRect(d,f,l,c)}var dY=class{constructor({editor:t,element:e,view:n,updateDelay:r=250,resizeDelay:i=60,shouldShow:o,appendTo:l,getReferencedVirtualElement:c,options:d}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:h,state:m,from:g,to:y})=>{const{doc:C,selection:w}=m,{empty:x}=w,k=!C.textBetween(g,y).length&&Uy(m.selection),A=this.element.contains(document.activeElement);return!(!(h.hasFocus()||A)||x||k||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:h})=>{var m;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}h?.relatedTarget&&((m=this.element.parentNode)!=null&&m.contains(h.relatedTarget))||h?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(h,m)=>{const g=!m?.selection.eq(h.state.selection),y=!m?.doc.eq(h.state.doc);!g&&!y||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(h,g,y,m)},this.updateDelay))},this.updateHandler=(h,m,g,y)=>{const{composing:C}=h;if(C||!m&&!g)return;if(!this.getShouldShow(y)){this.hide();return}this.updatePosition(),this.show()},this.transactionHandler=({transaction:h})=>{h.getMeta("bubbleMenu")==="updatePosition"&&this.updatePosition()};var f;this.editor=t,this.element=e,this.view=n,this.updateDelay=r,this.resizeDelay=i,this.appendTo=l,this.scrollTarget=(f=d?.scrollTarget)!=null?f:window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...d},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(Kp(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(I3(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(Zp(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(ET(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(Gp(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(TT(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(kT(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(MT(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}get virtualElement(){var t;const{selection:e}=this.editor.state,n=(t=this.getReferencedVirtualElement)==null?void 0:t.call(this);if(n)return n;const r=Jx(this.view,e.from,e.to);let i={getBoundingClientRect:()=>r,getClientRects:()=>[r]};if(e instanceof me){let o=this.view.nodeDOM(e.from);const l=o.dataset.nodeViewWrapper?o:o.querySelector("[data-node-view-wrapper]");l&&(o=l),o&&(i={getBoundingClientRect:()=>o.getBoundingClientRect(),getClientRects:()=>[o.getBoundingClientRect()]})}if(e instanceof dt){const{$anchorCell:o,$headCell:l}=e,c=o?o.pos:l.pos,d=l?l.pos:o.pos,f=this.view.nodeDOM(c),h=this.view.nodeDOM(d);if(!f||!h)return;const m=f===h?f.getBoundingClientRect():uY(f.getBoundingClientRect(),h.getBoundingClientRect());i={getBoundingClientRect:()=>m,getClientRects:()=>[m]}}return i}updatePosition(){const t=this.virtualElement;t&&ju(t,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:n,strategy:r})=>{this.element.style.width="max-content",this.element.style.position=r,this.element.style.left=`${e}px`,this.element.style.top=`${n}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(t,e);return}const i=!e?.selection.eq(t.state.selection),o=!e?.doc.eq(t.state.doc);this.updateHandler(t,i,o,e)}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:i}=r,o=Math.min(...i.map(d=>d.$from.pos)),l=Math.max(...i.map(d=>d.$to.pos));return((e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:o,to:l}))||!1}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},LE=t=>new Ve({key:typeof t.pluginKey=="string"?new qe(t.pluginKey):t.pluginKey,view:e=>new dY({view:e,...t})});Ze.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[LE({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var fY=class{constructor({editor:t,element:e,view:n,options:r,appendTo:i,shouldShow:o}){this.preventHide=!1,this.isVisible=!1,this.shouldShow=({view:l,state:c})=>{const{selection:d}=c,{$anchor:f,empty:h}=d,m=f.depth===1,g=f.parent.isTextblock&&!f.parent.type.spec.code&&!f.parent.textContent&&f.parent.childCount===0&&!this.getTextContent(f.parent);return!(!l.hasFocus()||!h||!m||!g||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(l,c,d,f)=>{const{composing:h}=l;if(h||!c&&!d)return;if(!this.getShouldShow(f)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:l})=>{var c;if(this.preventHide){this.preventHide=!1;return}l?.relatedTarget&&((c=this.element.parentNode)!=null&&c.contains(l.relatedTarget))||l?.relatedTarget!==this.editor.view.dom&&this.hide()},this.editor=t,this.element=e,this.view=n,this.appendTo=i,this.floatingUIOptions={...this.floatingUIOptions,...r},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(t){return Zx(t,{textSerializers:qy(this.editor.schema)})}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(Kp(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(I3(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(Zp(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(ET(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(Gp(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(TT(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(kT(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(MT(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:i}=r,o=Math.min(...i.map(d=>d.$from.pos)),l=Math.max(...i.map(d=>d.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,view:this.view,state:n,oldState:t,from:o,to:l})}updatePosition(){const{selection:t}=this.editor.state,e=Jx(this.view,t.from,t.to);ju({getBoundingClientRect:()=>e,getClientRects:()=>[e]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:r,y:i,strategy:o})=>{this.element.style.width="max-content",this.element.style.position=o,this.element.style.left=`${r}px`,this.element.style.top=`${i}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const n=!e?.selection.eq(t.state.selection),r=!e?.doc.eq(t.state.doc);this.updateHandler(t,n,r,e)}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},_E=t=>new Ve({key:typeof t.pluginKey=="string"?new qe(t.pluginKey):t.pluginKey,view:e=>new fY({view:e,...t})});Ze.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[_E({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});var hY=Qe.forwardRef(({pluginKey:t="bubbleMenu",editor:e,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:o=null,getReferencedVirtualElement:l,options:c,children:d,...f},h)=>{const m=E.useRef(document.createElement("div"));typeof h=="function"?h(m.current):h&&(h.current=m.current);const{editor:g}=e3(),y=e||g,C={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:t,shouldShow:o,getReferencedVirtualElement:l,options:c},w=E.useRef(C);return w.current=C,E.useEffect(()=>{if(y?.isDestroyed)return;if(!y){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const x=m.current;x.style.visibility="hidden",x.style.position="absolute";const k=LE({...w.current,editor:y,element:x});y.registerPlugin(k);const A=w.current.pluginKey;return()=>{y.unregisterPlugin(A),window.requestAnimationFrame(()=>{x.parentNode&&x.parentNode.removeChild(x)})}},[y]),Oa.createPortal(S.jsx("div",{...f,children:d}),m.current)});Qe.forwardRef(({pluginKey:t="floatingMenu",editor:e,appendTo:n,shouldShow:r=null,options:i,children:o,...l},c)=>{const d=E.useRef(document.createElement("div"));typeof c=="function"?c(d.current):c&&(c.current=d.current);const{editor:f}=e3();return E.useEffect(()=>{const h=d.current;if(h.style.visibility="hidden",h.style.position="absolute",e?.isDestroyed||f?.isDestroyed)return;const m=e||f;if(!m){console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");return}const g=_E({editor:m,element:h,pluginKey:t,appendTo:n,shouldShow:r,options:i});return m.registerPlugin(g),()=>{m.unregisterPlugin(t),window.requestAnimationFrame(()=>{h.parentNode&&h.parentNode.removeChild(h)})}},[e,f,n,t,r,i]),Oa.createPortal(S.jsx("div",{...l,children:o}),d.current)});const Q0={cs:{addFolioTiptapColumnBefore:"Přidat sloupec před",addFolioTiptapColumnAfter:"Přidat sloupec za",deleteFolioTiptapColumn:"Odstranit sloupec"},en:{addFolioTiptapColumnBefore:"Add column before",addFolioTiptapColumnAfter:"Add column after",deleteFolioTiptapColumn:"Remove column"}},pY={pluginKey:"folioTiptapColumnsBubbleMenu",priority:1,shouldShow:({editor:t})=>t.isActive(o1.name),items:[[{key:"addFolioTiptapColumnBefore",title:pe(Q0,"addFolioTiptapColumnBefore"),icon:t8,command:({editor:t})=>{t.chain().focus().addFolioTiptapColumnBefore().run()}},{key:"deleteFolioTiptapColumn",title:pe(Q0,"deleteFolioTiptapColumn"),icon:i1,command:({editor:t})=>{t.chain().focus().deleteFolioTiptapColumn().run()}},{key:"addFolioTiptapColumnAfter",title:pe(Q0,"addFolioTiptapColumnAfter"),icon:e8,command:({editor:t})=>{t.chain().focus().addFolioTiptapColumnAfter().run()}}]]},wr={cs:{addColumnAfter:"Přidat sloupec za",addColumnBefore:"Přidat sloupec před",addRowAfter:"Přidat řádek pod",addRowBefore:"Přidat řádek nad",deleteColumn:"Odstranit sloupec",deleteRow:"Odstranit řádek",deleteTable:"Odstranit tabulku",mergeCells:"Sloučit buňky",splitCell:"Rozdělit buňku",toggleHeaderCell:"Přepnout buňku na záhlaví",toggleHeaderColumn:"Přepnout sloupec na záhlaví",toggleHeaderRow:"Přepnout řádek na záhlaví"},en:{addColumnAfter:"Add column after",addColumnBefore:"Add column before",addRowAfter:"Add row below",addRowBefore:"Add row above",deleteColumn:"Remove column",deleteRow:"Remove row",deleteTable:"Remove table",mergeCells:"Merge cells",splitCell:"Split cell",toggleHeaderCell:"Toggle cell header",toggleHeaderColumn:"Toggle column header",toggleHeaderRow:"Toggle row header"}},mY={pluginKey:"tableBubbleMenu",priority:2,shouldShow:({editor:t})=>t.isActive("table"),disabledKeys:({editor:t})=>{const e=[];return t.can().splitCell()||e.push("splitCell"),t.can().mergeCells()||e.push("mergeCells"),e},items:[[{key:"addColumnBefore",title:pe(wr,"addColumnBefore"),icon:L8,command:({editor:t})=>{t.chain().focus().addColumnBefore().run()}},{key:"addColumnAfter",title:pe(wr,"addColumnAfter"),icon:D8,command:({editor:t})=>{t.chain().focus().addColumnAfter().run()}},{key:"deleteColumn",title:pe(wr,"deleteColumn"),icon:I8,command:({editor:t})=>{t.chain().focus().deleteColumn().run()}}],[{key:"addRowBefore",title:pe(wr,"addRowBefore"),icon:H8,command:({editor:t})=>{t.chain().focus().addRowBefore().run()}},{key:"addRowAfter",title:pe(wr,"addRowAfter"),icon:_8,command:({editor:t})=>{t.chain().focus().addRowAfter().run()}},{key:"deleteRow",title:pe(wr,"deleteRow"),icon:z8,command:({editor:t})=>{t.chain().focus().deleteRow().run()}}],[{key:"toggleHeaderColumn",title:pe(wr,"toggleHeaderColumn"),icon:P8,command:({editor:t})=>{t.chain().focus().toggleHeaderColumn().run()}},{key:"toggleHeaderRow",title:pe(wr,"toggleHeaderRow"),icon:F8,command:({editor:t})=>{t.chain().focus().toggleHeaderRow().run()}},{key:"toggleHeaderCell",title:pe(wr,"toggleHeaderCell"),icon:U8,command:({editor:t})=>{t.chain().focus().toggleHeaderCell().run()}}],[{key:"mergeCells",title:pe(wr,"mergeCells"),icon:j8,command:({editor:t})=>{t.chain().focus().mergeCells().run()}},{key:"splitCell",title:pe(wr,"splitCell"),icon:V8,command:({editor:t})=>{t.chain().focus().splitCell().run()}},{key:"deleteTable",title:pe(wr,"deleteTable"),icon:B8,command:({editor:t})=>{t.chain().focus().deleteTable().run()}}]]};function gY({editor:t,source:e,activeMenus:n}){const r={placement:e.placement||"bottom",offset:e.offset||12,flip:!0},[i,o]=Qe.useState([]),[l,c]=Qe.useState([]),d=(m,g)=>{n.set(m,g)},f=m=>{n.delete(m)},h=(m,g)=>{if(n.size===0||!n.has(m))return!1;let y=-1/0;for(const[,C]of n.entries())C>y&&(y=C);return g>=y};return S.jsx(hY,{pluginKey:e.pluginKey,shouldShow:({editor:m,state:g})=>{const y=e.shouldShow({editor:m,state:g});let C=!1;if(y?(d(e.pluginKey,e.priority),C=h(e.pluginKey,e.priority)):f(e.pluginKey),C){if(e.activeKeys){const w=e.activeKeys({editor:m,state:g});o(w)}if(e.disabledKeys){const w=e.disabledKeys({editor:m,state:g});c(w)}}return C},options:r,className:"f-tiptap-editor-bubble-menu","data-bubble-menu-type":e.pluginKey,children:e.items.map((m,g)=>S.jsx("div",{className:"f-tiptap-editor-bubble-menu__row",children:m.map(y=>{const C=y.icon,w=i.indexOf(y.key)!==-1,x=l.indexOf(y.key)!==-1;return S.jsx(xt,{type:"button","data-style":"ghost","data-size":"large-icon",role:"button",tabIndex:-1,"aria-label":y.title,disabled:x,"data-active-state":w?"on":"off","aria-pressed":w,tooltip:y.title,onClick:x?void 0:()=>{y.command({editor:t})},children:S.jsx(C,{className:"tiptap-button-icon"})},y.title)})},g))})}const yY=[pY,mY,WF,Tj,IF];function vY({editor:t,blockEditor:e}){if(!t||!e)return null;const n=new Map;return S.jsx(S.Fragment,{children:yY.map(r=>S.jsx(gY,{editor:t,source:r,activeMenus:n},r.pluginKey))})}const HE=E.forwardRef(({orientation:t="horizontal",size:e,className:n="",style:r={},...i},o)=>{const l={...r,...t==="horizontal"&&!e&&{flex:1},...e&&{width:t==="vertical"?"1px":e,height:t==="horizontal"?"1px":e}};return S.jsx("div",{ref:o,...i,className:n,style:l})});HE.displayName="Spacer";const gv=t=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})},yv=(t,e)=>{E.useEffect(()=>{const n=t.current;if(!n)return;let r=!0;r&&requestAnimationFrame(e);const i=new MutationObserver(()=>{r&&requestAnimationFrame(e)});return i.observe(n,{childList:!0,subtree:!0,attributes:!0}),()=>{r=!1,i.disconnect()}},[t,e])},bY=t=>{E.useEffect(()=>{const e=t.current;if(!e)return;const n=()=>Array.from(e.querySelectorAll('button:not([disabled]), [role="button"]:not([disabled]), [tabindex="0"]:not([disabled])')),r=(d,f,h)=>{d.preventDefault();let m=f;m>=h.length?m=0:m<0&&(m=h.length-1),h[m]?.focus()},i=d=>{const f=n();if(!f.length)return;const h=document.activeElement,m=f.indexOf(h);if(!e.contains(h))return;const y={ArrowRight:()=>r(d,m+1,f),ArrowDown:()=>r(d,m+1,f),ArrowLeft:()=>r(d,m-1,f),ArrowUp:()=>r(d,m-1,f),Home:()=>r(d,0,f),End:()=>r(d,f.length-1,f)}[d.key];y&&y()},o=d=>{const f=d.target;e.contains(f)&&f.setAttribute("data-focus-visible","true")},l=d=>{const f=d.target;e.contains(f)&&f.removeAttribute("data-focus-visible")};return e.addEventListener("keydown",i),e.addEventListener("focus",o,!0),e.addEventListener("blur",l,!0),n().forEach(d=>{d.addEventListener("focus",o),d.addEventListener("blur",l)}),()=>{e.removeEventListener("keydown",i),e.removeEventListener("focus",o,!0),e.removeEventListener("blur",l,!0),n().forEach(f=>{f.removeEventListener("focus",o),f.removeEventListener("blur",l)})}},[t])},CY=t=>{const[e,n]=E.useState(!0),r=E.useRef(!1);E.useEffect(()=>(r.current=!0,()=>{r.current=!1}),[]);const i=E.useCallback(()=>{if(!r.current)return;const o=t.current;if(!o)return;const l=Array.from(o.children).some(c=>c instanceof HTMLElement&&c.getAttribute("role")==="group"?c.children.length>0:!1);n(l)},[t]);return yv(t,i),e},wY=t=>{const[e,n]=E.useState(!0),r=E.useRef(!1);E.useEffect(()=>(r.current=!0,()=>{r.current=!1}),[]);const i=E.useCallback(()=>{if(!r.current)return;const o=t.current;if(!o)return;const l=Array.from(o.children).some(c=>c instanceof HTMLElement);n(l)},[t]);return yv(t,i),e},xY=t=>{const[e,n]=E.useState(!0),r=E.useRef(!1);E.useEffect(()=>(r.current=!0,()=>{r.current=!1}),[]);const i=E.useCallback(()=>{if(!r.current)return;const o=t.current;if(!o)return;const l=o.previousElementSibling,c=o.nextElementSibling;if(!l||!c){n(!1);return}const d=l.getAttribute("role")==="group"&&c.getAttribute("role")==="group",f=l.children.length>0&&c.children.length>0;n(d&&f)},[t]);return yv(t,i),e},IE=E.forwardRef(({children:t,className:e,variant:n="fixed",...r},i)=>{const o=E.useRef(null),l=CY(o);return bY(o),l?S.jsx("div",{ref:gv([o,i]),role:"toolbar","aria-label":"toolbar","data-variant":n,className:`f-tiptap-editor-toolbar ${e||""}`,...r,children:t}):null});IE.displayName="Toolbar";const $n=E.forwardRef(({children:t,className:e,...n},r)=>{const i=E.useRef(null);return wY(i)?S.jsx("div",{ref:gv([i,r]),role:"group",className:`f-tiptap-editor-toolbar__group ${e||""}`,...n,children:t}):null});$n.displayName="ToolbarGroup";const Ir=E.forwardRef(({...t},e)=>{const n=E.useRef(null);return xY(n)?S.jsx(Yu,{ref:gv([n,e]),orientation:"vertical",decorative:!0,...t}):null});Ir.displayName="ToolbarSeparator";const SY={cs:{insert:"Vložit obsah"},en:{insert:"Insert content"}};function TY(t,e){if(!t)return console.log("No editor available for insertFolioTiptapNode"),!1;try{return t.commands.insertFolioTiptapNode(e)}catch(n){return console.error("insertFolioTiptapNode error",n),!1}}const zE=E.forwardRef(({editor:t,disabled:e},n)=>{const r=E.useCallback(o=>{!o.defaultPrevented&&!e&&t&&t.chain().focus().triggerFolioTiptapCommand(null).run()},[e,t]);if(E.useEffect(()=>{const o=l=>{l.origin===window.origin&&(!l.data||l.data.type!=="f-c-tiptap-overlay:saved"||l.data.uniqueId||TY(t,l.data.node))};return window.addEventListener("message",o),()=>{window.removeEventListener("message",o)}},[t]),!t||!t.isEditable)return null;const i=pe(SY,"insert");return S.jsx(xt,{ref:n,type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":i,tooltip:i,onClick:r,children:S.jsx(r1,{className:"tiptap-button-icon"})})});zE.displayName="FolioTiptapNodeButton";const kY=(t,e)=>e?.schema?e.schema.spec.marks.get(t)!==void 0:!1,EY=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function MY(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return!t||t.replace(EY,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}function AY(t,e,n){try{const r=new URL(t,e);if(MY(r.href,n))return r.href}catch{}return"#"}const BE=E.createContext(null);function jE(){const t=E.useContext(BE);if(!t)throw new Error("Popover components must be wrapped in ");return t}function NY({initialOpen:t=!1,modal:e,open:n,onOpenChange:r,side:i="bottom",align:o="center",sideOffset:l=4,alignOffset:c=0}={}){const[d,f]=E.useState(t),[h,m]=E.useState(),[g,y]=E.useState(),[C,w]=E.useState(`${i}-${o}`),[x,k]=E.useState({sideOffset:l,alignOffset:c}),A=n??d,N=r??f,R=E.useMemo(()=>[Yp({mainAxis:x.sideOffset,crossAxis:x.alignOffset}),B3({fallbackAxisSideDirection:"end",crossAxis:!1}),z3({limiter:oU({offset:x.sideOffset})})],[x.sideOffset,x.alignOffset]),L=e1({placement:C,open:A,onOpenChange:N,whileElementsMounted:qp,middleware:R}),z=t1([IT(L.context),U3(L.context),P3(L.context)]),_=E.useCallback((q,J,U,ne)=>{w(`${q}-${J}`),(U!==void 0||ne!==void 0)&&k({sideOffset:U??x.sideOffset,alignOffset:ne??x.alignOffset})},[x.sideOffset,x.alignOffset]);return E.useMemo(()=>({open:A,setOpen:N,...z,...L,modal:e,labelId:h,descriptionId:g,setLabelId:m,setDescriptionId:y,updatePosition:_}),[A,N,z,L,e,h,g,_])}function RY({children:t,modal:e=!1,...n}){const r=NY({modal:e,...n});return S.jsx(BE.Provider,{value:r,children:t})}const VE=E.forwardRef(function({children:e,asChild:n=!1,...r},i){const o=jE(),l=E.isValidElement(e)?parseInt(E.version,10)>=19?e.props.ref:e.ref:void 0,c=ol([o.refs.setReference,i,l]);return n&&E.isValidElement(e)?E.cloneElement(e,o.getReferenceProps({ref:c,...r,...e.props,"data-state":o.open?"open":"closed"})):S.jsx("button",{ref:c,"data-state":o.open?"open":"closed",...o.getReferenceProps(r),children:e})}),UE=E.forwardRef(function({className:e,side:n="bottom",align:r="center",sideOffset:i,alignOffset:o,style:l,portal:c=!0,portalProps:d={},asChild:f=!1,children:h,...m},g){const y=jE(),C=E.isValidElement(h)?parseInt(E.version,10)>=19?h.props.ref:h.ref:void 0,w=ol([y.refs.setFloating,g,C]);if(E.useEffect(()=>{y.updatePosition(n,r,i,o)},[y,n,r,i,o]),!y.context.open)return null;const x={ref:w,style:{position:y.strategy,top:y.y??0,left:y.x??0,...l},"aria-labelledby":y.labelId,"aria-describedby":y.descriptionId,className:`tiptap-popover ${e||""}`,"data-side":n,"data-align":r,"data-state":y.context.open?"open":"closed",...y.getFloatingProps(m)},k=f&&E.isValidElement(h)?E.cloneElement(h,{...x,...h.props}):S.jsx("div",{...x,children:h}),A=S.jsx(HT,{context:y.context,modal:y.modal,children:k});return c?S.jsx(Qp,{...d,children:A}):A});VE.displayName="PopoverTrigger";UE.displayName="PopoverContent";const Lo={cs:{apply:"Uložit",openTheLink:"Otevřít odkaz",openSettings:"Upravit odkaz",removeLink:"Odstranit odkaz",placeholder:"Vložit URL odkazu …",settings:"Nastavit odkaz",openInNew:"Otevřít v novém okně",link:"Odkaz"},en:{apply:"Apply",openTheLink:"Open the link",openSettings:"Edit link",removeLink:"Remove link",placeholder:"Paste link URL …",settings:"Link settings",openInNew:"Open in new window",link:"Link"}},Vf={href:null,rel:null,target:null},OY=t=>{const{editor:e,onSetLink:n,onLinkActive:r,editorState:i}=t,[o,l]=E.useState({...Vf});E.useEffect(()=>{if(!i.active)return;const f=e.getAttributes("link");e.isActive("link")&&o.href===null&&(l({href:f.href||null,rel:f.rel||null,target:f.target||null}),r?.())},[i.active,r,o,e]),E.useEffect(()=>{if(!i.active)return;const f=()=>{const h=e.getAttributes("link");l({href:h.href||null,rel:h.rel||null,target:h.target||null}),e.isActive("link")&&h.href!==null&&r?.()};return e.on("selectionUpdate",f),()=>{e.off("selectionUpdate",f)}},[i.active,r,o,e]);const c=E.useCallback((f=Vf)=>{!o.href&&!f.href||(e.chain().focus().extendMarkRange("link").setLink({href:f.href||o.href||"",rel:typeof f.rel>"u"?o.rel:f.rel,target:typeof f.target>"u"?o.target:f.target}).run(),l({...Vf}),n?.())},[e,n,o.href,o.rel,o.target]),d=E.useCallback(()=>{e&&(e.chain().focus().extendMarkRange("link").unsetLink().setMeta("preventAutolink",!0).run(),l({...Vf}))},[e]);return{linkData:o,setLinkData:l,setLink:c,removeLink:d}},PE=E.forwardRef(({className:t,children:e,...n},r)=>{const i=pe(Lo,"link");return S.jsx(xt,{type:"button",className:t,"data-style":"ghost",role:"button",tabIndex:-1,"aria-label":i,tooltip:i,ref:r,...n,children:e||S.jsx(b8,{className:"tiptap-button-icon"})})}),DY=({linkData:t,setLinkData:e,setLink:n,removeLink:r,active:i})=>{const o=d=>{d.key==="Enter"&&(d.preventDefault(),n())},l=()=>{window.parent.postMessage({type:"f-tiptap-editor:open-link-popover",urlJson:t},"*")},c=()=>{if(!t.href)return;const d=AY(t.href,window.location.href);d!=="#"&&window.open(d,"_blank","noopener,noreferrer")};return S.jsx("div",{className:"f-tiptap-link-popover",children:S.jsxs("div",{className:"tiptap-popover__rows",children:[S.jsxs("div",{className:"tiptap-popover__row",children:[S.jsx("input",{type:"url",placeholder:pe(Lo,"placeholder"),value:t.href||"",onChange:d=>e({...t,href:d.target.value||null}),onKeyDown:o,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",className:"f-tiptap-link-popover__input"}),S.jsx("div",{className:"tiptap-button-group","data-orientation":"horizontal",children:S.jsx(xt,{type:"button",onClick:()=>n(),title:pe(Lo,"apply"),disabled:!t.href&&!i,"data-style":"ghost",children:S.jsx(u8,{className:"tiptap-button-icon"})})}),S.jsx(Yu,{}),S.jsxs("div",{className:"tiptap-button-group","data-orientation":"horizontal",children:[S.jsx(xt,{type:"button",onClick:c,title:pe(Lo,"openTheLink"),disabled:!t.href&&!i,"data-style":"ghost",children:S.jsx(f8,{className:"tiptap-button-icon"})}),S.jsx(xt,{type:"button",onClick:r,title:pe(Lo,"removeLink"),disabled:!t.href&&!i,"data-style":"ghost",children:S.jsx($8,{className:"tiptap-button-icon"})})]})]}),S.jsxs("div",{className:"tiptap-popover__row",children:[S.jsxs(xt,{type:"button",onClick:l,"data-active-state":t.rel?"on":"off",title:pe(Lo,"openSettings"),"data-style":"ghost",className:"f-tiptap-link-popover__settings-button",children:[S.jsx(dF,{className:"tiptap-button-icon"}),pe(Lo,"settings")]}),S.jsxs("label",{className:"f-tiptap-link-popover__checkbox-label",children:[S.jsx("input",{type:"checkbox",className:"f-tiptap-link-popover__checkbox",checked:t.target==="_blank",onChange:d=>{n({...t,target:d.target.checked?"_blank":null})}}),S.jsx("span",{className:"f-tiptap-link-popover__checkbox-text",children:pe(Lo,"openInNew")})]})]})]})})};function LY({editor:t,editorState:e}){const[n,r]=E.useState(!1),l=OY({editor:t,onSetLink:()=>{r(!1)},onLinkActive:()=>r(!0),editorState:e}),c=E.useCallback(d=>{r(d)},[]);return E.useEffect(()=>{if(!n)return;const d=f=>{if(f.origin===window.origin&&f.data?.type==="f-input-tiptap:save-url-json"&&f.data.urlJson){const h={href:f.data.urlJson.href||null,rel:f.data.urlJson.rel||null,target:f.data.urlJson.target||null};l.setLinkData(h),l.setLink(h)}};return window.addEventListener("message",d),()=>{window.removeEventListener("message",d)}},[n,l]),S.jsxs(RY,{open:n,onOpenChange:c,children:[S.jsx(VE,{asChild:!0,children:S.jsx(PE,{disabled:!e.enabled,"data-active-state":e.active?"on":"off","data-disabled":!e.enabled})}),S.jsx(UE,{children:S.jsx(DY,{active:e.active,...l})})]})}PE.displayName="LinkButton";function FE(t){const{editor:e}=e3();return E.useMemo(()=>t||e,[t,e])}const _Y={bold:a8,italic:Bp,underline:k3,strike:w3,code:c8,superscript:S3,subscript:x3},HY={bold:"Ctrl-b",italic:"Ctrl-i",underline:"Ctrl-u",strike:"Ctrl-Shift-s",code:"Ctrl-e",superscript:"Ctrl-.",subscript:"Ctrl-,"},IY={cs:{bold:"Tučné",italic:"Kurzíva",underline:"Podtržené",strike:"Přeškrtnuté",code:"Kód",superscript:"Horní index",subscript:"Dolní index"},en:{bold:"Bold",italic:"Italic",underline:"Underline",strike:"Strike",code:"Code",superscript:"Superscript",subscript:"Subscript"}};function $E(t,e){if(!t)return!1;try{return t.can().toggleMark(e)}catch{return!1}}function zY(t,e){return t?t.isActive(e):!1}function BY(t,e){t&&t.chain().focus().toggleMark(e).run()}function jY(t,e,n=!1){return!!(!t||n||t.isActive("codeBlock")||!$E(t,e))}function VY(t){const{editor:e,type:n,hideWhenUnavailable:r,markInSchema:i}=t;return!(!i||!e||r&&(Ky(e.state.selection)||!$E(e,n)))}function UY(t){return pe(IY,t)}function PY(t,e,n=!1){const r=kY(e,t),i=jY(t,e,n),o=zY(t,e),l=_Y[e],c=HY[e],d=UY(e);return{markInSchema:r,isDisabled:i,isActive:o,Icon:l,shortcutKey:c,formattedName:d}}const qE=E.forwardRef(({editor:t,type:e,text:n,hideWhenUnavailable:r=!1,className:i="",disabled:o,onClick:l,children:c,...d},f)=>{const h=FE(t),{markInSchema:m,isDisabled:g,isActive:y,Icon:C,shortcutKey:w,formattedName:x}=PY(h,e,o),k=E.useCallback(N=>{l?.(N),!N.defaultPrevented&&!g&&h&&BY(h,e)},[l,g,h,e]);return!E.useMemo(()=>VY({editor:h,type:e,hideWhenUnavailable:r,markInSchema:m}),[h,e,r,m])||!h||!h.isEditable?null:S.jsx(xt,{type:"button",className:i.trim(),disabled:g,"data-style":"ghost","data-active-state":y?"on":"off","data-disabled":g,role:"button",tabIndex:-1,"aria-label":x,"aria-pressed":y,tooltip:x,shortcutKeys:w,onClick:k,...d,ref:f,children:c||S.jsxs(S.Fragment,{children:[S.jsx(C,{className:"tiptap-button-icon"}),n&&S.jsx("span",{className:"tiptap-button-text",children:n})]})})});qE.displayName="MarkButton";const FY={undo:q8,redo:M8},$Y={undo:"Ctrl-z",redo:"Ctrl-Shift-z"},qY={cs:{undo:"Zpět",redo:"Znovu"},en:{undo:"Undo",redo:"Redo"}};function ZY(t){return pe(qY,t)}function KY(t,e){if(!t)return!1;const n=t.chain().focus();return e==="undo"?n.undo().run():n.redo().run()}const gy=E.forwardRef(({editor:t,action:e,className:n="",enabled:r,active:i,children:o,...l},c)=>{const d=FE(t),f=E.useCallback(()=>{!d||!r||KY(d,e)},[d,e,r]),h=FY[e],m=ZY(e),g=$Y[e],y=E.useCallback(C=>{console.log("if","!e.defaultPrevented:",!C.defaultPrevented,"!enabled:",!r),!C.defaultPrevented&&r&&f()},[r,f]);return!d||!d.isEditable?null:S.jsx(xt,{ref:c,type:"button",className:n.trim(),disabled:!r,"data-style":"ghost","data-active-state":i?"on":"off","data-disabled":!r,role:"button",tabIndex:-1,"aria-label":m,"aria-pressed":i,tooltip:m,shortcutKeys:g,onClick:y,...l,children:o||S.jsx(S.Fragment,{children:S.jsx(h,{className:"tiptap-button-icon"})})})});gy.displayName="UndoRedoButton";const GY={cs:{showHtml:"Zobrazit HTML kód"},en:{showHtml:"Show HTML code"}},ZE=E.forwardRef(({editor:t},e)=>{const n=E.useCallback(i=>{if(!i.defaultPrevented){const o=t.getHTML();window.parent.postMessage({type:"f-tiptap-editor:show-html",html:o},"*")}},[t]),r=pe(GY,"showHtml");return S.jsx(xt,{ref:e,type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":r,tooltip:r,onClick:n,children:S.jsx(aP,{className:"tiptap-button-icon"})})});ZE.displayName="FolioTiptapShowHtmlButton";const YY={cs:{erase:"Smazat formátování"},en:{erase:"Erase formatting"}},KE=E.forwardRef(({editor:t,enabled:e},n)=>{const r=E.useCallback(o=>{if(!o.defaultPrevented){const l=t.view.state.selection;if(l.empty){const c=t.view.state.doc.nodeAt(l.from);if(c&&c.marks&&c.marks.length>0){const d=t.view.state.doc.resolve(l.from);let f=d.start(d.depth+1);isNaN(f)&&(f=l.from);const h={from:f-1,to:f+c.nodeSize+1};t.chain().focus().setTextSelection(h).unsetAllMarks().run()}}else t.chain().focus().unsetAllMarks().run()}},[t]),i=pe(YY,"erase");return S.jsx(xt,{ref:n,type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":i,tooltip:i,onClick:r,disabled:!e,"data-disabled":!e,children:S.jsx(h8,{className:"tiptap-button-icon"})})});KE.displayName="FolioTiptapEraseMarksButton";function GE({children:t,enabled:e,active:n,onClick:r,tooltip:i}){return S.jsx(xt,{type:"button",disabled:!e,"data-style":"ghost","data-active-state":n?"on":"off","data-disabled":!e,role:"button",tabIndex:-1,"aria-label":i,"aria-pressed":n,tooltip:i,onClick:r,children:t})}const WY=({command:t,editor:e})=>()=>{const n=e.chain();n.focus(),t.command({chain:n}),n.run()};function jc({editorState:t,commandGroup:e,editor:n}){const[r,i]=Qe.useState(!1),o=Qe.useCallback(h=>{i(h)},[]),l=Qe.useCallback(()=>{const h=t.values;return h&&e.commands.find(m=>!m.dontShowAsActiveInCollapsedToolbar&&h.includes(m.key))||null},[t.values,e.commands]);if(!n)return null;const c=l(),d=c&&!t.multiselect?c.icon:e.icon,f=e.title[document.documentElement.lang]||e.title.en;return S.jsxs(mv,{open:r,onOpenChange:o,children:[S.jsx(x1,{asChild:!0,children:S.jsxs(xt,{type:"button",disabled:!t.enabled,"data-style":"ghost","data-active-state":t.active?"on":"off","data-disabled":!t.enabled,role:"button",tabIndex:-1,"aria-label":f,"aria-pressed":t.active,tooltip:f,children:[S.jsx(d,{className:"tiptap-button-icon"}),S.jsx(g3,{className:"tiptap-button-dropdown-small"})]})}),S.jsx(S1,{children:S.jsx(k1,{children:e.commands.map(h=>h.hideInToolbarDropdown?null:S.jsx(T1,{asChild:!0,children:S.jsxs(GE,{active:t.values?t.values.includes(h.key):!1,enabled:t.enabled,onClick:WY({editor:n,command:h}),children:[S.jsx(h.icon,{className:"tiptap-button-icon"}),h.title[document.documentElement.lang]||h.title.en]})},h.key))})})]})}const J6={cs:"Vložit",en:"Insert"},YE=({editor:t,node:e})=>{const n=E.useCallback(()=>{window.parent.postMessage({type:"f-tiptap-slash-command:selected",attrs:{type:e?.type}},"*")},[e]);if(!e)return;if(!t||!t.isEditable)return null;const r={cs:{insert:e.title.cs||J6.cs},en:{insert:e.title.en||J6.en}},i=pe(r,"insert"),o=Wf(e.config?.icon);return S.jsx(xt,{type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":i,tooltip:i,onClick:n,children:S.jsx(o,{size:16})})};YE.displayName="FolioEditorToolbarSlotButton";function X6({editor:t,nodes:e}){return!t||!e||e.length===0?null:S.jsx(S.Fragment,{children:e.map(n=>S.jsx($n,{children:S.jsx(YE,{editor:t,node:n})}))})}const JY=t=>t&&t.length>0?t:window.Folio?.Tiptap?.nodeGroups||[];function XY({groupKey:t,groupConfig:e,nodes:n}){const[r,i]=Qe.useState(!1),o=Qe.useCallback(h=>{i(h)},[]),l=Qe.useCallback(h=>()=>{window.parent.postMessage({type:"f-tiptap-slash-command:selected",attrs:{type:h.type}},"*"),i(!1)},[]),c=f6(e.icon||t),d=document.documentElement.lang,f=e.title[d]||e.title.en;return S.jsxs(mv,{open:r,onOpenChange:o,children:[S.jsx(x1,{asChild:!0,children:S.jsxs(xt,{type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":f,tooltip:f,children:[S.jsx(c,{className:"tiptap-button-icon"}),S.jsx(g3,{className:"tiptap-button-dropdown-small"})]})}),S.jsx(S1,{children:S.jsx(k1,{children:n.map(h=>{const m=f6(h.config?.icon),g=h.title[d]||h.title.en;return S.jsx(T1,{asChild:!0,children:S.jsxs(GE,{active:!1,enabled:!0,onClick:l(h),children:[S.jsx(m,{className:"tiptap-button-icon"}),g]})},h.type)})})})]})}function QY({editor:t,nodes:e,nodeGroupsConfig:n}){if(!t||!t.isEditable||!e||e.length===0)return null;const r=JY(n),i={};e.forEach(c=>{const d=c.config?.group;d&&(i[d]||(i[d]=[]),i[d].push(c))});const o=Object.keys(i).sort((c,d)=>{const f=r.find(y=>y.key===c),h=r.find(y=>y.key===d),m=!!f?.toolbar_slot,g=!!h?.toolbar_slot;return m&&!g?-1:!m&&g?1:c.localeCompare(d)}),l=c=>{const d=r.find(f=>f.key===c);return d||{key:c,title:{cs:c,en:c},icon:c}};return S.jsx(S.Fragment,{children:o.map(c=>{const d=l(c);return S.jsx($n,{children:S.jsx(XY,{groupKey:c,groupConfig:d,nodes:i[c]})},c)})})}const Q6={cs:{mobile:"Mobilní layout",desktop:"Desktop layout"},en:{mobile:"Mobile layout",desktop:"Desktop layout"}},WE=({setResponsivePreviewEnabled:t})=>{const e=pe(Q6,"mobile"),n=pe(Q6,"desktop");return S.jsxs("div",{className:"f-tiptap-editor-responsive-preview-buttons",children:[S.jsx(xt,{type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":e,tooltip:e,className:"f-tiptap-editor-responsive-preview-buttons__button f-tiptap-editor-responsive-preview-buttons__button--mobile",onClick:r=>{r.target.blur(),t(!0)},children:S.jsx(O8,{className:"tiptap-button-icon"})}),S.jsx(xt,{type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":n,tooltip:n,className:"f-tiptap-editor-responsive-preview-buttons__button f-tiptap-editor-responsive-preview-buttons__button--desktop",onClick:r=>{r.target.blur(),t(!1)},children:S.jsx(S8,{className:"tiptap-button-icon"})})]})};WE.displayName="ResponsivePreviewButtons";const JE=E.forwardRef(({editor:t,command:e},n)=>{const r=E.useCallback(()=>{if(!t)return;const o=t.chain();o.focus(),e.command({chain:o}),o.run()},[e,t]),i=e.title[document.documentElement.lang]||e.title.en;return t?S.jsx(xt,{ref:n,type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":i,tooltip:i,onClick:r,children:S.jsx(e.icon,{className:"tiptap-button-icon"})}):null});JE.displayName="FolioEditorToolbarCommandButton";const Cp={cs:{saveAt:"Uloženo v",saveOn:"Uloženo",failedToAutosave:"Chyba ukládání rozpracovaného textu."},en:{saveAt:"Saved at",saveOn:"Saved on",failedToAutosave:"Failed to autosave draft text."}};function eW(t){const e=new Date;if(t.toDateString()===e.toDateString()){const r=t.toLocaleTimeString("cs-CZ",{hour:"2-digit",minute:"2-digit",second:"2-digit"});return`${pe(Cp,"saveAt")} ${r}`}else{const r=t.toLocaleDateString("cs-CZ",{day:"numeric",month:"numeric",hour:"2-digit",minute:"2-digit"});return`${pe(Cp,"saveOn")} ${r}`}}const XE=E.forwardRef(({autosaveIndicatorInfo:t},e)=>{const[n,r]=E.useState(t?.latestRevisionAt?new Date(t.latestRevisionAt):null),[i,o]=E.useState(t?.hasUnsavedChanges??!1),[l,c]=E.useState(!1),d=t?.newRecord??!0;E.useEffect(()=>{const g=y=>{y.data?.type==="f-input-tiptap:autosave:auto-saved"?(r(new Date(y.data.updatedAt)),c(!1)):y.data?.type==="f-input-tiptap:autosave:continue-unsaved-changes"?o(!1):y.data?.type==="f-input-tiptap:autosave:failed-to-autosave"&&c(!0)};return window.addEventListener("message",g),()=>window.removeEventListener("message",g)},[]);const f=n?eW(n):pe(Cp,"saveAt"),m=(()=>{if(d)return{icon:S.jsx(l6,{className:"tiptap-button-icon",color:"#FF9A52"}),style:{pointerEvents:"none"},"aria-label":void 0,tooltip:void 0};if(i)return{icon:S.jsx(CF,{className:"tiptap-button-icon",color:"#FF9A52"}),style:{pointerEvents:"none"},"aria-label":void 0,tooltip:void 0};if(l){const g=pe(Cp,"failedToAutosave");return{icon:S.jsx(l6,{className:"tiptap-button-icon",color:"#F0655D"}),style:{cursor:"help"},"data-no-hover":"true","aria-label":g,tooltip:g}}return{icon:S.jsx(lF,{className:"tiptap-button-icon",color:"#00B594"}),style:{cursor:"help"},"data-no-hover":"true","aria-label":f,tooltip:f}})();return S.jsx(xt,{ref:e,type:"button","data-style":"ghost",role:"button",tabIndex:-1,style:m.style,"data-no-hover":m["data-no-hover"],"aria-label":m["aria-label"],tooltip:m.tooltip,children:m.icon})});XE.displayName="FolioTiptapAutosaveIndicator";const Xl=t=>({editor:e})=>e.isActive("codeBlock")&&e.can().toggleMark(t),As=t=>({editor:e})=>e.isActive(t),Ns={undo:{enabled:({editor:t})=>t.can().undo(),active:()=>!1},redo:{enabled:({editor:t})=>t.can().redo(),active:()=>!1},bold:{enabled:Xl("bold"),active:As("bold")},italic:{enabled:Xl("italic"),active:As("italic")},strike:{enabled:Xl("strike"),active:As("strike")},underline:{enabled:Xl("underline"),active:As("underline")},superscript:{enabled:Xl("superscript"),active:As("superscript")},subscript:{enabled:Xl("subscript"),active:As("subscript")},link:{enabled:({editor:t})=>t.can().setLink?.({href:""}),active:As("link")},textAlign:{enabled:({editor:t})=>t.can().setTextAlign("left")||t.can().setTextAlign("center"),active:({editor:t})=>t.isActive({textAlign:"center"})||t.isActive({textAlign:"right"}),values:({editor:t})=>{if(t.isActive({textAlign:"left"}))return["align-left"];if(t.isActive({textAlign:"center"}))return["align-center"];if(t.isActive({textAlign:"right"}))return["align-right"]}},erase:{enabled:({editor:t})=>{let e=!1;const n=t.view.state.selection;if(n.empty){const r=t.view.state.doc.nodeAt(n.from);r&&r.marks&&r.marks.length>0&&(e=!0)}else t.view.state.doc.nodesBetween(n.from,n.to,r=>{if(r.marks&&r.marks.length>0)return e=!0,!1});return e},active:()=>!1},textStyles:{enabled:({editor:t})=>t.can().toggleNode("heading","paragraph"),active:({editor:t})=>t.isActive("heading")||t.isActive("folioTiptapStyledParagraph"),values:({editor:t})=>{if(t.isActive("heading")){const e=t.getAttributes("heading");if(e&&e.level)return[`heading-${e.level}`]}else if(t.isActive("folioTiptapStyledParagraph")){const e=t.getAttributes("folioTiptapStyledParagraph");if(e&&e.variant)return[`folioTiptapStyledParagraph-${e.variant}`]}else if(t.isActive("paragraph"))return["paragraph"]}},lists:{enabled:({editor:t})=>t.can().toggleBulletList()||t.can().toggleOrderedList(),active:({editor:t})=>t.isActive("bulletList")||t.isActive("orderedList"),values:({editor:t})=>{if(t.isActive("bulletList"))return["bulletList"];if(t.isActive("orderedList"))return["orderedList"]}},layouts:{onlyInBlockEditor:!0,enabled:({editor:t})=>t.can().insertFolioTiptapColumns()||t.can().insertTable(),active:()=>!1,values:({editor:t})=>{if(t.isActive("folioTiptapColumns"))return["folioTiptapColumns"];if(t.isActive("table"))return["table"]}},textDecorations:{multiselect:!0,enabled:()=>!0,active:({editor:t})=>t.isActive("italic")||t.isActive("underline")||t.isActive("strike")||t.isActive("superscript")||t.isActive("subscript"),values:({editor:t})=>{const e=[];return t.isActive("italic")&&e.push("italic"),t.isActive("underline")&&e.push("underline"),t.isActive("strike")&&e.push("strike"),t.isActive("superscript")&&e.push("superscript"),t.isActive("subscript")&&e.push("subscript"),e}}},tW=({editor:t,blockEditor:e})=>{const n={};let r=Object.keys(Ns);return e||(r=r.filter(i=>!Ns[i].onlyInBlockEditor)),t&&t.isEditable?r.forEach(i=>{n[i]={multiselect:Ns[i].multiselect,enabled:Ns[i].enabled({editor:t}),active:Ns[i].active({editor:t}),values:Ns[i].values?Ns[i].values({editor:t}):void 0}}):r.forEach(i=>{n[i]={enabled:!1,active:!1}}),n},nW=({blockEditor:t,editor:e,folioTiptapConfig:n,textStylesCommandGroup:r,layoutsCommandGroup:i,setResponsivePreviewEnabled:o,autosaveIndicatorInfo:l})=>{const c=pS({editor:e,selector:({editor:h})=>tW({editor:h,blockEditor:t})}),{nodesForSlots:d,groupedNodes:f}=Qe.useMemo(()=>{const h={},m=[];return t&&n?.nodes&&n.nodes.forEach(g=>{const y=g.config?.toolbar_slot;g.config?.group&&m.push(g),y&&(h[y]||(h[y]=[]),h[y].push(g))}),{nodesForSlots:h,groupedNodes:m}},[t,n]);return S.jsxs(S.Fragment,{children:[t?S.jsxs(S.Fragment,{children:[S.jsx($n,{children:S.jsx(zE,{editor:e})}),S.jsx(Ir,{})]}):null,S.jsxs($n,{children:[S.jsx(gy,{action:"undo",active:c.undo.active,enabled:c.undo.enabled}),S.jsx(gy,{action:"redo",active:c.redo.active,enabled:c.redo.enabled})]}),S.jsx(Ir,{}),S.jsxs($n,{children:[S.jsx(jc,{editorState:c.textStyles,commandGroup:r,editor:e}),S.jsx(jc,{editorState:c.lists,commandGroup:F3,editor:e})]}),S.jsx(Ir,{}),S.jsxs($n,{children:[S.jsx(qE,{editor:e,type:"bold"}),S.jsx(jc,{editorState:c.textDecorations,commandGroup:v$,editor:e})]}),S.jsx(Ir,{}),S.jsx($n,{children:S.jsx(KE,{editor:e,enabled:c.erase.enabled})}),S.jsx(Ir,{}),S.jsxs($n,{children:[S.jsx(LY,{editor:e,editorState:c.link}),S.jsx(X6,{editor:e,nodes:d.after_link})]}),S.jsx(Ir,{}),S.jsx($n,{children:S.jsx(jc,{editorState:c.textAlign,commandGroup:y$,editor:e})}),t?S.jsxs(S.Fragment,{children:[S.jsx(Ir,{}),i&&S.jsx($n,{children:S.jsx(jc,{editorState:c.layouts,commandGroup:i,editor:e})}),S.jsx(Ir,{}),S.jsx(X6,{editor:e,nodes:d.after_layouts}),S.jsx(QY,{editor:e,nodes:f,nodeGroupsConfig:n?.node_groups}),S.jsx(JE,{editor:e,command:ZT})]}):null,S.jsx(Ir,{}),S.jsx($n,{children:S.jsx(ZE,{editor:e})}),S.jsx(HE,{}),o&&S.jsx($n,{children:S.jsx(WE,{setResponsivePreviewEnabled:o})}),n?.autosave&&t&&S.jsxs(S.Fragment,{children:[S.jsx(Ir,{}),S.jsx($n,{children:S.jsx(XE,{editor:e,autosaveIndicatorInfo:l})})]})]})};function rW({editor:t,blockEditor:e,folioTiptapConfig:n,textStylesCommandGroup:r,layoutsCommandGroup:i,setResponsivePreviewEnabled:o,autosaveIndicatorInfo:l}){return t?S.jsx(IE,{children:S.jsx(nW,{blockEditor:e,editor:t,folioTiptapConfig:n,textStylesCommandGroup:r,layoutsCommandGroup:i,setResponsivePreviewEnabled:o,autosaveIndicatorInfo:l})}):null}const iW=(t,e,n)=>{let r=null;return e===void 0&&(e=150),n===void 0&&(n=!1),function(...i){const o=this,l=()=>{r=null,n||t.apply(o,i)},c=n&&!r;r&&clearTimeout(r),r=setTimeout(l,e),c&&t.apply(o,i)}};function oW({scrollContainerRef:t}){const e=E.useRef(null);E.useEffect(()=>{const n=t.current;if(!n)return;const r=3,i=15,o=50,l=.015,c=1.3,d=3;let f=null,h=null,m=0,g=null,y=0,C=window.innerWidth,w=window.innerHeight;const x=q=>{q&&q.clientY!==void 0&&(h=q.clientY)},k=q=>{const J=1-q/o,U=r+(i-r)*(J*J),ne=1+Math.min(m*l,c-1);return U*ne},A=()=>{if(h===null){m=0,f=window.requestAnimationFrame(A);return}const q=h;let J=0,U=0;const ne=window.innerWidth,le=window.innerHeight;if(!g||y===0||C!==ne||w!==le?(g=n.getBoundingClientRect(),C=ne,w=le,y=d):y--,!g){f=window.requestAnimationFrame(A);return}const G=g.top,P=g.bottom-G,H=q-G;if(H>=o&&H<=P-o){m=0,g=null,f=window.requestAnimationFrame(A);return}if(H0||J>0&&j{e.current&&e.current(),f=window.requestAnimationFrame(A);const q=ne=>x(ne),J=ne=>x(ne),U=ne=>x(ne);document.addEventListener("mousemove",q,{passive:!0,capture:!0}),document.addEventListener("dragover",J,{passive:!0,capture:!0}),document.addEventListener("drag",U,{passive:!0,capture:!0}),n.addEventListener("dragover",J,{passive:!0,capture:!0}),n.addEventListener("drag",U,{passive:!0,capture:!0}),e.current=()=>{document.removeEventListener("mousemove",q,{capture:!0}),document.removeEventListener("dragover",J,{capture:!0}),document.removeEventListener("drag",U,{capture:!0}),n.removeEventListener("dragover",J,{capture:!0}),n.removeEventListener("drag",U,{capture:!0}),f!==null&&(window.cancelAnimationFrame(f),f=null),h=null,g=null,m=0}},R=()=>{e.current&&(e.current(),e.current=null)},L=q=>{const J=q.target;n.contains(J)&&N()},z=()=>{R()},_=()=>{R()};return document.addEventListener("dragstart",L,{capture:!0}),document.addEventListener("dragend",z,{capture:!0}),n.addEventListener("drop",_,{capture:!0}),()=>{R(),document.removeEventListener("dragstart",L,{capture:!0}),document.removeEventListener("dragend",z,{capture:!0}),n.removeEventListener("drop",_,{capture:!0})}},[t])}const e9=375;function sW({enabled:t,shouldScrollToInitial:e,setShouldScrollToInitial:n,children:r}){const[i,o]=E.useState(e9),l=E.useRef(null);oW({scrollContainerRef:l});const c=E.useCallback(f=>{f.preventDefault(),f.stopPropagation();const h=f.clientX,m=i,g=C=>{const w=Math.max(m+2*(C.clientX-h),e9),x=Math.min(window.innerWidth-36,w);o(x)},y=()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",y)};document.addEventListener("mousemove",g),document.addEventListener("mouseup",y)},[i]);E.useEffect(()=>{e!==null&&l.current&&(n(null),window.setTimeout(()=>{l.current&&(l.current.scrollTop=e)},0))},[e,n]);const d=E.useMemo(()=>iW(()=>{l.current&&window.parent.postMessage({type:"f-tiptap-editor:scrolled",scrollTop:l.current.scrollTop},"*")}),[]);return S.jsxs("div",{className:"f-tiptap-editor-responsive-preview",children:[S.jsx("div",{className:"f-tiptap-editor-responsive-preview__scroll",ref:l,onScroll:d,children:S.jsx("div",{className:"f-tiptap-editor-responsive-preview__inner",style:{width:t&&i?`${i}px`:"auto"},children:r})}),t?S.jsx("div",{className:"f-tiptap-editor-responsive-preview__handle",style:{left:`calc(50% + ${i/2-18}px)`},onMouseDown:c,children:S.jsxs("div",{className:"f-tiptap-editor-responsive-preview__handle-flex",children:[S.jsx("div",{className:"f-tiptap-editor-responsive-preview__handle-icon-wrap",children:S.jsx(l8,{})}),S.jsx("div",{className:"f-tiptap-editor-responsive-preview__handle-text",children:`${i}px`})]})}):null]})}function lW({onCreate:t,onUpdate:e,defaultContent:n,type:r,folioTiptapConfig:i,readonly:o,initialScrollTop:l,autosaveIndicatorInfo:c}){const d=E.useRef(null),f=E.useRef(!1),h=E.useRef(0),m=r==="block",[g,y]=E.useState(!1),[C,w]=E.useState(!1),[x,k]=E.useState(!1),[A,N]=E.useState(l),R=E.useMemo(()=>i&&i.styled_paragraph_variants&&i.styled_paragraph_variants.length?VF(i.styled_paragraph_variants):[],[i]),L=E.useMemo(()=>i&&i.enable_pages?BF(i.enable_pages):[],[i]),z=E.useMemo(()=>i&&i.styled_wrap_variants&&i.styled_wrap_variants.length?FF(i.styled_wrap_variants):[],[i]),_=E.useMemo(()=>i&&i.heading_levels?i.heading_levels:[2,3,4],[i]),q=E.useMemo(()=>x$({folioTiptapStyledParagraphCommands:R,folioTiptapHeadingLevels:_}),[R,_]),J=E.useMemo(()=>w$({folioTiptapStyledWrapCommands:z,folioTiptapPagesCommands:L}),[z,L]),U=EH({onUpdate:e,onCreate(oe){k(!0),t&&t(oe)},onDrop(){for(const oe of document.querySelectorAll(".prosemirror-dropcursor-block"))oe.hidden=!0},autofocus:m,immediatelyRender:!0,shouldRerenderOnTransaction:!1,editable:!o,editorProps:{attributes:{autocomplete:"off",autocorrect:"off",autocapitalize:"off","aria-label":"Main content area, start typing to enter text.",class:"f-tiptap-editor__tiptap-editor"}},extensions:[dz.configure({heading:{levels:_},gapcursor:!1,link:{openOnClick:!1,enableClickSelection:!0,HTMLAttributes:{rel:null,target:null}}}),fz.configure({alignments:["left","center","right"],types:["heading","paragraph"]}),Iz(),zz,hz,QF,az.configure({includeChildren:!0,placeholder:({editor:oe,node:G})=>{if(m){let P="commandPlaceholder";if(G.type.name==="heading"){const H=At(B=>B.type.name===Xo.name)(oe.state.selection);let j=!1;H&&(j=Vx(H.node,re=>re.type.name==="heading")[0].node===G),j?P="headingInPagesPlaceholder":_.length===1?P="singleHeadingPlaceholder":G.attrs.level&&[2,3,4].indexOf(G.attrs.level)!==-1&&(P=`h${G.attrs.level}Placeholder`)}return pe(W6,P)}else return pe(W6,"defaultPlaceholder")}}),...m?[Y8.configure({nodes:i.nodes||[],embedNodeClassName:i.embed_node_class_name}),Sj,kj,o1,tp,zF,Fu,Xo,Ta,qT,YF,QS.extend({parseHTML(){return[{tag:"div.f-tiptap-table-wrapper",contentElement:"table"},{tag:"table"}]},renderHTML({HTMLAttributes:oe}){return["div",{class:"f-tiptap-table-wrapper"},["table",oe,0]]}}).configure({allowTableNodeSelection:!0,resizable:!1}),KB.configure({table:!1}),M$.configure({suggestion:m?{...WT,items:YT([q,F3,J,...i.nodes&&i.nodes.length?(()=>{const oe=C$(i.nodes,i.node_groups);return Array.isArray(oe)?oe:[oe]})():[]])}:O$({textStylesCommandGroup:q})})]:[],jF.configure({variants:i.styled_paragraph_variants||[],variantCommands:R}),PF.configure({variantCommands:z})]});E.useEffect(()=>{if(!d.current)return;const oe=d.current,G=new ResizeObserver(P=>{for(const H of P)window.parent.postMessage({type:"f-tiptap-editor:resized",height:H.contentRect.height},"*")});return G.observe(oe),()=>{G.disconnect()}},[]),E.useEffect(()=>{if(!U||!x||!C||!d.current||f.current)return;f.current=!0;const oe=DE(M3(U.getJSON())),G=Math.max(d.current.clientHeight,150);h.current=G,window.parent.postMessage({type:"f-tiptap:created",content:oe,height:G},"*");const P=()=>{if(!d.current)return;const j=Math.max(d.current.clientHeight,150);j!==h.current&&(h.current=j,window.parent.postMessage({type:"f-tiptap-editor:resized",height:j},"*"))};[0,50,100,150].forEach(j=>{window.setTimeout(P,j)})},[U,x,C]),E.useEffect(()=>{if(!x||C)return;const oe=sY({content:n,editor:U,allowedFolioTiptapNodeTypes:i.nodes||[]});oe&&U.commands.setContent(oe,{emitUpdate:!1,errorOnInvalidContent:!1}),w(!0),window.parent.postMessage({type:"f-tiptap-editor:initialized-content",content:oe},"*")},[n,C,x,U,i]);const ne=E.useCallback(oe=>{oe.target.classList.contains("f-tiptap-editor__content-wrap")&&U&&U.view&&U.view.dom&&U.view.focus()},[U]);let le="f-tiptap-editor__content f-tiptap-styles";return i.theme&&(le+=` f-tiptap-styles--theme-${i.theme}`),o&&(le+=" f-tiptap-editor__content--readonly"),!x||!C?null:S.jsx(Qy.Provider,{value:{editor:U},children:S.jsxs("div",{ref:d,className:`f-tiptap-editor f-tiptap-editor--${m?"block":"rich-text"}${g?" f-tiptap-editor--responsive-preview":""}`,children:[o?null:S.jsx(rW,{editor:U,blockEditor:m,textStylesCommandGroup:q,layoutsCommandGroup:J,folioTiptapConfig:i,setResponsivePreviewEnabled:m?y:void 0,autosaveIndicatorInfo:c}),S.jsx(sW,{enabled:g,shouldScrollToInitial:A,setShouldScrollToInitial:N,children:S.jsxs("div",{className:"f-tiptap-editor__content-wrap",onClick:ne,children:[m&&!o?S.jsx(oY,{editor:U}):null,S.jsx(CH,{editor:U,role:"presentation",className:le}),o?null:S.jsx(vY,{editor:U,blockEditor:m})]})})]})})}function aW({onCreate:t,onUpdate:e,defaultContent:n,type:r,folioTiptapConfig:i,readonly:o,initialScrollTop:l,autosaveIndicatorInfo:c}){switch(r){case"block":case"rich-text":return S.jsx(lW,{onCreate:t,onUpdate:e,defaultContent:n,type:r,folioTiptapConfig:i,readonly:o,initialScrollTop:l,autosaveIndicatorInfo:c});default:throw new Error(`Unknown editor type: ${r}`)}}window.Folio=window.Folio||{};window.Folio.Tiptap=window.Folio.Tiptap||{};window.Folio.Tiptap.root=window.Folio.Tiptap.root||null;window.Folio.Tiptap.getHeight=()=>{const t=document.querySelector(".f-tiptap-editor");if(!t)return 0;const e=t.clientHeight;return Math.max(e,150)};window.Folio.Tiptap.init=t=>{if(window.Folio.Tiptap.root)throw new Error("Tiptap editor is already initialized");if(!t.node)throw new Error("Node is required");const e=({editor:l})=>{t.onCreate&&t.onCreate({editor:l})},n=({editor:l})=>{window.parent.postMessage({type:"f-tiptap:updated",content:DE(M3(l.getJSON())),height:window.Folio.Tiptap.getHeight()},"*"),t.onUpdate&&t.onUpdate({editor:l})};let r;t.content&&(r=W8(t.content));const i={nodes:[],styled_paragraph_variants:[],styled_wrap_variants:[],enable_pages:!1},o=SN.createRoot(t.node);return o.render(S.jsx(E.StrictMode,{children:S.jsx(aW,{onCreate:e,onUpdate:n,defaultContent:r,type:t.type,folioTiptapConfig:t.folioTiptapConfig?{...i,...t.folioTiptapConfig}:i,readonly:t.readonly,initialScrollTop:t.scrollTop||null,autosaveIndicatorInfo:t.autosaveIndicatorInfo})})),window.Folio.Tiptap.root=o,o};window.Folio.Tiptap.destroy=()=>{window.Folio.Tiptap.root&&(window.Folio.Tiptap.root.unmount(),window.Folio.Tiptap.root=null)};window.addEventListener("message",t=>{if(t.origin===window.origin&&t.data){if(t.data.type==="f-input-tiptap:start"){if(!window.Folio.Tiptap.root){const e=document.querySelector(".f-tiptap-iframe-content");if(!e)throw new Error("Node not found for Tiptap editor");if(t.data.lang&&(document.documentElement.lang=t.data.lang),t.data.stylesheetPath){const n=document.createElement("link");n.rel="stylesheet",n.href=t.data.stylesheetPath,document.body.appendChild(n)}e.classList.toggle("f-tiptap-iframe-content--console-aside",!!t.data.windowWidth&&t.data.windowWidth>=1700),window.Folio.Tiptap.init({node:e,type:e.dataset.tiptapType==="block"?"block":"rich-text",folioTiptapConfig:t.data.folioTiptapConfig,content:t.data.content,readonly:!!t.data.readonly,scrollTop:t.data.tiptapScrollTop||0,autosaveIndicatorInfo:t.data.autosaveIndicatorInfo})}}else if(t.data.type==="f-input-tiptap:window-resize"){const e=document.querySelector(".f-tiptap-iframe-content");e&&e.classList.toggle("f-tiptap-iframe-content--console-aside",!!t.data.windowWidth&&t.data.windowWidth>=1700)}}});window.parent.postMessage({type:"f-tiptap:javascript-evaluated"},"*"); +`?l.insert.slice(0,-1):l.insert;(typeof c!="string"||c.length>0)&&Y0(r,this,i,c,l.attributes||{})}else l.retain!==void 0?j6(r,this,i,l.retain,l.attributes||{}):l.delete!==void 0&&V6(r,i,l.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??Sn();const i=[],o=new Map,l=this.doc;let c="",d=this._start;function f(){if(c.length>0){const m={};let g=!1;o.forEach((C,w)=>{g=!0,m[w]=C});const y={insert:c};g&&(y.attributes=m),i.push(y),c=""}}const h=()=>{for(;d!==null;){if(Ds(d,e)||n!==void 0&&Ds(d,n))switch(d.content.constructor){case Gr:{const m=o.get("ychange");e!==void 0&&!Ds(d,e)?(m===void 0||m.user!==d.id.client||m.type!=="removed")&&(f(),o.set("ychange",r?r("removed",d.id):{type:"removed"})):n!==void 0&&!Ds(d,n)?(m===void 0||m.user!==d.id.client||m.type!=="added")&&(f(),o.set("ychange",r?r("added",d.id):{type:"added"})):m!==void 0&&(f(),o.delete("ychange")),c+=d.content.str;break}case Wr:case ll:{f();const m={insert:d.content.getContent()[0]};if(o.size>0){const g={};m.attributes=g,o.forEach((y,C)=>{g[C]=y})}i.push(m);break}case qt:Ds(d,e)&&(f(),ja(o,d.content));break}d=d.right}f()};return e||n?ct(l,m=>{e&&sy(m,e),n&&sy(m,n),h()},"cleanup"):h(),i}insert(e,n,r){if(n.length<=0)return;const i=this.doc;i!==null?ct(i,o=>{const l=zf(o,this,e,!r);r||(r={},l.currentAttributes.forEach((c,d)=>{r[d]=c})),Y0(o,this,l,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const i=this.doc;i!==null?ct(i,o=>{const l=zf(o,this,e,!r);Y0(o,this,l,n,r||{})}):this._pending.push(()=>this.insertEmbed(e,n,r||{}))}delete(e,n){if(n===0)return;const r=this.doc;r!==null?ct(r,i=>{V6(i,zf(i,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const i=this.doc;i!==null?ct(i,o=>{const l=zf(o,this,e,!1);l.right!==null&&j6(o,this,l,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?ct(this.doc,n=>{hp(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?ct(this.doc,r=>{cv(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return uv(this,e)}getAttributes(){return tE(this)}_write(e){e.writeTypeRef(BK)}}const bK=t=>new ts;class W0{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Sn()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===xn||n.constructor===tl)&&n._start!==null)e=n._start;else for(;e!==null;){const r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class tl extends rn{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new tl}clone(){const e=new tl;return e.insert(0,this.toArray().map(n=>n instanceof rn?n.clone():n)),e}get length(){return this.doc??Sn(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new W0(this,e)}querySelector(e){e=e.toUpperCase();const r=new W0(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),el(new W0(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){v1(this,e,new xK(this,n,e))}toString(){return Wk(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const i=e.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),Au(this,o=>{i.insertBefore(o.toDOM(e,n,r),null)}),i}insert(e,n){this.doc!==null?ct(this.doc,r=>{Qk(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)ct(this.doc,r=>{const i=e&&e instanceof rn?e._item:e;fp(r,this,i,n)});else{const r=this._prelimContent,i=e===null?0:r.findIndex(o=>o===e)+1;if(i===0&&e!==null)throw fi("Reference item not found");r.splice(i,0,...n)}}delete(e,n=1){this.doc!==null?ct(this.doc,r=>{eE(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return Gk(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Jk(this,e)}slice(e=0,n=this.length){return Kk(this,e,n)}forEach(e){Au(this,e)}_write(e){e.writeTypeRef(VK)}}const CK=t=>new tl;class xn extends tl{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((r,i)=>{this.setAttribute(i,r)}),this._prelimAttrs=null}_copy(){return new xn(this.nodeName)}clone(){const e=new xn(this.nodeName),n=this.getAttributes();return Tq(n,(r,i)=>{e.setAttribute(i,r)}),e.insert(0,this.toArray().map(r=>r instanceof rn?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],r=[];for(const c in e)r.push(c);r.sort();const i=r.length;for(let c=0;c0?" "+n.join(" "):"";return`<${o}${l}>${super.toString()}`}removeAttribute(e){this.doc!==null?ct(this.doc,n=>{hp(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?ct(this.doc,r=>{cv(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return uv(this,e)}hasAttribute(e){return nE(this,e)}getAttributes(e){return e?uK(this,e):tE(this)}toDOM(e=document,n={},r){const i=e.createElement(this.nodeName),o=this.getAttributes();for(const l in o){const c=o[l];typeof c=="string"&&i.setAttribute(l,c)}return Au(this,l=>{i.appendChild(l.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(jK),e.writeKey(this.nodeName)}}const wK=t=>new xn(t.readKey());class xK extends g1{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(i=>{i===null?this.childListChanged=!0:this.attributesChanged.add(i)})}}class pp extends Ra{constructor(e){super(),this.hookName=e}_copy(){return new pp(this.hookName)}clone(){const e=new pp(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const i=n[this.hookName];let o;return i!==void 0?o=i.createDom(this):o=document.createElement(this.hookName),o.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(o,this),o}_write(e){e.writeTypeRef(UK),e.writeKey(this.hookName)}}const SK=t=>new pp(t.readKey());class Xn extends ts{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new Xn}clone(){const e=new Xn;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const i=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(i,this),i}toString(){return this.toDelta().map(e=>{const n=[];for(const i in e.attributes){const o=[];for(const l in e.attributes[i])o.push({key:l,value:e.attributes[i][l]});o.sort((l,c)=>l.keyi.nodeName=0;i--)r+=``;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(PK)}}const TK=t=>new Xn;class dv{constructor(e,n){this.id=e,this.length=n}get deleted(){throw Nr()}mergeWith(e){return!1}write(e,n,r){throw Nr()}integrate(e,n){throw Nr()}}const kK=0;class Er extends dv{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),Vk(e.doc.store,this)}write(e,n){e.writeInfo(kK),e.writeLen(this.length-n)}getMissing(e,n){return null}}class Ku{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Ku(this.content)}splice(e){throw Nr()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const EK=t=>new Ku(t.readBuf());class Nu{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Nu(this.len)}splice(e){const n=new Nu(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){Tu(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const MK=t=>new Nu(t.readLen()),lE=(t,e)=>new sl({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Gu{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Gu(lE(this.doc.guid,this.opts))}splice(e){throw Nr()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const AK=t=>new Gu(lE(t.readString(),t.readAny()));class ll{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ll(this.embed)}splice(e){throw Nr()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const NK=t=>new ll(t.readJSON());class qt{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new qt(this.key,this.value)}splice(e){throw Nr()}mergeWith(e){return!1}integrate(e,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const RK=t=>new qt(t.readKey(),t.readJSON());class mp{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new mp(this.arr)}splice(e){const n=new mp(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let i=n;i{const e=t.readLen(),n=[];for(let r=0;r{const e=t.readLen(),n=[];for(let r=0;r=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const _K=t=>new Gr(t.readString()),HK=[fK,pK,bK,wK,CK,SK,TK],IK=0,zK=1,BK=2,jK=3,VK=4,UK=5,PK=6;class Wr{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Wr(this.type._copy())}splice(e){throw Nr()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}}const FK=t=>new Wr(HK[t.readTypeRef()](t)),cy=(t,e)=>{let n=e,r=0,i;do r>0&&(n=De(n.client,n.clock+r)),i=fa(t,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof et);return{item:i,diff:r}},fv=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},gp=(t,e,n)=>{const{client:r,clock:i}=e.id,o=new et(De(r,i+n),e,De(r,i+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&o.markDeleted(),e.keep&&(o.keep=!0),e.redone!==null&&(o.redone=De(e.redone.client,e.redone.clock+n)),e.right=o,o.right!==null&&(o.right.left=o),t._mergeStructs.push(o),o.parentSub!==null&&o.right===null&&o.parent._map.set(o.parentSub,o),e.length=n,o},U6=(t,e)=>q3(t,n=>Ba(n.deletions,e)),aE=(t,e,n,r,i,o)=>{const l=t.doc,c=l.store,d=l.clientID,f=e.redone;if(f!==null)return Kn(t,f);let h=e.parent._item,m=null,g;if(h!==null&&h.deleted===!0){if(h.redone===null&&(!n.has(h)||aE(t,h,n,r,i,o)===null))return null;for(;h.redone!==null;)h=Kn(t,h.redone)}const y=h===null?e.parent:h.content.type;if(e.parentSub===null){for(m=e.left,g=e;m!==null;){let k=m;for(;k!==null&&k.parent._item!==h;)k=k.redone===null?null:Kn(t,k.redone);if(k!==null&&k.parent._item===h){m=k;break}m=m.left}for(;g!==null;){let k=g;for(;k!==null&&k.parent._item!==h;)k=k.redone===null?null:Kn(t,k.redone);if(k!==null&&k.parent._item===h){g=k;break}g=g.right}}else if(g=null,e.right&&!i){for(m=e;m!==null&&m.right!==null&&(m.right.redone||Ba(r,m.right.id)||U6(o.undoStack,m.right.id)||U6(o.redoStack,m.right.id));)for(m=m.right;m.redone;)m=Kn(t,m.redone);if(m&&m.right!==null)return null}else m=y._map.get(e.parentSub)||null;const C=It(c,d),w=De(d,C),x=new et(w,m,m&&m.lastId,g,g&&g.id,y,e.parentSub,e.content.copy());return e.redone=w,fv(x,!0),x.integrate(t,0),x};class et extends dv{constructor(e,n,r,i,o,l,c,d){super(e,d.getLength()),this.origin=r,this.left=n,this.right=i,this.rightOrigin=o,this.parent=l,this.parentSub=c,this.redone=null,this.content=d,this.info=this.content.isCountable()?m6:0}set marker(e){(this.info&U0)>0!==e&&(this.info^=U0)}get marker(){return(this.info&U0)>0}get keep(){return(this.info&p6)>0}set keep(e){this.keep!==e&&(this.info^=p6)}get countable(){return(this.info&m6)>0}get deleted(){return(this.info&V0)>0}set deleted(e){this.deleted!==e&&(this.info^=V0)}markDeleted(){this.info|=V0}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=It(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=It(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===da&&this.id.client!==this.parent.client&&this.parent.clock>=It(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=O6(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Kn(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Er||this.right&&this.right.constructor===Er)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===et?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===et&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===da){const r=fa(n,this.parent);r.constructor===Er?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=O6(e,e.doc.store,De(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,i;if(r!==null)i=r.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;const o=new Set,l=new Set;for(;i!==null&&i!==this.right;){if(l.add(i),o.add(i),_f(this.origin,i.origin)){if(i.id.client{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Tu(e.deleteSet,this.id.client,this.id.clock,this.length),L6(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw En();this.content.gc(e),n?GZ(e,this,new Er(this.id,this.length)):this.content=new Nu(this.length)}write(e,n){const r=n>0?De(this.id.client,this.id.clock+n-1):this.origin,i=this.rightOrigin,o=this.parentSub,l=this.content.getRef()&s1|(r===null?0:Dn)|(i===null?0:Gi)|(o===null?0:bu);if(e.writeInfo(l),r!==null&&e.writeLeftID(r),i!==null&&e.writeRightID(i),r===null&&i===null){const c=this.parent;if(c._item!==void 0){const d=c._item;if(d===null){const f=ku(c);e.writeParentInfo(!0),e.writeString(f)}else e.writeParentInfo(!1),e.writeLeftID(d.id)}else c.constructor===String?(e.writeParentInfo(!0),e.writeString(c)):c.constructor===da?(e.writeParentInfo(!1),e.writeLeftID(c)):En();o!==null&&e.writeString(o)}this.content.write(e,n)}}const cE=(t,e)=>$K[e&s1](t),$K=[()=>{En()},MK,OK,EK,_K,NK,RK,FK,LK,AK,()=>{En()}],qK=10;class Br extends dv{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){En()}write(e,n){e.writeInfo(qK),Pe(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const uE=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},dE="__ $YJS$ __";uE[dE]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");uE[dE]=!0;const ZK=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},KK=/[\uD800-\uDBFF]/,GK=/[\uDC00-\uDFFF]/,YK=(t,e)=>{let n=0,r=0;for(;n0&&KK.test(t[n-1])&&n--;r+n0&&GK.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},WK=YK,ci=(t,e)=>t>>>e|t<<32-e,JK=t=>ci(t,2)^ci(t,13)^ci(t,22),XK=t=>ci(t,6)^ci(t,11)^ci(t,25),QK=t=>ci(t,7)^ci(t,18)^t>>>3,eG=t=>ci(t,17)^ci(t,19)^t>>>10,tG=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),nG=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class rG{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(nG),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let m=16;m<64;m++)n[m]=eG(n[m-2])+n[m-7]+QK(n[m-15])+n[m-16];let r=e[0],i=e[1],o=e[2],l=e[3],c=e[4],d=e[5],f=e[6],h=e[7];for(let m=0,g,y;m<64;m++)g=h+XK(c)+(c&d^~c&f)+tG[m]+n[m]>>>0,y=JK(r)+(r&i^r&o^i&o)>>>0,h=f,f=d,d=c,c=l+g>>>0,l=o,o=i,i=r,r=g+y>>>0;e[0]+=r,e[1]+=i,e[2]+=o,e[3]+=l,e[4]+=c,e[5]+=d,e[6]+=f,e[7]+=h}digest(e){let n=0;for(;n+56<=e.length;){let l=0;for(;l<16&&n+3=0&&n>>(3-c)*8;return o}}const iG=t=>new rG().digest(t),Ct=new Ze("y-sync"),Yi=new Ze("y-undo");new Ze("yjs-cursor");const oG=t=>{for(let n=6;nHq(oG(iG(Iq(t)))),yp=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!Ba(e.ds,t.id),lG=[{light:"#ecd44433",dark:"#ecd444"}],aG=(t,e,n)=>{if(!t.has(n)){if(t.sizer.add(i)),e=e.filter(i=>!r.has(i))}t.set(n,mq(e))}return t.get(n)},cG=(t,{colors:e=lG,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:o}={})=>{let l=!1;const c=new fG(t,o),d=new Ue({props:{editable:f=>{const h=Ct.getState(f);return h.snapshot==null&&h.prevSnapshot==null}},key:Ct,state:{init:(f,h)=>({type:t,doc:t.doc,binding:c,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(f,h)=>{const m=f.getMeta(Ct);if(m!==void 0){h=Object.assign({},h);for(const g in m)h[g]=m[g]}return h.addToHistory=f.getMeta("addToHistory")!==!1,h.isChangeOrigin=m!==void 0&&!!m.isChangeOrigin,h.isUndoRedoOperation=m!==void 0&&!!m.isChangeOrigin&&!!m.isUndoRedoOperation,c.prosemirrorView!==null&&m!==void 0&&(m.snapshot!=null||m.prevSnapshot!=null)&&Ek(0,()=>{c.prosemirrorView!=null&&(m.restore==null?c._renderSnapshot(m.snapshot,m.prevSnapshot,h):(c._renderSnapshot(m.snapshot,m.snapshot,h),delete h.restore,delete h.snapshot,delete h.prevSnapshot,c.mux(()=>{c._prosemirrorChanged(c.prosemirrorView.state.doc)})))}),h}},view:f=>(c.initView(f),o==null&&c._forceRerender(),i(),{update:()=>{const h=d.getState(f.state);if(h.snapshot==null&&h.prevSnapshot==null&&(l||f.state.doc.content.findDiffStart(f.state.doc.type.createAndFill().content)!==null)){if(l=!0,h.addToHistory===!1&&!h.isChangeOrigin){const m=Yi.getState(f.state),g=m&&m.undoManager;g&&g.stopCapturing()}c.mux(()=>{h.doc.transact(m=>{m.meta.set("addToHistory",h.addToHistory),c._prosemirrorChanged(f.state.doc)},Ct)})}},destroy:()=>{c.destroy()}})});return d},uG=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")t.setSelection(new Yn(t.doc));else if(e.type==="node"){const r=iu(n.doc,n.type,e.anchor,n.mapping);t.setSelection(dG(t,r))}else{const r=iu(n.doc,n.type,e.anchor,n.mapping),i=iu(n.doc,n.type,e.head,n.mapping);r!==null&&i!==null&&t.setSelection(ue.between(t.doc.resolve(r),t.doc.resolve(i)))}},dG=(t,e)=>{const n=t.doc.resolve(e);return n.nodeAfter?me.create(t.doc,e):ue.near(n)},uy=(t,e)=>({type:e.selection.jsonID,anchor:bp(e.selection.anchor,t.type,t.mapping),head:bp(e.selection.head,t.type,t.mapping)});class fG{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=ZK(),this.mapping=n,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=uy(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(ak&&this._domSelectionInView===null&&(Ek(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;const n=this.prosemirrorView._root.createRange();n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const i=n.getBoundingClientRect(),o=Zu.documentElement;return i.bottom>=0&&i.right>=0&&i.left<=(window.innerWidth||o.clientWidth||0)&&i.top<=(window.innerHeight||o.clientHeight||0)}renderSnapshot(e,n){n||(n=Bk(_k(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Ct,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>nh(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ce(te.from(e),0,0));n.setMeta(Ct,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(i=>nh(i,this.prosemirrorView.state.schema,this)).filter(i=>i!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ce(te.from(n),0,0));if(e){const i=Ea(Qo(e.anchor,0),r.doc.content.size),o=Ea(Qo(e.head,0),r.doc.content.size);r.setSelection(ue.create(r.doc,i,o))}this.prosemirrorView.dispatch(r.setMeta(Ct,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let i=this.doc,o=this.type;if(e||(e=G0(this.doc)),e instanceof Uint8Array||n instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&En(),i=new sl({gc:!1}),oy(i,n),n=G0(i),oy(i,e),e=G0(i),o._item===null){const l=Array.from(this.doc.share.keys()).find(c=>this.doc.share.get(c)===this.type);o=i.getXmlFragment(l)}else{const l=i.store.clients.get(o._item.id.client)??[],c=Kr(l,o._item.id.clock);o=l[c].content.type}this.mapping.clear(),this.mux(()=>{i.transact(l=>{const c=r.permanentUserData;c&&c.dss.forEach(m=>{es(l,m,g=>{})});const d=(m,g)=>{const y=m==="added"?c.getUserByClientId(g.client):c.getUserByDeletedId(g);return{user:y,type:m,color:aG(r.colorMapping,r.colors,y)}},f=Yk(o,new lv(n.ds,e.sv)).map(m=>!m._item.deleted||yp(m._item,e)||yp(m._item,n)?nh(m,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,n,d):null).filter(m=>m!==null),h=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ce(te.from(f),0,0));this.prosemirrorView.dispatch(h.setMeta(Ct,{isChangeOrigin:!0}))},Ct)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=Ct.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const i=(c,d)=>this.mapping.delete(d);es(n,n.deleteSet,c=>{if(c.constructor===et){const d=c.content.type;d&&this.mapping.delete(d)}}),n.changed.forEach(i),n.changedParentTypes.forEach(i);const o=this.type.toArray().map(c=>fE(c,this.prosemirrorView.state.schema,this)).filter(c=>c!==null);let l=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ce(te.from(o),0,0));uG(l,this.beforeTransactionSelection,this),l=l.setMeta(Ct,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof Fk}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&l.scrollIntoView(),this.prosemirrorView.dispatch(l)})}_prosemirrorChanged(e){this.doc.transact(()=>{fy(this.doc,this.type,e,this),this.beforeTransactionSelection=uy(this,this.prosemirrorView.state)},Ct)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const fE=(t,e,n,r,i,o)=>{const l=n.mapping.get(t);if(l===void 0){if(t instanceof xn)return nh(t,e,n,r,i,o);throw Nr()}return l},nh=(t,e,n,r,i,o)=>{const l=[],c=d=>{if(d instanceof xn){const f=fE(d,e,n,r,i,o);f!==null&&l.push(f)}else{const f=d._item.right?.content?.type;f instanceof ts&&!f._item.deleted&&f._item.id.client===f.doc.clientID&&(d.applyDelta([{retain:d.length},...f.toDelta()]),f.doc.transact(m=>{f._item.delete(m)}));const h=hG(d,e,n,r,i,o);h!==null&&h.forEach(m=>{m!==null&&l.push(m)})}};r===void 0||i===void 0?t.toArray().forEach(c):Yk(t,new lv(i.ds,r.sv)).forEach(c);try{const d=t.getAttributes(r);r!==void 0&&(yp(t._item,r)?yp(t._item,i)||(d.ychange=o?o("added",t._item.id):{type:"added"}):d.ychange=o?o("removed",t._item.id):{type:"removed"});const f=e.node(t.nodeName,d,l);return n.mapping.set(t,f),f}catch{return t.doc.transact(f=>{t._item.delete(f)},Ct),n.mapping.delete(t),null}},hG=(t,e,n,r,i,o)=>{const l=[],c=t.toDelta(r,i,o);try{for(let d=0;d{t._item.delete(f)},Ct),null}return l},pG=(t,e)=>{const n=new Xn,r=t.map(i=>({insert:i.text,attributes:pE(i.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n},mG=(t,e)=>{const n=new xn(t.type.name);for(const r in t.attrs){const i=t.attrs[r];i!==null&&r!=="ychange"&&n.setAttribute(r,i)}return n.insert(0,b1(t).map(r=>dy(r,e))),e.mapping.set(n,t),n},dy=(t,e)=>t instanceof Array?pG(t,e):mG(t,e),P6=t=>typeof t=="object"&&t!==null,hv=(t,e)=>{const n=Object.keys(t).filter(i=>t[i]!==null);let r=n.length===Object.keys(e).filter(i=>e[i]!==null).length;for(let i=0;i{const e=t.content.content,n=[];for(let r=0;r{const n=t.toDelta();return n.length===e.length&&n.every((r,i)=>r.insert===e[i].text&&ok(r.attributes||{}).length===e[i].marks.length&&Ha(r.attributes,(o,l)=>{const c=pv(l),d=e[i].marks;return d.find(h=>h.type.name===c)?hv(o,d.find(h=>h.type.name===c)?.attrs):!1}))},Ru=(t,e)=>{if(t instanceof xn&&!(e instanceof Array)&&hy(t,e)){const n=b1(e);return t._length===n.length&&hv(t.getAttributes(),e.attrs)&&t.toArray().every((r,i)=>Ru(r,n[i]))}return t instanceof Xn&&e instanceof Array&&hE(t,e)},vp=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),F6=(t,e,n)=>{const r=t.toArray(),i=b1(e),o=i.length,l=r.length,c=Ea(l,o);let d=0,f=0,h=!1;for(;d{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof Gr?e+=n.content.str:n.content instanceof qt&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},yG=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:i}=gG(t),o=e.map(f=>({insert:f.text,attributes:Object.assign({},r,pE(f.marks,n))})),{insert:l,remove:c,index:d}=WK(i,o.map(f=>f.insert).join(""));t.delete(d,c),t.insert(d,l),t.applyDelta(o.map(f=>({retain:f.insert.length,attributes:f.attributes})))},vG=/(.*)(--[a-zA-Z0-9+/=]{8})$/,pv=t=>vG.exec(t)?.[1]??t,bG=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(pv(r),t[r]));return n},pE=(t,e)=>{const n={};return t.forEach(r=>{if(r.type.name!=="ychange"){const i=to(e.isOMark,r.type,()=>!r.type.excludes(r.type));n[i?`${r.type.name}--${sG(r.toJSON())}`:r.type.name]=r.attrs}}),n},fy=(t,e,n,r)=>{if(e instanceof xn&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof xn){const m=e.getAttributes(),g=n.attrs;for(const y in g)g[y]!==null?m[y]!==g[y]&&y!=="ychange"&&e.setAttribute(y,g[y]):e.removeAttribute(y);for(const y in m)g[y]===void 0&&e.removeAttribute(y)}const i=b1(n),o=i.length,l=e.toArray(),c=l.length,d=Ea(o,c);let f=0,h=0;for(;f{for(;c-f-h>0&&o-f-h>0;){const g=l[f],y=i[f],C=l[c-h-1],w=i[o-h-1];if(g instanceof Xn&&y instanceof Array)hE(g,y)||yG(g,y,r),f+=1;else{let x=g instanceof xn&&hy(g,y),k=C instanceof xn&&hy(C,w);if(x&&k){const A=F6(g,y,r),N=F6(C,w,r);A.foundMappedChild&&!N.foundMappedChild?k=!1:!A.foundMappedChild&&N.foundMappedChild||A.equalityFactor0&&(e.slice(f,f+m).forEach(g=>r.mapping.delete(g)),e.delete(f,m)),f+h!(e instanceof Array)&&t.nodeName===e.type.name,bp=(t,e,n)=>{if(t===0)return K0(e,0,-1);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof Xn){if(r._length>=t)return K0(r,t,-1);if(t-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,t--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const i=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&t1)return new dp(r._item===null?null:r._item.id,r._item===null?ku(r):null,null);if(t-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(t===0)return r=r._item===null?r:r._item.parent,new dp(r._item===null?null:r._item.id,r._item===null?ku(r):null,null);do r=r._item.parent,t--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw En();if(t===0&&r.constructor!==Xn&&r!==e)return CG(r._item.parent,r._item)}return K0(e,e._length,-1)},CG=(t,e)=>{let n=null,r=null;return t._item===null?r=ku(t):n=De(t._item.id.client,t._item.id.clock),new dp(n,r,e.id)},iu=(t,e,n,r)=>{const i=ZZ(n,t);if(i===null||i.type!==e&&!Eu(e,i.type._item))return null;let o=i.type,l=0;if(o.constructor===Xn)l=i.index;else if(o._item===null||!o._item.deleted){let c=o._first,d=0;for(;d{let i;if(r instanceof Xn)i=r.toDelta().map(l=>{const c={type:"text",text:l.insert};return l.attributes&&(c.marks=Object.keys(l.attributes).map(d=>{const f=l.attributes[d],m={type:pv(d)};return Object.keys(f)&&(m.attrs=f),m})),c});else if(r instanceof xn){i={type:r.nodeName};const o=r.getAttributes();Object.keys(o).length&&(i.attrs=o);const l=r.toArray();l.length&&(i.content=l.map(n).flat())}else En();return i};return{type:"doc",content:e.map(n)}}const xG=t=>{const e=Yi.getState(t).undoManager;if(e!=null)return e.undo(),!0},SG=t=>{const e=Yi.getState(t).undoManager;if(e!=null)return e.redo(),!0},TG=new Set(["paragraph"]),kG=(t,e)=>!(t instanceof et)||!(t.content instanceof Wr)||!(t.content.type instanceof ts||t.content.type instanceof xn&&e.has(t.content.type.nodeName))||t.content.type._length===0,EG=({protectedNodes:t=TG,trackedOrigins:e=[],undoManager:n=null}={})=>new Ue({key:Yi,state:{init:(r,i)=>{const o=Ct.getState(i),l=n||new Fk(o.type,{trackedOrigins:new Set([Ct].concat(e)),deleteFilter:c=>kG(c,t),captureTransaction:c=>c.meta.get("addToHistory")!==!1});return{undoManager:l,prevSel:null,hasUndoOps:l.undoStack.length>0,hasRedoOps:l.redoStack.length>0}},apply:(r,i,o,l)=>{const c=Ct.getState(l).binding,d=i.undoManager,f=d.undoStack.length>0,h=d.redoStack.length>0;return c?{undoManager:d,prevSel:uy(c,o),hasUndoOps:f,hasRedoOps:h}:f!==i.hasUndoOps||h!==i.hasRedoOps?Object.assign({},i,{hasUndoOps:d.undoStack.length>0,hasRedoOps:d.redoStack.length>0}):i}},view:r=>{const i=Ct.getState(r.state),o=Yi.getState(r.state).undoManager;return o.on("stack-item-added",({stackItem:l})=>{const c=i.binding;c&&l.meta.set(c,Yi.getState(r.state).prevSel)}),o.on("stack-item-popped",({stackItem:l})=>{const c=i.binding;c&&(c.beforeTransactionSelection=l.meta.get(c)||c.beforeTransactionSelection)}),{destroy:()=>{o.destroy()}}}});function mE(t){return!!t.getMeta(Ct)}function MG(t,e){const n=Ct.getState(t);return iu(n.doc,n.type,e,n.binding.mapping)||0}function gE(t,e){const n=Ct.getState(t);return bp(e,n.type,n.binding.mapping)}var rh=class yE extends Gy{constructor(e,n){super(e),this.yRelativePosition=n}static fromJSON(e){return new yE(e.position,e.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};function AG(t,e){const n=gE(e,t);return new rh(t,n)}function NG(t,e,n){const r=t instanceof rh?t.yRelativePosition:null;if(mE(e)&&r){const l=MG(n,r);return{position:new rh(l,r),mapResult:null}}const i=Wx(t,e),o=i.position.position;return{position:new rh(o,r??gE(n,o)),mapResult:i.mapResult}}Ke.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(t=>t.name==="undoRedo")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".')},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(t,e)=>NG(t,e,this.editor.state),this.editor.utils.createMappablePosition=t=>AG(t,this.editor.state)},addCommands(){return{undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Yi.getState(e).undoManager.undoStack.length===0?!1:n?xG(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Yi.getState(e).undoManager.redoStack.length===0?!1:n?SG(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){var t;const e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),n=EG(this.options.yUndoOptions),r=n.spec.view;n.spec.view=l=>{const{undoManager:c}=Yi.getState(l.state);c.restore&&(c.restore(),c.restore=()=>{});const d=r?r(l):void 0;return{destroy:()=>{const f=c.trackedOrigins.has(c),h=c._observers;c.restore=()=>{f&&c.trackedOrigins.add(c),c.doc.on("afterTransaction",c.afterTransactionHandler),c._observers=h},d?.destroy&&d.destroy()}}};const i={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender},o=cG(e,i);return this.editor.options.enableContentCheck&&((t=e.doc)==null||t.on("beforeTransaction",()=>{try{const l=wG(e);if(l.content.length===0)return;this.editor.schema.nodeFromJSON(l).check()}catch(l){return this.editor.emit("contentError",{error:l,editor:this.editor,disableCollaboration:()=>{var c;(c=e.doc)==null||c.destroy(),this.storage.isDisabled=!0}}),!1}})),[o,n,this.editor.options.enableContentCheck&&new Ue({key:new Ze("filterInvalidContent"),filterTransaction:()=>{var l;return this.storage.isDisabled!==!1&&((l=e.doc)==null||l.destroy()),!0}})].filter(Boolean)}});function $6(t){if(!t.length)return Qe.empty;const e=[],n=t[0].$from.node(0);return t.forEach(r=>{const i=r.$from.pos,o=r.$from.nodeAfter;o&&e.push(Ft.node(i,i+o.nodeSize,{class:"ProseMirror-selectednoderange"}))}),Qe.create(n,e)}function C1(t,e,n){const r=[],i=t.node(0);typeof n=="number"&&n>=0||(t.sameParent(e)?n=Math.max(0,t.sharedDepth(e.pos)-1):n=t.sharedDepth(e.pos));const o=new su(t,e,n),l=o.depth===0?0:i.resolve(o.start).posAtIndex(0);return o.parent.forEach((c,d)=>{const f=l+d,h=f+c.nodeSize;if(f=o.end)return;const m=new wy(i.resolve(f),i.resolve(h));r.push(m)}),r}var RG=class vE{constructor(e,n){this.anchor=e,this.head=n}map(e){return new vE(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return new qo(n,r)}},qo=class Do extends Se{constructor(e,n,r,i=1){const{doc:o}=e,l=e===n,c=e.pos===o.content.size&&n.pos===o.content.size,d=l&&!c?o.resolve(n.pos+(i>0?1:-1)):n,f=l&&c?o.resolve(e.pos-(i>0?1:-1)):e,h=C1(f.min(d),f.max(d),r),m=d.pos>=e.pos?h[0].$from:h[h.length-1].$to,g=d.pos>=e.pos?h[h.length-1].$to:h[0].$from;super(m,g,h),this.depth=r}get $to(){return this.ranges[this.ranges.length-1].$to}eq(e){return e instanceof Do&&e.$from.pos===this.$from.pos&&e.$to.pos===this.$to.pos}map(e,n){const r=e.resolve(n.map(this.anchor)),i=e.resolve(n.map(this.head));return new Do(r,i)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:e}=this.$from;if(this.isForwards&&this.ranges.length>1){const i=this.ranges.slice(0,-1),o=i[0].$from,l=i[i.length-1].$to;return new Do(o,l,this.depth)}const n=this.ranges[0],r=e.resolve(Math.max(0,n.$from.pos-1));return new Do(this.$anchor,r,this.depth)}extendForwards(){const{doc:e}=this.$from;if(this.isBackwards&&this.ranges.length>1){const i=this.ranges.slice(1),o=i[0].$from,l=i[i.length-1].$to;return new Do(l,o,this.depth)}const n=this.ranges[this.ranges.length-1],r=e.resolve(Math.min(e.content.size,n.$to.pos+1));return new Do(this.$anchor,r,this.depth)}static fromJSON(e,n){return new Do(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r,i,o=1){return new this(e.resolve(n),e.resolve(r),i,o)}getBookmark(){return new RG(this.anchor,this.head)}};qo.prototype.visible=!1;function Bf(t){return t instanceof qo}Ke.create({name:"nodeRange",addOptions(){return{depth:void 0,key:"Mod"}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:i,selection:o,tr:l}=r,{anchor:c,head:d}=o;if(!Bf(o)){const h=qo.create(i,c,d,e,-1);return l.setSelection(h),n.dispatch(l),!0}const f=o.extendBackwards();return l.setSelection(f),n.dispatch(l),!0},"Shift-ArrowDown":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:i,selection:o,tr:l}=r,{anchor:c,head:d}=o;if(!Bf(o)){const h=qo.create(i,c,d,e);return l.setSelection(h),n.dispatch(l),!0}const f=o.extendForwards();return l.setSelection(f),n.dispatch(l),!0},"Mod-a":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:i,tr:o}=r,l=qo.create(i,0,i.content.size,e);return o.setSelection(l),n.dispatch(o),!0}}},onSelectionUpdate(){const{selection:t}=this.editor.state;Bf(t)&&this.editor.view.dom.classList.add("ProseMirror-noderangeselection")},addProseMirrorPlugins(){let t=!1,e=!1;return[new Ue({key:new Ze("nodeRange"),props:{attributes:()=>t?{class:"ProseMirror-noderangeselection"}:{class:""},handleDOMEvents:{mousedown:(n,r)=>{const{key:i}=this.options,o=/Mac/.test(navigator.platform),l=!!r.shiftKey,c=!!r.ctrlKey,d=!!r.altKey,f=!!r.metaKey,h=o?f:c;return(i==null||i==="Shift"&&l||i==="Control"&&c||i==="Alt"&&d||i==="Meta"&&f||i==="Mod"&&h)&&(e=!0),e&&document.addEventListener("mouseup",()=>{e=!1;const{state:m}=n,{doc:g,selection:y,tr:C}=m,{$anchor:w,$head:x}=y;if(w.sameParent(x))return;const k=qo.create(g,w.pos,x.pos,this.options.depth);C.setSelection(k),n.dispatch(C)},{once:!0}),!1}},decorations:n=>{const{selection:r}=n,i=Bf(r);if(t=!1,!e)return i?(t=!0,$6(r.ranges)):null;const{$from:o,$to:l}=r;if(!i&&o.sameParent(l))return null;const c=C1(o,l,this.options.depth);return c.length?(t=!0,$6(c)):null}}})]}});function OG(t){let e="";const n=getComputedStyle(t);for(let r=0;r{r[o].style.cssText=OG(i)}),e}function LG(t,e){let n=t;for(;n?.parentElement&&n.parentElement!==e.dom;)n=n.parentElement;return n?.parentElement===e.dom?n:void 0}function _G(t,e,n,r=5){const i=t.dom,o=i.firstElementChild,l=i.lastElementChild;if(!o||!l)return{x:e,y:n};const c=o.getBoundingClientRect(),d=l.getBoundingClientRect(),f=Math.min(Math.max(c.top+r,n),d.bottom-r),h=.5,m=Math.abs(c.left-d.left){const{x:e,y:n,editor:r}=t,{view:i,state:o}=r,{x:l,y:c}=_G(i,e,n,5),d=i.root.elementsFromPoint(l,c);let f;if(Array.prototype.some.call(d,g=>{if(!i.dom.contains(g))return!1;const y=LG(g,i);return y?(f=y,!0):!1}),!f)return{resultElement:null,resultNode:null,pos:null};let h;try{h=i.posAtDOM(f,0)}catch{return{resultElement:null,resultNode:null,pos:null}}const m=o.doc.nodeAt(h);if(!m){const g=o.doc.resolve(h),y=g.parent;return{resultElement:f,resultNode:y,pos:g.start()}}return{resultElement:f,resultNode:m,pos:h}};function jf(t,e){return window.getComputedStyle(t)[e]}function HG(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function IG(t,e,n){const r=parseInt(jf(t.dom,"paddingLeft"),10),i=parseInt(jf(t.dom,"paddingRight"),10),o=parseInt(jf(t.dom,"borderLeftWidth"),10),l=parseInt(jf(t.dom,"borderLeftWidth"),10),c=t.dom.getBoundingClientRect();return{left:HG(e,c.left+r+o,c.right-i-l),top:n}}function CE(t){var e;(e=t.parentNode)==null||e.removeChild(t)}function zG(t,e){const{doc:n}=e.view.state,r=bE({editor:e,x:t.clientX,y:t.clientY});if(!r.resultNode||r.pos===null)return[];const i=t.clientX,o=IG(e.view,i,t.clientY),l=e.view.posAtCoords(o);if(!l)return[];const{pos:c}=l;if(!n.resolve(c).parent)return[];const f=n.resolve(r.pos),h=n.resolve(r.pos+1);return C1(f,h,0)}function BG(t,e){const{view:n}=e;if(!t.dataTransfer)return;const{empty:r,$from:i,$to:o}=n.state.selection,l=zG(t,e),c=C1(i,o,0),d=c.some(x=>l.find(k=>k.$from===x.$from&&k.$to===x.$to)),f=r||!d?l:c;if(!f.length)return;const{tr:h}=n.state,m=document.createElement("div"),g=f[0].$from.pos,y=f[f.length-1].$to.pos,C=qo.create(n.state.doc,g,y),w=C.content();f.forEach(x=>{const k=n.nodeDOM(x.$from.pos),A=DG(k);m.append(A)}),m.style.position="absolute",m.style.top="-10000px",document.body.append(m),t.dataTransfer.clearData(),t.dataTransfer.setDragImage(m,0,0),n.dragging={slice:w,move:!0},h.setSelection(C),n.dispatch(h),document.addEventListener("drop",()=>CE(m),{once:!0})}var q6=(t,e)=>{const n=t.resolve(e),{depth:r}=n;return r===0?e:n.pos-n.parentOffset-1},Z6=(t,e)=>{const n=t.nodeAt(e),r=t.resolve(e);let{depth:i}=r,o=n;for(;i>0;){const l=r.node(i);i-=1,i===0&&(o=l)}return o},J0=(t,e)=>{const n=Ct.getState(t);return n?bp(e,n.type,n.binding.mapping):null},jG=(t,e)=>{const n=Ct.getState(t);return n?iu(n.doc,n.type,e,n.binding.mapping)||0:-1},K6=(t,e)=>{let n=e;for(;n?.parentNode&&n.parentNode!==t.dom;)n=n.parentNode;return n},wE=new Ze("dragHandle"),xE=({pluginKey:t=wE,element:e,editor:n,computePositionConfig:r,getReferencedVirtualElement:i,onNodeChange:o,onElementDragStart:l,onElementDragEnd:c})=>{const d=document.createElement("div");let f=!1,h=null,m=-1,g,y=null,C=null;function w(){e&&(e.style.visibility="hidden",e.style.pointerEvents="none")}function x(){if(e){if(!n.isEditable){w();return}e.style.visibility="",e.style.pointerEvents="auto"}}function k(R){const L=i?.()||{getBoundingClientRect:()=>R.getBoundingClientRect()};ju(L,e,r).then(z=>{Object.assign(e.style,{position:z.strategy,left:`${z.x}px`,top:`${z.y}px`})})}function A(R){l?.(R),BG(R,n),e&&(e.dataset.dragging="true"),setTimeout(()=>{e&&(e.style.pointerEvents="none")},0)}function N(R){c?.(R),w(),e&&(e.style.pointerEvents="auto",e.dataset.dragging="false")}return e.addEventListener("dragstart",A),e.addEventListener("dragend",N),d.appendChild(e),{unbind(){e.removeEventListener("dragstart",A),e.removeEventListener("dragend",N),y&&(cancelAnimationFrame(y),y=null,C=null)},plugin:new Ue({key:typeof t=="string"?new Ze(t):t,state:{init(){return{locked:!1}},apply(R,L,z,_){const $=R.getMeta("lockDragHandle"),J=R.getMeta("hideDragHandle");if($!==void 0&&(f=$),J)return w(),f=!1,h=null,m=-1,o?.({editor:n,node:null,pos:-1}),L;if(R.docChanged&&m!==-1&&e)if(mE(R)){const U=jG(_,g);U!==m&&(m=U)}else{const U=R.mapping.map(m);U!==m&&(m=U,g=J0(_,m))}return L}},view:R=>{var L;return e.draggable=!0,e.style.pointerEvents="auto",e.dataset.dragging="false",(L=n.view.dom.parentElement)==null||L.appendChild(d),d.style.pointerEvents="none",d.style.position="absolute",d.style.top="0",d.style.left="0",{update(z,_){if(!e)return;if(!n.isEditable){w();return}if(f?e.draggable=!1:e.draggable=!0,R.state.doc.eq(_.doc)||m===-1)return;let $=R.nodeDOM(m);if($=K6(R,$),$===R.dom||$?.nodeType!==1)return;const J=R.posAtDOM($,0),U=Z6(n.state.doc,J),ne=q6(n.state.doc,J);h=U,m=ne,g=J0(R.state,m),o?.({editor:n,node:h,pos:m}),k($)},destroy(){y&&(cancelAnimationFrame(y),y=null,C=null),e&&CE(d)}}},props:{handleDOMEvents:{keydown(R){return!e||f||R.hasFocus()&&(w(),h=null,m=-1,o?.({editor:n,node:null,pos:-1})),!1},mouseleave(R,L){return f||L.target&&!d.contains(L.relatedTarget)&&(w(),h=null,m=-1,o?.({editor:n,node:null,pos:-1})),!1},mousemove(R,L){return!e||f||(C={x:L.clientX,y:L.clientY},y)||(y=requestAnimationFrame(()=>{if(y=null,!C)return;const{x:z,y:_}=C;C=null;const $=bE({x:z,y:_,editor:n});if(!$.resultElement)return;let J=$.resultElement;if(J=K6(R,J),J===R.dom||J?.nodeType!==1)return;const U=R.posAtDOM(J,0),ne=Z6(n.state.doc,U);if(ne!==h){const se=q6(n.state.doc,U);h=ne,m=se,g=J0(R.state,m),o?.({editor:n,node:h,pos:m}),k(J),x()}})),!1}}}})}},py={placement:"left-start",strategy:"absolute"};Ke.create({name:"dragHandle",addOptions(){return{render(){const t=document.createElement("div");return t.classList.add("drag-handle"),t},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0}},addCommands(){return{lockDragHandle:()=>({editor:t})=>(this.options.locked=!0,t.commands.setMeta("lockDragHandle",this.options.locked)),unlockDragHandle:()=>({editor:t})=>(this.options.locked=!1,t.commands.setMeta("lockDragHandle",this.options.locked)),toggleDragHandle:()=>({editor:t})=>(this.options.locked=!this.options.locked,t.commands.setMeta("lockDragHandle",this.options.locked))}},addProseMirrorPlugins(){const t=this.options.render();return[xE({computePositionConfig:{...py,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:t,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd}).plugin]}});var VG=t=>{const{className:e="drag-handle",children:n,editor:r,pluginKey:i=wE,onNodeChange:o,onElementDragStart:l,onElementDragEnd:c,computePositionConfig:d=py}=t,[f,h]=E.useState(null),m=E.useRef(null);return E.useEffect(()=>{let g=null;return f?r.isDestroyed?()=>{m.current=null}:(m.current||(g=xE({editor:r,element:f,pluginKey:i,computePositionConfig:{...py,...d},onElementDragStart:l,onElementDragEnd:c,onNodeChange:o}),m.current=g.plugin,r.registerPlugin(m.current)),()=>{r.unregisterPlugin(i),m.current=null,g&&(g.unbind(),g=null)}):()=>{m.current=null}},[f,r,o,i,d,l,c]),S.jsx("div",{className:e,style:{visibility:"hidden",position:"absolute"},"data-dragging":"false",ref:h,children:n})},UG=VG;function PG({initialOpen:t=!1,placement:e="top",open:n,onOpenChange:r,delay:i=600,closeDelay:o=0}={}){const[l,c]=E.useState(t),d=n??l,f=r??c,h=e1({placement:e,open:d,onOpenChange:f,whileElementsMounted:qp,middleware:[Yp(4),B3({crossAxis:e.includes("-"),fallbackAxisSideDirection:"start",padding:4}),z3({padding:4})]}),m=h.context,g=yU(m,{mouseOnly:!0,move:!1,restMs:i,enabled:n==null,delay:{close:o}}),y=LU(m,{enabled:n==null}),C=U3(m),w=P3(m,{role:"tooltip"}),x=t1([g,y,C,w]);return E.useMemo(()=>({open:d,setOpen:f,...x,...h}),[d,f,x,h])}const my=E.createContext(null);function SE(){const t=E.useContext(my);if(t==null)throw new Error("Tooltip components must be wrapped in ");return t}function TE({children:t,...e}){const n=PG(e);return e.useDelayGroup?S.jsx(bU,{delay:{open:e.delay??0,close:e.closeDelay??0},timeoutMs:e.timeout,children:S.jsx(my.Provider,{value:n,children:t})}):S.jsx(my.Provider,{value:n,children:t})}const kE=E.forwardRef(function({children:e,asChild:n=!1,...r},i){const o=SE(),l=E.isValidElement(e)?parseInt(E.version,10)>=19?e.props.ref:e.ref:void 0,c=ol([o.refs.setReference,i,l]);if(n&&E.isValidElement(e)){const d={"data-tooltip-state":o.open?"open":"closed"};return E.cloneElement(e,o.getReferenceProps({ref:c,...r,...typeof e.props=="object"?e.props:{},...d}))}return S.jsx("button",{ref:c,"data-tooltip-state":o.open?"open":"closed",...o.getReferenceProps(r),children:e})}),EE=E.forwardRef(function({style:e,children:n,portal:r=!0,portalProps:i={},...o},l){const c=SE(),d=ol([c.refs.setFloating,l]);if(!c.open)return null;const f=S.jsx("div",{ref:d,style:{...c.floatingStyles,...e},...c.getFloatingProps(o),className:"tiptap-tooltip",children:n});return r?S.jsx(Qp,{...i,children:f}):f});TE.displayName="Tooltip";kE.displayName="TooltipTrigger";EE.displayName="TooltipContent";const FG={ctrl:"⌘",alt:"⌥",shift:"⇧"},$G=(t,e)=>{if(e){const n=t.toLowerCase();return FG[n]||t.toUpperCase()}return t.charAt(0).toUpperCase()+t.slice(1)},qG=(t,e)=>t?t.split("-").map(n=>n.trim()).map(n=>$G(n,e)):[],ZG=({shortcuts:t})=>t.length===0?null:S.jsx("div",{children:t.map((e,n)=>S.jsxs(E.Fragment,{children:[n>0&&S.jsx("kbd",{children:"+"}),S.jsx("kbd",{children:e})]},n))}),xt=E.forwardRef(({className:t="",spanTag:e,children:n,tooltip:r,showTooltip:i=!0,shortcutKeys:o,"aria-label":l,...c},d)=>{const f=E.useMemo(()=>typeof navigator<"u"&&navigator.platform.toLowerCase().includes("mac"),[]),h=E.useMemo(()=>qG(o,f),[o,f]);return!r||!i?e?S.jsx("span",{className:`tiptap-button ${t}`.trim(),ref:d,"aria-label":l,...c,children:n}):S.jsx("button",{className:`tiptap-button ${t}`.trim(),ref:d,"aria-label":l,...c,children:n}):S.jsxs(TE,{delay:200,children:[S.jsx(kE,{className:`tiptap-button ${t}`.trim(),ref:d,"aria-label":l,...c,children:n}),S.jsxs(EE,{children:[r,S.jsx(ZG,{shortcuts:h})]})]})});xt.displayName="Button";const Yu=E.forwardRef(({decorative:t,orientation:e="vertical",className:n="",...r},i)=>{const l=t?{role:"none"}:{"aria-orientation":e==="vertical"?e:void 0,role:"separator"};return S.jsx("div",{className:`tiptap-separator ${n}`.trim(),"data-orientation":e,...l,...r,ref:i})});Yu.displayName="Separator";const ME=E.createContext(null);function w1(){const t=E.useContext(ME);if(!t)throw new Error("DropdownMenu components must be wrapped in ");return t}function KG({initialOpen:t=!1,open:e,onOpenChange:n,side:r="bottom",align:i="start"}){const[o,l]=E.useState(t),[c,d]=E.useState(`${r}-${i}`),[f,h]=E.useState(null),[m,g]=E.useState(null),y=e??o,C=n??l,w=E.useRef([]),x=E.useRef([]),k=e1({open:y,onOpenChange:C,placement:c,middleware:[Yp({mainAxis:4}),B3(),z3({padding:4}),NT({apply({availableHeight:L}){const z=L-16;g(z)}})],whileElementsMounted:qp}),{context:A}=k,N=t1([IT(A,{event:"click",toggle:!0,ignoreMouse:!1}),P3(A,{role:"menu"}),U3(A,{outsidePress:!0,outsidePressEvent:"mousedown"}),HU(A,{listRef:w,activeIndex:f,onNavigate:h,loop:!0}),zU(A,{listRef:x,onMatch:y?h:void 0,activeIndex:f})]),R=E.useCallback((L,z)=>{d(`${L}-${z}`)},[]);return E.useMemo(()=>({open:y,setOpen:C,activeIndex:f,setActiveIndex:h,elementsRef:w,labelsRef:x,updatePosition:R,maxHeight:m,...N,...k}),[y,C,f,N,k,R,m])}function mv({children:t,...e}){const n=KG(e);return S.jsx(ME.Provider,{value:n,children:S.jsx(lU,{elementsRef:n.elementsRef,labelsRef:n.labelsRef,children:t})})}const x1=E.forwardRef(({children:t,asChild:e=!1,...n},r)=>{const i=w1(),o=E.isValidElement(t)?parseInt(E.version,10)>=19?t.props.ref:t.ref:void 0,l=ol([i.refs.setReference,r,o]);if(e&&E.isValidElement(t)){const c={"data-state":i.open?"open":"closed"};return E.cloneElement(t,i.getReferenceProps({ref:l,...n,...typeof t.props=="object"?t.props:{},"aria-expanded":i.open,"aria-haspopup":"menu",...c}))}return S.jsx("button",{ref:l,"aria-expanded":i.open,"aria-haspopup":"menu","data-state":i.open?"open":"closed",...i.getReferenceProps(n),children:t})});x1.displayName="DropdownMenuTrigger";const S1=E.forwardRef(({style:t,className:e,orientation:n="vertical",side:r="bottom",align:i="start",portal:o=!0,portalProps:l={},...c},d)=>{const f=w1(),h=ol([f.refs.setFloating,d]);if(E.useEffect(()=>{f.updatePosition(r,i)},[f,r,i]),!f.open)return null;const m=S.jsx(HT,{context:f.context,modal:!1,initialFocus:0,returnFocus:!0,children:S.jsx("div",{ref:h,className:`tiptap-dropdown-menu ${e||""}`,style:{position:f.strategy,top:f.y??0,left:f.x??0,outline:"none",...t},"aria-orientation":n,"data-orientation":n,"data-state":f.open?"open":"closed","data-side":r,"data-align":i,...f.getFloatingProps(c),children:c.children})});return o?S.jsx(Qp,{...l,children:m}):m});S1.displayName="DropdownMenuContent";const T1=E.forwardRef(({children:t,disabled:e,asChild:n=!1,onSelect:r,className:i,...o},l)=>{const c=w1(),d=aU({label:e?null:t?.toString()}),f=c.activeIndex===d.index,h=E.useCallback(g=>{e||(r?.(),o.onClick?.(g),c.setOpen(!1))},[c,e,r,o]),m={ref:ol([d.ref,l]),role:"menuitem",className:i,tabIndex:f?0:-1,"data-highlighted":f,"aria-disabled":e,...c.getItemProps({...o,onClick:h})};if(n&&E.isValidElement(t)){const g=t.props,y={...m,...typeof t.props=="object"?t.props:{}},C={onClick:w=>{h(w),g.onClick?.(w)}};return E.cloneElement(t,{...y,...C})}return S.jsx("div",{...m,children:t})});T1.displayName="DropdownMenuItem";const k1=E.forwardRef(({children:t,label:e,className:n,...r},i)=>{const o=w1(),l={};return o.maxHeight&&(l.maxHeight=`${o.maxHeight}px`),S.jsx("div",{...r,ref:i,role:"group","aria-label":e,className:`tiptap-button-group ${n||""}`,style:l,children:t})});k1.displayName="DropdownMenuGroup";const GG=E.forwardRef(({className:t,...e},n)=>S.jsx(Yu,{ref:n,className:`tiptap-dropdown-menu-separator ${t||""}`,...e}));GG.displayName=Yu.displayName;function AE(t){const{x:e,y:n,direction:r,editor:i}=t;let o=null,l=null,c=null,d=e,f=null;for(;l===null&&d0;){const h=document.elementsFromPoint(d,n),m=h.findIndex(y=>y.classList.contains("ProseMirror")),g=h.slice(0,m);if(g.length>0){let y=g[0],C=y,w=100;for(;w>0&&C.parentElement&&!C.parentElement.classList.contains("f-tiptap-editor__tiptap-editor");)C=C.parentElement,w--;if(C&&(y=C),o=y,c=i.view.posAtDOM(y,0),c>=0){f=i.state.doc.resolve(c),f.depth>=1&&(l=f.node(1)),l||(l=i.state.doc.nodeAt(Math.max(c-1,0)),l||(l=i.state.doc.nodeAt(Math.max(c,0))));break}}r==="left"?d-=1:d+=1}return{resultElement:o,resultNode:l,pos:c!==null?c:null,resolvedPos:f}}const YG=({event:t,editor:e})=>{const n=t.target.closest(".drag-handle").getBoundingClientRect(),r=AE({x:n.left,y:n.top+16,direction:"right",editor:e});if(!r||r.resolvedPos===null){console.error("No node found at the clicked position");return}e.chain().focus().triggerFolioTiptapCommand(r.resolvedPos).run()},WG=()=>{},NE=(t,e)=>{if(!e.resultNode||e.pos===null)throw new Error("Invalid target node");const n=t.state.doc.resolve(e.pos);let r,i;return e.resultNode.isLeaf||e.resultNode.content.size===0?(r=e.pos,i=e.pos+e.resultNode.nodeSize):(r=n.before(1),i=n.after(1)),{startPos:r,endPos:i}},JG=async(t,e,n)=>{try{if(e&&e.resultElement){const r=e.resultElement.outerHTML,i=e.resultElement.textContent||"";try{await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:"text/html"}),"text/plain":new Blob([i],{type:"text/plain"})})])}catch(o){console.error("Failed to write to clipboard:",o)}return{success:!0,data:{html:r}}}return console.error("No target node found for copying"),{success:!1}}catch(r){return console.error("Error copying node:",r),{success:!1}}},XG=(t,e,n)=>{try{if(!n.html)return{success:!1};const{startPos:r,endPos:i}=NE(t,e);return e.resultNode?.type.name==="paragraph"&&e.resultNode.content.size===0?t.commands.insertContentAt(r,n.html):t.commands.insertContentAt(i,n.html),{success:!0}}catch(r){return console.error("Error pasting node:",r),{success:!1}}},QG=(t,e,n)=>{try{const{startPos:r,endPos:i}=NE(t,e);if(typeof r=="number"&&typeof i=="number"){const o=t.state.tr;return o.delete(r,i),t.view.dispatch(o),{success:!0}}else return console.error("Error removing node"),{success:!1}}catch(r){return console.error("Error removing node:",r),{success:!1}}},eY=(t,e,n)=>{if(!e.resultNode||e.pos===null)return console.error("Invalid target node"),{success:!1};if(e.resultElement){const r=new CustomEvent("f-tiptap-node:edit");return e.resultElement.dispatchEvent(r),{success:!0}}return{success:!1}},G6={cs:{copyNode:"Kopírovat",pasteNode:"Vložit",removeNode:"Odstranit",editFolioTiptapNode:"Upravit"},en:{copyNode:"Copy",pasteNode:"Paste",removeNode:"Remove",editFolioTiptapNode:"Edit"}},X0=[{type:"copyNode",icon:iP,command:JG},{type:"removeNode",icon:zp,command:QG}],tY={type:"pasteNode",icon:sP,command:XG},nY={type:"editFolioTiptapNode",icon:E8,command:eY},rY=(t,e,n,r,i)=>async()=>{const o=document.querySelector(".f-tiptap-smart-drag-handle__button--drag").getBoundingClientRect(),l=AE({x:o.left,y:o.top+16,direction:"right",editor:t});if(l&&l.resultNode&&l.pos!==null){const{success:c,data:d}=await e.command(t,l,r);c&&(n(null),e.type==="copyNode"&&d&&d.html&&i({at:Date.now(),html:d.html}))}else n(null)},Y6=1e3;function iY({editor:t,selectedNodeData:e,clipboardData:n,setClipboardData:r}){const[i,o]=E.useState(null),[,l]=Ve.useReducer(m=>m+1,0),c=Ve.useRef(null),[d]=Ve.useState(void 0);if(Ve.useEffect(()=>{if(n.at){const m=setTimeout(()=>{l()},Y6);return()=>clearTimeout(m)}},[n.at]),!t)return null;let f;n.at?f=[...X0.slice(0,1),tY,...X0.slice(1)]:f=X0;const h=[...e&&e.type==="folioTiptapNode"?[...f.slice(0,f.length-1),nY,f[f.length-1]]:f];return S.jsx("div",{className:"f-tiptap-smart-drag-handle-content",style:d,ref:c,children:S.jsxs("div",{className:"f-tiptap-smart-drag-handle-content__flex",children:[S.jsx(xt,{type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":"Plus",onClick:m=>{YG({event:m,editor:t})},className:"f-tiptap-smart-drag-handle__button f-tiptap-smart-drag-handle__button--plus",children:S.jsx(r1,{className:"tiptap-button-icon"})}),S.jsxs(mv,{open:i==="drag",onOpenChange:m=>{o(m?"drag":null)},children:[S.jsx(x1,{asChild:!0,children:S.jsx(xt,{spanTag:!0,type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":"Drag",onClick:WG,className:"f-tiptap-smart-drag-handle__button f-tiptap-smart-drag-handle__button--drag",children:n.at&&Date.now()-n.atS.jsx(T1,{asChild:!0,children:S.jsxs(xt,{type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":pe(G6,m.type),className:"f-tiptap-smart-drag-handle__dropdown-button",onClick:rY(t,m,o,n,r),children:[E.createElement(m.icon,{className:"tiptap-button-icon"}),pe(G6,m.type)]})},m.type))})})]})]})})}function oY({editor:t}){const[e,n]=Ve.useState(null),r=Ve.useRef(-1),[i,o]=Ve.useState({at:null,html:null});return S.jsx(UG,{editor:t,onElementDragStart:l=>{const c=r.current;if(!t.view.dragging&&c>=0){if(!t.state.doc.nodeAt(c))return;const f=me.create(t.state.doc,c),h=f.content();t.view.dragging={slice:h,move:!0};const m=t.state.tr.setSelection(f);if(t.view.dispatch(m),l.dataTransfer){l.dataTransfer.effectAllowed="move";const g=t.view.nodeDOM(c);if(g instanceof HTMLElement){const y=document.createElement("div");y.appendChild(g.cloneNode(!0)),y.style.position="absolute",y.style.top="-10000px",document.body.appendChild(y),l.dataTransfer.setDragImage(y,0,0),document.addEventListener("drop",()=>y.remove(),{once:!0})}}}},onNodeChange:({node:l,pos:c})=>{if(r.current=c,l){const d=document.querySelector(".drag-handle");if(d){const f=d.getBoundingClientRect(),h={type:l.type.name,x:f.x,y:f.y};if(e&&e.type===h.type&&e.x===h.x&&e.y===h.y)return;n(h);return}}n(null)},children:S.jsx(iY,{editor:t,selectedNodeData:e,clipboardData:i,setClipboardData:o})})}const RE=({content:t,schema:e,allowedNodeTypes:n})=>{if(!t)return t;if(t.type&&!e.nodes[t.type])return console.error(`Removed unsupported node type: ${t.type}`),{type:"folioTiptapInvalidNode",attrs:{invalidNodeHash:t}};if(t.type==="folioTiptapNode"&&n&&n.length>0){const r=t.attrs?.type;if(r&&!n.includes(r))return console.error(`Removed disallowed folioTiptapNode type: ${r}`),{type:"folioTiptapInvalidNode",attrs:{invalidNodeHash:t}}}if(Array.isArray(t.content)){const r=[];return t.content.forEach(i=>{const o=RE({content:i,schema:e,allowedNodeTypes:n});o&&r.push(o)}),{...t,content:r}}return t},sY=({content:t,editor:e,allowedFolioTiptapNodeTypes:n})=>{if(!t)return t;const r=n?.map(i=>i.type);return RE({content:t,schema:e.schema,allowedNodeTypes:r})},lY=t=>t.type==="paragraph"&&(!t.content||t.content.length===0),OE=t=>{if(!t.content||!Array.isArray(t.content)||t.content.length===0)return t;const e=t.content.map(n=>OE(n));return e.length>1&&lY(e[e.length-1])?{...t,content:e.slice(0,-1)}:{...t,content:e}},DE=t=>OE(t),aY={commandPlaceholder:'Začněte psát, nebo stiskněte "/" pro příkazy…',defaultPlaceholder:"Začněte psát…",headingInPagesPlaceholder:"Napište titulek stránky",h2Placeholder:'Napište H2 titulek, nebo "/" pro příkazy',h3Placeholder:'Napište H3 titulek, nebo "/" pro příkazy',h4Placeholder:'Napište H4 titulek, nebo "/" pro příkazy',singleHeadingPlaceholder:'Napište mezititulek, nebo "/" pro příkazy'},cY={commandPlaceholder:'Start writing, or press "/" for commands…',defaultPlaceholder:"Start writing…",headingInPagesPlaceholder:"Write page title",h2Placeholder:'Write H2 heading or "/" for commands',h3Placeholder:'Write H3 heading or "/" for commands',h4Placeholder:'Write H4 heading or "/" for commands',singleHeadingPlaceholder:'Write title or "/" for commands'},W6={cs:aY,en:cY};function uY(t,e){const n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),i=Math.min(t.left,e.left),l=Math.max(t.right,e.right)-i,c=r-n,d=i,f=n;return new DOMRect(d,f,l,c)}var dY=class{constructor({editor:t,element:e,view:n,updateDelay:r=250,resizeDelay:i=60,shouldShow:o,appendTo:l,getReferencedVirtualElement:c,options:d}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:h,state:m,from:g,to:y})=>{const{doc:C,selection:w}=m,{empty:x}=w,k=!C.textBetween(g,y).length&&Uy(m.selection),A=this.element.contains(document.activeElement);return!(!(h.hasFocus()||A)||x||k||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:h})=>{var m;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}h?.relatedTarget&&((m=this.element.parentNode)!=null&&m.contains(h.relatedTarget))||h?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(h,m)=>{const g=!m?.selection.eq(h.state.selection),y=!m?.doc.eq(h.state.doc);!g&&!y||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(h,g,y,m)},this.updateDelay))},this.updateHandler=(h,m,g,y)=>{const{composing:C}=h;if(C||!m&&!g)return;if(!this.getShouldShow(y)){this.hide();return}this.updatePosition(),this.show()},this.transactionHandler=({transaction:h})=>{h.getMeta("bubbleMenu")==="updatePosition"&&this.updatePosition()};var f;this.editor=t,this.element=e,this.view=n,this.updateDelay=r,this.resizeDelay=i,this.appendTo=l,this.scrollTarget=(f=d?.scrollTarget)!=null?f:window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...d},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(Kp(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(I3(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(Zp(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(ET(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(Gp(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(TT(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(kT(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(MT(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}get virtualElement(){var t;const{selection:e}=this.editor.state,n=(t=this.getReferencedVirtualElement)==null?void 0:t.call(this);if(n)return n;const r=Jx(this.view,e.from,e.to);let i={getBoundingClientRect:()=>r,getClientRects:()=>[r]};if(e instanceof me){let o=this.view.nodeDOM(e.from);const l=o.dataset.nodeViewWrapper?o:o.querySelector("[data-node-view-wrapper]");l&&(o=l),o&&(i={getBoundingClientRect:()=>o.getBoundingClientRect(),getClientRects:()=>[o.getBoundingClientRect()]})}if(e instanceof dt){const{$anchorCell:o,$headCell:l}=e,c=o?o.pos:l.pos,d=l?l.pos:o.pos,f=this.view.nodeDOM(c),h=this.view.nodeDOM(d);if(!f||!h)return;const m=f===h?f.getBoundingClientRect():uY(f.getBoundingClientRect(),h.getBoundingClientRect());i={getBoundingClientRect:()=>m,getClientRects:()=>[m]}}return i}updatePosition(){const t=this.virtualElement;t&&ju(t,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:n,strategy:r})=>{this.element.style.width="max-content",this.element.style.position=r,this.element.style.left=`${e}px`,this.element.style.top=`${n}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(t,e);return}const i=!e?.selection.eq(t.state.selection),o=!e?.doc.eq(t.state.doc);this.updateHandler(t,i,o,e)}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:i}=r,o=Math.min(...i.map(d=>d.$from.pos)),l=Math.max(...i.map(d=>d.$to.pos));return((e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:o,to:l}))||!1}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},LE=t=>new Ue({key:typeof t.pluginKey=="string"?new Ze(t.pluginKey):t.pluginKey,view:e=>new dY({view:e,...t})});Ke.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[LE({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var fY=class{constructor({editor:t,element:e,view:n,options:r,appendTo:i,shouldShow:o}){this.preventHide=!1,this.isVisible=!1,this.shouldShow=({view:l,state:c})=>{const{selection:d}=c,{$anchor:f,empty:h}=d,m=f.depth===1,g=f.parent.isTextblock&&!f.parent.type.spec.code&&!f.parent.textContent&&f.parent.childCount===0&&!this.getTextContent(f.parent);return!(!l.hasFocus()||!h||!m||!g||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(l,c,d,f)=>{const{composing:h}=l;if(h||!c&&!d)return;if(!this.getShouldShow(f)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:l})=>{var c;if(this.preventHide){this.preventHide=!1;return}l?.relatedTarget&&((c=this.element.parentNode)!=null&&c.contains(l.relatedTarget))||l?.relatedTarget!==this.editor.view.dom&&this.hide()},this.editor=t,this.element=e,this.view=n,this.appendTo=i,this.floatingUIOptions={...this.floatingUIOptions,...r},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(t){return Zx(t,{textSerializers:qy(this.editor.schema)})}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(Kp(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(I3(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(Zp(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(ET(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(Gp(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(TT(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(kT(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(MT(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:i}=r,o=Math.min(...i.map(d=>d.$from.pos)),l=Math.max(...i.map(d=>d.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,view:this.view,state:n,oldState:t,from:o,to:l})}updatePosition(){const{selection:t}=this.editor.state,e=Jx(this.view,t.from,t.to);ju({getBoundingClientRect:()=>e,getClientRects:()=>[e]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:r,y:i,strategy:o})=>{this.element.style.width="max-content",this.element.style.position=o,this.element.style.left=`${r}px`,this.element.style.top=`${i}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const n=!e?.selection.eq(t.state.selection),r=!e?.doc.eq(t.state.doc);this.updateHandler(t,n,r,e)}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},_E=t=>new Ue({key:typeof t.pluginKey=="string"?new Ze(t.pluginKey):t.pluginKey,view:e=>new fY({view:e,...t})});Ke.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[_E({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});var hY=Ve.forwardRef(({pluginKey:t="bubbleMenu",editor:e,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:o=null,getReferencedVirtualElement:l,options:c,children:d,...f},h)=>{const m=E.useRef(document.createElement("div"));typeof h=="function"?h(m.current):h&&(h.current=m.current);const{editor:g}=e3(),y=e||g,C={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:t,shouldShow:o,getReferencedVirtualElement:l,options:c},w=E.useRef(C);return w.current=C,E.useEffect(()=>{if(y?.isDestroyed)return;if(!y){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const x=m.current;x.style.visibility="hidden",x.style.position="absolute";const k=LE({...w.current,editor:y,element:x});y.registerPlugin(k);const A=w.current.pluginKey;return()=>{y.unregisterPlugin(A),window.requestAnimationFrame(()=>{x.parentNode&&x.parentNode.removeChild(x)})}},[y]),Oa.createPortal(S.jsx("div",{...f,children:d}),m.current)});Ve.forwardRef(({pluginKey:t="floatingMenu",editor:e,appendTo:n,shouldShow:r=null,options:i,children:o,...l},c)=>{const d=E.useRef(document.createElement("div"));typeof c=="function"?c(d.current):c&&(c.current=d.current);const{editor:f}=e3();return E.useEffect(()=>{const h=d.current;if(h.style.visibility="hidden",h.style.position="absolute",e?.isDestroyed||f?.isDestroyed)return;const m=e||f;if(!m){console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");return}const g=_E({editor:m,element:h,pluginKey:t,appendTo:n,shouldShow:r,options:i});return m.registerPlugin(g),()=>{m.unregisterPlugin(t),window.requestAnimationFrame(()=>{h.parentNode&&h.parentNode.removeChild(h)})}},[e,f,n,t,r,i]),Oa.createPortal(S.jsx("div",{...l,children:o}),d.current)});const Q0={cs:{addFolioTiptapColumnBefore:"Přidat sloupec před",addFolioTiptapColumnAfter:"Přidat sloupec za",deleteFolioTiptapColumn:"Odstranit sloupec"},en:{addFolioTiptapColumnBefore:"Add column before",addFolioTiptapColumnAfter:"Add column after",deleteFolioTiptapColumn:"Remove column"}},pY={pluginKey:"folioTiptapColumnsBubbleMenu",priority:1,shouldShow:({editor:t})=>t.isActive(o1.name),items:[[{key:"addFolioTiptapColumnBefore",title:pe(Q0,"addFolioTiptapColumnBefore"),icon:t8,command:({editor:t})=>{t.chain().focus().addFolioTiptapColumnBefore().run()}},{key:"deleteFolioTiptapColumn",title:pe(Q0,"deleteFolioTiptapColumn"),icon:i1,command:({editor:t})=>{t.chain().focus().deleteFolioTiptapColumn().run()}},{key:"addFolioTiptapColumnAfter",title:pe(Q0,"addFolioTiptapColumnAfter"),icon:e8,command:({editor:t})=>{t.chain().focus().addFolioTiptapColumnAfter().run()}}]]},wr={cs:{addColumnAfter:"Přidat sloupec za",addColumnBefore:"Přidat sloupec před",addRowAfter:"Přidat řádek pod",addRowBefore:"Přidat řádek nad",deleteColumn:"Odstranit sloupec",deleteRow:"Odstranit řádek",deleteTable:"Odstranit tabulku",mergeCells:"Sloučit buňky",splitCell:"Rozdělit buňku",toggleHeaderCell:"Přepnout buňku na záhlaví",toggleHeaderColumn:"Přepnout sloupec na záhlaví",toggleHeaderRow:"Přepnout řádek na záhlaví"},en:{addColumnAfter:"Add column after",addColumnBefore:"Add column before",addRowAfter:"Add row below",addRowBefore:"Add row above",deleteColumn:"Remove column",deleteRow:"Remove row",deleteTable:"Remove table",mergeCells:"Merge cells",splitCell:"Split cell",toggleHeaderCell:"Toggle cell header",toggleHeaderColumn:"Toggle column header",toggleHeaderRow:"Toggle row header"}},mY={pluginKey:"tableBubbleMenu",priority:2,shouldShow:({editor:t})=>t.isActive("table"),disabledKeys:({editor:t})=>{const e=[];return t.can().splitCell()||e.push("splitCell"),t.can().mergeCells()||e.push("mergeCells"),e},items:[[{key:"addColumnBefore",title:pe(wr,"addColumnBefore"),icon:L8,command:({editor:t})=>{t.chain().focus().addColumnBefore().run()}},{key:"addColumnAfter",title:pe(wr,"addColumnAfter"),icon:D8,command:({editor:t})=>{t.chain().focus().addColumnAfter().run()}},{key:"deleteColumn",title:pe(wr,"deleteColumn"),icon:I8,command:({editor:t})=>{t.chain().focus().deleteColumn().run()}}],[{key:"addRowBefore",title:pe(wr,"addRowBefore"),icon:H8,command:({editor:t})=>{t.chain().focus().addRowBefore().run()}},{key:"addRowAfter",title:pe(wr,"addRowAfter"),icon:_8,command:({editor:t})=>{t.chain().focus().addRowAfter().run()}},{key:"deleteRow",title:pe(wr,"deleteRow"),icon:z8,command:({editor:t})=>{t.chain().focus().deleteRow().run()}}],[{key:"toggleHeaderColumn",title:pe(wr,"toggleHeaderColumn"),icon:P8,command:({editor:t})=>{t.chain().focus().toggleHeaderColumn().run()}},{key:"toggleHeaderRow",title:pe(wr,"toggleHeaderRow"),icon:F8,command:({editor:t})=>{t.chain().focus().toggleHeaderRow().run()}},{key:"toggleHeaderCell",title:pe(wr,"toggleHeaderCell"),icon:U8,command:({editor:t})=>{t.chain().focus().toggleHeaderCell().run()}}],[{key:"mergeCells",title:pe(wr,"mergeCells"),icon:j8,command:({editor:t})=>{t.chain().focus().mergeCells().run()}},{key:"splitCell",title:pe(wr,"splitCell"),icon:V8,command:({editor:t})=>{t.chain().focus().splitCell().run()}},{key:"deleteTable",title:pe(wr,"deleteTable"),icon:B8,command:({editor:t})=>{t.chain().focus().deleteTable().run()}}]]};function gY({editor:t,source:e,activeMenus:n}){const r={placement:e.placement||"bottom",offset:e.offset||12,flip:!0},[i,o]=Ve.useState([]),[l,c]=Ve.useState([]),d=(m,g)=>{n.set(m,g)},f=m=>{n.delete(m)},h=(m,g)=>{if(n.size===0||!n.has(m))return!1;let y=-1/0;for(const[,C]of n.entries())C>y&&(y=C);return g>=y};return S.jsx(hY,{pluginKey:e.pluginKey,shouldShow:({editor:m,state:g})=>{const y=e.shouldShow({editor:m,state:g});let C=!1;if(y?(d(e.pluginKey,e.priority),C=h(e.pluginKey,e.priority)):f(e.pluginKey),C){if(e.activeKeys){const w=e.activeKeys({editor:m,state:g});o(w)}if(e.disabledKeys){const w=e.disabledKeys({editor:m,state:g});c(w)}}return C},options:r,className:"f-tiptap-editor-bubble-menu","data-bubble-menu-type":e.pluginKey,children:e.items.map((m,g)=>S.jsx("div",{className:"f-tiptap-editor-bubble-menu__row",children:m.map(y=>{const C=y.icon,w=i.indexOf(y.key)!==-1,x=l.indexOf(y.key)!==-1;return S.jsx(xt,{type:"button","data-style":"ghost","data-size":"large-icon",role:"button",tabIndex:-1,"aria-label":y.title,disabled:x,"data-active-state":w?"on":"off","aria-pressed":w,tooltip:y.title,onClick:x?void 0:()=>{y.command({editor:t})},children:S.jsx(C,{className:"tiptap-button-icon"})},y.title)})},g))})}const yY=[pY,mY,WF,Tj,IF];function vY({editor:t,blockEditor:e}){if(!t||!e)return null;const n=new Map;return S.jsx(S.Fragment,{children:yY.map(r=>S.jsx(gY,{editor:t,source:r,activeMenus:n},r.pluginKey))})}const HE=E.forwardRef(({orientation:t="horizontal",size:e,className:n="",style:r={},...i},o)=>{const l={...r,...t==="horizontal"&&!e&&{flex:1},...e&&{width:t==="vertical"?"1px":e,height:t==="horizontal"?"1px":e}};return S.jsx("div",{ref:o,...i,className:n,style:l})});HE.displayName="Spacer";const gv=t=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})},yv=(t,e)=>{E.useEffect(()=>{const n=t.current;if(!n)return;let r=!0;r&&requestAnimationFrame(e);const i=new MutationObserver(()=>{r&&requestAnimationFrame(e)});return i.observe(n,{childList:!0,subtree:!0,attributes:!0}),()=>{r=!1,i.disconnect()}},[t,e])},bY=t=>{E.useEffect(()=>{const e=t.current;if(!e)return;const n=()=>Array.from(e.querySelectorAll('button:not([disabled]), [role="button"]:not([disabled]), [tabindex="0"]:not([disabled])')),r=(d,f,h)=>{d.preventDefault();let m=f;m>=h.length?m=0:m<0&&(m=h.length-1),h[m]?.focus()},i=d=>{const f=n();if(!f.length)return;const h=document.activeElement,m=f.indexOf(h);if(!e.contains(h))return;const y={ArrowRight:()=>r(d,m+1,f),ArrowDown:()=>r(d,m+1,f),ArrowLeft:()=>r(d,m-1,f),ArrowUp:()=>r(d,m-1,f),Home:()=>r(d,0,f),End:()=>r(d,f.length-1,f)}[d.key];y&&y()},o=d=>{const f=d.target;e.contains(f)&&f.setAttribute("data-focus-visible","true")},l=d=>{const f=d.target;e.contains(f)&&f.removeAttribute("data-focus-visible")};return e.addEventListener("keydown",i),e.addEventListener("focus",o,!0),e.addEventListener("blur",l,!0),n().forEach(d=>{d.addEventListener("focus",o),d.addEventListener("blur",l)}),()=>{e.removeEventListener("keydown",i),e.removeEventListener("focus",o,!0),e.removeEventListener("blur",l,!0),n().forEach(f=>{f.removeEventListener("focus",o),f.removeEventListener("blur",l)})}},[t])},CY=t=>{const[e,n]=E.useState(!0),r=E.useRef(!1);E.useEffect(()=>(r.current=!0,()=>{r.current=!1}),[]);const i=E.useCallback(()=>{if(!r.current)return;const o=t.current;if(!o)return;const l=Array.from(o.children).some(c=>c instanceof HTMLElement&&c.getAttribute("role")==="group"?c.children.length>0:!1);n(l)},[t]);return yv(t,i),e},wY=t=>{const[e,n]=E.useState(!0),r=E.useRef(!1);E.useEffect(()=>(r.current=!0,()=>{r.current=!1}),[]);const i=E.useCallback(()=>{if(!r.current)return;const o=t.current;if(!o)return;const l=Array.from(o.children).some(c=>c instanceof HTMLElement);n(l)},[t]);return yv(t,i),e},xY=t=>{const[e,n]=E.useState(!0),r=E.useRef(!1);E.useEffect(()=>(r.current=!0,()=>{r.current=!1}),[]);const i=E.useCallback(()=>{if(!r.current)return;const o=t.current;if(!o)return;const l=o.previousElementSibling,c=o.nextElementSibling;if(!l||!c){n(!1);return}const d=l.getAttribute("role")==="group"&&c.getAttribute("role")==="group",f=l.children.length>0&&c.children.length>0;n(d&&f)},[t]);return yv(t,i),e},IE=E.forwardRef(({children:t,className:e,variant:n="fixed",...r},i)=>{const o=E.useRef(null),l=CY(o);return bY(o),l?S.jsx("div",{ref:gv([o,i]),role:"toolbar","aria-label":"toolbar","data-variant":n,className:`f-tiptap-editor-toolbar ${e||""}`,...r,children:t}):null});IE.displayName="Toolbar";const $n=E.forwardRef(({children:t,className:e,...n},r)=>{const i=E.useRef(null);return wY(i)?S.jsx("div",{ref:gv([i,r]),role:"group",className:`f-tiptap-editor-toolbar__group ${e||""}`,...n,children:t}):null});$n.displayName="ToolbarGroup";const Ir=E.forwardRef(({...t},e)=>{const n=E.useRef(null);return xY(n)?S.jsx(Yu,{ref:gv([n,e]),orientation:"vertical",decorative:!0,...t}):null});Ir.displayName="ToolbarSeparator";const SY={cs:{insert:"Vložit obsah"},en:{insert:"Insert content"}};function TY(t,e){if(!t)return console.log("No editor available for insertFolioTiptapNode"),!1;try{return t.commands.insertFolioTiptapNode(e)}catch(n){return console.error("insertFolioTiptapNode error",n),!1}}const zE=E.forwardRef(({editor:t,disabled:e},n)=>{const r=E.useCallback(o=>{!o.defaultPrevented&&!e&&t&&t.chain().focus().triggerFolioTiptapCommand(null).run()},[e,t]);if(E.useEffect(()=>{const o=l=>{l.origin===window.origin&&(!l.data||l.data.type!=="f-c-tiptap-overlay:saved"||l.data.uniqueId||TY(t,l.data.node))};return window.addEventListener("message",o),()=>{window.removeEventListener("message",o)}},[t]),!t||!t.isEditable)return null;const i=pe(SY,"insert");return S.jsx(xt,{ref:n,type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":i,tooltip:i,onClick:r,children:S.jsx(r1,{className:"tiptap-button-icon"})})});zE.displayName="FolioTiptapNodeButton";const kY=(t,e)=>e?.schema?e.schema.spec.marks.get(t)!==void 0:!1,EY=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function MY(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return!t||t.replace(EY,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}function AY(t,e,n){try{const r=new URL(t,e);if(MY(r.href,n))return r.href}catch{}return"#"}const BE=E.createContext(null);function jE(){const t=E.useContext(BE);if(!t)throw new Error("Popover components must be wrapped in ");return t}function NY({initialOpen:t=!1,initialFocus:e=0,modal:n,open:r,onOpenChange:i,side:o="bottom",align:l="center",sideOffset:c=4,alignOffset:d=0}={}){const[f,h]=E.useState(t),[m,g]=E.useState(),[y,C]=E.useState(),[w,x]=E.useState(`${o}-${l}`),[k,A]=E.useState({sideOffset:c,alignOffset:d}),N=r??f,R=i??h,L=E.useMemo(()=>[Yp({mainAxis:k.sideOffset,crossAxis:k.alignOffset}),B3({fallbackAxisSideDirection:"end",crossAxis:!1}),z3({limiter:oU({offset:k.sideOffset})})],[k.sideOffset,k.alignOffset]),z=e1({placement:w,open:N,onOpenChange:R,whileElementsMounted:qp,middleware:L}),_=t1([IT(z.context),U3(z.context),P3(z.context)]),$=E.useCallback((J,U,ne,se)=>{x(`${J}-${U}`),(ne!==void 0||se!==void 0)&&A({sideOffset:ne??k.sideOffset,alignOffset:se??k.alignOffset})},[k.sideOffset,k.alignOffset]);return E.useMemo(()=>({open:N,setOpen:R,..._,...z,initialFocus:e,modal:n,labelId:m,descriptionId:y,setLabelId:g,setDescriptionId:C,updatePosition:$}),[N,R,_,z,e,n,m,y,$])}function RY({children:t,modal:e=!1,...n}){const r=NY({modal:e,...n});return S.jsx(BE.Provider,{value:r,children:t})}const VE=E.forwardRef(function({children:e,asChild:n=!1,...r},i){const o=jE(),l=E.isValidElement(e)?parseInt(E.version,10)>=19?e.props.ref:e.ref:void 0,c=ol([o.refs.setReference,i,l]);return n&&E.isValidElement(e)?E.cloneElement(e,o.getReferenceProps({ref:c,...r,...e.props,"data-state":o.open?"open":"closed"})):S.jsx("button",{ref:c,"data-state":o.open?"open":"closed",...o.getReferenceProps(r),children:e})}),UE=E.forwardRef(function({className:e,side:n="bottom",align:r="center",sideOffset:i,alignOffset:o,style:l,portal:c=!0,portalProps:d={},asChild:f=!1,children:h,...m},g){const y=jE(),C=E.isValidElement(h)?parseInt(E.version,10)>=19?h.props.ref:h.ref:void 0,w=ol([y.refs.setFloating,g,C]);if(E.useEffect(()=>{y.updatePosition(n,r,i,o)},[y,n,r,i,o]),!y.context.open)return null;const x={ref:w,style:{position:y.strategy,top:y.y??0,left:y.x??0,...l},"aria-labelledby":y.labelId,"aria-describedby":y.descriptionId,className:`tiptap-popover ${e||""}`,"data-side":n,"data-align":r,"data-state":y.context.open?"open":"closed",...y.getFloatingProps(m)},k=f&&E.isValidElement(h)?E.cloneElement(h,{...x,...h.props}):S.jsx("div",{...x,children:h}),A=S.jsx(HT,{context:y.context,modal:y.modal,initialFocus:y.initialFocus,children:k});return c?S.jsx(Qp,{...d,children:A}):A});VE.displayName="PopoverTrigger";UE.displayName="PopoverContent";const Lo={cs:{apply:"Uložit",openTheLink:"Otevřít odkaz",openSettings:"Upravit odkaz",removeLink:"Odstranit odkaz",placeholder:"Vložit URL odkazu …",settings:"Nastavit odkaz",openInNew:"Otevřít v novém okně",link:"Odkaz"},en:{apply:"Apply",openTheLink:"Open the link",openSettings:"Edit link",removeLink:"Remove link",placeholder:"Paste link URL …",settings:"Link settings",openInNew:"Open in new window",link:"Link"}},Vf={href:null,rel:null,target:null},OY=t=>{const{editor:e,onSetLink:n,onLinkActive:r,editorState:i}=t,[o,l]=E.useState({...Vf});E.useEffect(()=>{if(!i.active)return;const f=e.getAttributes("link");e.isActive("link")&&o.href===null&&(l({href:f.href||null,rel:f.rel||null,target:f.target||null}),r?.())},[i.active,r,o,e]),E.useEffect(()=>{if(!i.active)return;const f=()=>{const h=e.getAttributes("link");l({href:h.href||null,rel:h.rel||null,target:h.target||null}),e.isActive("link")&&h.href!==null&&r?.()};return e.on("selectionUpdate",f),()=>{e.off("selectionUpdate",f)}},[i.active,r,o,e]);const c=E.useCallback((f=Vf)=>{!o.href&&!f.href||(e.chain().focus().extendMarkRange("link").setLink({href:f.href||o.href||"",rel:typeof f.rel>"u"?o.rel:f.rel,target:typeof f.target>"u"?o.target:f.target}).run(),l({...Vf}),n?.())},[e,n,o.href,o.rel,o.target]),d=E.useCallback(()=>{e&&(e.chain().focus().extendMarkRange("link").unsetLink().setMeta("preventAutolink",!0).run(),l({...Vf}),n?.())},[e,n]);return{linkData:o,setLinkData:l,setLink:c,removeLink:d}},PE=E.forwardRef(({className:t,children:e,...n},r)=>{const i=pe(Lo,"link");return S.jsx(xt,{type:"button",className:t,"data-style":"ghost",role:"button",tabIndex:-1,"aria-label":i,tooltip:i,ref:r,...n,children:e||S.jsx(b8,{className:"tiptap-button-icon"})})}),DY=({linkData:t,setLinkData:e,setLink:n,removeLink:r,active:i})=>{const o=d=>{d.key==="Enter"&&(d.preventDefault(),n())},l=()=>{window.parent.postMessage({type:"f-tiptap-editor:open-link-popover",urlJson:t},"*")},c=()=>{if(!t.href)return;const d=AY(t.href,window.location.href);d!=="#"&&window.open(d,"_blank","noopener,noreferrer")};return S.jsx("div",{className:"f-tiptap-link-popover",children:S.jsxs("div",{className:"tiptap-popover__rows",children:[S.jsxs("div",{className:"tiptap-popover__row",children:[S.jsx("input",{type:"url",placeholder:pe(Lo,"placeholder"),value:t.href||"",onChange:d=>e({...t,href:d.target.value||null}),onKeyDown:o,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",className:"f-tiptap-link-popover__input"}),S.jsx("div",{className:"tiptap-button-group","data-orientation":"horizontal",children:S.jsx(xt,{type:"button",onClick:()=>n(),title:pe(Lo,"apply"),disabled:!t.href&&!i,"data-style":"ghost",children:S.jsx(u8,{className:"tiptap-button-icon"})})}),S.jsx(Yu,{}),S.jsxs("div",{className:"tiptap-button-group","data-orientation":"horizontal",children:[S.jsx(xt,{type:"button",onClick:c,title:pe(Lo,"openTheLink"),disabled:!t.href&&!i,"data-style":"ghost",children:S.jsx(f8,{className:"tiptap-button-icon"})}),S.jsx(xt,{type:"button",onClick:r,title:pe(Lo,"removeLink"),disabled:!t.href&&!i,"data-style":"ghost",children:S.jsx($8,{className:"tiptap-button-icon"})})]})]}),S.jsxs("div",{className:"tiptap-popover__row",children:[S.jsxs(xt,{type:"button",onClick:l,"data-active-state":t.rel?"on":"off",title:pe(Lo,"openSettings"),"data-style":"ghost",className:"f-tiptap-link-popover__settings-button",children:[S.jsx(dF,{className:"tiptap-button-icon"}),pe(Lo,"settings")]}),S.jsxs("label",{className:"f-tiptap-link-popover__checkbox-label",children:[S.jsx("input",{type:"checkbox",className:"f-tiptap-link-popover__checkbox",checked:t.target==="_blank",onChange:d=>{n({...t,target:d.target.checked?"_blank":null})}}),S.jsx("span",{className:"f-tiptap-link-popover__checkbox-text",children:pe(Lo,"openInNew")})]})]})]})})};function LY({editor:t,editorState:e,onClose:n}){const[r,i]=E.useState(!1),c=OY({editor:t,onSetLink:()=>{i(!1),n?.()},onLinkActive:()=>i(!0),editorState:e}),d=E.useCallback(f=>{i(f)},[]);return E.useEffect(()=>{if(!r)return;const f=h=>{if(h.origin===window.origin&&h.data?.type==="f-input-tiptap:save-url-json"&&h.data.urlJson){const m={href:h.data.urlJson.href||null,rel:h.data.urlJson.rel||null,target:h.data.urlJson.target||null};c.setLinkData(m),c.setLink(m)}};return window.addEventListener("message",f),()=>{window.removeEventListener("message",f)}},[r,c]),S.jsxs(RY,{open:r,onOpenChange:d,initialFocus:-1,children:[S.jsx(VE,{asChild:!0,children:S.jsx(PE,{disabled:!e.enabled,"data-active-state":e.active?"on":"off","data-disabled":!e.enabled})}),S.jsx(UE,{children:S.jsx(DY,{active:e.active,...c})})]})}PE.displayName="LinkButton";function FE(t){const{editor:e}=e3();return E.useMemo(()=>t||e,[t,e])}const _Y={bold:a8,italic:Bp,underline:k3,strike:w3,code:c8,superscript:S3,subscript:x3},HY={bold:"Ctrl-b",italic:"Ctrl-i",underline:"Ctrl-u",strike:"Ctrl-Shift-s",code:"Ctrl-e",superscript:"Ctrl-.",subscript:"Ctrl-,"},IY={cs:{bold:"Tučné",italic:"Kurzíva",underline:"Podtržené",strike:"Přeškrtnuté",code:"Kód",superscript:"Horní index",subscript:"Dolní index"},en:{bold:"Bold",italic:"Italic",underline:"Underline",strike:"Strike",code:"Code",superscript:"Superscript",subscript:"Subscript"}};function $E(t,e){if(!t)return!1;try{return t.can().toggleMark(e)}catch{return!1}}function zY(t,e){return t?t.isActive(e):!1}function BY(t,e){t&&t.chain().focus().toggleMark(e).run()}function jY(t,e,n=!1){return!!(!t||n||t.isActive("codeBlock")||!$E(t,e))}function VY(t){const{editor:e,type:n,hideWhenUnavailable:r,markInSchema:i}=t;return!(!i||!e||r&&(Ky(e.state.selection)||!$E(e,n)))}function UY(t){return pe(IY,t)}function PY(t,e,n=!1){const r=kY(e,t),i=jY(t,e,n),o=zY(t,e),l=_Y[e],c=HY[e],d=UY(e);return{markInSchema:r,isDisabled:i,isActive:o,Icon:l,shortcutKey:c,formattedName:d}}const qE=E.forwardRef(({editor:t,type:e,text:n,hideWhenUnavailable:r=!1,className:i="",disabled:o,onClick:l,children:c,...d},f)=>{const h=FE(t),{markInSchema:m,isDisabled:g,isActive:y,Icon:C,shortcutKey:w,formattedName:x}=PY(h,e,o),k=E.useCallback(N=>{l?.(N),!N.defaultPrevented&&!g&&h&&BY(h,e)},[l,g,h,e]);return!E.useMemo(()=>VY({editor:h,type:e,hideWhenUnavailable:r,markInSchema:m}),[h,e,r,m])||!h||!h.isEditable?null:S.jsx(xt,{type:"button",className:i.trim(),disabled:g,"data-style":"ghost","data-active-state":y?"on":"off","data-disabled":g,role:"button",tabIndex:-1,"aria-label":x,"aria-pressed":y,tooltip:x,shortcutKeys:w,onClick:k,...d,ref:f,children:c||S.jsxs(S.Fragment,{children:[S.jsx(C,{className:"tiptap-button-icon"}),n&&S.jsx("span",{className:"tiptap-button-text",children:n})]})})});qE.displayName="MarkButton";const FY={undo:q8,redo:M8},$Y={undo:"Ctrl-z",redo:"Ctrl-Shift-z"},qY={cs:{undo:"Zpět",redo:"Znovu"},en:{undo:"Undo",redo:"Redo"}};function ZY(t){return pe(qY,t)}function KY(t,e){if(!t)return!1;const n=t.chain().focus();return e==="undo"?n.undo().run():n.redo().run()}const gy=E.forwardRef(({editor:t,action:e,className:n="",enabled:r,active:i,children:o,...l},c)=>{const d=FE(t),f=E.useCallback(()=>{!d||!r||KY(d,e)},[d,e,r]),h=FY[e],m=ZY(e),g=$Y[e],y=E.useCallback(C=>{console.log("if","!e.defaultPrevented:",!C.defaultPrevented,"!enabled:",!r),!C.defaultPrevented&&r&&f()},[r,f]);return!d||!d.isEditable?null:S.jsx(xt,{ref:c,type:"button",className:n.trim(),disabled:!r,"data-style":"ghost","data-active-state":i?"on":"off","data-disabled":!r,role:"button",tabIndex:-1,"aria-label":m,"aria-pressed":i,tooltip:m,shortcutKeys:g,onClick:y,...l,children:o||S.jsx(S.Fragment,{children:S.jsx(h,{className:"tiptap-button-icon"})})})});gy.displayName="UndoRedoButton";const GY={cs:{showHtml:"Zobrazit HTML kód"},en:{showHtml:"Show HTML code"}},ZE=E.forwardRef(({editor:t},e)=>{const n=E.useCallback(i=>{if(!i.defaultPrevented){const o=t.getHTML();window.parent.postMessage({type:"f-tiptap-editor:show-html",html:o},"*")}},[t]),r=pe(GY,"showHtml");return S.jsx(xt,{ref:e,type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":r,tooltip:r,onClick:n,children:S.jsx(aP,{className:"tiptap-button-icon"})})});ZE.displayName="FolioTiptapShowHtmlButton";const YY={cs:{erase:"Smazat formátování"},en:{erase:"Erase formatting"}},KE=E.forwardRef(({editor:t,enabled:e},n)=>{const r=E.useCallback(o=>{if(!o.defaultPrevented){const l=t.view.state.selection;if(l.empty){const c=t.view.state.doc.nodeAt(l.from);if(c&&c.marks&&c.marks.length>0){const d=t.view.state.doc.resolve(l.from);let f=d.start(d.depth+1);isNaN(f)&&(f=l.from);const h={from:f-1,to:f+c.nodeSize+1};t.chain().focus().setTextSelection(h).unsetAllMarks().run()}}else t.chain().focus().unsetAllMarks().run()}},[t]),i=pe(YY,"erase");return S.jsx(xt,{ref:n,type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":i,tooltip:i,onClick:r,disabled:!e,"data-disabled":!e,children:S.jsx(h8,{className:"tiptap-button-icon"})})});KE.displayName="FolioTiptapEraseMarksButton";function GE({children:t,enabled:e,active:n,onClick:r,tooltip:i}){return S.jsx(xt,{type:"button",disabled:!e,"data-style":"ghost","data-active-state":n?"on":"off","data-disabled":!e,role:"button",tabIndex:-1,"aria-label":i,"aria-pressed":n,tooltip:i,onClick:r,children:t})}const WY=({command:t,editor:e})=>()=>{const n=e.chain();n.focus(),t.command({chain:n}),n.run()};function jc({editorState:t,commandGroup:e,editor:n}){const[r,i]=Ve.useState(!1),o=Ve.useCallback(h=>{i(h)},[]),l=Ve.useCallback(()=>{const h=t.values;return h&&e.commands.find(m=>!m.dontShowAsActiveInCollapsedToolbar&&h.includes(m.key))||null},[t.values,e.commands]);if(!n)return null;const c=l(),d=c&&!t.multiselect?c.icon:e.icon,f=e.title[document.documentElement.lang]||e.title.en;return S.jsxs(mv,{open:r,onOpenChange:o,children:[S.jsx(x1,{asChild:!0,children:S.jsxs(xt,{type:"button",disabled:!t.enabled,"data-style":"ghost","data-active-state":t.active?"on":"off","data-disabled":!t.enabled,role:"button",tabIndex:-1,"aria-label":f,"aria-pressed":t.active,tooltip:f,children:[S.jsx(d,{className:"tiptap-button-icon"}),S.jsx(g3,{className:"tiptap-button-dropdown-small"})]})}),S.jsx(S1,{children:S.jsx(k1,{children:e.commands.map(h=>h.hideInToolbarDropdown?null:S.jsx(T1,{asChild:!0,children:S.jsxs(GE,{active:t.values?t.values.includes(h.key):!1,enabled:t.enabled,onClick:WY({editor:n,command:h}),children:[S.jsx(h.icon,{className:"tiptap-button-icon"}),h.title[document.documentElement.lang]||h.title.en]})},h.key))})})]})}const J6={cs:"Vložit",en:"Insert"},YE=({editor:t,node:e})=>{const n=E.useCallback(()=>{window.parent.postMessage({type:"f-tiptap-slash-command:selected",attrs:{type:e?.type}},"*")},[e]);if(!e)return;if(!t||!t.isEditable)return null;const r={cs:{insert:e.title.cs||J6.cs},en:{insert:e.title.en||J6.en}},i=pe(r,"insert"),o=Wf(e.config?.icon);return S.jsx(xt,{type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":i,tooltip:i,onClick:n,children:S.jsx(o,{size:16})})};YE.displayName="FolioEditorToolbarSlotButton";function X6({editor:t,nodes:e}){return!t||!e||e.length===0?null:S.jsx(S.Fragment,{children:e.map(n=>S.jsx($n,{children:S.jsx(YE,{editor:t,node:n})}))})}const JY=t=>t&&t.length>0?t:window.Folio?.Tiptap?.nodeGroups||[];function XY({groupKey:t,groupConfig:e,nodes:n}){const[r,i]=Ve.useState(!1),o=Ve.useCallback(h=>{i(h)},[]),l=Ve.useCallback(h=>()=>{window.parent.postMessage({type:"f-tiptap-slash-command:selected",attrs:{type:h.type}},"*"),i(!1)},[]),c=f6(e.icon||t),d=document.documentElement.lang,f=e.title[d]||e.title.en;return S.jsxs(mv,{open:r,onOpenChange:o,children:[S.jsx(x1,{asChild:!0,children:S.jsxs(xt,{type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":f,tooltip:f,children:[S.jsx(c,{className:"tiptap-button-icon"}),S.jsx(g3,{className:"tiptap-button-dropdown-small"})]})}),S.jsx(S1,{children:S.jsx(k1,{children:n.map(h=>{const m=f6(h.config?.icon),g=h.title[d]||h.title.en;return S.jsx(T1,{asChild:!0,children:S.jsxs(GE,{active:!1,enabled:!0,onClick:l(h),children:[S.jsx(m,{className:"tiptap-button-icon"}),g]})},h.type)})})})]})}function QY({editor:t,nodes:e,nodeGroupsConfig:n}){if(!t||!t.isEditable||!e||e.length===0)return null;const r=JY(n),i={};e.forEach(c=>{const d=c.config?.group;d&&(i[d]||(i[d]=[]),i[d].push(c))});const o=Object.keys(i).sort((c,d)=>{const f=r.find(y=>y.key===c),h=r.find(y=>y.key===d),m=!!f?.toolbar_slot,g=!!h?.toolbar_slot;return m&&!g?-1:!m&&g?1:c.localeCompare(d)}),l=c=>{const d=r.find(f=>f.key===c);return d||{key:c,title:{cs:c,en:c},icon:c}};return S.jsx(S.Fragment,{children:o.map(c=>{const d=l(c);return S.jsx($n,{children:S.jsx(XY,{groupKey:c,groupConfig:d,nodes:i[c]})},c)})})}const Q6={cs:{mobile:"Mobilní layout",desktop:"Desktop layout"},en:{mobile:"Mobile layout",desktop:"Desktop layout"}},WE=({setResponsivePreviewEnabled:t})=>{const e=pe(Q6,"mobile"),n=pe(Q6,"desktop");return S.jsxs("div",{className:"f-tiptap-editor-responsive-preview-buttons",children:[S.jsx(xt,{type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":e,tooltip:e,className:"f-tiptap-editor-responsive-preview-buttons__button f-tiptap-editor-responsive-preview-buttons__button--mobile",onClick:r=>{r.target.blur(),t(!0)},children:S.jsx(O8,{className:"tiptap-button-icon"})}),S.jsx(xt,{type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":n,tooltip:n,className:"f-tiptap-editor-responsive-preview-buttons__button f-tiptap-editor-responsive-preview-buttons__button--desktop",onClick:r=>{r.target.blur(),t(!1)},children:S.jsx(S8,{className:"tiptap-button-icon"})})]})};WE.displayName="ResponsivePreviewButtons";const JE=E.forwardRef(({editor:t,command:e},n)=>{const r=E.useCallback(()=>{if(!t)return;const o=t.chain();o.focus(),e.command({chain:o}),o.run()},[e,t]),i=e.title[document.documentElement.lang]||e.title.en;return t?S.jsx(xt,{ref:n,type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":i,tooltip:i,onClick:r,children:S.jsx(e.icon,{className:"tiptap-button-icon"})}):null});JE.displayName="FolioEditorToolbarCommandButton";const Cp={cs:{saveAt:"Uloženo v",saveOn:"Uloženo",failedToAutosave:"Chyba ukládání rozpracovaného textu."},en:{saveAt:"Saved at",saveOn:"Saved on",failedToAutosave:"Failed to autosave draft text."}};function eW(t){const e=new Date;if(t.toDateString()===e.toDateString()){const r=t.toLocaleTimeString("cs-CZ",{hour:"2-digit",minute:"2-digit",second:"2-digit"});return`${pe(Cp,"saveAt")} ${r}`}else{const r=t.toLocaleDateString("cs-CZ",{day:"numeric",month:"numeric",hour:"2-digit",minute:"2-digit"});return`${pe(Cp,"saveOn")} ${r}`}}const XE=E.forwardRef(({autosaveIndicatorInfo:t},e)=>{const[n,r]=E.useState(t?.latestRevisionAt?new Date(t.latestRevisionAt):null),[i,o]=E.useState(t?.hasUnsavedChanges??!1),[l,c]=E.useState(!1),d=t?.newRecord??!0;E.useEffect(()=>{const g=y=>{y.data?.type==="f-input-tiptap:autosave:auto-saved"?(r(new Date(y.data.updatedAt)),c(!1)):y.data?.type==="f-input-tiptap:autosave:continue-unsaved-changes"?o(!1):y.data?.type==="f-input-tiptap:autosave:failed-to-autosave"&&c(!0)};return window.addEventListener("message",g),()=>window.removeEventListener("message",g)},[]);const f=n?eW(n):pe(Cp,"saveAt"),m=(()=>{if(d)return{icon:S.jsx(l6,{className:"tiptap-button-icon",color:"#FF9A52"}),style:{pointerEvents:"none"},"aria-label":void 0,tooltip:void 0};if(i)return{icon:S.jsx(CF,{className:"tiptap-button-icon",color:"#FF9A52"}),style:{pointerEvents:"none"},"aria-label":void 0,tooltip:void 0};if(l){const g=pe(Cp,"failedToAutosave");return{icon:S.jsx(l6,{className:"tiptap-button-icon",color:"#F0655D"}),style:{cursor:"help"},"data-no-hover":"true","aria-label":g,tooltip:g}}return{icon:S.jsx(lF,{className:"tiptap-button-icon",color:"#00B594"}),style:{cursor:"help"},"data-no-hover":"true","aria-label":f,tooltip:f}})();return S.jsx(xt,{ref:e,type:"button","data-style":"ghost",role:"button",tabIndex:-1,style:m.style,"data-no-hover":m["data-no-hover"],"aria-label":m["aria-label"],tooltip:m.tooltip,children:m.icon})});XE.displayName="FolioTiptapAutosaveIndicator";const Xl=t=>({editor:e})=>e.isActive("codeBlock")&&e.can().toggleMark(t),As=t=>({editor:e})=>e.isActive(t),Ns={undo:{enabled:({editor:t})=>t.can().undo(),active:()=>!1},redo:{enabled:({editor:t})=>t.can().redo(),active:()=>!1},bold:{enabled:Xl("bold"),active:As("bold")},italic:{enabled:Xl("italic"),active:As("italic")},strike:{enabled:Xl("strike"),active:As("strike")},underline:{enabled:Xl("underline"),active:As("underline")},superscript:{enabled:Xl("superscript"),active:As("superscript")},subscript:{enabled:Xl("subscript"),active:As("subscript")},link:{enabled:({editor:t})=>t.can().setLink?.({href:""}),active:As("link")},textAlign:{enabled:({editor:t})=>t.can().setTextAlign("left")||t.can().setTextAlign("center"),active:({editor:t})=>t.isActive({textAlign:"center"})||t.isActive({textAlign:"right"}),values:({editor:t})=>{if(t.isActive({textAlign:"left"}))return["align-left"];if(t.isActive({textAlign:"center"}))return["align-center"];if(t.isActive({textAlign:"right"}))return["align-right"]}},erase:{enabled:({editor:t})=>{let e=!1;const n=t.view.state.selection;if(n.empty){const r=t.view.state.doc.nodeAt(n.from);r&&r.marks&&r.marks.length>0&&(e=!0)}else t.view.state.doc.nodesBetween(n.from,n.to,r=>{if(r.marks&&r.marks.length>0)return e=!0,!1});return e},active:()=>!1},textStyles:{enabled:({editor:t})=>t.can().toggleNode("heading","paragraph"),active:({editor:t})=>t.isActive("heading")||t.isActive("folioTiptapStyledParagraph"),values:({editor:t})=>{if(t.isActive("heading")){const e=t.getAttributes("heading");if(e&&e.level)return[`heading-${e.level}`]}else if(t.isActive("folioTiptapStyledParagraph")){const e=t.getAttributes("folioTiptapStyledParagraph");if(e&&e.variant)return[`folioTiptapStyledParagraph-${e.variant}`]}else if(t.isActive("paragraph"))return["paragraph"]}},lists:{enabled:({editor:t})=>t.can().toggleBulletList()||t.can().toggleOrderedList(),active:({editor:t})=>t.isActive("bulletList")||t.isActive("orderedList"),values:({editor:t})=>{if(t.isActive("bulletList"))return["bulletList"];if(t.isActive("orderedList"))return["orderedList"]}},layouts:{onlyInBlockEditor:!0,enabled:({editor:t})=>t.can().insertFolioTiptapColumns()||t.can().insertTable(),active:()=>!1,values:({editor:t})=>{if(t.isActive("folioTiptapColumns"))return["folioTiptapColumns"];if(t.isActive("table"))return["table"]}},textDecorations:{multiselect:!0,enabled:()=>!0,active:({editor:t})=>t.isActive("italic")||t.isActive("underline")||t.isActive("strike")||t.isActive("superscript")||t.isActive("subscript"),values:({editor:t})=>{const e=[];return t.isActive("italic")&&e.push("italic"),t.isActive("underline")&&e.push("underline"),t.isActive("strike")&&e.push("strike"),t.isActive("superscript")&&e.push("superscript"),t.isActive("subscript")&&e.push("subscript"),e}}},tW=({editor:t,blockEditor:e})=>{const n={};let r=Object.keys(Ns);return e||(r=r.filter(i=>!Ns[i].onlyInBlockEditor)),t&&t.isEditable?r.forEach(i=>{n[i]={multiselect:Ns[i].multiselect,enabled:Ns[i].enabled({editor:t}),active:Ns[i].active({editor:t}),values:Ns[i].values?Ns[i].values({editor:t}):void 0}}):r.forEach(i=>{n[i]={enabled:!1,active:!1}}),n},nW=({blockEditor:t,editor:e,folioTiptapConfig:n,textStylesCommandGroup:r,layoutsCommandGroup:i,setResponsivePreviewEnabled:o,autosaveIndicatorInfo:l})=>{const[c,d]=Ve.useState(null),f=Ve.useRef(!1),h=pS({editor:e,selector:({editor:w})=>tW({editor:w,blockEditor:t})});Ve.useEffect(()=>{const w=()=>{f.current=!0,d(null)};return e.on("selectionUpdate",w),()=>{e.off("selectionUpdate",w)}},[e]);const m=Ve.useMemo(()=>f.current?c===null?h.link:{...h.link,active:c}:{...h.link,active:!1},[h.link,c]),g=Ve.useCallback(()=>{d(!1)},[]),{nodesForSlots:y,groupedNodes:C}=Ve.useMemo(()=>{const w={},x=[];return t&&n?.nodes&&n.nodes.forEach(k=>{const A=k.config?.toolbar_slot;k.config?.group&&x.push(k),A&&(w[A]||(w[A]=[]),w[A].push(k))}),{nodesForSlots:w,groupedNodes:x}},[t,n]);return S.jsxs(S.Fragment,{children:[t?S.jsxs(S.Fragment,{children:[S.jsx($n,{children:S.jsx(zE,{editor:e})}),S.jsx(Ir,{})]}):null,S.jsxs($n,{children:[S.jsx(gy,{action:"undo",active:h.undo.active,enabled:h.undo.enabled}),S.jsx(gy,{action:"redo",active:h.redo.active,enabled:h.redo.enabled})]}),S.jsx(Ir,{}),S.jsxs($n,{children:[S.jsx(jc,{editorState:h.textStyles,commandGroup:r,editor:e}),S.jsx(jc,{editorState:h.lists,commandGroup:F3,editor:e})]}),S.jsx(Ir,{}),S.jsxs($n,{children:[S.jsx(qE,{editor:e,type:"bold"}),S.jsx(jc,{editorState:h.textDecorations,commandGroup:v$,editor:e})]}),S.jsx(Ir,{}),S.jsx($n,{children:S.jsx(KE,{editor:e,enabled:h.erase.enabled})}),S.jsx(Ir,{}),S.jsxs($n,{children:[S.jsx(LY,{editor:e,editorState:m,onClose:g}),S.jsx(X6,{editor:e,nodes:y.after_link})]}),S.jsx(Ir,{}),S.jsx($n,{children:S.jsx(jc,{editorState:h.textAlign,commandGroup:y$,editor:e})}),t?S.jsxs(S.Fragment,{children:[S.jsx(Ir,{}),i&&S.jsx($n,{children:S.jsx(jc,{editorState:h.layouts,commandGroup:i,editor:e})}),S.jsx(Ir,{}),S.jsx(X6,{editor:e,nodes:y.after_layouts}),S.jsx(QY,{editor:e,nodes:C,nodeGroupsConfig:n?.node_groups}),S.jsx(JE,{editor:e,command:ZT})]}):null,S.jsx(Ir,{}),S.jsx($n,{children:S.jsx(ZE,{editor:e})}),S.jsx(HE,{}),o&&S.jsx($n,{children:S.jsx(WE,{setResponsivePreviewEnabled:o})}),n?.autosave&&t&&S.jsxs(S.Fragment,{children:[S.jsx(Ir,{}),S.jsx($n,{children:S.jsx(XE,{editor:e,autosaveIndicatorInfo:l})})]})]})};function rW({editor:t,blockEditor:e,folioTiptapConfig:n,textStylesCommandGroup:r,layoutsCommandGroup:i,setResponsivePreviewEnabled:o,autosaveIndicatorInfo:l}){return t?S.jsx(IE,{children:S.jsx(nW,{blockEditor:e,editor:t,folioTiptapConfig:n,textStylesCommandGroup:r,layoutsCommandGroup:i,setResponsivePreviewEnabled:o,autosaveIndicatorInfo:l})}):null}const iW=(t,e,n)=>{let r=null;return e===void 0&&(e=150),n===void 0&&(n=!1),function(...i){const o=this,l=()=>{r=null,n||t.apply(o,i)},c=n&&!r;r&&clearTimeout(r),r=setTimeout(l,e),c&&t.apply(o,i)}};function oW({scrollContainerRef:t}){const e=E.useRef(null);E.useEffect(()=>{const n=t.current;if(!n)return;const r=3,i=15,o=50,l=.015,c=1.3,d=3;let f=null,h=null,m=0,g=null,y=0,C=window.innerWidth,w=window.innerHeight;const x=$=>{$&&$.clientY!==void 0&&(h=$.clientY)},k=$=>{const J=1-$/o,U=r+(i-r)*(J*J),ne=1+Math.min(m*l,c-1);return U*ne},A=()=>{if(h===null){m=0,f=window.requestAnimationFrame(A);return}const $=h;let J=0,U=0;const ne=window.innerWidth,se=window.innerHeight;if(!g||y===0||C!==ne||w!==se?(g=n.getBoundingClientRect(),C=ne,w=se,y=d):y--,!g){f=window.requestAnimationFrame(A);return}const G=g.top,P=g.bottom-G,H=$-G;if(H>=o&&H<=P-o){m=0,g=null,f=window.requestAnimationFrame(A);return}if(H0||J>0&&j{e.current&&e.current(),f=window.requestAnimationFrame(A);const $=ne=>x(ne),J=ne=>x(ne),U=ne=>x(ne);document.addEventListener("mousemove",$,{passive:!0,capture:!0}),document.addEventListener("dragover",J,{passive:!0,capture:!0}),document.addEventListener("drag",U,{passive:!0,capture:!0}),n.addEventListener("dragover",J,{passive:!0,capture:!0}),n.addEventListener("drag",U,{passive:!0,capture:!0}),e.current=()=>{document.removeEventListener("mousemove",$,{capture:!0}),document.removeEventListener("dragover",J,{capture:!0}),document.removeEventListener("drag",U,{capture:!0}),n.removeEventListener("dragover",J,{capture:!0}),n.removeEventListener("drag",U,{capture:!0}),f!==null&&(window.cancelAnimationFrame(f),f=null),h=null,g=null,m=0}},R=()=>{e.current&&(e.current(),e.current=null)},L=$=>{const J=$.target;n.contains(J)&&N()},z=()=>{R()},_=()=>{R()};return document.addEventListener("dragstart",L,{capture:!0}),document.addEventListener("dragend",z,{capture:!0}),n.addEventListener("drop",_,{capture:!0}),()=>{R(),document.removeEventListener("dragstart",L,{capture:!0}),document.removeEventListener("dragend",z,{capture:!0}),n.removeEventListener("drop",_,{capture:!0})}},[t])}const e9=375;function sW({enabled:t,shouldScrollToInitial:e,setShouldScrollToInitial:n,children:r}){const[i,o]=E.useState(e9),l=E.useRef(null);oW({scrollContainerRef:l});const c=E.useCallback(f=>{f.preventDefault(),f.stopPropagation();const h=f.clientX,m=i,g=C=>{const w=Math.max(m+2*(C.clientX-h),e9),x=Math.min(window.innerWidth-36,w);o(x)},y=()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",y)};document.addEventListener("mousemove",g),document.addEventListener("mouseup",y)},[i]);E.useEffect(()=>{e!==null&&l.current&&(n(null),window.setTimeout(()=>{l.current&&(l.current.scrollTop=e)},0))},[e,n]);const d=E.useMemo(()=>iW(()=>{l.current&&window.parent.postMessage({type:"f-tiptap-editor:scrolled",scrollTop:l.current.scrollTop},"*")}),[]);return S.jsxs("div",{className:"f-tiptap-editor-responsive-preview",children:[S.jsx("div",{className:"f-tiptap-editor-responsive-preview__scroll",ref:l,onScroll:d,children:S.jsx("div",{className:"f-tiptap-editor-responsive-preview__inner",style:{width:t&&i?`${i}px`:"auto"},children:r})}),t?S.jsx("div",{className:"f-tiptap-editor-responsive-preview__handle",style:{left:`calc(50% + ${i/2-18}px)`},onMouseDown:c,children:S.jsxs("div",{className:"f-tiptap-editor-responsive-preview__handle-flex",children:[S.jsx("div",{className:"f-tiptap-editor-responsive-preview__handle-icon-wrap",children:S.jsx(l8,{})}),S.jsx("div",{className:"f-tiptap-editor-responsive-preview__handle-text",children:`${i}px`})]})}):null]})}function lW({onCreate:t,onUpdate:e,defaultContent:n,type:r,folioTiptapConfig:i,readonly:o,initialScrollTop:l,autosaveIndicatorInfo:c}){const d=E.useRef(null),f=E.useRef(!1),h=E.useRef(0),m=r==="block",[g,y]=E.useState(!1),[C,w]=E.useState(!1),[x,k]=E.useState(!1),[A,N]=E.useState(l),R=E.useMemo(()=>i&&i.styled_paragraph_variants&&i.styled_paragraph_variants.length?VF(i.styled_paragraph_variants):[],[i]),L=E.useMemo(()=>i&&i.enable_pages?BF(i.enable_pages):[],[i]),z=E.useMemo(()=>i&&i.styled_wrap_variants&&i.styled_wrap_variants.length?FF(i.styled_wrap_variants):[],[i]),_=E.useMemo(()=>i&&i.heading_levels?i.heading_levels:[2,3,4],[i]),$=E.useMemo(()=>x$({folioTiptapStyledParagraphCommands:R,folioTiptapHeadingLevels:_}),[R,_]),J=E.useMemo(()=>w$({folioTiptapStyledWrapCommands:z,folioTiptapPagesCommands:L}),[z,L]),U=EH({onUpdate:e,onCreate(oe){k(!0),t&&t(oe)},onDrop(){for(const oe of document.querySelectorAll(".prosemirror-dropcursor-block"))oe.hidden=!0},autofocus:m,immediatelyRender:!0,shouldRerenderOnTransaction:!1,editable:!o,editorProps:{attributes:{autocomplete:"off",autocorrect:"off",autocapitalize:"off","aria-label":"Main content area, start typing to enter text.",class:"f-tiptap-editor__tiptap-editor"}},extensions:[dz.configure({heading:{levels:_},gapcursor:!1,link:{openOnClick:!1,enableClickSelection:!0,HTMLAttributes:{rel:null,target:null}}}),fz.configure({alignments:["left","center","right"],types:["heading","paragraph"]}),Iz(),zz,hz,QF,az.configure({includeChildren:!0,placeholder:({editor:oe,node:G})=>{if(m){let P="commandPlaceholder";if(G.type.name==="heading"){const H=At(B=>B.type.name===Xo.name)(oe.state.selection);let j=!1;H&&(j=Vx(H.node,re=>re.type.name==="heading")[0].node===G),j?P="headingInPagesPlaceholder":_.length===1?P="singleHeadingPlaceholder":G.attrs.level&&[2,3,4].indexOf(G.attrs.level)!==-1&&(P=`h${G.attrs.level}Placeholder`)}return pe(W6,P)}else return pe(W6,"defaultPlaceholder")}}),...m?[Y8.configure({nodes:i.nodes||[],embedNodeClassName:i.embed_node_class_name}),Sj,kj,o1,tp,zF,Fu,Xo,Ta,qT,YF,QS.extend({parseHTML(){return[{tag:"div.f-tiptap-table-wrapper",contentElement:"table"},{tag:"table"}]},renderHTML({HTMLAttributes:oe}){return["div",{class:"f-tiptap-table-wrapper"},["table",oe,0]]}}).configure({allowTableNodeSelection:!0,resizable:!1}),KB.configure({table:!1}),M$.configure({suggestion:m?{...WT,items:YT([$,F3,J,...i.nodes&&i.nodes.length?(()=>{const oe=C$(i.nodes,i.node_groups);return Array.isArray(oe)?oe:[oe]})():[]])}:O$({textStylesCommandGroup:$})})]:[],jF.configure({variants:i.styled_paragraph_variants||[],variantCommands:R}),PF.configure({variantCommands:z})]});E.useEffect(()=>{if(!d.current)return;const oe=d.current,G=new ResizeObserver(P=>{for(const H of P)window.parent.postMessage({type:"f-tiptap-editor:resized",height:H.contentRect.height},"*")});return G.observe(oe),()=>{G.disconnect()}},[]),E.useEffect(()=>{if(!U||!x||!C||!d.current||f.current)return;f.current=!0;const oe=DE(M3(U.getJSON())),G=Math.max(d.current.clientHeight,150);h.current=G,window.parent.postMessage({type:"f-tiptap:created",content:oe,height:G},"*");const P=()=>{if(!d.current)return;const j=Math.max(d.current.clientHeight,150);j!==h.current&&(h.current=j,window.parent.postMessage({type:"f-tiptap-editor:resized",height:j},"*"))};[0,50,100,150].forEach(j=>{window.setTimeout(P,j)})},[U,x,C]),E.useEffect(()=>{if(!x||C)return;const oe=sY({content:n,editor:U,allowedFolioTiptapNodeTypes:i.nodes||[]});oe&&U.commands.setContent(oe,{emitUpdate:!1,errorOnInvalidContent:!1}),w(!0),window.parent.postMessage({type:"f-tiptap-editor:initialized-content",content:oe},"*")},[n,C,x,U,i]);const ne=E.useCallback(oe=>{oe.target.classList.contains("f-tiptap-editor__content-wrap")&&U&&U.view&&U.view.dom&&U.view.focus()},[U]);let se="f-tiptap-editor__content f-tiptap-styles";return i.theme&&(se+=` f-tiptap-styles--theme-${i.theme}`),o&&(se+=" f-tiptap-editor__content--readonly"),!x||!C?null:S.jsx(Qy.Provider,{value:{editor:U},children:S.jsxs("div",{ref:d,className:`f-tiptap-editor f-tiptap-editor--${m?"block":"rich-text"}${g?" f-tiptap-editor--responsive-preview":""}`,children:[o?null:S.jsx(rW,{editor:U,blockEditor:m,textStylesCommandGroup:$,layoutsCommandGroup:J,folioTiptapConfig:i,setResponsivePreviewEnabled:m?y:void 0,autosaveIndicatorInfo:c}),S.jsx(sW,{enabled:g,shouldScrollToInitial:A,setShouldScrollToInitial:N,children:S.jsxs("div",{className:"f-tiptap-editor__content-wrap",onClick:ne,children:[m&&!o?S.jsx(oY,{editor:U}):null,S.jsx(CH,{editor:U,role:"presentation",className:se}),o?null:S.jsx(vY,{editor:U,blockEditor:m})]})})]})})}function aW({onCreate:t,onUpdate:e,defaultContent:n,type:r,folioTiptapConfig:i,readonly:o,initialScrollTop:l,autosaveIndicatorInfo:c}){switch(r){case"block":case"rich-text":return S.jsx(lW,{onCreate:t,onUpdate:e,defaultContent:n,type:r,folioTiptapConfig:i,readonly:o,initialScrollTop:l,autosaveIndicatorInfo:c});default:throw new Error(`Unknown editor type: ${r}`)}}window.Folio=window.Folio||{};window.Folio.Tiptap=window.Folio.Tiptap||{};window.Folio.Tiptap.root=window.Folio.Tiptap.root||null;window.Folio.Tiptap.getHeight=()=>{const t=document.querySelector(".f-tiptap-editor");if(!t)return 0;const e=t.clientHeight;return Math.max(e,150)};window.Folio.Tiptap.init=t=>{if(window.Folio.Tiptap.root)throw new Error("Tiptap editor is already initialized");if(!t.node)throw new Error("Node is required");const e=({editor:l})=>{t.onCreate&&t.onCreate({editor:l})},n=({editor:l})=>{window.parent.postMessage({type:"f-tiptap:updated",content:DE(M3(l.getJSON())),height:window.Folio.Tiptap.getHeight()},"*"),t.onUpdate&&t.onUpdate({editor:l})};let r;t.content&&(r=W8(t.content));const i={nodes:[],styled_paragraph_variants:[],styled_wrap_variants:[],enable_pages:!1},o=SN.createRoot(t.node);return o.render(S.jsx(E.StrictMode,{children:S.jsx(aW,{onCreate:e,onUpdate:n,defaultContent:r,type:t.type,folioTiptapConfig:t.folioTiptapConfig?{...i,...t.folioTiptapConfig}:i,readonly:t.readonly,initialScrollTop:t.scrollTop||null,autosaveIndicatorInfo:t.autosaveIndicatorInfo})})),window.Folio.Tiptap.root=o,o};window.Folio.Tiptap.destroy=()=>{window.Folio.Tiptap.root&&(window.Folio.Tiptap.root.unmount(),window.Folio.Tiptap.root=null)};window.addEventListener("message",t=>{if(t.origin===window.origin&&t.data){if(t.data.type==="f-input-tiptap:start"){if(!window.Folio.Tiptap.root){const e=document.querySelector(".f-tiptap-iframe-content");if(!e)throw new Error("Node not found for Tiptap editor");if(t.data.lang&&(document.documentElement.lang=t.data.lang),t.data.stylesheetPath){const n=document.createElement("link");n.rel="stylesheet",n.href=t.data.stylesheetPath,document.body.appendChild(n)}e.classList.toggle("f-tiptap-iframe-content--console-aside",!!t.data.windowWidth&&t.data.windowWidth>=1700),window.Folio.Tiptap.init({node:e,type:e.dataset.tiptapType==="block"?"block":"rich-text",folioTiptapConfig:t.data.folioTiptapConfig,content:t.data.content,readonly:!!t.data.readonly,scrollTop:t.data.tiptapScrollTop||0,autosaveIndicatorInfo:t.data.autosaveIndicatorInfo})}}else if(t.data.type==="f-input-tiptap:window-resize"){const e=document.querySelector(".f-tiptap-iframe-content");e&&e.classList.toggle("f-tiptap-iframe-content--console-aside",!!t.data.windowWidth&&t.data.windowWidth>=1700)}}});window.parent.postMessage({type:"f-tiptap:javascript-evaluated"},"*"); //# sourceMappingURL=folio-tiptap.js.map diff --git a/tiptap/src/components/tiptap-editors/folio-editor/folio-editor-toolbar.tsx b/tiptap/src/components/tiptap-editors/folio-editor/folio-editor-toolbar.tsx index 664708a75..3169c53a1 100644 --- a/tiptap/src/components/tiptap-editors/folio-editor/folio-editor-toolbar.tsx +++ b/tiptap/src/components/tiptap-editors/folio-editor/folio-editor-toolbar.tsx @@ -303,6 +303,11 @@ const MainToolbarContent = ({ setResponsivePreviewEnabled?: (enabled: boolean) => void; autosaveIndicatorInfo?: FolioTiptapAutosaveIndicatorInfo; }) => { + const [linkActiveOverride, setLinkActiveOverride] = React.useState< + boolean | null + >(null); + const hasSelectionUpdatedRef = React.useRef(false); + const editorState: FolioEditorToolbarState = useEditorState({ editor, @@ -312,6 +317,40 @@ const MainToolbarContent = ({ }, }); + // Reset override when editor selection changes and track first selection + React.useEffect(() => { + const handleSelectionUpdate = () => { + hasSelectionUpdatedRef.current = true; + setLinkActiveOverride(null); + }; + + editor.on("selectionUpdate", handleSelectionUpdate); + return () => { + editor.off("selectionUpdate", handleSelectionUpdate); + }; + }, [editor]); + + const linkEditorState = React.useMemo(() => { + // Don't show as active until first selection update (prevents auto-open on load) + if (!hasSelectionUpdatedRef.current) { + return { + ...editorState.link, + active: false, + }; + } + + if (linkActiveOverride === null) return editorState.link; + + return { + ...editorState.link, + active: linkActiveOverride, + }; + }, [editorState.link, linkActiveOverride]); + + const closeLinkPopover = React.useCallback(() => { + setLinkActiveOverride(false); + }, []); + const { nodesForSlots, groupedNodes } = React.useMemo(() => { const slotNodes: Record = {}; const grouped: FolioTiptapNodeFromInput[] = []; @@ -405,7 +444,11 @@ const MainToolbarContent = ({ - + & { interface PopoverOptions { initialOpen?: boolean; + initialFocus?: number; modal?: boolean; open?: boolean; onOpenChange?: (open: boolean) => void; @@ -55,6 +56,7 @@ function usePopoverContext() { function usePopover({ initialOpen = false, + initialFocus = 0, modal, open: controlledOpen, onOpenChange: setControlledOpen, @@ -129,6 +131,7 @@ function usePopover({ setOpen, ...interactions, ...floating, + initialFocus, modal, labelId, descriptionId, @@ -141,6 +144,7 @@ function usePopover({ setOpen, interactions, floating, + initialFocus, modal, labelId, descriptionId, @@ -271,7 +275,11 @@ const PopoverContent = React.forwardRef( ); const wrappedContent = ( - + {content} ); diff --git a/tiptap/src/components/tiptap-ui/link-popover/link-popover.tsx b/tiptap/src/components/tiptap-ui/link-popover/link-popover.tsx index f9d6f6bda..8323e6f2e 100644 --- a/tiptap/src/components/tiptap-ui/link-popover/link-popover.tsx +++ b/tiptap/src/components/tiptap-ui/link-popover/link-popover.tsx @@ -171,7 +171,8 @@ export const useLinkHandler = (props: LinkHandlerProps) => { .run(); setLinkData({ ...DEFAULT_STATE }); - }, [editor]); + onSetLink?.(); + }, [editor, onSetLink]); return { linkData, @@ -329,13 +330,19 @@ const LinkMain: React.FC = ({ export interface LinkPopoverProps extends Omit { editor: Editor; editorState: FolioEditorToolbarButtonState; + onClose?: () => void; } -export function LinkPopover({ editor, editorState }: LinkPopoverProps) { +export function LinkPopover({ + editor, + editorState, + onClose, +}: LinkPopoverProps) { const [isOpen, setIsOpen] = React.useState(false); const onSetLink = () => { setIsOpen(false); + onClose?.(); }; const onLinkActive = () => setIsOpen(true); @@ -384,7 +391,7 @@ export function LinkPopover({ editor, editorState }: LinkPopoverProps) { }, [isOpen, linkHandler]); return ( - + Date: Wed, 11 Mar 2026 12:04:01 +0100 Subject: [PATCH 11/34] chore(version): 7.4.1 --- CHANGELOG.md | 3 +++ Gemfile.lock | 2 +- lib/folio/version.rb | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7181cbca9..f1ff586c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file. ## [Unreleased] + +## [7.4.1] - 2026-03-11 + ### Fixed - audited dropdown css layout diff --git a/Gemfile.lock b/Gemfile.lock index 5fef481a1..d961a9a9a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,7 +10,7 @@ GIT PATH remote: . specs: - folio (7.4.0) + folio (7.4.1) aasm activejob-uniqueness (>= 0.3.0) acts-as-taggable-on diff --git a/lib/folio/version.rb b/lib/folio/version.rb index 32e8d12da..1a824a3dd 100644 --- a/lib/folio/version.rb +++ b/lib/folio/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Folio - VERSION = "7.4.0" + VERSION = "7.4.1" end From 6175c23640ca9d75b712f92110c308cec957eda2 Mon Sep 17 00:00:00 2001 From: Nikolaj Kolesnik Date: Wed, 11 Mar 2026 13:41:22 +0100 Subject: [PATCH 12/34] feat(scss): optimize aside css code --- app/assets/stylesheets/folio/tiptap/_styles.scss | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/folio/tiptap/_styles.scss b/app/assets/stylesheets/folio/tiptap/_styles.scss index 389d6bf03..082cc361d 100644 --- a/app/assets/stylesheets/folio/tiptap/_styles.scss +++ b/app/assets/stylesheets/folio/tiptap/_styles.scss @@ -53,13 +53,14 @@ $f-tiptap__media-min-width--desktop: 708px !default; --f-tiptap-columns__gap: var(--f-tiptap__spacer); --f-tiptap-float__aside-margin-y: var(--f-tiptap__spacer); - --f-tiptap-float__aside-width: 0; --f-tiptap-float__aside-margin-x: 0; --f-tiptap-float__aside-offset: 0; --f-tiptap-float__aside-offset--tablet: 0; --f-tiptap-float__aside-margin-x--tablet: 1rem; --f-tiptap-float__aside-offset--desktop: 0; --f-tiptap-float__aside-margin-x--desktop: 1rem; + --f-tiptap-float__aside-side: left; + --f-tiptap-float__aside-width: 100%; --f-tiptap-li__margin-top: 0.5rem; --f-tiptap-li__margin-bottom: 0.5rem; @@ -576,12 +577,6 @@ $f-tiptap__media-min-width--desktop: 708px !default; float: var(--f-tiptap-float__aside-side); } - /* Mobile first - Aside width and spacing */ - .f-tiptap-float { - --f-tiptap-float__aside-side: left; - --f-tiptap-float__aside-width: 100%; - } - @container (min-width: #{$f-tiptap__media-min-width--tablet}) { .f-tiptap-float { // Default aside width (medium) From 29d1857bdb85fced3bf491214f6090f78d87fb30 Mon Sep 17 00:00:00 2001 From: Vlada Date: Mon, 16 Mar 2026 13:33:19 +0100 Subject: [PATCH 13/34] fix(thumbnails): add try to dont_run_after_save_jobs to prevent private_attachments error --- CHANGELOG.md | 3 +++ .../concerns/folio/console/api/file_controller_base.rb | 3 ++- app/jobs/folio/generate_missing_thumb_webp_job.rb | 2 +- app/jobs/folio/generate_thumbnail_job.rb | 2 +- app/jobs/folio/pregenerate_thumbnails/check_job.rb | 2 +- app/jobs/folio/regenerate_thumb_webp_job.rb | 2 +- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1ff586c0..8ddf6d899 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Fixed + +- add `try` to `dont_run_after_save_jobs` to enable thumbnail generation for `private_attachments` ## [7.4.1] - 2026-03-11 diff --git a/app/controllers/concerns/folio/console/api/file_controller_base.rb b/app/controllers/concerns/folio/console/api/file_controller_base.rb index f291d7259..33094801c 100644 --- a/app/controllers/concerns/folio/console/api/file_controller_base.rb +++ b/app/controllers/concerns/folio/console/api/file_controller_base.rb @@ -314,7 +314,8 @@ def update_thumbnails_crop } end - @file.dont_run_after_save_jobs = true + @file.try(:dont_run_after_save_jobs=, true) + @file.update!(thumbnail_configuration:, thumbnail_sizes:, diff --git a/app/jobs/folio/generate_missing_thumb_webp_job.rb b/app/jobs/folio/generate_missing_thumb_webp_job.rb index e440a9275..7006874bf 100644 --- a/app/jobs/folio/generate_missing_thumb_webp_job.rb +++ b/app/jobs/folio/generate_missing_thumb_webp_job.rb @@ -27,7 +27,7 @@ def perform(image) if changed image.thumbnail_sizes = thumbnail_sizes - image.dont_run_after_save_jobs = true + image.try(:dont_run_after_save_jobs=, true) image.save!(validate: false) end end diff --git a/app/jobs/folio/generate_thumbnail_job.rb b/app/jobs/folio/generate_thumbnail_job.rb index d5c006b51..3f22f6f38 100644 --- a/app/jobs/folio/generate_thumbnail_job.rb +++ b/app/jobs/folio/generate_thumbnail_job.rb @@ -24,7 +24,7 @@ def perform(image, size, quality, x: nil, y: nil, force: false) # need to reload here because of parallel jobs image.reload.with_lock do thumbnail_sizes = image.thumbnail_sizes || {} - image.dont_run_after_save_jobs = true + image.try(:dont_run_after_save_jobs=, true) image.thumbnail_sizes = thumbnail_sizes.merge(size => new_thumb) image.save!(validate: false) end diff --git a/app/jobs/folio/pregenerate_thumbnails/check_job.rb b/app/jobs/folio/pregenerate_thumbnails/check_job.rb index a738e1030..cd10df9c0 100644 --- a/app/jobs/folio/pregenerate_thumbnails/check_job.rb +++ b/app/jobs/folio/pregenerate_thumbnails/check_job.rb @@ -9,7 +9,7 @@ class Folio::PregenerateThumbnails::CheckJob < Folio::ApplicationJob def perform(attachmentable) if attachmentable && attachmentable.respond_to?(:file_placements) attachmentable.file_placements.find_each do |file_placement| - file_placement.dont_run_after_save_jobs = true + file_placement.try(:dont_run_after_save_jobs=, true) file_placement.try(:pregenerate_thumbnails) end end diff --git a/app/jobs/folio/regenerate_thumb_webp_job.rb b/app/jobs/folio/regenerate_thumb_webp_job.rb index 117b7e1ab..5ff41fc52 100644 --- a/app/jobs/folio/regenerate_thumb_webp_job.rb +++ b/app/jobs/folio/regenerate_thumb_webp_job.rb @@ -27,7 +27,7 @@ def perform(image) if changed image.thumbnail_sizes = thumbnail_sizes - image.dont_run_after_save_jobs = true + image.try(:dont_run_after_save_jobs=, true) image.save!(validate: false) end end From d7e80a53d1b65c80dbe5757d61d7fde194737459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Motejl?= <74706221+jirkamotejl@users.noreply.github.com> Date: Mon, 16 Mar 2026 15:49:15 +0100 Subject: [PATCH 14/34] =?UTF-8?q?fix(tiptap):=20reset=20white-space=20na?= =?UTF-8?q?=20.f-embed-box=20proti=20zd=C4=9Bd=C4=9Bn=C3=A9mu=20pre-wrap?= =?UTF-8?q?=20(#555)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit .f-tiptap-content__root nastavuje white-space: pre-wrap pro správné renderování textu. Tato hodnota se dědí do .f-embed-box, kde způsobuje, že whitespace text nodes v raw HTML embedech (YouTube, Twitter apod.) se renderují jako viditelné prázdné řádky. ProseMirror tento problém řeší v editoru přes .ProseMirror [contenteditable="false"] { white-space: normal }, ale na frontendu atribut contenteditable chybí — proto je potřeba reset přímo na embed wrapperu. --- app/components/folio/embed/box_component.sass | 1 + 1 file changed, 1 insertion(+) diff --git a/app/components/folio/embed/box_component.sass b/app/components/folio/embed/box_component.sass index d8f8a04d1..9adf45763 100644 --- a/app/components/folio/embed/box_component.sass +++ b/app/components/folio/embed/box_component.sass @@ -1,6 +1,7 @@ .f-embed-box min-height: 150px position: relative + white-space: normal &__iframe width: 100% From 82a9a3ffe5577c6225ed6993d455d6703454b166 Mon Sep 17 00:00:00 2001 From: Filip Ornstein Date: Thu, 19 Mar 2026 11:21:24 +0100 Subject: [PATCH 15/34] feat(roadmap): add comprehensive roadmap document outlining planning principles, foundational and migration tracks for Folio development --- ROADMAP.md | 276 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 276 insertions(+) create mode 100644 ROADMAP.md diff --git a/ROADMAP.md b/ROADMAP.md new file mode 100644 index 000000000..bd3410f33 --- /dev/null +++ b/ROADMAP.md @@ -0,0 +1,276 @@ +# Folio Roadmap + +This document collects proposed roadmap themes for Folio as an open-source Rails CMS engine. +It is a planning draft intended to support discussion and prioritization, not a delivery commitment. + +## Planning Principles + +- Prefer engine-level contracts over one-off rewrites. +- Keep the default path simple for small projects. +- Support multiple infrastructure models where justified. +- Treat generators, documentation, tests, and automation as part of the product surface. +- Reduce legacy surface area in stages, with clear migration paths. +- Optimize for both human contributors and AI-assisted workflows. + +## Now + +The "Now" horizon is split into foundational tracks and migration tracks. +Foundational tracks define the contracts and platform direction that later migrations should build on. +Migration tracks reduce the current legacy surface without losing delivery focus. + +### Foundational Tracks + +#### 1. Pluggable Image Transformation Pipeline + +**Problem** + +Dragonfly-based thumbnail generation creates operational and architectural pain: + +- background thumbnail jobs are fragile and add queue pressure +- storage, URL generation, and processing orchestration are tightly coupled +- cache behavior is hard to reason about +- different projects need different infrastructure models + +**Target Outcome** + +Introduce a provider-based image transformation layer with a stable Folio contract and multiple backend implementations. + +**Initial Scope** + +- Define a canonical Folio thumbnail interface. +- Introduce stable application-facing thumbnail URLs. +- Internally use versioned or immutable result objects derived from source checksum + variant specification. +- Add a built-in compatibility provider for Sidekiq-based processing. +- Design a remote transformer API contract for external processing services. +- Make private files, signed access, crop variants, and invalidation part of the design from day one. + +**Delivery Options** + +- Built-in Sidekiq provider for small projects. +- Remote transformer service running on Kubernetes, either per app or per cluster. +- AWS-oriented provider using Thumbor and S3-compatible storage. +- Optional future serverless provider for low-traffic or bursty workloads. + +**Success Criteria** + +- Folio no longer depends on Dragonfly thumbnail jobs as the only model. +- Projects can switch providers without changing view-level APIs. +- Thumbnail URLs remain stable at the application level. +- Processing failures and cache misses are observable and debuggable. + +#### 2. Cache Architecture Refresh + +**Problem** + +The current `cache_key_base` approach is not sufficient for larger projects and does not provide a robust invalidation model across dimensions such as site, locale, session-sensitive rendering, and public/private variants. + +**Target Outcome** + +Move from a narrow cache key convention to a clearer cache architecture with explicit dimensions, invalidation rules, and debugging support. + +**Initial Scope** + +- Formalize cache dimensions: site, locale, user/session requirements, published state, content version, and other relevant axes. +- Replace or supersede `cache_key_base` with a better engine-level contract. +- Integrate with existing HTTP cache work and component session requirements. +- Add cache diagnostics and developer tooling so cache decisions are explainable. +- Validate the approach against a larger-project proof of concept. +- Use the existing exploratory branch `petr/has-folio-tiptap-and-cache` as an initial reference point, then clean up and extract the durable architectural direction from it. + +**Success Criteria** + +- Cache invalidation is predictable on large installs. +- Cache contracts are documented and testable. +- Developers can inspect why a response or component was cached or bypassed. + +#### 3. Packwerk and Modular Folio Surface + +**Problem** + +Folio still behaves largely as one large engine surface. +That makes architectural boundaries harder to enforce, increases accidental coupling, and makes it difficult to enable only selected parts of the engine in a clean way. + +**Target Outcome** + +Introduce explicit package boundaries and a more modular Folio layout so projects can reason about dependencies and selectively adopt engine capabilities. + +**Initial Scope** + +- Use the existing cache proof of concept, currently explored in `petr/has-folio-tiptap-and-cache`, as one of the first validation areas for package boundaries. +- Introduce Packwerk in a way that provides architectural feedback without blocking all development immediately. +- Identify candidate packages such as caching, files/media, console UI, TipTap, users, newsletter features, and other separable engine areas. +- Define which parts of Folio should be independently switchable at the configuration level and which should remain core. +- Reduce implicit cross-package dependencies and document allowed dependency directions. + +**Success Criteria** + +- Architectural boundaries become visible and enforceable. +- Large projects can adopt only the Folio areas they need with less incidental coupling. +- New engine work happens inside clearer module boundaries instead of expanding a monolith. + +#### 4. OSS Contributor Platform + +**Problem** + +Folio works today, but the open-source contributor experience is still too dependent on internal knowledge and manual setup steps. + +**Target Outcome** + +Make the repository easy to install, run, test, and change for any external Rails developer. + +**Initial Scope** + +- Standardize local entrypoints such as setup, dev, test, lint, and CI commands. +- Reduce or isolate secrets required for local development. +- Define and document the supported version matrix for Ruby, Rails, Node, and external tooling. +- Treat generators as public API and harden them with real smoke tests. +- Improve release metadata, docs consistency, and contributor-facing guidance. + +**Success Criteria** + +- A new contributor can boot the project from documented commands alone. +- Generator workflows are tested, not just documented. +- Documentation reflects the actual supported stack. + +### Migration Tracks + +#### 5. UI Modernization Phase 1 + +**Problem** + +Folio still carries a large legacy UI surface across Cells, jQuery, and legacy React islands. +That slows down maintenance, increases onboarding cost, and keeps multiple frontend patterns alive at the same time. + +**Target Outcome** + +Make ViewComponent + Stimulus the default and preferred path for Folio UI. + +**Initial Scope** + +- Continue the staged migration from Cells to ViewComponents on the most-used engine surfaces. +- Replace jQuery-driven interactions with Stimulus controllers where practical. +- Identify legacy React islands that should be migrated to Stimulus rather than expanded. +- Stop growing the legacy surface area through generators and new features. +- Publish a migration tracker so the remaining legacy footprint is visible. + +**Success Criteria** + +- New engine UI work does not introduce additional Cells or jQuery. +- The highest-value admin and public components have ViewComponent-based replacements. +- Frontend interaction patterns become more uniform across the codebase. + +## Next + +### 6. Atom to TipTap Migration Program + +**Problem** + +Atoms and TipTap currently coexist, but there is no complete engine-level migration program covering authoring UX, content migration, coexistence rules, and project guidance. + +**Target Outcome** + +Provide a realistic path for teams that want to move from atom-heavy editing flows to TipTap-driven structured content. + +**Scope** + +- Define the target role of Atoms vs TipTap nodes in Folio. +- Prepare authoring UI and editor affordances needed for wider TipTap adoption. +- Write migration guidelines for teams and projects. +- Support coexistence during migration rather than forcing a big-bang rewrite. +- Add tooling for content migration where possible. + +**Success Criteria** + +- Teams understand when to use Atoms, when to use TipTap, and how to migrate. +- Folio can support mixed-mode projects during transition. +- New content modeling guidance is coherent and maintainable. + +### 7. UI Modernization Phase 2 + +**Problem** + +After the first modernization pass, some legacy frontend surface will still remain for edge cases, generators, and older admin workflows. + +**Target Outcome** + +Complete the shift to the modern engine UI stack and retire legacy defaults. + +**Scope** + +- Finish the Cells to ViewComponents migration where a compatible replacement exists. +- Remove remaining jQuery-heavy workflows from core engine paths. +- Reassess the role of the legacy React app and either shrink it further or replace it. +- Update generators so newly generated code always follows the modern stack. + +**Success Criteria** + +- Legacy UI technologies are no longer the default scaffolding path. +- The maintenance burden of multiple frontend stacks is materially reduced. + +### 8. AI Agent Readiness + +**Problem** + +Folio already includes AI-oriented instructions, but host applications generated by Folio do not yet get a strong, deterministic, agent-friendly contract. + +**Target Outcome** + +Make Folio-generated projects easier to use with coding agents such as Codex, Cursor, and Claude Code. + +**Scope** + +- Generate a richer local `AGENTS.md` for installed apps instead of only pointing back to the gem source. +- Provide deterministic setup, lint, test, and build entrypoints. +- Expose generators, config keys, and environment expectations in a machine-friendly way where useful. +- Reduce ambiguity around which stack is authoritative in each part of the repository. + +**Success Criteria** + +- Agents can bootstrap work from local project instructions without manual discovery. +- Folio-generated apps are easier to navigate and modify safely. + +## Later + +### 9. Data Model Cleanup + +**Problem** + +Some engine areas still rely on older persistence conventions and compatibility code that complicate upgrades and long-term maintenance. + +**Target Outcome** + +Reduce legacy persistence patterns and simplify the internal model layer. + +**Scope** + +- Replace remaining YAML `serialize` usage with more modern typed or JSON-based approaches where appropriate. +- Continue removing transitional compatibility branches once replacement paths are established. +- Document deprecation timelines for internal contracts that should disappear in the next major version. + +### 10. Deployment Model Portfolio + +**Problem** + +Different Folio projects have very different scale and infrastructure requirements. +A single mandatory operations model is not a good fit. + +**Target Outcome** + +Support multiple validated deployment models without forcing the same trade-offs on every installation. + +**Candidate Models** + +- Simple in-app processing for small projects. +- Shared or dedicated transformer service for Kubernetes-based stacks. +- AWS-native image pipeline for teams that prefer cloud-managed primitives. + +**Goal** + +Keep the Folio developer-facing contract stable while making infrastructure a deployment choice instead of an engine constraint. + +## Cross-Cutting Questions + +- Which parts of the current engine are true public API and need compatibility guarantees? +- Which migrations should be automated, and which should remain guided/manual? +- Where do we want strict defaults, and where do we want provider-based extensibility? +- Which large reference projects should be used to validate the roadmap decisions before declaring them as engine direction? From d6258e5389486af0f23b6f945ec490ab382af609 Mon Sep 17 00:00:00 2001 From: Filip Ornstein Date: Thu, 19 Mar 2026 11:23:25 +0100 Subject: [PATCH 16/34] fix(roadmap): update AWS-oriented provider description to include reference to sinfin/aws-file-handler --- ROADMAP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ROADMAP.md b/ROADMAP.md index bd3410f33..d94022ea5 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -48,7 +48,7 @@ Introduce a provider-based image transformation layer with a stable Folio contra - Built-in Sidekiq provider for small projects. - Remote transformer service running on Kubernetes, either per app or per cluster. -- AWS-oriented provider using Thumbor and S3-compatible storage. +- AWS-oriented provider using Thumbor and S3-compatible storage, with [`sinfin/aws-file-handler`](https://github.com/sinfin/aws-file-handler) as an existing reference point. - Optional future serverless provider for low-traffic or bursty workloads. **Success Criteria** From e82c49ede11f648ed386cacfa7047fe035bc0a65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Motejl?= <74706221+jirkamotejl@users.noreply.github.com> Date: Thu, 19 Mar 2026 14:04:48 +0100 Subject: [PATCH 17/34] feat(video): CRA presigned S3 URLs & progress tracking + no-download video workflow (#538) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(cra): presigned S3 URLs, progress tracking, multi-phase encoding - Replace SFTP video upload with presigned S3 URLs (CRA downloads directly from S3) - Add two-phase encoding support (SD first, then HD) with backward compat - Add real-time encoding progress tracking via MessageBus with phase milestones - Add encoding info ViewComponent with Stimulus controller for live progress display - Add error handling with automatic retry (1 retry on CRA failure) - Add safety nets: stuck video recovery, 4-hour timeout, reference_id cap at 128 chars - Add S3 server-side copy for video uploads (zero data transfer through pod) - Add single ffprobe call for video metadata via presigned URL - Prefer CRA cover for thumbnails to prevent 8K HEVC OOMKill - Add progressive video availability (SD playable before HD finishes) - Gracefully handle missing S3 source files in CreateMediaJob * fix(cra): review fixes — S3 dedup, race condition, state naming, tests Code review fixes for PR #538: - Extract s3_dragonfly_head_object/extract_s3_etag into Folio::S3::Client - Remove duplicate get_s3_metadata/extract_etag from Encoder and CreateMediaJob - Rewrite Folio::File#file_presigned_url to delegate to S3::Client module - Consolidate handle_job_failure to single save (eliminate double-save race) - Use "encoding_failed" state for CRA failures (distinct from "upload_failed") - Add broadcast after timeout transitions in CheckProgressJob and MonitorProcessingJob - Replace shell backticks with Open3.capture3 in video_resolution_too_high? - Fix MonitorProcessingJob to read encoding_generation from remote_services_data - Remove dead upload_progress line in upload_is_stuck? - Fix phase_failed locale to not instruct deleting indestructible videos - Add tests for processing_timed_out? and finalize_from_completed_phases! - Fix stale test assertions (mapped progress, encoding_failed state) - Add concurrency documentation comments * docs: add CRA encoding system design document Describes the complete folio + economia CRA integration: upload flow, two-phase encoding (single manifest with processingPhases attribute), progress tracking, state machine, error handling, progressive video availability, thumbnail generation, and S3 optimizations. Also documents known implementation gaps and test coverage gaps. * fix(cra): address code review issues — locks, safe defaults, query fix - Move broadcasts outside with_lock in CheckProgressJob#check_progress and remove them from handle_job_failure (emitted by caller after lock release) to avoid Redis I/O while holding a Postgres row lock - Wrap save_intermediate_phase_data calls in with_lock in both fetch_job_response and select_multi_phase_job to protect against concurrent MonitorProcessingJob/CreateMediaJob runs - Filter REMOVED jobs in reconcile_with_remote_jobs before JobResolver to avoid silently skipping active jobs in multi-phase encodings - Add COALESCE to retry_count query so videos without the key (pre- migration) are picked up by the lost-retry safety net - Return true (skip ffmpeg) on ffprobe exception instead of false to prevent OOMKilling pods on unknown-resolution videos - Fix cra_file? to check FileProcessing inclusion, covering enqueued state before remote_services_data["service"] is written - Move require "open-uri" to top of file; fix design doc references * fix(cra): move broadcasts outside lock in finalize_from_completed_phases! The previous round of fixes missed that finalize_from_completed_phases! still broadcast inside with_lock. This moves those broadcasts out of the lock block (same pattern as check_progress). Also adds comment explaining why processing_timed_out? intentionally broadcasts without a lock (unique job constraint prevents concurrency), and adds a regression test for reconcile_with_remote_jobs scheduling CheckProgressJob when all CRA jobs are REMOVED. * test: add coverage for failed-upload retry and orphan reconciliation - handle_failed_uploads_needing_retry: upload_failed and encoding_failed videos older than 5 min get CreateMediaJob; fresh failures are skipped - reconcile_video_state: API returns active job → remote_id updated, CheckProgressJob scheduled; API returns no jobs → reference_id and processing_state cleared (video queued for re-upload) * docs: correct REMOVED status explanation, mark test gaps closed Production investigation (20 oldest CRA videos, 4+ months old) confirmed CRA does NOT auto-purge completed jobs — DONE status persists indefinitely. REMOVED appears only when job content is explicitly deleted via DeleteMediaJob. - Fix misleading comment in check_progress_job.rb - Add REMOVED note + production finding to safety nets table in design doc - Mark MonitorProcessingJob and AdditionalHtmlComponent test gaps as closed * fix: defer Redis I/O outside Postgres lock, remove dead code, update docs - handle_job_failure: replace CreateMediaJob.perform_later with @pending_retry flag so the Redis RPUSH happens after with_lock releases the Postgres row lock - select_multi_phase_job next_phase_exists path: broadcast after with_lock when intermediate phase data is freshly saved (makes SD playability visible in UI) - encoder.rb: remove unused CHUNK_SIZE constant; use s3_bucket helper instead of raw ENV["S3_BUCKET_NAME"] (consistent with rest of S3::Client module) - create_media_job.rb: add comment explaining why REMOVED pre-filtering is intentionally omitted (JobResolver maps REMOVED → :not_found; CreateMediaJob correctly treats all-REMOVED as "start fresh", unlike MonitorProcessingJob) - design doc: remove duplicate XML block in §2 (already shown in §1), clarify timeout behaviour (CheckProgressJob 4h vs MonitorProcessingJob 6h backstop) - test: add REMOVED remote_id test — clears remote_id, reschedules, stays processing * fix(test): remove S3::Client include from CreateFileJobTest Minitest picks up test_aware_* module methods as test cases when the module is included, causing ArgumentError (missing keyword args). The test only needs the LOCAL_TEST_PATH constant, accessed via Folio::S3::Client::LOCAL_TEST_PATH — no include needed. * fix(cra): schedule CheckProgressJob when remote_id matches but state is stale When CreateMediaJob finds the CRA job DONE and the stored remote_id already matches, it previously did nothing ('already pointing to correct job'). If the local processing_state was stale (upload_failed, encoding_failed) — e.g. because CRA returned FAILED earlier but later completed the job — the video would be stuck forever: MonitorProcessingJob re-enqueued CreateMediaJob every 5 min, which kept finding remote_id == successful_job_id and silently returning. Fix: when remote_id matches but processing_state != full_media_processed, reset state to full_media_processing and schedule CheckProgressJob to finalize. Discovered via production video #327115 stuck for 25+ hours (manually unblocked). * chore: remove superseded CRA plan files Design doc (docs/design/cra-encoding-system.md) is the canonical reference. * docs: update cra-encoding-system.md — missing recovery paths, test coverage * test: close remaining CRA test coverage gaps Add tests for the three previously uncovered areas identified in the design doc: - Encoder: upload_file (manifest content + SFTP path), upload_with_retry (max_retries=0, transient failure, all retries exhausted), and with_robust_sftp_session (SSH auth failure, generic SFTP error wrapping) - CreateFileJob: S3 server-side copy path — verifies server-side copy is used instead of download flow when not on local file system - AASM state machine integration with CraMediaCloud::FileProcessing concern — process! enqueues CreateMediaJob, encoding_generation changes on re-encode, all AASM transitions (done/failed/retry), and destroy_attached_file enqueues DeleteMediaJob only when remote_id is present * feat: add video_poster_url provider-neutral hook to File::Video and CRA concern * refactor: remove CRA-specific knowledge from GenerateThumbnailJob Use provider-neutral video_poster_url hook instead of querying for remote_cover_url by name. Fixes log message and comments that named the CRA provider explicitly in a general folio job. * fix: set S3_BUCKET_NAME in create_media_job tests s3_dragonfly_head_object evaluates ENV.fetch("S3_BUCKET_NAME") as a positional argument before the mocked head_object can intercept it. Set the env var in with_mocked_s3_and_encoder and in the source_file_missing test so the KeyError no longer surfaces. * fix: delegate generate_dragonfly_uid to Dragonfly's own datastore method Avoids duplicating the S3DataStore UID format in folio code. Falls back to the hardcoded format for datastores that don't implement generate_uid (e.g. FileDataStore in test env). * bump to 7.5.0 CRA encoding improvements: presigned S3 URLs, two-phase encoding (SD + HD), progress tracking with ETA, console encoding info component. * chore: update Gemfile.lock for 7.5.0 --- CHANGELOG.md | 16 + Gemfile.lock | 2 +- app/assets/javascripts/folio/console/base.js | 1 + .../files/show/encoding_info_component.js | 46 ++ .../files/show/encoding_info_component.rb | 74 +++ .../files/show/encoding_info_component.sass | 26 + .../files/show/encoding_info_component.slim | 13 + .../folio/console/files/show_component.js | 56 +- .../folio/console/files/show_component.rb | 3 +- .../folio/console/files/show_component.slim | 6 +- .../cra_media_cloud/check_progress_job.rb | 454 +++++++++++++-- .../folio/cra_media_cloud/create_media_job.rb | 146 +++-- .../folio/cra_media_cloud/delete_media_job.rb | 29 +- .../cra_media_cloud/monitor_processing_job.rb | 196 +++++-- app/jobs/folio/file/get_video_metadata_job.rb | 35 ++ app/jobs/folio/generate_thumbnail_job.rb | 125 +++- app/jobs/folio/s3/create_file_job.rb | 46 ++ app/lib/folio/cra_media_cloud/encoder.rb | 201 ++----- app/lib/folio/cra_media_cloud/job_resolver.rb | 33 ++ app/lib/folio/s3/client.rb | 42 ++ .../folio/cra_media_cloud/file_processing.rb | 20 +- .../folio/media_file_processing_base.rb | 31 +- app/models/folio/file.rb | 43 +- app/models/folio/file/video.rb | 4 + .../folio/console/file_serializer.rb | 6 +- config/locales/aasm.cs.yml | 1 + config/locales/aasm.en.yml | 1 + config/locales/console/files.cs.yml | 13 + config/locales/console/files.en.yml | 13 + data/images/missing-video.png | Bin 0 -> 13993 bytes docs/design/cra-encoding-system.md | 342 +++++++++++ lib/folio/version.rb | 2 +- .../video_upload_no_download_test.rb | 23 + .../check_progress_job_test.rb | 534 +++++++++++++++++- .../cra_media_cloud/create_media_job_test.rb | 197 ++++++- .../folio/cra_media_cloud/encoder_test.rb | 195 +++++++ .../monitor_processing_job_test.rb | 264 +++++++++ .../folio/file/get_video_metadata_job_test.rb | 27 + test/jobs/folio/s3/create_file_job_test.rb | 73 +++ .../lib/folio/cra_media_cloud/encoder_test.rb | 42 ++ .../cra_media_cloud/job_resolver_test.rb | 43 ++ .../folio/media_file_processing_base_test.rb | 50 ++ .../cra_media_cloud_file_processing_test.rb | 127 +++++ test/models/folio/file_test.rb | 9 + 44 files changed, 3207 insertions(+), 403 deletions(-) create mode 100644 app/components/folio/console/files/show/encoding_info_component.js create mode 100644 app/components/folio/console/files/show/encoding_info_component.rb create mode 100644 app/components/folio/console/files/show/encoding_info_component.sass create mode 100644 app/components/folio/console/files/show/encoding_info_component.slim create mode 100644 app/jobs/folio/file/get_video_metadata_job.rb create mode 100644 app/lib/folio/cra_media_cloud/job_resolver.rb create mode 100644 data/images/missing-video.png create mode 100644 docs/design/cra-encoding-system.md create mode 100644 test/integration/video_upload_no_download_test.rb create mode 100644 test/jobs/folio/cra_media_cloud/encoder_test.rb create mode 100644 test/jobs/folio/file/get_video_metadata_job_test.rb create mode 100644 test/jobs/folio/s3/create_file_job_test.rb create mode 100644 test/lib/folio/cra_media_cloud/encoder_test.rb create mode 100644 test/lib/folio/cra_media_cloud/job_resolver_test.rb create mode 100644 test/models/folio/file/cra_media_cloud_file_processing_test.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ddf6d899..0a2e3601f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +## [7.5.0] - 2026-03-19 + +### Added + +- **CRA presigned S3 URLs**: Encoder no longer downloads video to local disk or uploads via SFTP. CRA fetches video directly from S3 via presigned URL (7-day expiry). Only the XML manifest is uploaded via SFTP. +- **Two-phase encoding**: When `encoder_processing_phases` > 1, CreateMediaJob submits two manifests with the same `refId` — SD first, then HD. Backward compatible: single-phase when `encoder_processing_phases` is nil/1. +- **Encoding progress tracking**: CheckProgressJob parses CRA `messages` array for per-phase milestones, extracts video duration, and estimates completion time. New processing states: `sd_processing → sd_processed → hd_processing → full_media_processed`. +- **Console encoding info component**: `EncodingInfoComponent` shows current encoding phase and progress percentage on video file detail page, with real-time updates via MessageBus. +- **S3 client and jobs**: `Folio::S3::Client` for presigned URL generation, `Folio::S3::CreateFileJob` for S3-based file creation, `Folio::File::GetVideoMetadataJob` for video metadata extraction. +- **Video thumbnail generation**: `GenerateThumbnailJob` reworked for reliable thumbnail generation from video files. + +### Changed + +- `ShowComponent` now exposes `aasmState` as a Stimulus value and reloads via Turbo on state transitions (encoding progress, file updates) +- `ShowComponent` layout: state badge moved to right side (`ms-auto`), encoding info rendered inline after state + ### Fixed - add `try` to `dont_run_after_save_jobs` to enable thumbnail generation for `private_attachments` diff --git a/Gemfile.lock b/Gemfile.lock index d961a9a9a..718a4ccc8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,7 +10,7 @@ GIT PATH remote: . specs: - folio (7.4.1) + folio (7.5.0) aasm activejob-uniqueness (>= 0.3.0) acts-as-taggable-on diff --git a/app/assets/javascripts/folio/console/base.js b/app/assets/javascripts/folio/console/base.js index 8e42fc92d..aedc53766 100644 --- a/app/assets/javascripts/folio/console/base.js +++ b/app/assets/javascripts/folio/console/base.js @@ -111,6 +111,7 @@ //= require folio/console/files/picker/document_component //= require folio/console/files/picker/image_component //= require folio/console/files/picker_component +//= require folio/console/files/show/encoding_info_component //= require folio/console/files/show/thumbnails/crop_edit_component //= require folio/console/files/show_component //= require folio/console/files/show_modal_component diff --git a/app/components/folio/console/files/show/encoding_info_component.js b/app/components/folio/console/files/show/encoding_info_component.js new file mode 100644 index 000000000..6e5d055b9 --- /dev/null +++ b/app/components/folio/console/files/show/encoding_info_component.js @@ -0,0 +1,46 @@ +window.Folio.Stimulus.register('f-c-files-show-encoding-info', class extends window.Stimulus.Controller { + static values = { + fileId: Number + } + + connect () { + this.messageBusCallbackKey = `f-c-files-show-encoding-info--${this.fileIdValue}` + window.Folio.MessageBus.callbacks[this.messageBusCallbackKey] = (message) => { + if (message.type === 'Folio::CraMediaCloud::CheckProgressJob/encoding_progress' && + message.data.id === this.fileIdValue) { + this.update(message.data) + } + } + } + + disconnect () { + if (this.messageBusCallbackKey && window.Folio.MessageBus.callbacks) { + delete window.Folio.MessageBus.callbacks[this.messageBusCallbackKey] + } + } + + update (data) { + const phaseEl = this.element.querySelector('.f-c-files-show-encoding-info__phase') + const progressEl = this.element.querySelector('.f-c-files-show-encoding-info__progress') + + if (data.aasm_state === 'processing_failed') { + if (phaseEl) { + phaseEl.classList.add('f-c-files-show-encoding-info__phase--failed') + phaseEl.textContent = data.failed_label || '' + } + if (progressEl) { + progressEl.textContent = '' + } + return + } + + if (phaseEl && data.current_phase_label) { + phaseEl.classList.remove('f-c-files-show-encoding-info__phase--failed') + phaseEl.textContent = data.current_phase_label + } + + if (progressEl) { + progressEl.textContent = data.progress_percentage != null ? `${data.progress_percentage}%` : '' + } + } +}) diff --git a/app/components/folio/console/files/show/encoding_info_component.rb b/app/components/folio/console/files/show/encoding_info_component.rb new file mode 100644 index 000000000..9ba94d1c7 --- /dev/null +++ b/app/components/folio/console/files/show/encoding_info_component.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true + +class Folio::Console::Files::Show::EncodingInfoComponent < Folio::Console::ApplicationComponent + def initialize(file:) + @file = file + @rsd = file.remote_services_data || {} + end + + def render? + cra_file? && (processing? || failed?) + end + + def processing? + @file.processing? + end + + def failed? + @file.processing_failed? + end + + def retrying? + failed? && @rsd["retry_scheduled_at"].present? && @rsd["retry_count"].to_i < 2 + end + + def current_phase + @rsd["current_phase"] + end + + def current_phase_label + return current_phase&.humanize if current_phase.blank? + + encoding_phase = @rsd["current_encoding_phase"] + processing_phases = @rsd["processing_phases"].to_i + + if processing_phases > 1 && encoding_phase.present? + phase_name = @file.try(:encoder_phase_name, encoding_phase) + if phase_name + t(".phase_#{current_phase}_named", + name: phase_name, + default: t(".phase_#{current_phase}", default: current_phase.humanize)) + else + t(".phase_#{current_phase}_multi", + phase: encoding_phase, + total: processing_phases, + default: t(".phase_#{current_phase}", default: current_phase.humanize)) + end + else + t(".phase_#{current_phase}", default: current_phase.humanize) + end + end + + def encoding_progress + @rsd["progress_percentage"] + end + + def data + { + "controller" => "f-c-files-show-encoding-info", + "f-c-files-show-encoding-info-file-id-value" => @file.id, + } + end + + private + def cra_file? + # Check capability first (covers enqueued state before 'service' is written) + return true if @file.is_a?(Folio::CraMediaCloud::FileProcessing) + + # Fallback for plain Folio::File::Video without concern (legacy or plain video) + @file.try(:processing_service) == "cra_media_cloud" || + @rsd["service"] == "cra_media_cloud" || + @rsd["current_phase"].present? || + @rsd["retry_count"].present? + end +end diff --git a/app/components/folio/console/files/show/encoding_info_component.sass b/app/components/folio/console/files/show/encoding_info_component.sass new file mode 100644 index 000000000..2b6a9b8d7 --- /dev/null +++ b/app/components/folio/console/files/show/encoding_info_component.sass @@ -0,0 +1,26 @@ +.f-c-files-show-encoding-info + display: inline + color: $gray-600 + font-size: $font-size-sm + white-space: nowrap + + &:empty + display: none + + &__progress + &:not(:empty)::before + content: " · " + + &__phase--failed + color: $danger + +// Pulse the yellow state dot when encoding info component follows the state cell +.f-c-files-show__meta-item:has(+ .f-c-files-show-encoding-info:not(:empty)) + .f-c-state__state-square--state-processing + animation: f-c-files-show-encoding-info-pulse 2s ease-in-out infinite + +@keyframes f-c-files-show-encoding-info-pulse + 0%, 100% + opacity: 1 + 50% + opacity: 0.35 diff --git a/app/components/folio/console/files/show/encoding_info_component.slim b/app/components/folio/console/files/show/encoding_info_component.slim new file mode 100644 index 000000000..72661dae4 --- /dev/null +++ b/app/components/folio/console/files/show/encoding_info_component.slim @@ -0,0 +1,13 @@ +span.f-c-files-show-encoding-info data=data + - if failed? + span.f-c-files-show-encoding-info__phase.f-c-files-show-encoding-info__phase--failed + - if retrying? + = t(".phase_failed_retrying") + - else + = t(".phase_failed") + - elsif processing? + span.f-c-files-show-encoding-info__phase + = current_phase_label + span.f-c-files-show-encoding-info__progress + - if encoding_progress.present? + = "#{encoding_progress}%" diff --git a/app/components/folio/console/files/show_component.js b/app/components/folio/console/files/show_component.js index 243e54426..d35675e23 100644 --- a/app/components/folio/console/files/show_component.js +++ b/app/components/folio/console/files/show_component.js @@ -6,7 +6,8 @@ window.Folio.Stimulus.register('f-c-files-show', class extends window.Stimulus.C fileType: String, id: String, showUrl: String, - indexUrl: String + indexUrl: String, + aasmState: String } disconnect () { @@ -93,6 +94,15 @@ window.Folio.Stimulus.register('f-c-files-show', class extends window.Stimulus.C messageBusCallback (event) { const message = event.detail.message + + if (message.type === 'Folio::CraMediaCloud::CheckProgressJob/encoding_progress') { + return this.handleEncodingProgress(message.data) + } + + if (message.type === 'Folio::ApplicationJob/file_update') { + return this.handleFileUpdate(message.data) + } + if (message.type !== 'Folio::S3::CreateFileJob') return switch (message.data.type) { case 'replace-success': @@ -104,10 +114,34 @@ window.Folio.Stimulus.register('f-c-files-show', class extends window.Stimulus.C } } - messageBusSuccess (data) { + handleEncodingProgress (data) { + if (data.aasm_state === 'processing') { + // Update state badge label + const stateLabel = this.element.querySelector('.f-c-state__state-label') + if (stateLabel) stateLabel.textContent = data.aasm_state_human + } else { + // Encoding finished or failed — reload to show final state + this.reloadFrame() + } + } + + handleFileUpdate (data) { + if (!data || !data.attributes) return + + const newState = data.attributes.aasm_state + if (newState && newState !== this.aasmStateValue) { + this.reloadFrame() + } + } + + reloadFrame () { window.Turbo.visit(this.showUrlValue, { frame: this.element.closest('turbo-frame').id }) } + messageBusSuccess (data) { + this.reloadFrame() + } + messageBusFailure (data) { this.loadingValue = false delete this.replacingFileData @@ -128,6 +162,24 @@ if (window.Folio && window.Folio.MessageBus && window.Folio.MessageBus.callbacks } } + if (message.type === 'Folio::CraMediaCloud::CheckProgressJob/encoding_progress') { + const selector = `.f-c-files-show[data-f-c-files-show-id-value="${message.data.id}"]` + const targets = document.querySelectorAll(selector) + + for (const target of targets) { + target.dispatchEvent(new CustomEvent('f-c-files-show/message', { detail: { message } })) + } + } + + if (message.type === 'Folio::ApplicationJob/file_update') { + const selector = `.f-c-files-show[data-f-c-files-show-id-value="${message.data.id}"]` + const targets = document.querySelectorAll(selector) + + for (const target of targets) { + target.dispatchEvent(new CustomEvent('f-c-files-show/message', { detail: { message } })) + } + } + if (message.type === 'f-c-files-show:reload') { const selector = `.f-c-files-show[data-f-c-files-show-id-value="${message.data.id}"]` const targets = document.querySelectorAll(selector) diff --git a/app/components/folio/console/files/show_component.rb b/app/components/folio/console/files/show_component.rb index 28cdd813f..cff49c407 100644 --- a/app/components/folio/console/files/show_component.rb +++ b/app/components/folio/console/files/show_component.rb @@ -14,7 +14,8 @@ def data id: @file.id, file_type: @file.class.to_s, show_url: controller.folio.url_for([:console, @file]), - index_url: controller.folio.url_for([:console, @file.class]) + index_url: controller.folio.url_for([:console, @file.class]), + aasm_state: @file.aasm_state }, action: { "f-uppy:upload-success": "uppyUploadSuccess", diff --git a/app/components/folio/console/files/show_component.slim b/app/components/folio/console/files/show_component.slim index 564f50ef7..c77b67b4b 100644 --- a/app/components/folio/console/files/show_component.slim +++ b/app/components/folio/console/files/show_component.slim @@ -53,12 +53,14 @@ = @file.file_mime_type - if @file.created_at.present? - .f-c-files-show__meta-item.me-auto + .f-c-files-show__meta-item ' #{t(".created_at")}: #{l(@file.created_at.to_date, format: :console_short)} - .f-c-files-show__meta-item + .f-c-files-show__meta-item.ms-auto == cell("folio/console/state", @file, active: false) + = render(Folio::Console::Files::Show::EncodingInfoComponent.new(file: @file)) + .f-c-files-show__table - table_rows.each do |key, config| .f-c-files-show__tr diff --git a/app/jobs/folio/cra_media_cloud/check_progress_job.rb b/app/jobs/folio/cra_media_cloud/check_progress_job.rb index efdb2de51..da83aa8e3 100644 --- a/app/jobs/folio/cra_media_cloud/check_progress_job.rb +++ b/app/jobs/folio/cra_media_cloud/check_progress_job.rb @@ -5,69 +5,276 @@ class Folio::CraMediaCloud::CheckProgressJob < Folio::ApplicationJob queue_as :default + unique :until_and_while_executing + + # Maximum time to poll CRA before giving up (4 hours). + # Long videos can take 2+ hours for HD encoding across multiple phases. + MAX_PROCESSING_DURATION = 4.hours + attr_reader :media_file def perform(media_file, preview: false, encoding_generation: nil) @media_file = media_file @encoding_generation = encoding_generation - # CraMediaCloud doesn't use preview parameter, but we accept it for consistency - # If encoding_generation is provided, check if it matches current generation - # This prevents stale jobs from interfering with newer encodings if @encoding_generation.present? && media_file.encoding_generation != @encoding_generation Rails.logger.info "[CraMediaCloud::CheckProgressJob] Skipping stale job for #{media_file.class.name}##{media_file.id} " \ "(job generation: #{@encoding_generation}, current: #{media_file.encoding_generation})" return end - # Early return if video doesn't need progress checking if media_file.ready? - Rails.logger.info "[CraMediaCloud::CheckProgressJob] Video #{media_file.id} is already in ready state, skipping progress check" + Rails.logger.info "[CraMediaCloud::CheckProgressJob] Video #{media_file.id} is already in ready state" return end - response = fetch_job_response + if processing_timed_out? + Rails.logger.error "[CraMediaCloud::CheckProgressJob] Timed out after #{MAX_PROCESSING_DURATION.inspect} " \ + "for video #{media_file.id}. Marking as processing_failed." + if media_file.may_processing_failed? + # No with_lock here: timeout is a one-time terminal state written only by + # this code path. CheckProgressJob is unique-constrained so no concurrent + # instance runs. Broadcasts immediately follow the DB write intentionally. + media_file.processing_failed! + broadcast_file_update(media_file) + broadcast_encoding_progress + end + return + end - return check_again_later if response.nil? + check_progress + end - update_remote_service_data(response) + private + def multi_phase? + media_file.remote_services_data["processing_phases"].to_i > 1 + end - if media_file.full_media_processed? - media_file.processing_done! - broadcast_file_update(media_file) - elsif media_file.upload_failed? - # Don't reschedule for failed uploads - MonitorProcessingJob will handle retries - media_file.save! - broadcast_file_update(media_file) - Rails.logger.info "[CraMediaCloud::CheckProgressJob] Video #{media_file.id} upload failed, not rescheduling" - elsif media_file.changed? - media_file.save! - broadcast_file_update(media_file) - check_again_later - else - check_again_later + def expected_phases + media_file.remote_services_data["processing_phases"].to_i + end + + def check_progress + response = fetch_job_response + return if response == :finalized # already handled by finalize_from_completed_phases! + return check_again_later if response.nil? + + # REMOVED means job content was explicitly deleted via DeleteMediaJob. + # CRA does NOT auto-purge jobs — production data confirms DONE jobs persist + # indefinitely. Clear remote_id so the next poll uses the reference_id path, + # which can finalize from stored phase data or eventually time out cleanly. + if response["status"] == "REMOVED" + Rails.logger.warn "[CraMediaCloud::CheckProgressJob] Job #{response['id']} for video #{media_file.id} " \ + "has been REMOVED. Clearing remote_id to fall back to reference_id polling." + media_file.with_lock do + media_file.remote_services_data.delete("remote_id") + media_file.save! + end + return check_again_later + end + + # All Redis I/O (check_again_later, CreateMediaJob.perform_later, broadcasts) + # is deferred until AFTER the Postgres row lock is released. + should_broadcast = false + should_reschedule = false + @pending_retry = false + + media_file.with_lock do + update_remote_service_data(response) + + if media_file.full_media_processed? + media_file.processing_done! + should_broadcast = true + elsif media_file.processing_failed? + should_broadcast = true # state set by handle_job_failure; @pending_retry set there too + elsif media_file.changed? + media_file.save! + should_broadcast = true + should_reschedule = true + else + should_reschedule = true + end + end + + check_again_later if should_reschedule + Folio::CraMediaCloud::CreateMediaJob.set(wait: 2.minutes).perform_later(media_file) if @pending_retry + + if should_broadcast + broadcast_file_update(media_file) + broadcast_encoding_progress + end end - end - private def fetch_job_response if media_file.remote_id.present? - api.get_job(media_file.remote_id) + response = api.get_job(media_file.remote_id) + Rails.logger.info "[CraMediaCloud::CheckProgressJob] Job #{media_file.remote_id} for video #{media_file.id}: " \ + "status=#{response&.dig('status')}, progress=#{response&.dig('progress')}, " \ + "profileGroup=#{response&.dig('profileGroup')}, phase=#{response&.dig('phase')}" + + # Multi-phase: if the tracked job is DONE but not the final phase, + # save intermediate data, clear remote_id, and look up by reference_id. + # Intermediate save is wrapped in with_lock to protect against concurrent + # MonitorProcessingJob or retry CreateMediaJob runs. + if multi_phase? && response&.dig("status") == "DONE" && response&.dig("phase").to_i < expected_phases + media_file.with_lock do + save_intermediate_phase_data(response) + media_file.remote_services_data.delete("remote_id") + media_file.save! + end + broadcast_encoding_progress + broadcast_file_update(media_file) + Rails.logger.info "[CraMediaCloud::CheckProgressJob] Phase #{response['phase']} done, cleared remote_id to discover next phase" + return nil + end + + response elsif media_file.remote_reference_id.present? - jobs = api.get_jobs(ref_id: media_file.remote_reference_id) + all_jobs = api.get_jobs(ref_id: media_file.remote_reference_id) + # Filter out REMOVED jobs. REMOVED appears when job content has been + # explicitly deleted via DeleteMediaJob (DELETE /jobs/{id}/content) — + # production data confirms CRA does NOT auto-purge completed jobs. + jobs = all_jobs.reject { |j| j["status"] == "REMOVED" } if jobs.empty? - Rails.logger.warn "[CraMediaCloud::CheckProgressJob] No jobs found for reference_id #{media_file.remote_reference_id}" + # All jobs REMOVED with stored phase data: job content was deleted + # (e.g. via DeleteMediaJob) after encoding completed. Finalize from + # the phase output we already saved locally rather than hitting CRA. + if multi_phase? && all_jobs.present? && has_any_completed_phase? + Rails.logger.info "[CraMediaCloud::CheckProgressJob] All CRA jobs REMOVED for video #{media_file.id} " \ + "with completed phase data. Finalizing from stored phase output." + finalize_from_completed_phases! + return :finalized + end + + Rails.logger.info "[CraMediaCloud::CheckProgressJob] No active jobs found for reference_id #{media_file.remote_reference_id} " \ + "(video #{media_file.id}, #{all_jobs.size} removed) — CRA may still be downloading the file" return nil end - # Get the most recent job by lastModified - job = jobs.max_by { |j| Time.parse(j["lastModified"]) } - Rails.logger.debug "[CraMediaCloud::CheckProgressJob] Found #{jobs.size} job(s) for #{media_file.remote_reference_id}, using most recent from #{job['lastModified']}" - job + if multi_phase? + select_multi_phase_job(jobs) + else + job = jobs.max_by { |j| Time.parse(j["lastModified"]) } + Rails.logger.info "[CraMediaCloud::CheckProgressJob] Found #{jobs.size} job(s) for #{media_file.remote_reference_id} (video #{media_file.id}): " \ + "status=#{job['status']}, progress=#{job['progress']}, id=#{job['id']}, " \ + "profileGroup=#{job['profileGroup']}, lastModified=#{job['lastModified']}" + job + end else - # No remote references exist - this should be handled by MonitorProcessingJob - Rails.logger.info "[CraMediaCloud::CheckProgressJob] No remote_id or remote_reference_id found for #{media_file.class.name} ID #{media_file.id}. MonitorProcessingJob should handle this." - nil # Return nil to stop processing this check job + Rails.logger.info "[CraMediaCloud::CheckProgressJob] No remote_id or remote_reference_id for #{media_file.class.name} ID #{media_file.id}" + nil + end + end + + def select_multi_phase_job(jobs) + # Sort by phase descending, pick the highest-phase job + job = jobs.sort_by { |j| -(j["phase"].to_i) }.first + + phase = job["phase"].to_i + Rails.logger.debug "[CraMediaCloud::CheckProgressJob] Multi-phase: found #{jobs.size} job(s), highest phase=#{phase}/#{expected_phases}, status=#{job['status']}" + + # If the highest-phase job is DONE but we haven't reached the final phase, + # check if CRA created a next phase job. CRA creates all phase jobs upfront — + # if no higher phase exists by now, CRA decided this is the final output. + if job["status"] == "DONE" && phase < expected_phases + next_phase_exists = jobs.any? { |j| j["phase"].to_i > phase } + + if next_phase_exists + # Next phase job exists but hasn't surpassed the current one yet — wait. + # Lock to guard against concurrent MonitorProcessingJob runs. + phase_data_saved = false + media_file.with_lock do + unless media_file.remote_services_data["phase_#{phase}_completed_at"].present? + save_intermediate_phase_data(job) + phase_data_saved = true + end + end + # Broadcast after lock so the UI reflects SD playback availability. + if phase_data_saved + broadcast_encoding_progress + broadcast_file_update(media_file) + end + return nil + else + # CRA did not create further phases — treat this as the final output + Rails.logger.info "[CraMediaCloud::CheckProgressJob] CRA created no phase #{phase + 1} job for video #{media_file.id}. " \ + "Treating phase #{phase} output as final." + return job + end + end + + job + end + + def has_any_completed_phase? + (1..expected_phases).any? { |p| media_file.remote_services_data["phase_#{p}_completed_at"].present? } + end + + # When all CRA jobs are REMOVED but we have stored phase output data, + # finalize the video using the last completed phase's output. + def finalize_from_completed_phases! + last_phase = (1..expected_phases).reverse_each.find { |p| + media_file.remote_services_data["phase_#{p}_completed_at"].present? + } + + media_file.with_lock do + # Build content_mp4_paths from all completed phases + content_mp4_paths = {} + (1..last_phase).each do |p| + phase_paths = media_file.remote_services_data["phase_#{p}_content_mp4_paths"] + content_mp4_paths.merge!(phase_paths) if phase_paths.present? + end + + media_file.remote_services_data.merge!( + "content_mp4_paths" => content_mp4_paths, + "processing_state" => "full_media_processed", + "progress_percentage" => 100.0, + "encoding_completed_at" => Time.current.iso8601, + ) + + media_file.processing_done! + end + + # Broadcasts after lock release to avoid Redis I/O while holding a Postgres row lock. + broadcast_file_update(media_file) + broadcast_encoding_progress + + Rails.logger.info "[CraMediaCloud::CheckProgressJob] Video #{media_file.id} finalized from #{last_phase} completed phase(s)" + end + + def save_intermediate_phase_data(phase_job) + phase_num = phase_job["phase"].to_i + mp4_paths = {} + manifest_hls = nil + manifest_dash = nil + + phase_job["output"]&.each do |output_file| + case output_file["type"] + when "MP4" + mp4_paths[output_file["profiles"].first] = output_file["path"] + when "HLS" + manifest_hls = select_output_file(manifest_hls, output_file) + when "DASH" + manifest_dash = select_output_file(manifest_dash, output_file) + when "THUMBNAILS" + update_thumbnail_path(output_file) + end end + + updates = { + "phase_#{phase_num}_content_mp4_paths" => mp4_paths, + "phase_#{phase_num}_completed_at" => Time.current.iso8601, + "phase_#{phase_num}_remote_id" => phase_job["id"], + } + updates["manifest_hls_path"] = manifest_hls["path"] if manifest_hls + updates["manifest_dash_path"] = manifest_dash["path"] if manifest_dash + + media_file.remote_services_data.merge!(updates) + media_file.save! + + Rails.logger.info "[CraMediaCloud::CheckProgressJob] Phase #{phase_num}/#{expected_phases} complete for video #{media_file.id}, " \ + "saved #{mp4_paths.size} MP4 paths" \ + "#{manifest_hls ? ', HLS manifest' : ''}" \ + "#{manifest_dash ? ', DASH manifest' : ''}." end def update_remote_service_data(response) @@ -76,35 +283,113 @@ def update_remote_service_data(response) case response["status"] when "DONE" process_output_hash(response["output"]) + parse_encoding_messages(response) media_file.remote_services_data.merge!( "output" => response["output"], "processing_state" => "full_media_processed", + "progress_percentage" => 100.0, + "encoding_completed_at" => Time.current.iso8601, ) - when "PROCESSING", "CREATED" - media_file.remote_services_data.merge!( - "processing_state" => "full_media_processing", - "progress_percentage" => (response["progress"] ? response["progress"] * 100.0 : 0).round(1), - ) + when "WAITING", "PROCESSING", "CREATED", "VALIDATING" + update_progress(response) when "FAILED", "ERROR" - error_messages = response["messages"]&.filter_map { |msg| msg["message"] if msg["type"] == "ERROR" }&.join("; ") + handle_job_failure(response) + end + end - media_file.remote_services_data.merge!( - "processing_state" => "upload_failed", - "error_message" => error_messages || "Upload failed", - "failed_at" => Time.current.iso8601, - "progress_percentage" => nil - ) + def update_progress(response) + return unless response + + media_file.remote_services_data["remote_id"] ||= response["id"] + media_file.remote_services_data["cra_status"] = response["status"] + media_file.remote_services_data["last_progress_check_at"] = Time.current.iso8601 + + raw_progress = response["progress"].to_f + media_file.remote_services_data["cra_raw_progress"] = raw_progress + + parse_encoding_messages(response) + + phase = current_phase(response) + media_file.remote_services_data["current_phase"] = phase + + if multi_phase? && response["phase"].to_i > 0 + media_file.remote_services_data["current_encoding_phase"] = response["phase"].to_i + end + + media_file.remote_services_data["progress_percentage"] = phase == "encoding" ? (raw_progress * 100).round(0) : nil + end + + # Derive current phase from CRA status and completed message phases. + def current_phase(response) + case response["status"] + when "WAITING", "CREATED", "VALIDATING" + "waiting" + when "PROCESSING" + phases = media_file.remote_services_data["phases_completed"] || [] + phases.include?("video") ? "packaging" : "encoding" + end + end + + def handle_job_failure(response) + error_messages = response["messages"]&.filter_map { |msg| msg["message"] if msg["type"] == "ERROR" }&.join("; ") + retry_count = (media_file.remote_services_data["retry_count"] || 0) + 1 + will_retry = retry_count <= 1 + + media_file.remote_services_data.merge!( + "processing_state" => "encoding_failed", + "error_message" => error_messages || "Encoding failed", + "failed_at" => Time.current.iso8601, + "progress_percentage" => nil, + "current_phase" => nil, + "retry_count" => retry_count, + ) + + if will_retry + media_file.remote_services_data["retry_scheduled_at"] = (Time.current + 2.minutes).iso8601 + else + media_file.remote_services_data.delete("retry_scheduled_at") + end - Rails.logger.error "[CraMediaCloud::CheckProgressJob] Video #{media_file.id} failed: #{error_messages}" + # Single save via processing_failed! — all data merged above. + # Broadcasts are emitted by check_progress after with_lock returns. + media_file.processing_failed! + + if will_retry + @pending_retry = true + Rails.logger.warn "[CraMediaCloud::CheckProgressJob] Video #{media_file.id} failed (attempt #{retry_count}), scheduling retry in 2 minutes: #{error_messages}" + else + Rails.logger.error "[CraMediaCloud::CheckProgressJob] Video #{media_file.id} failed permanently (attempt #{retry_count}): #{error_messages}" + end + end + + def parse_encoding_messages(response) + messages = response["messages"] + return unless messages.present? + + phases_completed = [] + messages.each do |msg| + text = msg["message"].to_s + phases_completed << "validation" if text.include?("verification: finished") + phases_completed << "audio" if text.include?("Transcoding worker - audio: finished") + phases_completed << "thumbnails" if text.include?("Transcoding worker - thumbnails: finished") + phases_completed << "video" if text.include?("Transcoding worker - video: finished") + phases_completed << "packaging" if text.include?("copying: started") end + + # Extract video duration from outputParams + video_duration = response.dig("outputParams", "duration") + + media_file.remote_services_data["phases_completed"] = phases_completed.uniq + media_file.remote_services_data["video_duration"] = video_duration if video_duration end - def process_output_hash(process_output_hash) - content_mp4_paths = {} - manifest_hls, manifest_dash = nil, nil + def process_output_hash(output_data) + content_mp4_paths = media_file.remote_services_data["content_mp4_paths"] || {} + manifest_hls = nil + manifest_dash = nil - process_output_hash.each do |output_file| + output_data.each do |output_file| case output_file["type"] when "MP4" content_mp4_paths[output_file["profiles"].first] = output_file["path"] @@ -117,11 +402,10 @@ def process_output_hash(process_output_hash) end end - media_file.remote_services_data.merge!( - "content_mp4_paths" => content_mp4_paths, - "manifest_hls_path" => manifest_hls["path"], - "manifest_dash_path" => manifest_dash["path"], - ) + updates = { "content_mp4_paths" => content_mp4_paths } + updates["manifest_hls_path"] = manifest_hls["path"] if manifest_hls + updates["manifest_dash_path"] = manifest_dash["path"] if manifest_dash + media_file.remote_services_data.merge!(updates) end def select_output_file(current, incoming) @@ -137,14 +421,70 @@ def update_thumbnail_path(output_file) end end + def broadcast_encoding_progress + return if message_bus_user_ids.blank? + + phase = media_file.remote_services_data["current_phase"] + retry_count = media_file.remote_services_data["retry_count"].to_i + + failed_label = if media_file.processing_failed? + if retry_count < 2 && media_file.remote_services_data["retry_scheduled_at"].present? + I18n.t("folio.console.files.show.encoding_info_component.phase_failed_retrying") + else + I18n.t("folio.console.files.show.encoding_info_component.phase_failed") + end + end + + phase_label = if phase.present? + encoding_phase = media_file.remote_services_data["current_encoding_phase"] + if multi_phase? && encoding_phase.present? + phase_name = media_file.encoder_phase_name(encoding_phase) + if phase_name + I18n.t("folio.console.files.show.encoding_info_component.phase_#{phase}_named", + name: phase_name, + default: I18n.t("folio.console.files.show.encoding_info_component.phase_#{phase}", default: phase.humanize)) + else + I18n.t("folio.console.files.show.encoding_info_component.phase_#{phase}_multi", + phase: encoding_phase, + total: expected_phases, + default: I18n.t("folio.console.files.show.encoding_info_component.phase_#{phase}", default: phase.humanize)) + end + else + I18n.t("folio.console.files.show.encoding_info_component.phase_#{phase}", default: phase.humanize) + end + end + + MessageBus.publish Folio::MESSAGE_BUS_CHANNEL, + { + type: "Folio::CraMediaCloud::CheckProgressJob/encoding_progress", + data: { + id: media_file.id, + aasm_state: media_file.aasm_state, + aasm_state_human: serialized_file(media_file).dig(:data, :attributes, :aasm_state_human), + progress_percentage: media_file.remote_services_data["progress_percentage"], + current_phase: phase, + current_phase_label: phase_label, + failed_label: failed_label, + cra_status: media_file.remote_services_data["cra_status"], + }, + }.to_json, + user_ids: message_bus_user_ids + end + def check_again_later - # Pass encoding_generation to ensure stale jobs don't interfere Folio::CraMediaCloud::CheckProgressJob.set(wait: 15.seconds).perform_later( media_file, encoding_generation: @encoding_generation || media_file.encoding_generation ) end + def processing_timed_out? + started_at = media_file.remote_services_data["processing_step_started_at"] + return false if started_at.blank? + + Time.parse(started_at.to_s) < MAX_PROCESSING_DURATION.ago + end + def api @api ||= Folio::CraMediaCloud::Api.new end diff --git a/app/jobs/folio/cra_media_cloud/create_media_job.rb b/app/jobs/folio/cra_media_cloud/create_media_job.rb index 66d43fb38..16d4d5d69 100644 --- a/app/jobs/folio/cra_media_cloud/create_media_job.rb +++ b/app/jobs/folio/cra_media_cloud/create_media_job.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class Folio::CraMediaCloud::CreateMediaJob < Folio::ApplicationJob + include Folio::S3::Client + # Discard if file no longer exists discard_on ActiveJob::DeserializationError @@ -9,8 +11,22 @@ class Folio::CraMediaCloud::CreateMediaJob < Folio::ApplicationJob def perform(media_file) fail "only video files are supported" unless media_file.is_a?(Folio::File::Video) - # Generate reference_id based on current file content - current_reference_id = generate_reference_id(media_file) + # If retrying after failure, transition back to processing + if media_file.processing_failed? && media_file.remote_services_data&.dig("retry_count").to_i > 0 + media_file.retry_processing! + Rails.logger.info "[CraMediaCloud::CreateMediaJob] Video #{media_file.id} retrying after failure" + end + + # Generate reference_id based on current file content. + # If the source file no longer exists on S3, mark as permanently failed + # and don't retry — the file cannot be re-uploaded without the original. + begin + current_reference_id = generate_reference_id(media_file) + rescue Excon::Error::NotFound => e + Rails.logger.error "[CraMediaCloud::CreateMediaJob] Source file not found on S3 for video #{media_file.id}: #{e.message}" + mark_source_file_missing!(media_file) + return + end # Check API for existing job with this reference_id existing_job_result = check_existing_job(current_reference_id, media_file) @@ -34,63 +50,44 @@ def perform(media_file) private def generate_reference_id(media_file) - # Combine video slug with S3 ETag (actual file content MD5) for stable, unique reference - # Format: {slug}-{s3_etag} - # This ensures uniqueness across environments and file versions + # Combine environment, video slug, S3 ETag, and encoding_generation for unique reference. + # encoding_generation changes on each re-encode, ensuring CRA gets a fresh refId. + # Format: {env}-{slug}-{s3_etag}-{generation} + # Total length is capped at 128 chars to avoid CRA lookup failures with long slugs. s3_etag = get_s3_etag(media_file) + env_prefix = ENV.fetch("DRAGONFLY_RAILS_ENV", Rails.env) + generation = media_file.encoding_generation - "#{media_file.slug}-#{s3_etag[0..7]}" - end - - def get_s3_etag(media_file) - # Get S3 ETag (MD5 hash) without downloading the file - s3_metadata = get_s3_metadata(media_file) - extract_etag(s3_metadata).delete_prefix('"').delete_suffix('"') - end + suffix = "-#{s3_etag[0..7]}-#{generation}" + max_slug_length = 128 - env_prefix.length - 1 - suffix.length + slug = media_file.slug.to_s[0, [max_slug_length, 1].max] - def get_s3_metadata(media_file) - s3_datastore = Dragonfly.app.datastore - s3_object_key = [s3_datastore.root_path, media_file.file_uid].join("/") - Rails.logger.debug("[CraMediaCloud::CreateMediaJob] Fetching S3 metadata for key: #{s3_object_key}") - s3_datastore.storage.head_object(ENV["S3_BUCKET_NAME"], s3_object_key) + "#{env_prefix}-#{slug}#{suffix}" end - def extract_etag(response) - # Handle different response types (AWS SDK, Excon, etc.) - if response.respond_to?(:etag) - response.etag - elsif response.respond_to?(:headers) - response.headers["ETag"] || response.headers["etag"] || response.headers["Etag"] - else - raise "Cannot extract ETag from response type: #{response.class}" - end + def get_s3_etag(media_file) + s3_metadata = s3_dragonfly_head_object(media_file.file_uid) + extract_s3_etag(s3_metadata).delete_prefix('"').delete_suffix('"') end def check_existing_job(reference_id, media_file) api = Folio::CraMediaCloud::Api.new jobs = api.get_jobs(ref_id: reference_id) - if jobs.empty? - { status: :not_found, job: nil } - else - # Get the most recent job with this reference_id by lastModified - job = jobs.max_by { |j| Time.parse(j["lastModified"]) } - Rails.logger.debug "[CraMediaCloud::CreateMediaJob] Found #{jobs.size} job(s) for #{reference_id}, using most recent from #{job['lastModified']}" - - case job["status"] - when "PROCESSING", "CREATED" - { status: :processing, job: job } - when "DONE" - { status: :done, job: job } - when "FAILED", "ERROR" - { status: :failed, job: job } - else - { status: :not_found, job: job } - end - end + # No need to pre-filter REMOVED jobs: JobResolver maps REMOVED → :not_found, + # so CreateMediaJob will proceed with a fresh upload. (MonitorProcessingJob + # pre-filters REMOVED before passing to reconcile_with_remote_jobs because it + # needs to distinguish "all REMOVED with stored phase data → finalize" from + # "no jobs at all → clear state". CreateMediaJob has no such distinction to make.) + result = Folio::CraMediaCloud::JobResolver.resolve(jobs) + + Rails.logger.debug "[CraMediaCloud::CreateMediaJob] Job check for #{reference_id}: " \ + "#{jobs.size} job(s), status=#{result[:status]}" + + result rescue => e Rails.logger.warn "[CraMediaCloud::CreateMediaJob] Could not check existing job for #{reference_id}: #{e.message}" - { status: :not_found, job: nil } # Assume not found if API call fails + { status: :not_found, job: nil } end def update_local_state_for_successful_job(media_file, job, reference_id) @@ -125,13 +122,33 @@ def update_local_state_for_successful_job(media_file, job, reference_id) Rails.logger.info "[CraMediaCloud::CreateMediaJob] Successfully updated local state for video #{media_file.id} to point to successful job #{successful_job_id}" else - Rails.logger.debug "[CraMediaCloud::CreateMediaJob] Local state already points to correct job #{successful_job_id} for video #{media_file.id}" + # remote_id already matches, but if local processing_state is stale (e.g. upload_failed + # or encoding_failed set before CRA recovered), schedule CheckProgressJob to finalize. + # This handles videos that got stuck with a failed state while the CRA job eventually + # completed successfully on CRA's side. + if media_file.remote_services_data["processing_state"] != "full_media_processed" + media_file.remote_services_data.merge!( + "processing_state" => "full_media_processing", + "processing_step_started_at" => Time.current.iso8601 + ) + media_file.save! + Folio::CraMediaCloud::CheckProgressJob.perform_later( + media_file, + encoding_generation: media_file.encoding_generation + ) + Rails.logger.info "[CraMediaCloud::CreateMediaJob] Remote ID #{successful_job_id} matches but state " \ + "was stale (#{media_file.remote_services_data['processing_state']}), " \ + "scheduling CheckProgressJob for video #{media_file.id}" + else + Rails.logger.debug "[CraMediaCloud::CreateMediaJob] Local state already points to correct job #{successful_job_id} for video #{media_file.id}" + end end end def process_media_upload(media_file, reference_id) # Capture encoding_generation before any state updates current_generation = media_file.encoding_generation + profile_group = media_file.try(:encoder_profile_group) # Set state to creating_media_job before starting upload rs_data = media_file.remote_services_data || {} @@ -145,24 +162,29 @@ def process_media_upload(media_file, reference_id) Rails.logger.info "[CraMediaCloud::CreateMediaJob] Starting upload for video #{media_file.id} with reference_id: #{reference_id}" begin - Folio::CraMediaCloud::Encoder.new.upload_file( + processing_phases = media_file.try(:encoder_processing_phases) + encoder = Folio::CraMediaCloud::Encoder.new + + encoder.upload_file( media_file, - profile_group: media_file.try(:encoder_profile_group), + profile_group: profile_group, + processing_phases: processing_phases, reference_id: reference_id ) - # Update to processing state after successful upload media_file.remote_services_data.merge!({ "reference_id" => reference_id, "processing_state" => "full_media_processing", - "processing_step_started_at" => Time.current.iso8601 + "processing_step_started_at" => Time.current.iso8601, + "processing_phases" => processing_phases.to_i > 1 ? processing_phases : nil, }) + # Clear any old remote_id since we're starting fresh media_file.remote_services_data.delete("remote_id") media_file.save! # Pass encoding_generation so CheckProgressJob can detect stale jobs - Folio::CraMediaCloud::CheckProgressJob.set(wait: 30.seconds).perform_later( + Folio::CraMediaCloud::CheckProgressJob.set(wait: 10.seconds).perform_later( media_file, encoding_generation: current_generation ) @@ -185,4 +207,24 @@ def process_media_upload(media_file, reference_id) raise e end end + + def mark_source_file_missing!(media_file) + rs_data = media_file.remote_services_data || {} + rs_data.merge!({ + "service" => "cra_media_cloud", + "processing_state" => "source_file_missing", + "error_message" => "Source file not found on S3 (file_uid: #{media_file.file_uid})", + "processing_step_started_at" => Time.current.iso8601, + }) + media_file.remote_services_data = rs_data + + begin + media_file.processing_failed! + rescue => e + Rails.logger.warn "[CraMediaCloud::CreateMediaJob] AASM transition failed for video #{media_file.id} (#{e.message}), forcing state" + media_file.update_columns(aasm_state: "processing_failed", remote_services_data: rs_data, updated_at: Time.current) + end + + broadcast_file_update(media_file) + end end diff --git a/app/jobs/folio/cra_media_cloud/delete_media_job.rb b/app/jobs/folio/cra_media_cloud/delete_media_job.rb index e30ea2881..70d6f369a 100644 --- a/app/jobs/folio/cra_media_cloud/delete_media_job.rb +++ b/app/jobs/folio/cra_media_cloud/delete_media_job.rb @@ -4,26 +4,39 @@ class Folio::CraMediaCloud::DeleteMediaJob < Folio::ApplicationJob queue_as :slow def perform(id, reference_id: nil) - if id.present? - api.delete_job_content(id) - elsif reference_id.present? - # Get all jobs with this reference_id + if id.blank? && reference_id.blank? + Rails.logger.warn "[CraMediaCloud::DeleteMediaJob] Skipping — no remote_id or reference_id (file was never processed by CRA)" + return + end + + if reference_id.present? + # Prefer reference_id — deletes all phase jobs (multi-phase encoding creates multiple jobs per ref) jobs = api.get_jobs(ref_id: reference_id) if jobs.any? - # Delete content for all jobs with this reference_id jobs.each do |job| Rails.logger.info "[CraMediaCloud::DeleteMediaJob] Deleting job content for job ID #{job['id']} (ref: #{reference_id})" - api.delete_job_content(job["id"]) + safe_delete_job_content(job["id"]) end Rails.logger.info "[CraMediaCloud::DeleteMediaJob] Deleted content for #{jobs.size} job(s) with reference_id #{reference_id}" end - else - raise "Missing remote_key and remote_reference_id" + elsif id.present? + safe_delete_job_content(id) end end private + def safe_delete_job_content(job_id) + api.delete_job_content(job_id) + rescue RuntimeError => e + # CRA returns 400 when content was already deleted — that's fine, goal achieved + if e.message.include?("status 400") || e.message.include?("status 404") + Rails.logger.info "[CraMediaCloud::DeleteMediaJob] Job #{job_id} content already removed (#{e.message})" + else + raise + end + end + def api @api ||= Folio::CraMediaCloud::Api.new end diff --git a/app/jobs/folio/cra_media_cloud/monitor_processing_job.rb b/app/jobs/folio/cra_media_cloud/monitor_processing_job.rb index ffa1f55a0..fdf52c7a8 100644 --- a/app/jobs/folio/cra_media_cloud/monitor_processing_job.rb +++ b/app/jobs/folio/cra_media_cloud/monitor_processing_job.rb @@ -8,6 +8,9 @@ def perform return if another_monitor_job_running? begin + # Handle videos stuck in unprocessed state with existing files + handle_stuck_unprocessed_videos + # Handle videos with orphaned or inconsistent states first handle_orphaned_videos @@ -17,6 +20,9 @@ def perform # Handle videos with failed uploads that need retry handle_failed_uploads_needing_retry + # Safety net: retry failed videos whose retry job was lost + handle_failed_videos_awaiting_retry + # Handle videos that are already processing and need progress checking handle_videos_needing_progress_check ensure @@ -26,22 +32,53 @@ def perform end private + def handle_stuck_unprocessed_videos + stuck = Folio::File::Video + .where(aasm_state: :unprocessed) + .where("file_uid IS NOT NULL AND file_uid != ''") + .where("created_at < ?", 5.minutes.ago) + + return if stuck.empty? + + Rails.logger.info("MonitorProcessingJob: Found #{stuck.count} stuck unprocessed video(s) with files") + + stuck.each do |video| + Rails.logger.info("MonitorProcessingJob: Triggering process! for stuck video ##{video.id} (created #{video.created_at})") + begin + video.process! + rescue => e + Rails.logger.error("MonitorProcessingJob: Failed to process stuck video ##{video.id}: #{e.message}") + end + end + end + def find_processing_videos Folio::File::Video .where(aasm_state: :processing) .where("remote_services_data ->> 'service' = ?", "cra_media_cloud") - .where("remote_services_data ->> 'processing_state' IN (?)", ["full_media_processing", "upload_completed"]) + .where("remote_services_data ->> 'processing_state' IN (?)", + %w[full_media_processing upload_completed]) end def find_videos_needing_upload - # Find videos that need initial upload (no remote references) + # Find videos that need initial upload (no remote references). + # Freshly enqueued videos (< 10 min) are excluded — they already have a + # CreateMediaJob queued. But enqueued videos older than 10 min are included + # because the job was likely lost (e.g., pod OOMKill). The Ruby handler + # checks for running/scheduled jobs before re-scheduling. Folio::File::Video .where(aasm_state: :processing) .where( "(remote_services_data ->> 'service' IS NULL OR remote_services_data ->> 'service' = ?) AND " \ "(remote_services_data ->> 'remote_id' IS NULL) AND " \ - "(remote_services_data ->> 'reference_id' IS NULL)", - "cra_media_cloud" + "(remote_services_data ->> 'reference_id' IS NULL) AND " \ + "(remote_services_data ->> 'processing_state' IS DISTINCT FROM ? OR " \ + " (remote_services_data ->> 'processing_state' = ? AND " \ + " (remote_services_data ->> 'processing_step_started_at')::timestamptz < ?))", + "cra_media_cloud", + "enqueued", + "enqueued", + 10.minutes.ago ) end @@ -50,8 +87,8 @@ def find_failed_uploads_needing_retry Folio::File::Video .where(aasm_state: :processing) .where("remote_services_data ->> 'service' = ?", "cra_media_cloud") - .where("remote_services_data ->> 'processing_state' = ?", "upload_failed") - .where("(remote_services_data ->> 'processing_step_started_at')::timestamp < ?", 5.minutes.ago) + .where("remote_services_data ->> 'processing_state' IN (?)", %w[upload_failed encoding_failed]) + .where("(remote_services_data ->> 'processing_step_started_at')::timestamptz < ?", 5.minutes.ago) end def handle_videos_needing_upload @@ -72,13 +109,13 @@ def handle_videos_needing_upload next end - # Check if video is stuck in creating state + # Check if video is stuck in creating/enqueued state rs_data = video.remote_services_data || {} Rails.logger.info("MonitorProcessingJob: Video ##{video.id} remote_services_data: #{rs_data}") - if rs_data["processing_state"] == "creating_media_job" + if rs_data["processing_state"].in?(%w[creating_media_job enqueued]) started_at = rs_data["processing_step_started_at"] - Rails.logger.info("MonitorProcessingJob: Video ##{video.id} is in creating_media_job state, started_at: #{started_at}") + Rails.logger.info("MonitorProcessingJob: Video ##{video.id} is in #{rs_data['processing_state']} state, started_at: #{started_at}") # Check if upload is genuinely stuck vs. just taking a long time if started_at && !upload_is_stuck?(video, Time.parse(started_at)) @@ -122,6 +159,31 @@ def handle_failed_uploads_needing_retry end end + def handle_failed_videos_awaiting_retry + # Safety net: find videos that were scheduled for retry but the retry job was lost + videos = Folio::File::Video + .where(aasm_state: :processing_failed) + .where("remote_services_data ->> 'service' = ?", "cra_media_cloud") + .where("COALESCE((remote_services_data ->> 'retry_count')::int, 0) < 2") + .where("(remote_services_data ->> 'retry_scheduled_at')::timestamptz < ?", 5.minutes.ago) + + return if videos.empty? + + Rails.logger.info("MonitorProcessingJob: Found #{videos.count} failed videos awaiting retry (safety net)") + + scheduled_create_jobs = find_scheduled_create_media_job_ids + + videos.each do |video| + if scheduled_create_jobs.include?(video.id) + Rails.logger.debug("MonitorProcessingJob: Failed video ##{video.id} already has scheduled CreateMediaJob") + next + end + + Rails.logger.info("MonitorProcessingJob: Re-scheduling retry for failed video ##{video.id}") + Folio::CraMediaCloud::CreateMediaJob.perform_later(video) + end + end + def handle_videos_needing_progress_check processing_videos = find_processing_videos @@ -155,7 +217,7 @@ def handle_videos_needing_progress_check end Rails.logger.debug("MonitorProcessingJob: Scheduling CheckProgressJob for video ##{video.id}") - Folio::CraMediaCloud::CheckProgressJob.perform_later(video) + Folio::CraMediaCloud::CheckProgressJob.perform_later(video, encoding_generation: video.remote_services_data&.dig("encoding_generation")) end end @@ -189,8 +251,8 @@ def find_orphaned_videos # in creating_media_job state for a very long time "(remote_services_data ->> 'reference_id' IS NOT NULL AND remote_services_data ->> 'remote_id' IS NULL) OR " \ "(remote_services_data ->> 'processing_state' = 'creating_media_job' AND " \ - "(remote_services_data ->> 'processing_step_started_at')::timestamp < ?)", - 3.hours.ago + "(remote_services_data ->> 'processing_step_started_at')::timestamptz < ?)", + 30.minutes.ago ) end @@ -208,7 +270,6 @@ def reconcile_video_state(video) if jobs.empty? Rails.logger.warn("MonitorProcessingJob: No remote jobs found for video ##{video.id} reference_id: #{reference_id}") - # Video has reference_id but no remote jobs - needs re-upload rs_data.delete("reference_id") rs_data.delete("remote_id") rs_data.delete("processing_state") @@ -217,42 +278,61 @@ def reconcile_video_state(video) return end - latest_job = jobs.max_by { |j| Time.parse(j["lastModified"]) } - current_remote_id = rs_data["remote_id"] + reconcile_with_remote_jobs(video, rs_data, jobs) - case latest_job["status"] - when "DONE" - if current_remote_id != latest_job["id"] - Rails.logger.info("MonitorProcessingJob: Updating video ##{video.id} to point to successful job #{latest_job['id']}") - rs_data["remote_id"] = latest_job["id"] - rs_data["processing_state"] = "full_media_processing" - video.update_column(:remote_services_data, rs_data) + rescue => e + Rails.logger.error("MonitorProcessingJob: Error reconciling video ##{video.id}: #{e.message}") + end + end - # Schedule progress check to update final state - Folio::CraMediaCloud::CheckProgressJob.perform_later(video) - end - when "PROCESSING", "CREATED" - if current_remote_id != latest_job["id"] - Rails.logger.info("MonitorProcessingJob: Updating video ##{video.id} to point to processing job #{latest_job['id']}") - rs_data["remote_id"] = latest_job["id"] - rs_data["processing_state"] = "full_media_processing" - video.update_column(:remote_services_data, rs_data) - end + # NOTE: update_column calls below are non-atomic read-modify-write on + # remote_services_data. Safe because MonitorProcessingJob uses a Redis lock + # (another_monitor_job_running?) to prevent concurrent instances. + def reconcile_with_remote_jobs(video, rs_data, jobs) + # Filter out REMOVED jobs before resolution: for multi-phase encodings, a + # REMOVED phase-1 job may have a later lastModified than an active phase-2 + # job, causing JobResolver to select it and return :not_found — silently + # skipping the active job. If all remaining jobs are REMOVED, schedule + # CheckProgressJob which handles the finalize_from_completed_phases! path. + active_jobs = jobs.reject { |j| j["status"] == "REMOVED" } + + if active_jobs.empty? + Rails.logger.info("MonitorProcessingJob: All CRA jobs REMOVED for video ##{video.id} — scheduling CheckProgressJob to finalize") + Folio::CraMediaCloud::CheckProgressJob.perform_later(video, encoding_generation: rs_data["encoding_generation"]) + return + end - # Schedule progress check - Folio::CraMediaCloud::CheckProgressJob.perform_later(video) - when "FAILED", "ERROR" - Rails.logger.warn("MonitorProcessingJob: Latest job for video ##{video.id} failed, marking for retry") - rs_data.merge!({ - "processing_state" => "upload_failed", - "error_message" => "Remote job failed: #{latest_job['status']}", - "processing_step_started_at" => Time.current.iso8601 - }) + result = Folio::CraMediaCloud::JobResolver.resolve(active_jobs) + latest_job = result[:job] + return unless latest_job + + current_remote_id = rs_data["remote_id"] + + case result[:status] + when :done + if current_remote_id != latest_job["id"] + Rails.logger.info("MonitorProcessingJob: Updating video ##{video.id} to point to successful job #{latest_job['id']}") + rs_data["remote_id"] = latest_job["id"] + rs_data["processing_state"] = "full_media_processing" video.update_column(:remote_services_data, rs_data) end - - rescue => e - Rails.logger.error("MonitorProcessingJob: Error reconciling video ##{video.id}: #{e.message}") + Folio::CraMediaCloud::CheckProgressJob.perform_later(video, encoding_generation: video.remote_services_data&.dig("encoding_generation")) + when :processing + if current_remote_id != latest_job["id"] + Rails.logger.info("MonitorProcessingJob: Updating video ##{video.id} to point to processing job #{latest_job['id']}") + rs_data["remote_id"] = latest_job["id"] + rs_data["processing_state"] = "full_media_processing" + video.update_column(:remote_services_data, rs_data) + end + Folio::CraMediaCloud::CheckProgressJob.perform_later(video, encoding_generation: video.remote_services_data&.dig("encoding_generation")) + when :failed + Rails.logger.warn("MonitorProcessingJob: Latest job for video ##{video.id} failed, marking for retry") + rs_data.merge!({ + "processing_state" => "encoding_failed", + "error_message" => "Remote job failed: #{latest_job['status']}", + "processing_step_started_at" => Time.current.iso8601 + }) + video.update_column(:remote_services_data, rs_data) end end @@ -334,42 +414,44 @@ def extract_video_id_from_job_data(job_data) end def processing_too_long?(video) - # Consider a video stuck if it's been processing for more than 2 hours started_at = video.remote_services_data["processing_step_started_at"] return false unless started_at + # Multi-phase encoding can legitimately take longer — scale timeouts by phase count + phases = video.remote_services_data["processing_phases"].to_i + phase_multiplier = [phases, 1].max + elapsed_hours = (Time.current - Time.parse(started_at)) / 1.hour + hard_timeout = 6 * phase_multiplier + warn_timeout = 2 * phase_multiplier - # Mark as failed after very long processing (6+ hours) - if elapsed_hours > 6 - Rails.logger.error("MonitorProcessingJob: Marking video ##{video.id} as failed after #{elapsed_hours.round(1)} hours") + # Mark as failed after very long processing + if elapsed_hours > hard_timeout + Rails.logger.error("MonitorProcessingJob: Marking video ##{video.id} as failed after #{elapsed_hours.round(1)} hours (timeout: #{hard_timeout}h)") - # Persist failure state even if validations fail begin video.processing_failed! + broadcast_file_update(video) rescue => e Rails.logger.warn("MonitorProcessingJob: AASM transition failed (#{e.message}), forcing state via update_columns") - # Use update_columns to update in DB and then reload to sync memory video.update_columns(aasm_state: "processing_failed", updated_at: Time.current) video.reload + broadcast_file_update(video) end return true - elsif elapsed_hours > 2 - Rails.logger.warn("MonitorProcessingJob: Video ##{video.id} has been processing for #{elapsed_hours.round(1)} hours") + elsif elapsed_hours > warn_timeout + Rails.logger.warn("MonitorProcessingJob: Video ##{video.id} has been processing for #{elapsed_hours.round(1)} hours (warning: #{warn_timeout}h)") end - # Return whether it's been processing too long (>2 hours) but without marking as failed - elapsed_hours > 2 + # Return whether it's been processing too long but without marking as failed + elapsed_hours > warn_timeout rescue => e Rails.logger.error("MonitorProcessingJob: Error checking processing time for video ##{video.id}: #{e.message}") false end def upload_is_stuck?(video, upload_started_at) - rs_data = video.remote_services_data || {} - rs_data["upload_progress"] - # Calculate appropriate timeout based on file size file_size = video.file_size || 0 base_timeout = 5.minutes # Base timeout for small files diff --git a/app/jobs/folio/file/get_video_metadata_job.rb b/app/jobs/folio/file/get_video_metadata_job.rb new file mode 100644 index 000000000..ce348b51c --- /dev/null +++ b/app/jobs/folio/file/get_video_metadata_job.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +class Folio::File::GetVideoMetadataJob < Folio::ApplicationJob + include Folio::Shell + + queue_as :default + + # Returns { duration: Integer|nil, width: Integer|nil, height: Integer|nil } + # Accepts local file path OR HTTP(S) URL (presigned S3 URL). + # ffprobe streams only container headers from URLs — does NOT download the whole file. + def perform(file_path_or_url) + output = shell("ffprobe", + "-select_streams", "v:0", + "-show_entries", "stream=duration,width,height", + "-show_entries", "format=duration", + "-of", "json", + "-v", "fatal", + file_path_or_url) + + data = JSON.parse(output) + stream = data.dig("streams", 0) || {} + format_data = data.dig("format") || {} + + duration_raw = stream["duration"] || format_data["duration"] + + { + duration: duration_raw ? duration_raw.to_f.ceil : nil, + width: stream["width"]&.to_i, + height: stream["height"]&.to_i, + } + rescue => e + Rails.logger.error("[GetVideoMetadataJob] ffprobe failed for #{file_path_or_url.to_s.truncate(100)}: #{e.message}") + { duration: nil, width: nil, height: nil } + end +end diff --git a/app/jobs/folio/generate_thumbnail_job.rb b/app/jobs/folio/generate_thumbnail_job.rb index 3f22f6f38..0b7d4efc2 100644 --- a/app/jobs/folio/generate_thumbnail_job.rb +++ b/app/jobs/folio/generate_thumbnail_job.rb @@ -1,5 +1,8 @@ # frozen_string_literal: true +require "open3" +require "open-uri" + class Folio::GenerateThumbnailJob < Folio::ApplicationJob queue_as :slow @@ -253,26 +256,126 @@ def make_thumb(image, raw_size, quality, x: nil, y: nil) end def image_file(image) + if image.class.human_type == "video" + return video_screenshot(image) + end + if Rails.env.development? && ENV["DRAGONFLY_PRODUCTION_S3_URL_BASE"] && image.respond_to?(:development_safe_file) thumbnail = image.development_safe_file(logger) else thumbnail = image.file end - if image.class.human_type == "video" - thumbnail = thumbnail.ffmpeg_screenshot_to_jpg(image.screenshot_time_in_ffmpeg_format) - thumbnail.name = Pathname.new(image.file_name).sub_ext(".jpg") - thumbnail.meta["mime_type"] = "image/jpeg" - else - thumbnail.name = image.file_name - thumbnail.meta["mime_type"] = image.file_mime_type + thumbnail.name = image.file_name + thumbnail.meta["mime_type"] = image.file_mime_type + thumbnail + rescue Dragonfly::Job::Fetch::NotFound + fallback_image(image) + end + + # Get a screenshot frame for video thumbnail generation. + # Priority: 1) Provider-supplied poster image (no decoding needed) + # 2) ffmpeg frame extraction (only for ≤4K — safe memory) + # 3) fallback placeholder image + def video_screenshot(image) + # Prefer a provider-supplied poster image when available — avoids decoding + # the source video entirely. Critical for high-res (4K/8K) HEVC content + # where decoding a single frame can require 800+ MB for reference frame buffers. + if (cover_url = image.video_poster_url).present? + thumbnail = download_remote_image(image, cover_url) + return thumbnail if thumbnail + end + + input = image.file_url_or_path + return fallback_image(image) if input.blank? + + # Check resolution via ffprobe before attempting decode. Decoding + # video above 4K can require 800+ MB for codec reference frame + # buffers (DPB), which OOMKills pods with typical memory limits. + # For >4K videos without a poster image, use fallback. The provider + # may supply one asynchronously after encoding completes. + if video_resolution_too_high?(input) + Rails.logger.info("GenerateThumbnailJob: Skipping ffmpeg for high-res video ##{image.id}, using fallback") + return fallback_image(image) + end + + screenshot_time = image.screenshot_time_in_ffmpeg_format + + tmpfile = Tempfile.new(["video_thumb", ".jpg"]) + begin + # Place -ss before -i for fast HTTP range-based seeking (avoids + # downloading entire file). Use -threads 1 to limit memory usage + # for high-resolution video decoding. + success = system( + "ffmpeg", "-y", "-ss", screenshot_time, + "-i", input, + "-frames:v", "1", "-q:v", "2", "-threads", "1", + tmpfile.path, + out: File::NULL, err: File::NULL + ) + + unless success && File.size?(tmpfile.path) + Rails.logger.warn("GenerateThumbnailJob: ffmpeg screenshot failed for file ##{image.id}") + return fallback_image(image) + end + + thumbnail = Dragonfly.app.create(File.binread(tmpfile.path)) + ensure + tmpfile.close! end + thumbnail.name = Pathname.new(image.file_name).sub_ext(".jpg").to_s + thumbnail.meta["mime_type"] = "image/jpeg" thumbnail - rescue Dragonfly::Job::Fetch::NotFound - missing_image_path = Folio::Engine.root.join("data/images/missing-image.png") - thumbnail = Dragonfly.app.create(File.binread(missing_image_path)) - thumbnail.name = image.file_name || "missing-image.png" + rescue => e + Rails.logger.error("GenerateThumbnailJob: Video screenshot error for file ##{image.id}: #{e.message}") + fallback_image(image) + end + + MAX_FFMPEG_DECODE_HEIGHT = 2160 # 4K + + def video_resolution_too_high?(input) + stdout, _stderr, status = Open3.capture3( + "ffprobe", "-v", "error", + "-select_streams", "v:0", + "-show_entries", "stream=height", + "-of", "csv=p=0", + input + ) + return false unless status.success? + + height = stdout.strip.to_i + return false if height == 0 + + height > MAX_FFMPEG_DECODE_HEIGHT + rescue => e + # Fail safe: if ffprobe cannot determine resolution, skip ffmpeg to avoid + # OOMKilling the pod on a potentially high-resolution video. + Rails.logger.warn("GenerateThumbnailJob: ffprobe resolution check failed, skipping ffmpeg: #{e.message}") + true + end + + def download_remote_image(image, url) + data = URI.parse(url).open(read_timeout: 15).read + thumbnail = Dragonfly.app.create(data) + thumbnail.name = Pathname.new(image.file_name).sub_ext(".jpg").to_s + thumbnail.meta["mime_type"] = "image/jpeg" + thumbnail + rescue => e + Rails.logger.warn("GenerateThumbnailJob: remote poster download failed for file ##{image.id}: #{e.message}") + nil + end + + def fallback_image(image) + filename = if image.class.human_type == "video" + "missing-video.png" + else + "missing-image.png" + end + + path = Folio::Engine.root.join("data/images/#{filename}") + thumbnail = Dragonfly.app.create(File.binread(path)) + thumbnail.name = filename thumbnail.meta["mime_type"] = "image/png" thumbnail.meta["fallback_image"] = true thumbnail diff --git a/app/jobs/folio/s3/create_file_job.rb b/app/jobs/folio/s3/create_file_job.rb index 2983a5095..702deda7a 100644 --- a/app/jobs/folio/s3/create_file_job.rb +++ b/app/jobs/folio/s3/create_file_job.rb @@ -8,6 +8,12 @@ def perform_for_valid(s3_path:, klass:, existing_id:, web_session_id:, user_id:, @file = prepare_file_model(klass, id: existing_id, web_session_id:, user_id:, attributes:) replacing_file = @file.persisted? + # For video files on S3: use server-side copy instead of download+reupload + if klass <= Folio::File::Video && !use_local_file_system? + perform_with_s3_copy(s3_path:, klass:, replacing_file:) + return + end + Dir.mktmpdir("folio-file-s3") do |tmpdir| @file.file = downloaded_file(s3_path, tmpdir) @@ -45,6 +51,46 @@ def perform_for_valid(s3_path:, klass:, existing_id:, web_session_id:, user_id:, end private + def perform_with_s3_copy(s3_path:, klass:, replacing_file:) + file_name = s3_path.split("/").pop + sanitized_name = file_name.split(".").map(&:parameterize).join(".") + + # Generate Dragonfly-compatible UID and S3 destination key + uid = generate_dragonfly_uid(sanitized_name) + dest_key = [dragonfly_s3_root_path, uid].compact_blank.join("/") + source_key = test_aware_s3_path(s3_path) + + # Server-side S3 copy (instant, no data transfer through pod) + s3_copy_object(source_key: source_key, dest_key: dest_key) + + # Get file metadata from S3 HEAD (no download) + head = s3_head_object(key: source_key) + + # Set file attributes directly — bypass Dragonfly download+upload + @file.file_uid = uid + @file.file_name = sanitized_name + @file.file_size = head.content_length + @file.file_mime_type = head.content_type.presence || Marcel::MimeType.for(name: sanitized_name) + + if save_file_with_slug_retry + if replacing_file + broadcast_replace_success(file: @file, s3_path:, file_type: klass.to_s) + else + broadcast_success(file: @file, s3_path:, file_type: klass.to_s) + end + else + # Rollback: delete the copied file + test_aware_s3_delete(s3_path: uid) + if replacing_file + broadcast_replace_error(file: @file, s3_path:, file_type: klass.to_s) + else + broadcast_error(file: @file, s3_path:, file_type: klass.to_s) + end + end + ensure + test_aware_s3_delete(s3_path:) + end + def downloaded_file(s3_path, tmpdir) tmp_file_path = "#{tmpdir}/#{s3_path.split("/").pop}" diff --git a/app/lib/folio/cra_media_cloud/encoder.rb b/app/lib/folio/cra_media_cloud/encoder.rb index edf61d6b2..b7126591d 100644 --- a/app/lib/folio/cra_media_cloud/encoder.rb +++ b/app/lib/folio/cra_media_cloud/encoder.rb @@ -5,6 +5,8 @@ module Folio module CraMediaCloud class Encoder + include Folio::S3::Client + DEFAULT_PROFILE_GROUP = "VoD" # SFTP connection configuration @@ -13,191 +15,62 @@ class Encoder SFTP_MAX_RETRIES = 3 SFTP_RETRY_DELAY = 5.seconds - # SFTP upload configuration - CHUNK_SIZE = 1.megabyte # Standard chunk size for file operations - - def upload_file(file, priority: "regular", profile_group: nil, reference_id: nil, media_file: nil) + def upload_file(file, priority: "regular", profile_group: nil, reference_id: nil, media_file: nil, processing_phases: nil) ref_id = reference_id || [file.id, Time.current.to_i].join("-") - Rails.logger.info("[CraMediaCloud::Encoder] Starting upload for file ID: #{file.id}, ref_id: #{ref_id}") - - # Get metadata without downloading the file - s3_metadata = get_s3_metadata(file) - md5 = extract_etag(s3_metadata).delete_prefix('"').delete_suffix('"') - - xml_manifest = build_ingest_manifest(file, md5:, ref_id:, profile_group:) - - folder_path = "/ingest/#{priority}" - file_path = "#{folder_path}/#{file.file_name}" - xml_manifest_path = "#{folder_path}/#{file.file_name.split(".").first}_manifest.xml" - - # Use plain temp file path to avoid Ruby memory buffering - temp_file_path = ::File.join(Dir.tmpdir, "cra_upload_#{ref_id}_#{Process.pid}_#{Time.current.to_i}.tmp") + Rails.logger.info("[CraMediaCloud::Encoder] Starting manifest upload for file ID: #{file.id}, ref_id: #{ref_id}") - begin - # Download using system tools (no Ruby file handles involved) - download_to_file_path(file, temp_file_path) + # Get S3 metadata for MD5 checksum + s3_metadata = s3_dragonfly_head_object(file.file_uid) + md5 = extract_s3_etag(s3_metadata).delete_prefix('"').delete_suffix('"') - # Verify file size - actual_size = ::File.size(temp_file_path) - if actual_size != file.file_size - Rails.logger.error("[CraMediaCloud::Encoder] Downloaded file size mismatch: got #{actual_size}, expected #{file.file_size}") - raise "Downloaded file size mismatch: got #{actual_size}, expected #{file.file_size}" - end + # Generate presigned URL for CRA to download directly from S3 + presigned_url = generate_presigned_url(file) + Rails.logger.info("[CraMediaCloud::Encoder] Generated presigned S3 URL for CRA (expires in 7 days)") - # Upload to SFTP with robust session management - with_robust_sftp_session do |sftp| - # Use standard upload for better performance - upload_with_retry(sftp, temp_file_path, file_path) - Rails.logger.info("[CraMediaCloud::Encoder] File uploaded to SFTP: #{file_path}") + xml_manifest = build_ingest_manifest(file, md5:, ref_id:, profile_group:, presigned_url:, processing_phases:) - # Upload manifest - upload_with_retry(sftp, StringIO.new(xml_manifest), xml_manifest_path) - Rails.logger.info("[CraMediaCloud::Encoder] Manifest uploaded to SFTP: #{xml_manifest_path}") - end + folder_path = "/ingest/#{priority}" + xml_manifest_path = "#{folder_path}/#{ref_id}_manifest.xml" - rescue => e - Rails.logger.error("[CraMediaCloud::Encoder] Error during upload process: #{e.class}: #{e.message}") - raise - ensure - # Clean up temp file - if ::File.exist?(temp_file_path) - begin - ::File.delete(temp_file_path) - rescue => e - Rails.logger.warn("[CraMediaCloud::Encoder] Could not delete temp file #{temp_file_path}: #{e.message}") - end - end + # Upload only the manifest via SFTP (CRA downloads the video itself) + with_robust_sftp_session do |sftp| + upload_with_retry(sftp, StringIO.new(xml_manifest), xml_manifest_path) + Rails.logger.info("[CraMediaCloud::Encoder] Manifest uploaded to SFTP: #{xml_manifest_path}") end { ref_id:, - file_path:, xml_manifest_path:, + presigned_url: presigned_url.present?, } end private - def get_s3_metadata(file) + def generate_presigned_url(file) s3_datastore = Dragonfly.app.datastore - s3_object_key = [s3_datastore.root_path, file.file_uid].join("/") - Rails.logger.info("[CraMediaCloud::Encoder] Fetching S3 metadata for key: #{s3_object_key}") - s3_datastore.storage.head_object(ENV["S3_BUCKET_NAME"], s3_object_key) - end - - def extract_etag(response) - # Handle different response types (AWS SDK, Excon, etc.) - if response.respond_to?(:etag) - response.etag - elsif response.respond_to?(:headers) - response.headers["ETag"] || response.headers["etag"] || response.headers["Etag"] - else - raise "Cannot extract ETag from response type: #{response.class}" - end - end - - def download_to_file_path(file, file_path) - s3_datastore = Dragonfly.app.datastore - s3_object_key = [s3_datastore.root_path, file.file_uid].join("/") - - download_success = false - - # Try AWS CLI first (if available) - if system("which aws > /dev/null 2>&1") - s3_url = "s3://#{ENV['S3_BUCKET_NAME']}/#{s3_object_key}" - aws_command = "aws s3 cp #{s3_url} #{file_path} --no-progress" - - if system(aws_command) - download_success = true - end - end - - # Fallback to curl with S3 presigned URL - unless download_success - begin - s3_client = s3_datastore.storage - presigned_url = s3_client.presigned_url( - :get_object, - bucket: ENV["S3_BUCKET_NAME"], - key: s3_object_key, - expires_in: 3600 - ) - - curl_command = [ - "curl", "-L", "-s", "-S", - "-o", file_path, - "--max-time", "1800", - "--connect-timeout", "30", - presigned_url - ] - - if system(*curl_command) - download_success = true - end - - rescue => e - Rails.logger.error("[CraMediaCloud::Encoder] Error generating presigned URL: #{e.message}") - end - end - - # Final fallback to Ruby download - unless download_success - Rails.logger.warn("[CraMediaCloud::Encoder] System download failed, using Ruby fallback") - - downloaded_bytes = 0 - - ::File.open(file_path, "wb") do |output_file| - loop do - range_start = downloaded_bytes - range_end = [downloaded_bytes + CHUNK_SIZE - 1, file.file_size - 1].min - - break if range_start >= file.file_size - - begin - s3_response = s3_datastore.storage.get_object( - ENV["S3_BUCKET_NAME"], - s3_object_key, - range: "bytes=#{range_start}-#{range_end}" - ) - - chunk_data = s3_response.body - output_file.write(chunk_data) - output_file.flush - - downloaded_bytes += chunk_data.length - - # Clear references - nil - nil - - rescue => e - Rails.logger.error("[CraMediaCloud::Encoder] Error downloading chunk #{range_start}-#{range_end}: #{e.message}") - raise "Failed to download chunk from S3: #{e.message}" - end - end - end - - download_success = true - end - - unless download_success - raise "All download methods failed" - end - - actual_size = ::File.size(file_path) - if actual_size != file.file_size - raise "Downloaded size mismatch: got #{actual_size}, expected #{file.file_size}" - end + s3_object_key = [s3_datastore.root_path, file.file_uid].compact_blank.join("/") + s3_presigner.presigned_url( + :get_object, + bucket: s3_bucket, + key: s3_object_key, + expires_in: 7.days.to_i # 604800 seconds + ) end - def build_ingest_manifest(file, md5:, ref_id:, profile_group:) + def build_ingest_manifest(file, md5:, ref_id:, profile_group:, presigned_url: nil, processing_phases: nil) xml = Builder::XmlMarkup.new; nil xml.instruct!(:xml, version: "1.0", encoding: "utf-8") - xml.vod_encoder_job do - xml.input(type: "VIDEO", - file: file.file_name, - size: file.file_size.to_s, - md5: md5) do + root_attrs = processing_phases.to_i > 1 ? { processingPhases: processing_phases } : {} + xml.vod_encoder_job(root_attrs) do + input_attrs = { type: "VIDEO", size: file.file_size.to_s, md5: md5 } + if presigned_url.present? + input_attrs[:src] = presigned_url + else + input_attrs[:file] = file.file_name + end + + xml.input(input_attrs) do xml.audioTrack(language: "cze", channels: "auto") end xml.profileGroup(profile_group || DEFAULT_PROFILE_GROUP) diff --git a/app/lib/folio/cra_media_cloud/job_resolver.rb b/app/lib/folio/cra_media_cloud/job_resolver.rb new file mode 100644 index 000000000..5727fac7c --- /dev/null +++ b/app/lib/folio/cra_media_cloud/job_resolver.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Folio + module CraMediaCloud + class JobResolver + STATUS_MAP = { + "WAITING" => :processing, + "PROCESSING" => :processing, + "CREATED" => :processing, + "VALIDATING" => :processing, + "DONE" => :done, + "FAILED" => :failed, + "ERROR" => :failed, + "REMOVED" => :not_found, + }.freeze + + def self.resolve(jobs) + return { status: :not_found, job: nil } if jobs.empty? + + job = latest_job(jobs) + status = STATUS_MAP[job["status"]] || :not_found + { status:, job: } + end + + def self.latest_job(jobs) + return nil if jobs.empty? + jobs.max_by { |j| Time.parse(j["lastModified"]) } + end + + private_class_method :latest_job + end + end +end diff --git a/app/lib/folio/s3/client.rb b/app/lib/folio/s3/client.rb index b6fd900c0..698278579 100644 --- a/app/lib/folio/s3/client.rb +++ b/app/lib/folio/s3/client.rb @@ -94,6 +94,48 @@ def test_aware_s3_upload(s3_path:, file:, acl: "private") end end + def s3_copy_object(source_key:, dest_key:) + s3_client.copy_object( + bucket: s3_bucket, + copy_source: "#{s3_bucket}/#{source_key}", + key: dest_key + ) + end + + def s3_head_object(key:) + s3_client.head_object(bucket: s3_bucket, key: key) + end + + def generate_dragonfly_uid(file_name) + if Dragonfly.app.datastore.respond_to?(:generate_uid) + Dragonfly.app.datastore.generate_uid(file_name) + else + "#{Time.now.strftime '%Y/%m/%d/%H/%M/%S'}/#{SecureRandom.uuid}/#{file_name}" + end + end + + def dragonfly_s3_root_path + Dragonfly.app.datastore.root_path + end + + # Fetch S3 HEAD metadata via Dragonfly's Fog storage layer. + # Returns Excon response (use extract_s3_etag to read ETag). + def s3_dragonfly_head_object(file_uid) + s3_object_key = [dragonfly_s3_root_path, file_uid].compact_blank.join("/") + Dragonfly.app.datastore.storage.head_object(s3_bucket, s3_object_key) + end + + # Extract ETag from either Fog/Excon or AWS SDK response. + def extract_s3_etag(response) + if response.respond_to?(:etag) + response.etag + elsif response.respond_to?(:headers) + response.headers["ETag"] || response.headers["etag"] || response.headers["Etag"] + else + raise "Cannot extract ETag from response type: #{response.class}" + end + end + private def use_local_file_system? @use_local_file_system ||= Dragonfly.app.datastore.is_a?(Dragonfly::FileDataStore) diff --git a/app/models/concerns/folio/cra_media_cloud/file_processing.rb b/app/models/concerns/folio/cra_media_cloud/file_processing.rb index 9891ed445..733b4eb46 100644 --- a/app/models/concerns/folio/cra_media_cloud/file_processing.rb +++ b/app/models/concerns/folio/cra_media_cloud/file_processing.rb @@ -8,6 +8,14 @@ def encoder_profile_group nil # use encoder's default end + def encoder_processing_phases + 1 # default: single phase; override in app for multi-phase + end + + def encoder_phase_name(phase_number) + nil # override in app to return e.g. "SD", "HD" + end + def remote_content_mp4_url_for(profile) path = remote_services_data.dig("content_mp4_paths", profile.to_s) remote_content_url_base + path if path @@ -39,6 +47,10 @@ def remote_cover_url end end + def video_poster_url + remote_cover_url + end + def remote_thumbnails_url if remote_services_data["thumbnails_path"] remote_content_url_base + remote_services_data["thumbnails_path"] @@ -58,6 +70,8 @@ def update_preview_media_length end def destroy_attached_file + return if remote_id.blank? && remote_reference_id.blank? + delete_media_job_class.perform_later(remote_id, reference_id: remote_reference_id) end @@ -77,7 +91,11 @@ def processed_by "cra_media_cloud" end + def check_media_processing(preview: false) + check_media_processing_job_class.perform_later(self, preview:, encoding_generation:) + end + def upload_failed? - processing_state == "upload_failed" + processing_state.in?(%w[upload_failed encoding_failed]) end end diff --git a/app/models/concerns/folio/media_file_processing_base.rb b/app/models/concerns/folio/media_file_processing_base.rb index 90d531e21..bb06b19cd 100644 --- a/app/models/concerns/folio/media_file_processing_base.rb +++ b/app/models/concerns/folio/media_file_processing_base.rb @@ -19,8 +19,11 @@ module Folio::MediaFileProcessingBase def process_attached_file regenerate_thumbnails if try(:thumbnailable?) - # Set new encoding generation to invalidate any old CheckProgressJobs - self.update(remote_services_data: { + # Set new encoding generation to invalidate any old CheckProgressJobs. + # Use update_columns to bypass validations — remote_services_data is processing + # metadata and must not be blocked by unrelated validation failures (e.g. missing + # file dimensions when ffprobe fails). + update_remote_services_data({ "processing_step_started_at" => Time.current, "encoding_generation" => Time.current.to_i }) @@ -91,8 +94,7 @@ def preview_media_processed? def create_full_media full_media_job_class.perform_later(self) - rsd = remote_services_data || {} - self.update(remote_services_data: rsd.merge!({ "service" => processed_by, "processing_state" => "enqueued", "processing_step_started_at" => Time.current })) + update_remote_services_data("service" => processed_by, "processing_state" => "enqueued", "processing_step_started_at" => Time.current) end def create_preview_media @@ -100,7 +102,7 @@ def create_preview_media preview_media_processed! else preview_media_job_class.perform_later(self) - self.update(remote_services_data: self.remote_services_data.merge!({ "processing_step_started_at" => Time.current })) + update_remote_services_data("processing_step_started_at" => Time.current) end end @@ -130,7 +132,7 @@ def preview_duration_in_seconds if (remote_services_data || {}).dig("preview_interval").present? preview_ends_at_second - preview_starts_at_second else - [file_track_duration_in_seconds, DEFAULT_PREVIEW_DURATION].min + file_track_duration_in_seconds.present? ? [file_track_duration_in_seconds, DEFAULT_PREVIEW_DURATION].min : DEFAULT_PREVIEW_DURATION end end @@ -148,4 +150,21 @@ def preview_duration=(secs) def preview_duration @preview_duration ||= ActiveSupport::Duration.build(preview_duration_in_seconds) end + + private + # Merge new data into remote_services_data and persist directly to DB, + # bypassing model validations and callbacks. This is necessary because + # remote_services_data is processing metadata that must not be blocked + # by unrelated validation failures on the model. + # + # NOTE: Non-atomic read-modify-write — if another process updates + # remote_services_data between read and write, changes will be lost. + # Acceptable at current call sites (process_attached_file, create_full_media) + # where the video is being initially processed and no concurrent job + # is modifying remote_services_data yet. + def update_remote_services_data(new_data) + merged = (remote_services_data || {}).merge(new_data) + update_columns(remote_services_data: merged) + write_attribute(:remote_services_data, merged) + end end diff --git a/app/models/folio/file.rb b/app/models/folio/file.rb index dd44804f1..b0b4009a9 100644 --- a/app/models/folio/file.rb +++ b/app/models/folio/file.rb @@ -9,6 +9,7 @@ class Folio::File < Folio::ApplicationRecord include Folio::Taggable include Folio::HasAasmStates include Folio::BelongsToSite + include Folio::S3::Client include Folio::FilesSharedAccrossSites if Rails.application.config.folio_shared_files_between_sites READY_STATE = :ready @@ -196,6 +197,10 @@ class Folio::File < Folio::ApplicationRecord event :reprocess do transitions from: READY_STATE, to: :processing end + + event :retry_processing do + transitions from: :processing_failed, to: :processing + end end def self.correct_site(site) @@ -267,6 +272,17 @@ def regenerate_thumbnails end end + # Returns a path or URL suitable for ffprobe/ffmpeg. + # For S3 storage with stored file: presigned URL (streams headers only, no full download). + # For pending uploads (file= assigned but not yet saved) or local storage: file system path. + def file_url_or_path + if file_uid.present? && !Dragonfly.app.datastore.is_a?(Dragonfly::FileDataStore) + file_presigned_url + else + file&.path.to_s + end + end + def thumbnailable? false end @@ -417,6 +433,15 @@ def update_file_placements_counts! end private + def file_presigned_url(expires_in: 1.hour.to_i) + s3_object_key = [dragonfly_s3_root_path, file_uid].compact_blank.join("/") + s3_presigner.presigned_url(:get_object, + bucket: s3_bucket, + key: s3_object_key, + expires_in: expires_in + ) + end + def slug_candidates %i[slug headline hash_id_for_slug to_label] end @@ -457,16 +482,24 @@ def check_usage_before_destroy end def set_file_track_duration - if %w[audio video].include?(self.class.human_type) - self.file_track_duration = Folio::File::GetFileTrackDurationJob.perform_now(file.path.to_s, self.class.human_type) # in seconds + if self.class.human_type == "video" + # For video: handled together with dimensions in set_video_file_dimensions + return + elsif self.class.human_type == "audio" + self.file_track_duration = Folio::File::GetFileTrackDurationJob.perform_now(file_url_or_path, "audio") self.preview_track_duration_in_seconds = self.respond_to?(:preview_duration_in_seconds) ? preview_duration_in_seconds : 0 end end def set_video_file_dimensions - if %w[video].include?(self.class.human_type) - self.file_width, self.file_height = Folio::File::GetVideoDimensionsJob.perform_now(file.path.to_s, self.class.human_type) - end + return unless self.class.human_type == "video" + + metadata = Folio::File::GetVideoMetadataJob.perform_now(file_url_or_path) + + self.file_width = metadata[:width] + self.file_height = metadata[:height] + self.file_track_duration = metadata[:duration] + self.preview_track_duration_in_seconds = self.respond_to?(:preview_duration_in_seconds) ? preview_duration_in_seconds : 0 end def validate_attribution_and_texts_if_needed diff --git a/app/models/folio/file/video.rb b/app/models/folio/file/video.rb index bb5e9a842..f9429ef04 100644 --- a/app/models/folio/file/video.rb +++ b/app/models/folio/file/video.rb @@ -19,6 +19,10 @@ def thumbnailable? true end + def video_poster_url + nil # override in provider concerns to return a static thumbnail image URL + end + def self.human_type "video" end diff --git a/app/serializers/folio/console/file_serializer.rb b/app/serializers/folio/console/file_serializer.rb index 48f9a1e8e..f4f332b4d 100644 --- a/app/serializers/folio/console/file_serializer.rb +++ b/app/serializers/folio/console/file_serializer.rb @@ -86,11 +86,7 @@ class Folio::Console::FileSerializer end attribute :aasm_state_human do |object| - if object.processing? && object.remote_services_data.try(:[], "progress_percentage") - "#{object.aasm.human_state} (#{object.remote_services_data.try(:[], "progress_percentage")}%)" - else - object.aasm.human_state - end + object.aasm.human_state end attribute :aasm_state_color do |object| diff --git a/config/locales/aasm.cs.yml b/config/locales/aasm.cs.yml index 54f31b891..9110a5a08 100644 --- a/config/locales/aasm.cs.yml +++ b/config/locales/aasm.cs.yml @@ -7,6 +7,7 @@ cs: folio/file: aasm_state/unprocessed: Nezpracováno aasm_state/processing: Zpracováváno + aasm_state/processing_failed: Zpracování selhalo aasm_state/ready: Připraveno folio/lead: diff --git a/config/locales/aasm.en.yml b/config/locales/aasm.en.yml index 26cc89b41..e63c318ea 100644 --- a/config/locales/aasm.en.yml +++ b/config/locales/aasm.en.yml @@ -7,6 +7,7 @@ en: folio/file: aasm_state/unprocessed: Unprocessed aasm_state/processing: Processing + aasm_state/processing_failed: Processing failed aasm_state/ready: Ready folio/lead: diff --git a/config/locales/console/files.cs.yml b/config/locales/console/files.cs.yml index c09108f60..9e7b7e135 100644 --- a/config/locales/console/files.cs.yml +++ b/config/locales/console/files.cs.yml @@ -22,6 +22,19 @@ cs: navigation_previous: Předchozí show: + encoding_info_component: + phase_waiting: "Čekání ve frontě" + phase_waiting_multi: "Čekání ve frontě (fáze %{phase}/%{total})" + phase_waiting_named: "Čekání ve frontě – %{name}" + phase_encoding: "Kódování videa" + phase_encoding_multi: "Kódování videa (%{phase}/%{total})" + phase_encoding_named: "Kódování %{name}" + phase_packaging: "Balení" + phase_packaging_multi: "Balení (%{phase}/%{total})" + phase_packaging_named: "Balení – %{name}" + phase_failed_retrying: "Zpracování selhalo, pokusíme se znovu" + phase_failed: "Zpracování selhalo. Zkuste video nahrát znovu, nebo kontaktujte podporu." + metadata_component: no_metadata: Žádná metadata extract_metadata: Znovu extrahovat metadata diff --git a/config/locales/console/files.en.yml b/config/locales/console/files.en.yml index 014c5663f..db393517b 100644 --- a/config/locales/console/files.en.yml +++ b/config/locales/console/files.en.yml @@ -22,6 +22,19 @@ en: navigation_previous: Previous show: + encoding_info_component: + phase_waiting: "Waiting in queue" + phase_waiting_multi: "Waiting in queue (phase %{phase}/%{total})" + phase_waiting_named: "Waiting in queue – %{name}" + phase_encoding: "Encoding video" + phase_encoding_multi: "Encoding video (%{phase}/%{total})" + phase_encoding_named: "Encoding %{name}" + phase_packaging: "Packaging" + phase_packaging_multi: "Packaging (%{phase}/%{total})" + phase_packaging_named: "Packaging – %{name}" + phase_failed_retrying: "Processing failed, retrying automatically" + phase_failed: "Processing failed. Try re-uploading or contact support." + metadata_component: no_metadata: No metadata extract_metadata: Extract metadata again diff --git a/data/images/missing-video.png b/data/images/missing-video.png new file mode 100644 index 0000000000000000000000000000000000000000..9167532d35e27fbe082982c86e1a34868e0805a1 GIT binary patch literal 13993 zcmeHN4Nz3q6+Ul4SQG?_3ehO5KD9RZgH{CvU5Ql)@h`Des9{vpSgm1OOpt(jqfU+1 zAFO7rmVoKlp~e~`qXkCARazzf;7?*|6m^{LBE1zMEebKkoQJbB*Dgbt48&dA}t zbM86c`Mvk4YbH+|@71yOI zu(SF6qBj!0^dI`-gwJb@t_Huiixy>{s)(uYmhN5ls^#4emqstVYM`3|E)`rfvR{a+ zk5kknxiUEsjR1+siKwrciGhH&7Ca7L0FT3OEto9~kEr^d5qCtj%K2usW?ML#T)l|$ zS`*P0h6id#i_CI<3!4{3h4Z<25p7|3yahN65f#DX{1%2Og2nmVyomlqJr4Lj5f$m< z{HNS)ALTUSNf%L3R5+h|FQTm!o#%7z@#Hv5Makp*R!Sl_FQQJugC9Sa#{&E?_vn56 zIhlK+R?+gEY#mYbIR7ahJml5q>pDCzcpZQ}w`U-+atG@_{7GeZ)=A{Sj8$`k z-0XBKrhG@3->m3$Y-`QG7SONhMcJNLZY&>7Dla5?L+WsP1<8sy`NdJHtuzeG*U(yA z`k(GE9)t=}gXz?u3~yV~tx5@sU;d1W|LEkjoe*615k;KjqVT)ga!V6jKqdfl`W08Y z1ec{OQ_uviJS|xYx2+5T@Gt>H8@9QV$}^z~a-a*#yrOD%E(HJcbQ{HBR6wO;dDI`w5MLv}0qkp{D-P@fVJqJ;WYZb~T3epD@?QJLT_1zPbgd#D#RmZ-k3+a2`V9)B2O zf9Y77#1i=4#>^FAD4`bJdh2ZKtcC)e-*4WFtRn5VF=)5GiQ1Q(7j?BKEpczKRloUF z%Dgi!Vu~9ZQUkB+3MU)C3agtlMtEH7YuDwQgd?SVxe$g zrGbSR?XbGtvO7cyK5^PZZItd!>ULC#!9HV%U(@q#(vj`%_LL#sYInSUTC#<_)n085 zx7s==9GMZIwn2{!wXZ@8)xoemVO|FsNX&y0oZqF4g3^!Ax-*Yb|GepJ8~co^TpG(x z(`g~D-4b|=P8K>S$RWu9=S~dV9GK5W4K^+rwsgd$*`BuA_E5ft%8w1sQa zl|f_b;R-ig7@8etW5U<;fDgJWQ0cFx_mp5)6-K>0#TE7`a;76)4WwKG+weEnW0;h> zY)oq+w;uTFj6aY`Hxh%PplqYRK|ybqz@w+4-Xj1~ebm>tB%s!yw!>l|fAXnX;&I7nRi-p}3@d~JZ7trDJ+ zBrqCm4?PtyH`_u^rc&Gpo@Seb{*1octBSq>P(6%^BAX8dq{Rz=LV3d-)r9X-GsjC% z9o$6jv3<$;R3_w!GPuW*nQx@Q8+yFJ`;ftY%>V^BOrm>+6_-i2!)@69b8D;-(S0Q3 zV!zBk())F5B;?QtVcFu+q5QTWq9%GU;1W^orAF^r2aXmdOVgb*A(I}KNhGxo4T+Tcxz0MDaAkC7`0Q z%lRT$oG%kJ`Z&DMtFv6emf0mPr8d4a&CST76Hn-|a?1Cc4$Hk+3|wiEPuxHD6tl22Whz$7e8Z_Q_LpL!8NmiE zmSw9u&`~?3pSc7SZ&}v@jv%^U+DFyd-*scA0#8r`}R8}`-JoIIkzlo zXW(YDQKH?~pp;om?R!a5qQi!^a%?latX`UNhDAvxK;1>3QLMq!W|;7Bs!8J*GxSRgFVk@gkaT6OKVVCE1v*xsq1-Wqo&w4F?W3TWogSzOe@1 zaK~^ui^D0xc$Cg*%L0rwozlUH<@Et-^=0MI>p$HIWR*8pPfuW`9wKTe(oc5NT_7)` z(ZI_(n2?R>1>aG0+mrS_k=aPc^-t;CWG2`JUopWZH$$Lj?1@YUlj%U1umzl> z5o+vZLXpuW6a1-9Sp!i%($XQNq4$rtJEnbX4i=!JKgXStqhvN7OW*aEfCh|>!wNUr zE_AV;eFA0OK=~pn6DmZPOz@{ZZHye{be=`9IA0G|`C{y}j0NlN-8}M9LKlX&*WP)7XKxhM`g`xM1Fg`mRQo5@? z%yCbuI(BnoZ(m2D42$U#-IHAygR}8|8Mql7gC7yGzR;&^v{1H)ns8v!C8DgEsGNuj zU~$+YSe!3{h5RK6ah|Wx8-B=R)zCQGsbya7c;j!J66GtP>6ZZp1NWuwJiPuN0ry;h-vf+`YB77Oz@|e>NNcKsdF^jI1$Y~%LL!H7(5QQajsFl-m?fE=gS1O zv=~f1INJBzyogR#v!~s!_bk%K`7%MLpIWy~grVa}7g4=vXy0@1MO0SJi)ahC7XI}h zE|FQzZ(;MIsBk_vFQP3Bk0+DE5K$34&TnCuB3PWy&5P(%dRXD&`$SZvkMo~$w;TP# z0D8}puSZ2u;e77Bh_+I6p3k|*ljAHEC6Du4DT&;C11;YjHnI=UD)!(1XxE+_(op(4 zUA`tpz{7`86aD7{T&eWlh%16H0L|o&!5%p#8nv-W&^+etEY)(yNY5%~6A32+>7;SJxN5;@0;Q*2gH=zvNy(ZX`~PcPTX8zBwMxl+$8OO} zg9iIk9p@ct%{&XfXyUG&fjkf7hZ#qdsjt(E&%%t;agEo2w%nZ*ce28?6I4fg>%@7g zdWJs>zUUkt+Q9mlSiNhLu9GIc8qtb7Y23*}S*J#{V4Td_Q#Ipe_|L2E_HkB+$@ee~ Okw2X{_S5j0EB*()`(-%* literal 0 HcmV?d00001 diff --git a/docs/design/cra-encoding-system.md b/docs/design/cra-encoding-system.md new file mode 100644 index 000000000..297281ec3 --- /dev/null +++ b/docs/design/cra-encoding-system.md @@ -0,0 +1,342 @@ +# CRA Video Encoding System — Design Document + +## Overview + +The CRA (CraMediaCloud) integration encodes uploaded videos into multiple quality profiles (SD/HD), HLS/DASH streaming manifests, and generates thumbnails/cover images. Videos become progressively available — SD quality is playable while HD encoding continues. + +**Repos:** folio gem (core engine) + economia app (overrides, player, UI) + +--- + +## 1. Upload & Manifest Delivery + +### Presigned S3 URL (no file transfer through pod) + +When a video is uploaded, the encoder generates a **presigned S3 URL** (7-day expiry) and embeds it in an XML manifest. Only the manifest (~1 KB) is uploaded via SFTP — CRA fetches the video directly from S3. + +```xml + + + + + VoDHDAuto + prod-video-slug-a1b2c3d4-1710000000 + +``` + +### Reference ID format + +`{env}-{slug(truncated)}-{s3_etag[0..7]}-{encoding_generation}` + +- Total capped at **128 chars** (CRA lookup fails with longer IDs) +- `encoding_generation` changes on each re-encode, ensuring CRA gets a fresh refId + +### Files + +| File (folio) | Purpose | +|---|---| +| `app/lib/folio/cra_media_cloud/encoder.rb` | Builds XML manifest, uploads via SFTP | +| `app/jobs/folio/cra_media_cloud/create_media_job.rb` | Orchestrates upload: generates ref ID, checks for existing jobs, calls Encoder | +| `app/lib/folio/s3/client.rb` | Shared S3 helpers: presigned URLs, HEAD metadata, ETag extraction | + +--- + +## 2. Two-Phase Encoding + +When `encoder_processing_phases` returns `> 1` (economia overrides to `2`), a **single manifest** is submitted with the `processingPhases="2"` XML attribute (same format as shown in §1). The profile group is always `VoDHDAuto` — CRA handles phasing internally. + +CRA creates multiple internal jobs (one per phase), each with a `phase` field in API responses: + +| CRA phase | Output | Enables | +|---|---|---| +| 1 (SD) | sd profiles, HLS/DASH (SD), cover, thumbnails | Playback at SD quality while HD encodes | +| 2 (HD) | All profiles incl. HD, full HLS/DASH | Full quality playback | + +When `CheckProgressJob` sees a phase-1 job reach DONE, `save_intermediate_phase_data` writes the SD manifest/cover paths to the top-level `remote_services_data` keys the player reads — making the video playable at SD quality. It then clears `remote_id` and polls by `reference_id` to discover the phase-2 job. Phase-2 output overwrites phase-1 paths when it completes. + +### Backward compatibility + +When `encoder_processing_phases` is `1` or `nil` (default), the manifest is submitted without the `processingPhases` attribute. All existing behavior preserved. + +### economia override (`feature/cra-encoding-improvements` branch) + +```ruby +# app/overrides/models/folio/file/video_override.rb +def encoder_profile_group + Rails.env.production? ? "VoDHDAuto" : "VoD" +end + +def encoder_processing_phases + 2 +end + +def encoder_phase_name(phase_number) + { 1 => "SD", 2 => "HD" }[phase_number] +end +``` + +--- + +## 3. Progress Tracking + +### CRA API polling + +`CheckProgressJob` polls every 15 seconds. It parses the CRA `messages` array to determine encoding phase: + +| CRA message | Internal phase | +|---|---| +| `verification: finished` | `validation` | +| `Transcoding worker - audio: finished` | `audio` | +| `Transcoding worker - video: finished` | `video` | +| `copying: started` | `packaging` | + +Progress percentage is raw CRA `progress` field × 100 (per-phase, not mapped across phases). + +### MessageBus real-time updates + +`broadcast_encoding_progress` publishes to `Folio::MESSAGE_BUS_CHANNEL` with phase label, progress %, and failure state. The `EncodingInfoComponent` Stimulus controller updates the UI badge in real time. + +### Files + +| File (folio) | Purpose | +|---|---| +| `app/jobs/folio/cra_media_cloud/check_progress_job.rb` | Polls CRA API, updates `remote_services_data`, handles phase transitions | +| `app/components/folio/console/files/show/encoding_info_component.*` | UI badge (Ruby + Stimulus + Sass + Slim) | + +--- + +## 4. State Machine + +### AASM states (`aasm_state` column) + +``` +unprocessed → [process!] → processing → [processing_done!] → ready + ↓ + [processing_failed!] + ↓ + processing_failed → [retry_processing!] → processing +``` + +### Processing states (`remote_services_data["processing_state"]`) + +``` +enqueued → creating_media_job → full_media_processing → full_media_processed + ↓ + encoding_failed (CRA FAILED/ERROR) + upload_failed (SFTP/S3 error in CreateMediaJob) + source_file_missing (S3 404) +``` + +Multi-phase adds intermediate data (`phase_N_content_mp4_paths`, `phase_N_completed_at`) but no new processing states. + +### `remote_services_data` JSON structure + +```json +{ + "service": "cra_media_cloud", + "processing_state": "full_media_processing", + "reference_id": "prod-video-slug-a1b2c3d4-1710000000", + "remote_id": "JOB123", + "encoding_generation": 1710000000, + "processing_step_started_at": "2026-03-17T10:30:00Z", + + "cra_status": "PROCESSING", + "progress_percentage": 60, + "current_phase": "encoding", + "current_encoding_phase": 1, + "processing_phases": 2, + "phases_completed": ["validation", "audio"], + "video_duration": 120, + + "phase_1_content_mp4_paths": { "sd0": "/path/sd0.mp4", "sd1": "/path/sd1.mp4" }, + "phase_1_completed_at": "2026-03-17T11:00:00Z", + "phase_1_remote_id": "JOB111", + + "content_mp4_paths": { "sd0": "/path/sd0.mp4", "hd1": "/path/hd1.mp4" }, + "manifest_hls_path": "/path/master.m3u8", + "manifest_dash_path": "/path/manifest.mpd", + "cover_path": "/path/cover.jpg", + "thumbnails_path": "/path/thumb.vtt", + + "error_message": null, + "retry_count": 0, + "retry_scheduled_at": null, + "failed_at": null +} +``` + +--- + +## 5. Error Handling & Recovery + +### Automatic retry + +On CRA `FAILED`/`ERROR`, `CheckProgressJob`: +1. Sets `processing_state` to `"encoding_failed"`, `retry_count` += 1 +2. Calls `processing_failed!` (single save) +3. Broadcasts failure state to UI +4. If `retry_count <= 1`: schedules `CreateMediaJob` in 2 minutes +5. If `retry_count > 1`: final failure, no retry + +### Timeout + +- **CheckProgressJob**: 4-hour `MAX_PROCESSING_DURATION` (flat, per video) — marks as `processing_failed` if `processing_step_started_at` is older. The unique-job constraint means one instance runs per video; if the worker is restarted the next `CheckProgressJob` re-checks this on each run. +- **MonitorProcessingJob**: 6-hour hard timeout (flat, not phase-multiplied in current code) — marks as `processing_failed` for any video that has been in `processing` AASM state for over 6 hours. Effectively a backstop for videos whose `CheckProgressJob` was lost or never fired. + +> **Note:** The two timeouts are intentionally overlapping rather than sequential. `CheckProgressJob` handles the common case (actively polling video); `MonitorProcessingJob` is the safety net for stuck/orphaned videos. A video that times out in `CheckProgressJob` at 4 hours will also be caught by `MonitorProcessingJob` at 6 hours if it somehow transitions back to `processing`. + +### Safety nets (MonitorProcessingJob) + +Runs periodically with Redis lock to prevent concurrent instances. Catches: + +| Scenario | Action | +|---|---| +| Stuck in `unprocessed` with `file_uid` > 5 min | Triggers `process!` | +| Stuck in `enqueued` > 10 min | Re-enqueues `CreateMediaJob` | +| `upload_failed` / `encoding_failed` > 5 min | Re-enqueues `CreateMediaJob` | +| `processing_failed` with `retry_count < 2` and lost retry job | Re-enqueues `CreateMediaJob` | +| Processing > 6 hours | Marks as `processing_failed` | +| Orphaned (has `reference_id` but no `remote_id`, or stuck in `creating_media_job` > 30 min) | Reconciles via API | +| All CRA jobs `REMOVED` with stored phase data | `finalize_from_completed_phases!` merges stored output and transitions to `ready` | + +**Note on `REMOVED` status:** Production data confirms CRA does **not** auto-purge completed jobs — DONE jobs remain accessible indefinitely (verified 4+ months). `REMOVED` appears only when job content is explicitly deleted via `DeleteMediaJob` (`DELETE /jobs/{id}/content`). The all-REMOVED handler therefore covers the edge case where both phase job contents were deleted while the video was still in `processing` AASM state. + +### Tracked job becomes REMOVED (CheckProgressJob) + +When `CheckProgressJob` is polling via `remote_id` and that specific job returns `REMOVED`, it: +1. Clears `remote_id` from `remote_services_data` +2. Calls `check_again_later` to resume polling by `reference_id` + +This handles the edge case where a single phase job is deleted while encoding is still in progress. Polling falls back to `reference_id` lookup to discover any replacement or remaining jobs. + +### Stale processing state after CRA recovery (CreateMediaJob) + +When `CreateMediaJob` finds an existing CRA job with `remote_id` matching the stored value but `processing_state` is stale (e.g. `upload_failed` or `encoding_failed` set while CRA eventually completed), it: +1. Resets `processing_state` to `"full_media_processing"` +2. Schedules `CheckProgressJob` to finalize + +Without this, videos could loop forever: `MonitorProcessingJob` re-enqueues `CreateMediaJob` every 5 min, `CreateMediaJob` finds matching `remote_id` and does nothing, state never advances. Root cause confirmed in production (video stuck 25+ hours while CRA job was `DONE`). + +### Missing S3 source file + +If S3 returns 404 during `CreateMediaJob`, video is marked `source_file_missing` + `processing_failed` permanently (no retry). + +--- + +## 6. Progressive Video Availability + +After phase 1 completes, `save_intermediate_phase_data` writes SD manifest/cover paths to the same top-level keys the player reads (`manifest_hls_path`, `manifest_dash_path`, `cover_path`). The video is playable at SD quality while AASM state remains `processing`. + +The economia `PlayerComponent` gates on manifest URL presence (not AASM `ready?`): +```ruby +@valid = @file.remote_manifest_hls_url.present? || @file.remote_manifest_dash_url.present? +``` + +When phase 2 completes, `process_output_hash` overwrites with HD paths. Next page load serves HD. + +### Console video detail (economia) + +`AdditionalHtmlComponent` shows: +- **Iframe with player** when manifest URL is present (same gate as PlayerComponent — manifest is available as soon as phase 1 completes, so this covers the SD-quality interim state) +- **"File not ready"** when no manifest is available yet + +--- + +## 7. Thumbnail Generation + +Priority order: +1. **CRA cover image** (small JPEG from CDN) — preferred, no decoding needed +2. **ffmpeg frame extraction** — only for ≤4K resolution (checked via `ffprobe`) +3. **Fallback placeholder** (`missing-video.png`) — for >4K or when both above fail + +Both ffprobe (resolution check) and ffmpeg (frame extraction) receive the **presigned S3 URL** from `file_url_or_path`. ffprobe reads only container headers (no full download). ffmpeg uses `-ss` before `-i` for fast HTTP range-based seeking, avoiding a full file download to the pod. + +### OOMKill prevention + +Videos >4K (2160p) skip ffmpeg decoding entirely — HEVC reference frame buffers can require 800+ MB. The fallback placeholder is used until CRA provides the cover image. + +### Files + +| File (folio) | Purpose | +|---|---| +| `app/jobs/folio/generate_thumbnail_job.rb` | Video screenshot extraction with resolution check | +| `app/jobs/folio/file/get_video_metadata_job.rb` | Single ffprobe call for duration + dimensions via presigned URL | + +--- + +## 8. S3 Optimizations + +| Optimization | File | Effect | +|---|---|---| +| Presigned URL for CRA | `encoder.rb` | No video download to pod | +| Presigned URL for ffprobe | `file.rb` → `file_url_or_path` | Streams ~100 KB headers, not full file | +| S3 server-side copy for uploads | `app/jobs/folio/s3/create_file_job.rb` | Zero data transfer for video copy | +| Shared S3 helpers | `app/lib/folio/s3/client.rb` | `s3_dragonfly_head_object`, `extract_s3_etag` | + +--- + +## 9. Legacy Video Support (economia) + +Videos imported from old Wowza/CDN77 system have `legacy_data["skip_cra_encoding"] = true`. These: +- Skip CRA encoding entirely (`process_attached_file` → just thumbnails + `processing_done!`) +- Use direct CDN URLs for playback +- Override `remote_manifest_url_base` and `remote_content_url_base` to match import domain +- Skip CRA delete on destroy + +### Files (economia, branch `feature/cra-encoding-improvements`) + +| File | Purpose | +|---|---| +| `app/overrides/models/folio/file/video_override.rb` | CRA concern inclusion, profile group, 2-phase config, legacy video handling | +| `app/overrides/jobs/folio/cra_media_cloud/create_media_job_override.rb` | Sets queue to `:video` | +| `app/components/economia/cra_media_cloud/player_component.rb` | OTT player rendering with manifest-based gate, subtitles, Gemius analytics | +| `app/components/economia/cra_media_cloud/player_component.js` | Stimulus controller: player lifecycle, viewport awareness, multi-instance coordination | +| `app/components/folio/console/economia/files/additional_html_component.rb` | Console video detail: iframe player (manifest gate) + manifest URL links | +| `app/components/folio/console/economia/files/additional_html_component.slim` | Template with manifest gate — shows player iframe or "not ready" | +| `app/jobs/economia/import_video_from_url_job.rb` | Legacy video import from article URLs | +| `app/lib/economia/article_storage/video_creator.rb` | Creates video records from Article Storage API | +| `lib/tasks/cra_audit.rake` | CRA audit rake task (330 lines) | + +--- + +## 10. Environment Variables + +``` +# SFTP (manifest upload) +CRA_MEDIA_CLOUD_SFTP_HOST / _USERNAME / _PASSWORD + +# API (job status polling) +CRA_MEDIA_CLOUD_API_BASE_URL / _USERNAME / _PASSWORD + +# CDN (output URLs) +CRA_MEDIA_CLOUD_CDN_CONTENT_URL # MP4, cover, thumbnails +CRA_MEDIA_CLOUD_CDN_MANIFEST_URL # HLS/DASH manifests + +# S3 +S3_BUCKET_NAME / S3_REGION / AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY +``` + +--- + +## 11. Known Gaps & TODO + +### Not yet implemented + +- [ ] **Subtitle trigger on SD completion** — ElevenLabs transcription from sd1 MP4 after phase 1. Not wired up. +- [ ] **Dynamic timeouts in MonitorProcessingJob** — currently fixed 6h. Design doc specified file-size/duration-based formula. +- [ ] **`playable` field in API JSON** — `videos_controller.rb` still returns `ready: video.ready?`. Should add `playable:` based on manifest presence. +- [ ] **SD quality badge on player** — no visual indicator that video is SD-only while HD encodes. + +### Test coverage gaps (folio) + +- [x] MonitorProcessingJob handler integration tests (`handle_failed_uploads_needing_retry`, `reconcile_video_state`, `reconcile_with_remote_jobs`) +- [x] CheckProgressJob: `processing_timed_out?` — video >4h old marks as `processing_failed`; video <4h continues polling +- [x] CheckProgressJob: `finalize_from_completed_phases!` — all jobs REMOVED + stored phase data → `ready` with merged MP4 paths +- [x] CheckProgressJob: tracked job becomes REMOVED → clears `remote_id`, reschedules +- [x] Encoder: `upload_file` method, SFTP session management, retry logic +- [x] CreateFileJob: S3 server-side copy path for videos +- [x] AASM state transition integration tests with CRA concern + +### Test coverage gaps (economia) + +- [x] `AdditionalHtmlComponent` — additional state coverage (legacy video, unprocessed video, ready video) diff --git a/lib/folio/version.rb b/lib/folio/version.rb index 1a824a3dd..81cee0c1d 100644 --- a/lib/folio/version.rb +++ b/lib/folio/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Folio - VERSION = "7.4.1" + VERSION = "7.5.0" end diff --git a/test/integration/video_upload_no_download_test.rb b/test/integration/video_upload_no_download_test.rb new file mode 100644 index 000000000..5be7e8c50 --- /dev/null +++ b/test/integration/video_upload_no_download_test.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require "test_helper" + +class VideoUploadNoDownloadTest < ActiveSupport::TestCase + test "video file metadata is extracted without full file download" do + video = create(:folio_file_video) + + # Verify metadata was extracted + assert_not_nil video.file_track_duration, "Duration should be extracted" + assert_not_nil video.file_width, "Width should be extracted" + assert_not_nil video.file_height, "Height should be extracted" + + # Verify file_url_or_path returns correct type + result = video.file_url_or_path + assert result.is_a?(String) + + # In test env (FileDataStore), should be local path + if Dragonfly.app.datastore.is_a?(Dragonfly::FileDataStore) + assert_not result.start_with?("http") + end + end +end diff --git a/test/jobs/folio/cra_media_cloud/check_progress_job_test.rb b/test/jobs/folio/cra_media_cloud/check_progress_job_test.rb index 97e850d72..3f24e8f63 100644 --- a/test/jobs/folio/cra_media_cloud/check_progress_job_test.rb +++ b/test/jobs/folio/cra_media_cloud/check_progress_job_test.rb @@ -16,12 +16,10 @@ class TestVideoFile < Folio::File::Video "reference_id" => "REF123" )) - # Job with old generation should be skipped - no new CheckProgressJob enqueued assert_no_enqueued_jobs only: Folio::CraMediaCloud::CheckProgressJob do Folio::CraMediaCloud::CheckProgressJob.perform_now(video, encoding_generation: 11111) end - # Video state should be unchanged video.reload assert_equal "full_media_processing", video.remote_services_data["processing_state"] end @@ -40,7 +38,6 @@ class TestVideoFile < Folio::File::Video api_mock = Minitest::Mock.new api_mock.expect(:get_jobs, [api_response], [], ref_id: "REF123") - # Job with matching generation should process and reschedule assert_enqueued_jobs 1, only: Folio::CraMediaCloud::CheckProgressJob do expect_method_called_on( object: Folio::CraMediaCloud::Api, @@ -66,7 +63,6 @@ class TestVideoFile < Folio::File::Video api_mock = Minitest::Mock.new api_mock.expect(:get_jobs, [api_response], [], ref_id: "REF123") - # Job without generation (old jobs) should still process assert_enqueued_jobs 1, only: Folio::CraMediaCloud::CheckProgressJob do expect_method_called_on( object: Folio::CraMediaCloud::Api, @@ -80,6 +76,260 @@ class TestVideoFile < Folio::File::Video api_mock.verify end + # --- Multi-phase tests --- + + test "phase 1 DONE does not trigger processing_done when processing_phases is 2" do + video = create_test_video_in_processing_state + video.update!(remote_services_data: video.remote_services_data.merge( + "processing_phases" => 2, + "remote_id" => "JOB_PHASE1", + "reference_id" => "REF123" + )) + + phase1_job = { + "id" => "JOB_PHASE1", + "status" => "DONE", + "phase" => 1, + "processingPhases" => 2, + "progress" => 1.0, + "lastModified" => Time.current.iso8601, + "output" => [ + { "type" => "MP4", "profiles" => ["sd0"], "path" => "/video/sd0.mp4" }, + { "type" => "MP4", "profiles" => ["sd1"], "path" => "/video/sd1.mp4" }, + { "type" => "MP4", "profiles" => ["sd2"], "path" => "/video/sd2.mp4" }, + { "type" => "HLS", "profiles" => ["sd0", "sd1", "sd2"], "path" => "/video/sd_master.m3u8" }, + { "type" => "DASH", "profiles" => ["sd0", "sd1", "sd2"], "path" => "/video/sd_manifest.mpd" }, + { "type" => "THUMBNAILS", "profiles" => ["cover"], "path" => "/video/cover.jpg" }, + { "type" => "THUMBNAILS", "profiles" => ["thumb"], "path" => "/video/thumb.vtt" }, + ] + } + + api_mock = Minitest::Mock.new + api_mock.expect(:get_job, phase1_job, ["JOB_PHASE1"]) + + # Should reschedule (phase 1 done, waiting for phase 2) + assert_enqueued_jobs 1, only: Folio::CraMediaCloud::CheckProgressJob do + expect_method_called_on( + object: Folio::CraMediaCloud::Api, + method: :new, + return_value: api_mock + ) do + Folio::CraMediaCloud::CheckProgressJob.perform_now(video) + end + end + + api_mock.verify + video.reload + + # AASM should stay in processing (not ready) + assert_equal "processing", video.aasm_state + assert_equal "full_media_processing", video.remote_services_data["processing_state"] + + # Intermediate phase data should be saved + assert_equal({ "sd0" => "/video/sd0.mp4", "sd1" => "/video/sd1.mp4", "sd2" => "/video/sd2.mp4" }, + video.remote_services_data["phase_1_content_mp4_paths"]) + assert_equal "JOB_PHASE1", video.remote_services_data["phase_1_remote_id"] + assert video.remote_services_data["phase_1_completed_at"].present? + + # Manifest/cover/thumbnails paths populated for immediate playability + assert_equal "/video/sd_master.m3u8", video.remote_services_data["manifest_hls_path"] + assert_equal "/video/sd_manifest.mpd", video.remote_services_data["manifest_dash_path"] + assert_equal "/video/cover.jpg", video.remote_services_data["cover_path"] + assert_equal "/video/thumb.vtt", video.remote_services_data["thumbnails_path"] + end + + test "phase 2 DONE triggers processing_done" do + video = create_test_video_in_processing_state + video.update!(remote_services_data: video.remote_services_data.merge( + "processing_phases" => 2, + "reference_id" => "REF123", + "phase_1_content_mp4_paths" => { "sd0" => "/video/sd0.mp4", "sd1" => "/video/sd1.mp4" }, + "phase_1_completed_at" => 1.minute.ago.iso8601, + "phase_1_remote_id" => "JOB_PHASE1", + )) + + full_output = [ + { "type" => "MP4", "profiles" => ["sd0"], "path" => "/video/sd0.mp4" }, + { "type" => "MP4", "profiles" => ["sd1"], "path" => "/video/sd1.mp4" }, + { "type" => "MP4", "profiles" => ["hd1"], "path" => "/video/hd1.mp4" }, + { "type" => "MP4", "profiles" => ["hd2"], "path" => "/video/hd2.mp4" }, + { "type" => "HLS", "profiles" => ["sd0", "sd1", "hd1", "hd2"], "path" => "/video/master.m3u8" }, + { "type" => "DASH", "profiles" => ["sd0", "sd1", "hd1", "hd2"], "path" => "/video/manifest.mpd" }, + { "type" => "THUMBNAILS", "profiles" => ["cover"], "path" => "/video/cover.jpg" }, + { "type" => "THUMBNAILS", "profiles" => ["thumb"], "path" => "/video/thumb.jpg" }, + ] + + phase1_job = { + "id" => "JOB_PHASE1", "status" => "DONE", "phase" => 1, + "processingPhases" => 2, "progress" => 1.0, + "lastModified" => 2.minutes.ago.iso8601, + "output" => full_output.select { |o| o["profiles"].first&.start_with?("sd") || o["type"] != "MP4" } + } + + phase2_job = { + "id" => "JOB_PHASE2", "status" => "DONE", "phase" => 2, + "processingPhases" => 2, "prevPhaseJobId" => "JOB_PHASE1", + "progress" => 1.0, "lastModified" => Time.current.iso8601, + "output" => full_output + } + + api_mock = Minitest::Mock.new + api_mock.expect(:get_jobs, [phase1_job, phase2_job], [], ref_id: "REF123") + + # Should NOT reschedule — processing is complete + assert_no_enqueued_jobs only: Folio::CraMediaCloud::CheckProgressJob do + expect_method_called_on( + object: Folio::CraMediaCloud::Api, + method: :new, + return_value: api_mock + ) do + Folio::CraMediaCloud::CheckProgressJob.perform_now(video) + end + end + + api_mock.verify + video.reload + + assert_equal "ready", video.aasm_state + assert_equal({ "sd0" => "/video/sd0.mp4", "sd1" => "/video/sd1.mp4", + "hd1" => "/video/hd1.mp4", "hd2" => "/video/hd2.mp4" }, + video.remote_services_data["content_mp4_paths"]) + assert_equal "/video/master.m3u8", video.remote_services_data["manifest_hls_path"] + assert_equal "/video/manifest.mpd", video.remote_services_data["manifest_dash_path"] + end + + test "phase 2 PROCESSING continues polling with mapped progress" do + video = create_test_video_in_processing_state + video.update!(remote_services_data: video.remote_services_data.merge( + "processing_phases" => 2, + "reference_id" => "REF123", + "phase_1_content_mp4_paths" => { "sd0" => "/video/sd0.mp4" }, + )) + + phase1_job = { + "id" => "JOB_PHASE1", "status" => "DONE", "phase" => 1, + "processingPhases" => 2, "progress" => 1.0, + "lastModified" => 2.minutes.ago.iso8601, + "output" => [] + } + + phase2_job = { + "id" => "JOB_PHASE2", "status" => "PROCESSING", "phase" => 2, + "processingPhases" => 2, "progress" => 0.6, + "lastModified" => Time.current.iso8601, + } + + api_mock = Minitest::Mock.new + api_mock.expect(:get_jobs, [phase1_job, phase2_job], [], ref_id: "REF123") + + assert_enqueued_jobs 1, only: Folio::CraMediaCloud::CheckProgressJob do + expect_method_called_on( + object: Folio::CraMediaCloud::Api, + method: :new, + return_value: api_mock + ) do + Folio::CraMediaCloud::CheckProgressJob.perform_now(video) + end + end + + api_mock.verify + video.reload + + # Raw CRA progress for current phase: 0.6 * 100 = 60 + assert_equal 60, video.remote_services_data["progress_percentage"] + assert_equal "processing", video.aasm_state + end + + test "single-phase job backward compat — DONE triggers ready" do + video = create_test_video_in_processing_state + video.update!(remote_services_data: video.remote_services_data.merge( + "reference_id" => "REF123" + )) + # No processing_phases key at all + + full_output = [ + { "type" => "MP4", "profiles" => ["sd0"], "path" => "/video/sd0.mp4" }, + { "type" => "MP4", "profiles" => ["hd1"], "path" => "/video/hd1.mp4" }, + { "type" => "HLS", "profiles" => ["sd0", "hd1"], "path" => "/video/master.m3u8" }, + { "type" => "DASH", "profiles" => ["sd0", "hd1"], "path" => "/video/manifest.mpd" }, + { "type" => "THUMBNAILS", "profiles" => ["cover"], "path" => "/video/cover.jpg" }, + { "type" => "THUMBNAILS", "profiles" => ["thumb"], "path" => "/video/thumb.jpg" }, + ] + + api_response = { + "id" => "JOB123", "status" => "DONE", "progress" => 1.0, + "lastModified" => Time.current.iso8601, + "output" => full_output + } + + api_mock = Minitest::Mock.new + api_mock.expect(:get_jobs, [api_response], [], ref_id: "REF123") + + assert_no_enqueued_jobs only: Folio::CraMediaCloud::CheckProgressJob do + expect_method_called_on( + object: Folio::CraMediaCloud::Api, + method: :new, + return_value: api_mock + ) do + Folio::CraMediaCloud::CheckProgressJob.perform_now(video) + end + end + + api_mock.verify + video.reload + + assert_equal "ready", video.aasm_state + assert_equal({ "sd0" => "/video/sd0.mp4", "hd1" => "/video/hd1.mp4" }, + video.remote_services_data["content_mp4_paths"]) + assert_equal "/video/master.m3u8", video.remote_services_data["manifest_hls_path"] + assert_equal "/video/manifest.mpd", video.remote_services_data["manifest_dash_path"] + end + + test "phase 2 FAILED triggers failure" do + video = create_test_video_in_processing_state + video.update!(remote_services_data: video.remote_services_data.merge( + "processing_phases" => 2, + "reference_id" => "REF123", + "phase_1_content_mp4_paths" => { "sd0" => "/video/sd0.mp4" }, + )) + + phase1_job = { + "id" => "JOB_PHASE1", "status" => "DONE", "phase" => 1, + "processingPhases" => 2, "progress" => 1.0, + "lastModified" => 2.minutes.ago.iso8601, + "output" => [] + } + + phase2_job = { + "id" => "JOB_PHASE2", "status" => "FAILED", "phase" => 2, + "processingPhases" => 2, "progress" => 0.3, + "lastModified" => Time.current.iso8601, + "messages" => [{ "type" => "ERROR", "message" => "HD encoding failed" }] + } + + api_mock = Minitest::Mock.new + api_mock.expect(:get_jobs, [phase1_job, phase2_job], [], ref_id: "REF123") + + # Should NOT reschedule — failure stops polling + assert_no_enqueued_jobs only: Folio::CraMediaCloud::CheckProgressJob do + expect_method_called_on( + object: Folio::CraMediaCloud::Api, + method: :new, + return_value: api_mock + ) do + Folio::CraMediaCloud::CheckProgressJob.perform_now(video) + end + end + + api_mock.verify + video.reload + + assert_equal "encoding_failed", video.remote_services_data["processing_state"] + assert_equal "HD encoding failed", video.remote_services_data["error_message"] + end + + # --- Existing encoding generation tests --- + test "skips already ready video regardless of encoding_generation" do video = create_test_video_in_processing_state video.update_column(:aasm_state, "ready") @@ -88,24 +338,294 @@ class TestVideoFile < Folio::File::Video "reference_id" => "REF123" )) - # Should skip because video is already ready assert_no_enqueued_jobs only: Folio::CraMediaCloud::CheckProgressJob do Folio::CraMediaCloud::CheckProgressJob.perform_now(video, encoding_generation: 12345) end end + # --- Progress tracking tests --- + + test "parses encoding messages for progress milestones" do + video = create_test_video_in_processing_state + video.update!(remote_services_data: video.remote_services_data.merge( + "processing_state" => "full_media_processing", + "reference_id" => "REF123" + )) + + api_response = { + "id" => "JOB123", "status" => "PROCESSING", "progress" => 0.5, + "lastModified" => Time.current.iso8601, + "outputParams" => { "duration" => 600.0 }, + "messages" => [ + { "createdDate" => "2026-02-25T10:00:00Z", "type" => "INFO", "message" => "validation started at host vodenc1" }, + { "createdDate" => "2026-02-25T10:00:05Z", "type" => "INFO", "message" => "processing started at host vodenc1" }, + { "createdDate" => "2026-02-25T10:00:06Z", "type" => "INFO", "message" => "Transcoding worker - video: going to transcode 600.0 seconds for 7 VIDEO profiles" }, + { "createdDate" => "2026-02-25T10:00:06Z", "type" => "INFO", "message" => "Transcoding worker - audio: going to transcode 600.0 seconds for 2 AUDIO profiles" }, + { "createdDate" => "2026-02-25T10:02:00Z", "type" => "INFO", "message" => "Transcoding worker - audio: finished" } + ] + } + + api_mock = Minitest::Mock.new + api_mock.expect(:get_jobs, [api_response], [], ref_id: "REF123") + + expect_method_called_on( + object: Folio::CraMediaCloud::Api, + method: :new, + return_value: api_mock + ) do + Folio::CraMediaCloud::CheckProgressJob.perform_now(video) + end + + video.reload + assert_equal 600.0, video.remote_services_data["video_duration"] + assert_includes video.remote_services_data["phases_completed"], "audio" + end + + test "DONE transition sets progress to 100 and state to ready" do + video = create_test_video_in_processing_state + video.update!(remote_services_data: video.remote_services_data.merge( + "processing_state" => "full_media_processing", + "reference_id" => "REF123" + )) + + output = [ + { "type" => "MP4", "profiles" => ["sd1"], "path" => "/test/sd1.mp4" }, + { "type" => "MP4", "profiles" => ["hd1"], "path" => "/test/hd1.mp4" }, + { "type" => "HLS", "profiles" => ["sd1", "hd1"], "path" => "/test/master.m3u8" }, + { "type" => "DASH", "profiles" => ["sd1", "hd1"], "path" => "/test/master.mpd" }, + { "type" => "THUMBNAILS", "profiles" => ["cover"], "path" => "/test/cover.jpg" }, + { "type" => "THUMBNAILS", "profiles" => ["thumb"], "path" => "/test/thumb.jpg" } + ] + + api_response = { + "id" => "JOB123", "status" => "DONE", "progress" => 1.0, + "lastModified" => Time.current.iso8601, + "output" => output, + "outputParams" => { "duration" => 120.0 }, + "messages" => [] + } + + api_mock = Minitest::Mock.new + api_mock.expect(:get_jobs, [api_response], [], ref_id: "REF123") + + expect_method_called_on( + object: Folio::CraMediaCloud::Api, + method: :new, + return_value: api_mock + ) do + Folio::CraMediaCloud::CheckProgressJob.perform_now(video) + end + + video.reload + assert_equal "full_media_processed", video.remote_services_data["processing_state"] + assert_equal 100.0, video.remote_services_data["progress_percentage"] + assert_equal "ready", video.aasm_state + end + + test "FAILED job transitions to processing_failed and schedules retry on first failure" do + video = create_test_video_in_processing_state + video.update!(remote_services_data: video.remote_services_data.merge( + "processing_state" => "full_media_processing", + "reference_id" => "REF123", + "progress_percentage" => 45.0 + )) + + api_response = { + "id" => "JOB123", "status" => "FAILED", + "lastModified" => Time.current.iso8601, + "messages" => [ + { "type" => "ERROR", "message" => "filesize mismatch" } + ] + } + + api_mock = Minitest::Mock.new + api_mock.expect(:get_jobs, [api_response], [], ref_id: "REF123") + + assert_enqueued_jobs 1, only: Folio::CraMediaCloud::CreateMediaJob do + expect_method_called_on( + object: Folio::CraMediaCloud::Api, + method: :new, + return_value: api_mock + ) do + Folio::CraMediaCloud::CheckProgressJob.perform_now(video) + end + end + + video.reload + assert_equal "processing_failed", video.aasm_state + assert_nil video.remote_services_data["progress_percentage"] + assert_equal "filesize mismatch", video.remote_services_data["error_message"] + assert_equal 1, video.remote_services_data["retry_count"] + assert video.remote_services_data["retry_scheduled_at"].present? + end + + test "FAILED job on second failure is final — no retry scheduled" do + video = create_test_video_in_processing_state + video.update!(remote_services_data: video.remote_services_data.merge( + "processing_state" => "full_media_processing", + "reference_id" => "REF123", + "retry_count" => 1 + )) + + api_response = { + "id" => "JOB123", "status" => "FAILED", + "lastModified" => Time.current.iso8601, + "messages" => [ + { "type" => "ERROR", "message" => "filesize mismatch again" } + ] + } + + api_mock = Minitest::Mock.new + api_mock.expect(:get_jobs, [api_response], [], ref_id: "REF123") + + assert_no_enqueued_jobs only: Folio::CraMediaCloud::CreateMediaJob do + expect_method_called_on( + object: Folio::CraMediaCloud::Api, + method: :new, + return_value: api_mock + ) do + Folio::CraMediaCloud::CheckProgressJob.perform_now(video) + end + end + + video.reload + assert_equal "processing_failed", video.aasm_state + assert_equal 2, video.remote_services_data["retry_count"] + assert_nil video.remote_services_data["retry_scheduled_at"] + end + + # --- Timeout tests --- + + test "processing_timed_out? marks video as failed after 4 hours" do + video = create_test_video_in_processing_state + video.update!(remote_services_data: video.remote_services_data.merge( + "processing_step_started_at" => 5.hours.ago.iso8601, + "reference_id" => "REF123" + )) + + assert_no_enqueued_jobs only: Folio::CraMediaCloud::CheckProgressJob do + Folio::CraMediaCloud::CheckProgressJob.perform_now(video) + end + + video.reload + assert_equal "processing_failed", video.aasm_state + end + + test "processing_timed_out? does not fire within 4 hours" do + video = create_test_video_in_processing_state + video.update!(remote_services_data: video.remote_services_data.merge( + "processing_step_started_at" => 3.hours.ago.iso8601, + "reference_id" => "REF123" + )) + + api_response = { "id" => "JOB123", "status" => "PROCESSING", "progress" => 0.5, + "lastModified" => Time.current.iso8601 } + api_mock = Minitest::Mock.new + api_mock.expect(:get_jobs, [api_response], [], ref_id: "REF123") + + assert_enqueued_jobs 1, only: Folio::CraMediaCloud::CheckProgressJob do + expect_method_called_on( + object: Folio::CraMediaCloud::Api, + method: :new, + return_value: api_mock + ) do + Folio::CraMediaCloud::CheckProgressJob.perform_now(video) + end + end + + video.reload + assert_equal "processing", video.aasm_state + end + + # --- Finalize from completed phases test --- + + test "finalizes from stored phase data when all CRA jobs are REMOVED" do + video = create_test_video_in_processing_state + video.update!(remote_services_data: video.remote_services_data.merge( + "processing_phases" => 2, + "reference_id" => "REF123", + "phase_1_content_mp4_paths" => { "sd0" => "/video/sd0.mp4", "sd1" => "/video/sd1.mp4" }, + "phase_1_completed_at" => 5.minutes.ago.iso8601, + "phase_1_remote_id" => "JOB_PHASE1", + "phase_2_content_mp4_paths" => { "hd1" => "/video/hd1.mp4", "hd2" => "/video/hd2.mp4" }, + "phase_2_completed_at" => 1.minute.ago.iso8601, + "phase_2_remote_id" => "JOB_PHASE2", + "manifest_hls_path" => "/video/master.m3u8", + "manifest_dash_path" => "/video/manifest.mpd", + )) + + removed_jobs = [ + { "id" => "JOB_PHASE1", "status" => "REMOVED", "phase" => 1, "lastModified" => 2.minutes.ago.iso8601 }, + { "id" => "JOB_PHASE2", "status" => "REMOVED", "phase" => 2, "lastModified" => 1.minute.ago.iso8601 }, + ] + + api_mock = Minitest::Mock.new + api_mock.expect(:get_jobs, removed_jobs, [], ref_id: "REF123") + + assert_no_enqueued_jobs only: Folio::CraMediaCloud::CheckProgressJob do + expect_method_called_on( + object: Folio::CraMediaCloud::Api, + method: :new, + return_value: api_mock + ) do + Folio::CraMediaCloud::CheckProgressJob.perform_now(video) + end + end + + api_mock.verify + video.reload + + assert_equal "ready", video.aasm_state + assert_equal "full_media_processed", video.remote_services_data["processing_state"] + assert_equal 100.0, video.remote_services_data["progress_percentage"] + expected_mp4 = { "sd0" => "/video/sd0.mp4", "sd1" => "/video/sd1.mp4", + "hd1" => "/video/hd1.mp4", "hd2" => "/video/hd2.mp4" } + assert_equal expected_mp4, video.remote_services_data["content_mp4_paths"] + end + + # --- REMOVED remote_id handling --- + + test "clears remote_id and reschedules when tracked job becomes REMOVED" do + video = create_test_video_in_processing_state + video.update!(remote_services_data: video.remote_services_data.merge( + "remote_id" => "JOB_GONE", + "reference_id" => "REF123" + )) + + removed_job = { "id" => "JOB_GONE", "status" => "REMOVED", "lastModified" => Time.current.iso8601 } + + api_mock = Minitest::Mock.new + api_mock.expect(:get_job, removed_job, ["JOB_GONE"]) + + assert_enqueued_jobs 1, only: Folio::CraMediaCloud::CheckProgressJob do + expect_method_called_on( + object: Folio::CraMediaCloud::Api, + method: :new, + return_value: api_mock + ) do + Folio::CraMediaCloud::CheckProgressJob.perform_now(video) + end + end + + api_mock.verify + video.reload + + # remote_id cleared so next poll falls back to reference_id path + assert_nil video.remote_services_data["remote_id"] + # AASM stays in processing — not marked failed + assert_equal "processing", video.aasm_state + end + private def create_test_video_in_processing_state video = TestVideoFile.new(site: get_any_site) video.file = Folio::Engine.root.join("test/fixtures/folio/blank.mp4") video.dont_run_after_save_jobs = true - # Stub create_full_media to prevent the full processing chain during save expect_method_called_on(object: video, method: :create_full_media) do video.save! end - # Set desired initial state (merge to preserve encoding_generation from process_attached_file) video.update!(remote_services_data: video.remote_services_data.merge( "service" => "cra_media_cloud", "processing_state" => "full_media_processing" diff --git a/test/jobs/folio/cra_media_cloud/create_media_job_test.rb b/test/jobs/folio/cra_media_cloud/create_media_job_test.rb index 6a27acbc4..e0005a2e3 100644 --- a/test/jobs/folio/cra_media_cloud/create_media_job_test.rb +++ b/test/jobs/folio/cra_media_cloud/create_media_job_test.rb @@ -14,54 +14,205 @@ class TestVideoFile < Folio::File::Video "encoding_generation" => generation_value )) - # Mock S3 metadata for reference_id generation - s3_metadata_mock = Struct.new(:etag).new('"abc12345def67890"') + with_mocked_s3_and_encoder(video) do |encoder_mock, api_mock| + encoder_mock.expect(:upload_file, nil, [video], profile_group: nil, processing_phases: 1, reference_id: String) + api_mock.expect(:get_jobs, [], [], ref_id: String) + + assert_enqueued_jobs 1, only: Folio::CraMediaCloud::CheckProgressJob do + perform_job(video, encoder_mock, api_mock) + end + end + + video.reload + assert_equal generation_value, video.encoding_generation, + "encoding_generation should be preserved through CreateMediaJob" + end + + test "submits single manifest and sets full_media_processing state" do + video = create_test_video_in_processing_state + + with_mocked_s3_and_encoder(video) do |encoder_mock, api_mock| + encoder_mock.expect(:upload_file, nil, [video], profile_group: nil, processing_phases: 1, reference_id: String) + api_mock.expect(:get_jobs, [], [], ref_id: String) + + perform_job(video, encoder_mock, api_mock) + encoder_mock.verify + end + + video.reload + assert_equal "full_media_processing", video.remote_services_data["processing_state"] + end + + test "passes processing_phases to encoder when video defines it" do + video = create_test_video_in_processing_state + video.define_singleton_method(:encoder_processing_phases) { 2 } + + with_mocked_s3_and_encoder(video) do |encoder_mock, api_mock| + encoder_mock.expect(:upload_file, nil, [video], + profile_group: nil, processing_phases: 2, reference_id: String) + api_mock.expect(:get_jobs, [], [], ref_id: String) + + assert_enqueued_jobs 1, only: Folio::CraMediaCloud::CheckProgressJob do + perform_job(video, encoder_mock, api_mock) + end + + encoder_mock.verify + end + + video.reload + assert_equal 2, video.remote_services_data["processing_phases"] + end + + test "check_existing_job: DONE returns :done" do + video = create_test_video_in_processing_state + + mock_api = Minitest::Mock.new + mock_api.expect(:get_jobs, [ + { "id" => 1, "refId" => "test-abc123", "status" => "DONE", + "profileGroup" => "VoD", "lastModified" => "2026-01-01T00:00:00Z", + "messages" => [], "output" => [] }, + ], [], ref_id: "test-abc123") + + job_instance = Folio::CraMediaCloud::CreateMediaJob.new + + Folio::CraMediaCloud::Api.stub(:new, mock_api) do + result = job_instance.send(:check_existing_job, "test-abc123", video) + assert_equal :done, result[:status] + end + end + + test "check_existing_job: picks latest job when multiple exist" do + video = create_test_video_in_processing_state + + mock_api = Minitest::Mock.new + mock_api.expect(:get_jobs, [ + { "id" => 1, "refId" => "test-abc123", "status" => "FAILED", + "profileGroup" => "VoD", "lastModified" => "2026-01-01T00:00:00Z", + "messages" => [], "output" => [] }, + { "id" => 2, "refId" => "test-abc123", "status" => "DONE", + "profileGroup" => "VoD", "lastModified" => "2026-01-02T00:00:00Z", + "messages" => [], "output" => [] }, + ], [], ref_id: "test-abc123") + + job_instance = Folio::CraMediaCloud::CreateMediaJob.new + + Folio::CraMediaCloud::Api.stub(:new, mock_api) do + result = job_instance.send(:check_existing_job, "test-abc123", video) + assert_equal :done, result[:status] + assert_equal 2, result[:job]["id"] + end + end + + test "check_existing_job: empty jobs returns :not_found" do + video = create_test_video_in_processing_state + + mock_api = Minitest::Mock.new + mock_api.expect(:get_jobs, [], [], ref_id: "test-abc123") + + job_instance = Folio::CraMediaCloud::CreateMediaJob.new + + Folio::CraMediaCloud::Api.stub(:new, mock_api) do + result = job_instance.send(:check_existing_job, "test-abc123", video) + assert_equal :not_found, result[:status] + end + end + + test "marks video as permanently failed when S3 source file is missing" do + video = create_test_video_in_processing_state + + # Mock S3 datastore to raise NotFound (simulates missing source file) s3_datastore_mock = Minitest::Mock.new storage_mock = Minitest::Mock.new - storage_mock.expect(:head_object, s3_metadata_mock, [String, String]) + storage_mock.expect(:head_object, nil) do |*_args| + raise Excon::Error::NotFound.new("Expected(200) <=> Actual(404 Not Found)") + end s3_datastore_mock.expect(:root_path, "uploads") s3_datastore_mock.expect(:storage, storage_mock) - # Mock encoder - encoder_mock = Minitest::Mock.new - encoder_mock.expect(:upload_file, nil, [video], profile_group: nil, reference_id: String) - - # Mock API for existing job check - api_mock = Minitest::Mock.new - api_mock.expect(:get_jobs, [], [], ref_id: String) - - assert_enqueued_jobs 1, only: Folio::CraMediaCloud::CheckProgressJob do + ENV["S3_BUCKET_NAME"] = "test-bucket" + begin Dragonfly.app.stub(:datastore, s3_datastore_mock) do - Folio::CraMediaCloud::Encoder.stub(:new, encoder_mock) do - Folio::CraMediaCloud::Api.stub(:new, api_mock) do - Folio::CraMediaCloud::CreateMediaJob.perform_now(video) - end + assert_no_enqueued_jobs only: Folio::CraMediaCloud::CheckProgressJob do + Folio::CraMediaCloud::CreateMediaJob.perform_now(video) end end + ensure + ENV.delete("S3_BUCKET_NAME") end - # Verify encoding_generation is preserved in remote_services_data video.reload - assert_equal generation_value, video.encoding_generation, - "encoding_generation should be preserved through CreateMediaJob" + assert_equal "processing_failed", video.aasm_state + assert_equal "source_file_missing", video.remote_services_data["processing_state"] + assert_includes video.remote_services_data["error_message"], "Source file not found" + end + + test "retries from processing_failed state via retry_processing!" do + video = create_test_video_in_processing_state + video.update_column(:aasm_state, "processing_failed") + video.update!(remote_services_data: video.remote_services_data.merge( + "retry_count" => 1, + "retry_scheduled_at" => Time.current.iso8601 + )) + + with_mocked_s3_and_encoder(video) do |encoder_mock, api_mock| + encoder_mock.expect(:upload_file, nil, [video], profile_group: nil, processing_phases: 1, reference_id: String) + api_mock.expect(:get_jobs, [], [], ref_id: String) + + assert_enqueued_jobs 1, only: Folio::CraMediaCloud::CheckProgressJob do + perform_job(video, encoder_mock, api_mock) + end + end + + video.reload + assert_equal "processing", video.aasm_state + assert_equal "full_media_processing", video.remote_services_data["processing_state"] end private - def create_test_video_in_processing_state - video = TestVideoFile.new(site: get_any_site) + def create_test_video_in_processing_state(klass: TestVideoFile) + video = klass.new(site: get_any_site) video.file = Folio::Engine.root.join("test/fixtures/folio/blank.mp4") video.dont_run_after_save_jobs = true - # Stub create_full_media to prevent the full processing chain during save expect_method_called_on(object: video, method: :create_full_media) do video.save! end - # Set desired initial state (merge to preserve encoding_generation from process_attached_file) video.update!(remote_services_data: video.remote_services_data.merge( "service" => "cra_media_cloud", "processing_state" => "full_media_processing" )) video end + + def with_mocked_s3_and_encoder(video) + s3_metadata_mock = Struct.new(:etag).new('"abc12345def67890"') + s3_datastore_mock = Minitest::Mock.new + storage_mock = Minitest::Mock.new + + # head_object is called with bucket_name (ENV) and key — allow any args + storage_mock.expect(:head_object, s3_metadata_mock) do |*_args| + true + end + s3_datastore_mock.expect(:root_path, "uploads") + s3_datastore_mock.expect(:storage, storage_mock) + + encoder_mock = Minitest::Mock.new + api_mock = Minitest::Mock.new + + ENV["S3_BUCKET_NAME"] = "test-bucket" + Dragonfly.app.stub(:datastore, s3_datastore_mock) do + yield encoder_mock, api_mock + end + ensure + ENV.delete("S3_BUCKET_NAME") + end + + def perform_job(video, encoder_mock, api_mock) + Folio::CraMediaCloud::Encoder.stub(:new, encoder_mock) do + Folio::CraMediaCloud::Api.stub(:new, api_mock) do + Folio::CraMediaCloud::CreateMediaJob.perform_now(video) + end + end + end end diff --git a/test/jobs/folio/cra_media_cloud/encoder_test.rb b/test/jobs/folio/cra_media_cloud/encoder_test.rb new file mode 100644 index 000000000..610173dfe --- /dev/null +++ b/test/jobs/folio/cra_media_cloud/encoder_test.rb @@ -0,0 +1,195 @@ +# frozen_string_literal: true + +require "test_helper" + +class Folio::CraMediaCloud::EncoderTest < ActiveSupport::TestCase + test "build_ingest_manifest uses src attribute with presigned URL" do + encoder = Folio::CraMediaCloud::Encoder.new + + file_mock = Struct.new(:file_name, :file_size, :file_uid, :id).new( + "video.mp4", 123456, "uploads/video.mp4", 1 + ) + + presigned_url = "https://s3.amazonaws.com/bucket/uploads/video.mp4?X-Amz-Credential=xxx&X-Amz-Expires=604800" + + manifest_xml = encoder.send( + :build_ingest_manifest, + file_mock, + md5: "abc123def456", + ref_id: "test-ref-001", + profile_group: "VoDSD", + presigned_url: presigned_url + ) + + assert_includes manifest_xml, 'src="https://s3.amazonaws.com/bucket/uploads/video.mp4' + assert_not_includes manifest_xml, 'file=' + assert_includes manifest_xml, 'size="123456"' + assert_includes manifest_xml, 'md5="abc123def456"' + assert_includes manifest_xml, "VoDSD" + assert_includes manifest_xml, "test-ref-001" + end + + test "build_ingest_manifest falls back to file attribute when no presigned URL" do + encoder = Folio::CraMediaCloud::Encoder.new + + file_mock = Struct.new(:file_name, :file_size, :file_uid, :id).new( + "video.mp4", 123456, "uploads/video.mp4", 1 + ) + + manifest_xml = encoder.send( + :build_ingest_manifest, + file_mock, + md5: "abc123def456", + ref_id: "test-ref-001", + profile_group: "VoD", + presigned_url: nil + ) + + assert_includes manifest_xml, 'file="video.mp4"' + assert_not_includes manifest_xml, 'src=' + end + + # --- upload_file --- + + test "upload_file builds manifest and uploads it via SFTP, returns result hash" do + encoder = Folio::CraMediaCloud::Encoder.new + + file_mock = Struct.new(:file_name, :file_size, :file_uid, :id, :slug).new( + "video.mp4", 123456, "uploads/video.mp4", 42, "my-video" + ) + + s3_metadata_mock = Struct.new(:headers).new({ "ETag" => '"abcd1234"' }) + fake_presigned_url = "https://s3.amazonaws.com/bucket/video.mp4?X-Amz-Expires=604800" + + uploaded_path = nil + uploaded_xml = nil + fake_sftp = Object.new + fake_sftp.define_singleton_method(:upload!) do |source, dest| + uploaded_path = dest + uploaded_xml = source.read + end + + encoder.define_singleton_method(:with_robust_sftp_session) { |&blk| blk.call(fake_sftp) } + + result = encoder.stub(:s3_dragonfly_head_object, s3_metadata_mock) do + encoder.stub(:generate_presigned_url, fake_presigned_url) do + encoder.upload_file(file_mock, reference_id: "test-ref-001") + end + end + + assert_equal "test-ref-001", result[:ref_id] + assert_equal "/ingest/regular/test-ref-001_manifest.xml", result[:xml_manifest_path] + assert result[:presigned_url], "presigned_url flag should be truthy" + assert_equal "/ingest/regular/test-ref-001_manifest.xml", uploaded_path + assert_includes uploaded_xml, "test-ref-001" + assert_includes uploaded_xml, fake_presigned_url + end + + test "upload_file uses provided reference_id in SFTP path" do + encoder = Folio::CraMediaCloud::Encoder.new + + file_mock = Struct.new(:file_name, :file_size, :file_uid, :id, :slug).new( + "video.mp4", 100, "uploads/video.mp4", 1, "slug" + ) + + s3_metadata_mock = Struct.new(:headers).new({ "ETag" => '"ff00ff00"' }) + uploaded_path = nil + fake_sftp = Object.new + fake_sftp.define_singleton_method(:upload!) { |_src, dest| uploaded_path = dest } + + encoder.define_singleton_method(:with_robust_sftp_session) { |&blk| blk.call(fake_sftp) } + + encoder.stub(:s3_dragonfly_head_object, s3_metadata_mock) do + encoder.stub(:generate_presigned_url, "https://s3.example.com/v.mp4") do + encoder.upload_file(file_mock, reference_id: "custom-ref-xyz") + end + end + + assert_equal "/ingest/regular/custom-ref-xyz_manifest.xml", uploaded_path + end + + # --- upload_with_retry --- + + test "upload_with_retry raises immediately when max_retries is 0" do + encoder = Folio::CraMediaCloud::Encoder.new + + failing_sftp = Object.new + failing_sftp.define_singleton_method(:upload!) { |_, _| raise "network error" } + + err = assert_raises(RuntimeError) do + encoder.send(:upload_with_retry, failing_sftp, StringIO.new("data"), "/dest/manifest.xml", max_retries: 0) + end + assert_match "network error", err.message + end + + test "upload_with_retry retries on transient failure and succeeds on next attempt" do + encoder = Folio::CraMediaCloud::Encoder.new + encoder.define_singleton_method(:sleep) { |_| } # no-op to avoid real sleep in tests + + attempts = 0 + flaky_sftp = Object.new + flaky_sftp.define_singleton_method(:upload!) do |_src, _dest| + attempts += 1 + raise "transient error" if attempts < 2 + end + + encoder.send(:upload_with_retry, flaky_sftp, StringIO.new("data"), "/dest/manifest.xml", max_retries: 1) + + assert_equal 2, attempts + end + + test "upload_with_retry raises after all retries exhausted" do + encoder = Folio::CraMediaCloud::Encoder.new + encoder.define_singleton_method(:sleep) { |_| } + + attempts = 0 + always_fail_sftp = Object.new + always_fail_sftp.define_singleton_method(:upload!) do |_, _| + attempts += 1 + raise "persistent error" + end + + assert_raises(RuntimeError, /persistent error/) do + encoder.send(:upload_with_retry, always_fail_sftp, StringIO.new("data"), "/dest/manifest.xml", max_retries: 2) + end + + assert_equal 3, attempts # 1 initial + 2 retries + end + + # --- with_robust_sftp_session --- + + test "with_robust_sftp_session wraps SSH authentication failure" do + encoder = Folio::CraMediaCloud::Encoder.new + + # ENV vars must be present so Net::SSH.start is actually reached (before the stub fires) + ENV["CRA_MEDIA_CLOUD_SFTP_HOST"] = "sftp.example.com" + ENV["CRA_MEDIA_CLOUD_SFTP_USERNAME"] = "user" + ENV["CRA_MEDIA_CLOUD_SFTP_PASSWORD"] = "pass" + + Net::SSH.stub(:start, ->(*_args, **_kwargs) { raise Net::SSH::AuthenticationFailed, "bad credentials" }) do + err = assert_raises(RuntimeError) do + encoder.send(:with_robust_sftp_session) { |_sftp| } + end + assert_match "SSH authentication failed", err.message + end + ensure + %w[CRA_MEDIA_CLOUD_SFTP_HOST CRA_MEDIA_CLOUD_SFTP_USERNAME CRA_MEDIA_CLOUD_SFTP_PASSWORD].each { |k| ENV.delete(k) } + end + + test "with_robust_sftp_session wraps generic SFTP errors" do + encoder = Folio::CraMediaCloud::Encoder.new + + ENV["CRA_MEDIA_CLOUD_SFTP_HOST"] = "sftp.example.com" + ENV["CRA_MEDIA_CLOUD_SFTP_USERNAME"] = "user" + ENV["CRA_MEDIA_CLOUD_SFTP_PASSWORD"] = "pass" + + Net::SSH.stub(:start, ->(*_args, **_kwargs) { raise "connection refused" }) do + err = assert_raises(RuntimeError) do + encoder.send(:with_robust_sftp_session) { |_sftp| } + end + assert_match "SFTP session error", err.message + end + ensure + %w[CRA_MEDIA_CLOUD_SFTP_HOST CRA_MEDIA_CLOUD_SFTP_USERNAME CRA_MEDIA_CLOUD_SFTP_PASSWORD].each { |k| ENV.delete(k) } + end +end diff --git a/test/jobs/folio/cra_media_cloud/monitor_processing_job_test.rb b/test/jobs/folio/cra_media_cloud/monitor_processing_job_test.rb index 0fbcd1225..79ad591e7 100644 --- a/test/jobs/folio/cra_media_cloud/monitor_processing_job_test.rb +++ b/test/jobs/folio/cra_media_cloud/monitor_processing_job_test.rb @@ -78,6 +78,125 @@ def eval(*); end # no-op for lock release assert_equal "processing_failed", video.aasm_state end + test "rescues failed video awaiting retry when retry job is lost" do + video = create(:folio_file_video) + video.update!( + aasm_state: :processing_failed, + remote_services_data: { + "service" => "cra_media_cloud", + "retry_count" => 1, + "retry_scheduled_at" => 10.minutes.ago.iso8601, + } + ) + + with_unlocked_monitor_job do + assert_enqueued_jobs 1, only: Folio::CraMediaCloud::CreateMediaJob do + Folio::CraMediaCloud::MonitorProcessingJob.perform_now + end + end + end + + test "does not rescue finally failed video (retry_count >= 2)" do + video = create(:folio_file_video) + video.update!( + aasm_state: :processing_failed, + remote_services_data: { + "service" => "cra_media_cloud", + "retry_count" => 2, + } + ) + + with_unlocked_monitor_job do + assert_no_enqueued_jobs only: Folio::CraMediaCloud::CreateMediaJob do + Folio::CraMediaCloud::MonitorProcessingJob.perform_now + end + end + end + + test "triggers process! for stuck unprocessed video with file_uid" do + video = create(:folio_file_video) + video.update_columns( + aasm_state: "unprocessed", + file_uid: "2026/03/09/13/20/26/test-uuid/test.mp4", + created_at: 10.minutes.ago + ) + + with_unlocked_monitor_job do + Folio::CraMediaCloud::MonitorProcessingJob.perform_now + end + + video.reload + assert_not_equal "unprocessed", video.aasm_state, "Video should no longer be unprocessed after safety net" + end + + test "does not trigger process! for recently created unprocessed video" do + video = create(:folio_file_video) + video.update_columns( + aasm_state: "unprocessed", + file_uid: "2026/03/09/13/20/26/test-uuid/test.mp4", + created_at: 2.minutes.ago + ) + + with_unlocked_monitor_job do + Folio::CraMediaCloud::MonitorProcessingJob.perform_now + end + + video.reload + assert_equal "unprocessed", video.aasm_state + end + + test "does not trigger process! for unprocessed video without file_uid" do + video = create(:folio_file_video) + video.update_columns( + aasm_state: "unprocessed", + file_uid: nil, + created_at: 10.minutes.ago + ) + + with_unlocked_monitor_job do + Folio::CraMediaCloud::MonitorProcessingJob.perform_now + end + + video.reload + assert_equal "unprocessed", video.aasm_state + end + + test "rescues video stuck in enqueued state for over 10 minutes" do + video = create(:folio_file_video) + video.update!( + aasm_state: :processing, + remote_services_data: { + "service" => "cra_media_cloud", + "processing_state" => "enqueued", + "processing_step_started_at" => 15.minutes.ago.iso8601 + } + ) + + with_unlocked_monitor_job do + assert_enqueued_jobs 1, only: Folio::CraMediaCloud::CreateMediaJob do + Folio::CraMediaCloud::MonitorProcessingJob.perform_now + end + end + end + + test "does not rescue freshly enqueued video" do + video = create(:folio_file_video) + video.update!( + aasm_state: :processing, + remote_services_data: { + "service" => "cra_media_cloud", + "processing_state" => "enqueued", + "processing_step_started_at" => 3.minutes.ago.iso8601 + } + ) + + with_unlocked_monitor_job do + assert_no_enqueued_jobs only: Folio::CraMediaCloud::CreateMediaJob do + Folio::CraMediaCloud::MonitorProcessingJob.perform_now + end + end + end + test "upload_is_stuck? returns false for small file within timeout" do video = create(:folio_file_video, file_size: 10.megabytes) upload_started_at = 2.minutes.ago @@ -152,4 +271,149 @@ def eval(*); end # no-op for lock release # Should use base timeout of 5 minutes assert_equal false, result end + + # --- handle_failed_uploads_needing_retry --- + + test "schedules CreateMediaJob for upload_failed video older than 5 minutes" do + video = create(:folio_file_video) + video.update!( + aasm_state: :processing, + remote_services_data: { + "service" => "cra_media_cloud", + "processing_state" => "upload_failed", + "processing_step_started_at" => 10.minutes.ago.iso8601 + } + ) + + job = Folio::CraMediaCloud::MonitorProcessingJob.new + + assert_enqueued_jobs 1, only: Folio::CraMediaCloud::CreateMediaJob do + job.send(:handle_failed_uploads_needing_retry) + end + end + + test "schedules CreateMediaJob for encoding_failed video older than 5 minutes" do + video = create(:folio_file_video) + video.update!( + aasm_state: :processing, + remote_services_data: { + "service" => "cra_media_cloud", + "processing_state" => "encoding_failed", + "processing_step_started_at" => 10.minutes.ago.iso8601 + } + ) + + job = Folio::CraMediaCloud::MonitorProcessingJob.new + + assert_enqueued_jobs 1, only: Folio::CraMediaCloud::CreateMediaJob do + job.send(:handle_failed_uploads_needing_retry) + end + end + + test "does not retry upload_failed video within 5 minutes" do + video = create(:folio_file_video) + video.update!( + aasm_state: :processing, + remote_services_data: { + "service" => "cra_media_cloud", + "processing_state" => "upload_failed", + "processing_step_started_at" => 3.minutes.ago.iso8601 + } + ) + + job = Folio::CraMediaCloud::MonitorProcessingJob.new + + assert_no_enqueued_jobs only: Folio::CraMediaCloud::CreateMediaJob do + job.send(:handle_failed_uploads_needing_retry) + end + end + + # --- reconcile_video_state --- + + test "reconcile_video_state schedules CheckProgressJob and updates remote_id when API finds active job" do + video = create(:folio_file_video) + video.update!( + aasm_state: :processing, + remote_services_data: { + "service" => "cra_media_cloud", + "processing_state" => "full_media_processing", + "reference_id" => "REF456", + "encoding_generation" => 99 + } + ) + + active_job = { "id" => "JOB_ACTIVE", "status" => "PROCESSING", "lastModified" => Time.current.iso8601 } + api_mock = Minitest::Mock.new + api_mock.expect(:get_jobs, [active_job], [], ref_id: "REF456") + + job = Folio::CraMediaCloud::MonitorProcessingJob.new + + Folio::CraMediaCloud::Api.stub(:new, api_mock) do + assert_enqueued_jobs 1, only: Folio::CraMediaCloud::CheckProgressJob do + job.send(:reconcile_video_state, video) + end + end + + api_mock.verify + video.reload + assert_equal "JOB_ACTIVE", video.remote_services_data["remote_id"] + end + + test "reconcile_video_state clears reference_id and processing_state when API finds no jobs" do + video = create(:folio_file_video) + video.update!( + aasm_state: :processing, + remote_services_data: { + "service" => "cra_media_cloud", + "processing_state" => "full_media_processing", + "reference_id" => "REF456" + } + ) + + api_mock = Minitest::Mock.new + api_mock.expect(:get_jobs, [], [], ref_id: "REF456") + + job = Folio::CraMediaCloud::MonitorProcessingJob.new + + Folio::CraMediaCloud::Api.stub(:new, api_mock) do + assert_enqueued_jobs 0 do + job.send(:reconcile_video_state, video) + end + end + + api_mock.verify + video.reload + assert_nil video.remote_services_data["reference_id"] + assert_nil video.remote_services_data["processing_state"] + end + + # --- reconcile_with_remote_jobs: all-REMOVED path --- + + test "reconcile_with_remote_jobs schedules CheckProgressJob when all CRA jobs are REMOVED" do + video = create(:folio_file_video) + rs_data = { + "service" => "cra_media_cloud", + "processing_state" => "full_media_processing", + "reference_id" => "REF123", + "encoding_generation" => 42, + "phase_1_completed_at" => 5.minutes.ago.iso8601, + "phase_1_content_mp4_paths" => { "sd0" => "/video/sd0.mp4" }, + } + video.update_column(:remote_services_data, rs_data) + + removed_jobs = [ + { "id" => "JOB1", "status" => "REMOVED", "phase" => 1, "lastModified" => 2.minutes.ago.iso8601 }, + { "id" => "JOB2", "status" => "REMOVED", "phase" => 2, "lastModified" => 1.minute.ago.iso8601 }, + ] + + job = Folio::CraMediaCloud::MonitorProcessingJob.new + + assert_enqueued_jobs 1, only: Folio::CraMediaCloud::CheckProgressJob do + job.send(:reconcile_with_remote_jobs, video, rs_data, removed_jobs) + end + + # Should NOT update processing_state — CheckProgressJob handles finalization + video.reload + assert_equal "full_media_processing", video.remote_services_data["processing_state"] + end end diff --git a/test/jobs/folio/file/get_video_metadata_job_test.rb b/test/jobs/folio/file/get_video_metadata_job_test.rb new file mode 100644 index 000000000..00b67c7e1 --- /dev/null +++ b/test/jobs/folio/file/get_video_metadata_job_test.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require "test_helper" + +class Folio::File::GetVideoMetadataJobTest < ActiveJob::TestCase + test "extracts duration, width, height from local video file" do + file_path = Folio::Engine.root.join("test/fixtures/folio/blank.mp4").to_s + result = Folio::File::GetVideoMetadataJob.perform_now(file_path) + + assert result.is_a?(Hash) + assert result[:duration].is_a?(Integer) + assert result[:duration] > 0 + assert result[:width].is_a?(Integer) + assert result[:width] > 0 + assert result[:height].is_a?(Integer) + assert result[:height] > 0 + end + + test "returns nil values gracefully for invalid path" do + result = Folio::File::GetVideoMetadataJob.perform_now("/nonexistent/file.mp4") + + assert result.is_a?(Hash) + assert_nil result[:duration] + assert_nil result[:width] + assert_nil result[:height] + end +end diff --git a/test/jobs/folio/s3/create_file_job_test.rb b/test/jobs/folio/s3/create_file_job_test.rb new file mode 100644 index 000000000..a6b6b580a --- /dev/null +++ b/test/jobs/folio/s3/create_file_job_test.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: true + +require "test_helper" + +class Folio::S3::CreateFileJobTest < ActiveJob::TestCase + test "video upload falls back to download flow for local file system" do + # In test env with FileDataStore, video upload should use the standard download path + # (S3 copy path is only for actual S3 storage) + s3_path = "test_video.mp4" + + # Create a temp file simulating S3 uploaded file + source_path = "#{Folio::S3::Client::LOCAL_TEST_PATH}/#{s3_path}" + FileUtils.mkdir_p(File.dirname(source_path)) + fixture_path = Folio::Engine.root.join("test/fixtures/folio/blank.mp4").to_s + FileUtils.cp(fixture_path, source_path) + + site = get_any_site + + Folio::S3::CreateFileJob.perform_now( + s3_path: s3_path, + type: "Folio::File::Video", + attributes: { site_id: site.id } + ) + + # File should be created successfully via download path + created_video = Folio::File::Video.last + assert created_video.present?, "Video should be created" + assert created_video.file_uid.present?, "Video should have file_uid" + assert created_video.file_name.present?, "Video should have file_name" + ensure + FileUtils.rm_f(source_path) if source_path + end + + test "video upload uses S3 server-side copy when on real S3 storage" do + site = get_any_site + s3_path = "uploads/test_video.mp4" + + fake_head = Struct.new(:content_length, :content_type).new(5_000_000, "video/mp4") + copy_source_key = nil + + job = Folio::S3::CreateFileJob.new + job.define_singleton_method(:use_local_file_system?) { false } + + # Stub before_validation :set_video_file_dimensions — it calls file_url_or_path which tries + # to fetch the Dragonfly-generated UID from FileDataStore (no actual file exists there). + # Provide fake dimensions so file_width/file_height validations pass. + Folio::File::Video.define_method(:set_video_file_dimensions) do + self.file_width = 1280 + self.file_height = 720 + self.file_track_duration = 0 + end + + job.stub(:test_aware_s3_exists?, true) do + job.stub(:s3_copy_object, ->(source_key:, dest_key:) { copy_source_key = source_key }) do + job.stub(:s3_head_object, fake_head) do + job.stub(:test_aware_s3_delete, nil) do + job.perform(s3_path: s3_path, type: "Folio::File::Video", attributes: { site_id: site.id }) + end + end + end + end + + created_video = Folio::File::Video.last + assert created_video.present?, "Video should be created" + assert created_video.file_uid.present?, "Video should have a Dragonfly UID" + assert_equal "test_video.mp4", created_video.file_name + assert_equal 5_000_000, created_video.file_size + assert_equal "video/mp4", created_video.file_mime_type + assert_includes copy_source_key, s3_path, "s3_copy_object should have been called with the source path" + ensure + Folio::File::Video.remove_method(:set_video_file_dimensions) + end +end diff --git a/test/lib/folio/cra_media_cloud/encoder_test.rb b/test/lib/folio/cra_media_cloud/encoder_test.rb new file mode 100644 index 000000000..1926c70bb --- /dev/null +++ b/test/lib/folio/cra_media_cloud/encoder_test.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require "test_helper" + +class Folio::CraMediaCloud::EncoderTest < ActiveSupport::TestCase + setup do + @encoder = Folio::CraMediaCloud::Encoder.new + @file = OpenStruct.new( + id: 42, + file_name: "test_video.mp4", + file_size: "123456", + ) + @defaults = { md5: "abc123", ref_id: "42-1234567890", profile_group: "VoD" } + end + + test "build_ingest_manifest includes processingPhases attribute when processing_phases is 2" do + xml = @encoder.send(:build_ingest_manifest, @file, **@defaults, processing_phases: 2) + + assert_includes xml, 'processingPhases="2"' + assert_includes xml, " id, + "refId" => ref_id, + "status" => status, + "profileGroup" => profile_group, + "lastModified" => last_modified, + "messages" => [], + "output" => [], + } + end + + test "returns latest job by lastModified" do + jobs = [ + make_job(id: 1, ref_id: "abc-123", status: "FAILED", last_modified: "2026-01-01T00:00:00Z"), + make_job(id: 2, ref_id: "abc-123", status: "DONE", last_modified: "2026-01-02T00:00:00Z"), + ] + result = Folio::CraMediaCloud::JobResolver.resolve(jobs) + assert_equal :done, result[:status] + assert_equal 2, result[:job]["id"] + end + + test "returns :not_found for empty jobs" do + result = Folio::CraMediaCloud::JobResolver.resolve([]) + assert_equal :not_found, result[:status] + assert_nil result[:job] + end + + test "maps CRA statuses correctly" do + { "PROCESSING" => :processing, "CREATED" => :processing, + "DONE" => :done, "FAILED" => :failed, "ERROR" => :failed, + "REMOVED" => :not_found }.each do |cra_status, expected| + jobs = [make_job(id: 1, ref_id: "x", status: cra_status)] + result = Folio::CraMediaCloud::JobResolver.resolve(jobs) + assert_equal expected, result[:status], "Expected #{expected} for CRA status #{cra_status}" + end + end +end diff --git a/test/models/concerns/folio/media_file_processing_base_test.rb b/test/models/concerns/folio/media_file_processing_base_test.rb index eeda86099..f15bbe852 100644 --- a/test/models/concerns/folio/media_file_processing_base_test.rb +++ b/test/models/concerns/folio/media_file_processing_base_test.rb @@ -58,4 +58,54 @@ class TestVideoFile < Folio::File::Video video.reload assert_equal original_generation, video.encoding_generation end + + test "encoding_generation is set even when model has validation errors" do + video = TestVideoFile.new(site: get_any_site) + video.file = Folio::Engine.root.join("test/fixtures/folio/blank.mp4") + video.dont_run_after_save_jobs = true + + expect_method_called_on(object: video, method: :create_full_media) do + video.save! + end + + # Simulate a video that would fail validation (e.g. ffprobe failed, dimensions missing) + video.update_columns(file_width: nil, file_height: nil) + video.reload + + assert_not video.valid?, "video should be invalid without dimensions" + + # process_attached_file uses update_columns, so it should succeed despite invalid model + freeze_time = Time.current + travel_to freeze_time do + video.send(:update_remote_services_data, { + "processing_step_started_at" => Time.current, + "encoding_generation" => freeze_time.to_i + }) + end + + video.reload + assert_equal freeze_time.to_i, video.encoding_generation + end + + test "create_full_media preserves encoding_generation" do + video = TestVideoFile.new(site: get_any_site) + video.file = Folio::Engine.root.join("test/fixtures/folio/blank.mp4") + video.dont_run_after_save_jobs = true + video.save! + + # Set encoding_generation like process_attached_file does + video.update_columns(aasm_state: "processing") + video.send(:update_remote_services_data, { + "processing_step_started_at" => Time.current, + "encoding_generation" => 12345 + }) + + # create_full_media should merge in service/state without losing encoding_generation + video.create_full_media + + video.reload + assert_equal 12345, video.encoding_generation + assert_equal "cra_media_cloud", video.remote_services_data["service"] + assert_equal "enqueued", video.remote_services_data["processing_state"] + end end diff --git a/test/models/folio/file/cra_media_cloud_file_processing_test.rb b/test/models/folio/file/cra_media_cloud_file_processing_test.rb new file mode 100644 index 000000000..88fab6f2d --- /dev/null +++ b/test/models/folio/file/cra_media_cloud_file_processing_test.rb @@ -0,0 +1,127 @@ +# frozen_string_literal: true + +require "test_helper" + +# Integration tests for AASM state machine + Folio::CraMediaCloud::FileProcessing concern. +# Verifies that the full state machine works correctly when the CRA concern is included. +class Folio::File::CraMediaCloudFileProcessingTest < ActiveJob::TestCase + class TestVideoFile < Folio::File::Video + include Folio::CraMediaCloud::FileProcessing + end + + # --- process! triggers CRA encoding --- + + test "process! transitions to processing and enqueues CreateMediaJob" do + video = build_saved_video + # after_commit :process! fires during build_saved_video's save!, leaving state = "processing". + # Reset to unprocessed so we can test a clean process! transition. + video.update_column(:aasm_state, "unprocessed") + + video.stub(:regenerate_thumbnails, nil) do + assert_enqueued_jobs 1, only: Folio::CraMediaCloud::CreateMediaJob do + video.process! + end + end + + video.reload + assert_equal "processing", video.aasm_state + assert_equal "cra_media_cloud", video.remote_services_data["service"] + assert_equal "enqueued", video.remote_services_data["processing_state"] + assert video.remote_services_data["encoding_generation"].present?, + "encoding_generation must be set so CheckProgressJob can detect stale jobs" + end + + test "process_attached_file sets a new encoding_generation each time" do + video = build_saved_video + # Reset state (after_commit :process! fired during save!, leaving state = "processing") + video.update_column(:aasm_state, "unprocessed") + video.update!(remote_services_data: { "encoding_generation" => 999 }) + + video.stub(:regenerate_thumbnails, nil) do + video.process! + end + + video.reload + assert_not_equal 999, video.remote_services_data["encoding_generation"], + "encoding_generation should change on re-encode" + end + + # --- AASM state transitions --- + + test "processing_done! transitions processing to ready" do + video = build_saved_video + video.update_column(:aasm_state, "processing") + + video.processing_done! + + assert_equal "ready", video.reload.aasm_state + end + + test "processing_failed! transitions processing to processing_failed" do + video = build_saved_video + video.update_column(:aasm_state, "processing") + + video.processing_failed! + + assert_equal "processing_failed", video.reload.aasm_state + end + + test "retry_processing! transitions processing_failed back to processing" do + video = build_saved_video + video.update_column(:aasm_state, "processing_failed") + + video.retry_processing! + + assert_equal "processing", video.reload.aasm_state + end + + # --- destroy_attached_file enqueues DeleteMediaJob --- + + test "destroy_attached_file enqueues DeleteMediaJob when remote_id is present" do + video = build_saved_video + video.update!(remote_services_data: { + "remote_id" => "JOB123", + "reference_id" => "REF456" + }) + + assert_enqueued_jobs 1, only: Folio::CraMediaCloud::DeleteMediaJob do + video.destroy_attached_file + end + end + + test "destroy_attached_file does nothing when no remote_id or reference_id" do + video = build_saved_video + video.update!(remote_services_data: {}) + + assert_no_enqueued_jobs only: Folio::CraMediaCloud::DeleteMediaJob do + video.destroy_attached_file + end + end + + # --- video_poster_url interface --- + + test "video_poster_url returns nil for Folio::File::Video with no provider concern" do + plain_video_class = Class.new(Folio::File::Video) + assert_nil plain_video_class.new.video_poster_url + end + + test "video_poster_url delegates to remote_cover_url in CRA concern" do + video = build_saved_video + video.stub(:remote_cover_url, "https://cdn.example.com/cover.jpg") do + assert_equal "https://cdn.example.com/cover.jpg", video.video_poster_url + end + end + + private + def build_saved_video + video = TestVideoFile.new(site: get_any_site) + video.file = Folio::Engine.root.join("test/fixtures/folio/blank.mp4") + video.dont_run_after_save_jobs = true + + expect_method_called_on(object: video, method: :create_full_media) do + video.save! + end + + video + end +end diff --git a/test/models/folio/file_test.rb b/test/models/folio/file_test.rb index 2ef95e2f3..a687e9139 100644 --- a/test/models/folio/file_test.rb +++ b/test/models/folio/file_test.rb @@ -345,6 +345,15 @@ def f_file.process_attached_file # hacking method to check if it is called end end +class Folio::FileUrlOrPathTest < ActiveSupport::TestCase + test "file_url_or_path returns local path for FileDataStore" do + video = create(:folio_file_video) + result = video.file_url_or_path + assert result.is_a?(String) + assert_not result.start_with?("http"), "Expected local path, got URL: #{result}" + end +end + class Folio::FileImageMetadataKeywordsTest < ActiveSupport::TestCase include ActiveJob::TestHelper From d6532d3248af8bf21e01f42dc03c9d51736b422f Mon Sep 17 00:00:00 2001 From: jirkamotejl Date: Thu, 19 Mar 2026 15:55:53 +0100 Subject: [PATCH 18/34] fix(cra): add video ID to reference_id and guard against nil encoding_generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit reference_id was using only slug (filename-derived) without the video record ID, a regression from when hash_id was replaced with slug. This allowed different video records uploading the same file to share reference_ids, causing CRA job cross-contamination. When encoding_generation was nil (race condition), the truncated reference_id matched stale CRA jobs from previous uploads, making CreateMediaJob incorrectly conclude the video was "already done" — leaving it stuck in processing for ~14 minutes until MonitorProcessingJob rescued it. Changes: - Add video ID to reference_id format: {env}-{slug}-{id}-{s3_etag}-{generation} - Fail fast if encoding_generation is nil (Sidekiq will retry) - Add tests for both guards --- .../folio/cra_media_cloud/create_media_job.rb | 11 ++++-- .../cra_media_cloud/create_media_job_test.rb | 37 ++++++++++++++++++- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/app/jobs/folio/cra_media_cloud/create_media_job.rb b/app/jobs/folio/cra_media_cloud/create_media_job.rb index 16d4d5d69..e935817dd 100644 --- a/app/jobs/folio/cra_media_cloud/create_media_job.rb +++ b/app/jobs/folio/cra_media_cloud/create_media_job.rb @@ -50,15 +50,20 @@ def perform(media_file) private def generate_reference_id(media_file) - # Combine environment, video slug, S3 ETag, and encoding_generation for unique reference. + # Combine environment, video slug, ID, S3 ETag, and encoding_generation for unique reference. + # ID guarantees uniqueness per video record (slug alone is derived from filename and can collide). # encoding_generation changes on each re-encode, ensuring CRA gets a fresh refId. - # Format: {env}-{slug}-{s3_etag}-{generation} + # Format: {env}-{slug}-{id}-{s3_etag}-{generation} # Total length is capped at 128 chars to avoid CRA lookup failures with long slugs. s3_etag = get_s3_etag(media_file) env_prefix = ENV.fetch("DRAGONFLY_RAILS_ENV", Rails.env) generation = media_file.encoding_generation - suffix = "-#{s3_etag[0..7]}-#{generation}" + if generation.nil? + fail "encoding_generation not set for video #{media_file.id} — cannot generate unique reference_id (would match stale CRA jobs)" + end + + suffix = "-#{media_file.id}-#{s3_etag[0..7]}-#{generation}" max_slug_length = 128 - env_prefix.length - 1 - suffix.length slug = media_file.slug.to_s[0, [max_slug_length, 1].max] diff --git a/test/jobs/folio/cra_media_cloud/create_media_job_test.rb b/test/jobs/folio/cra_media_cloud/create_media_job_test.rb index e0005a2e3..7d5a2b394 100644 --- a/test/jobs/folio/cra_media_cloud/create_media_job_test.rb +++ b/test/jobs/folio/cra_media_cloud/create_media_job_test.rb @@ -117,6 +117,40 @@ class TestVideoFile < Folio::File::Video end end + test "raises when encoding_generation is nil to prevent stale CRA job matching" do + video = create_test_video_in_processing_state + video.update!(remote_services_data: video.remote_services_data.merge( + "encoding_generation" => nil + )) + + with_mocked_s3_and_encoder(video) do |encoder_mock, api_mock| + assert_raises(RuntimeError, /encoding_generation not set/) do + perform_job(video, encoder_mock, api_mock) + end + end + end + + test "reference_id includes video ID to prevent cross-contamination between records" do + video = create_test_video_in_processing_state + + with_mocked_s3_and_encoder(video) do |encoder_mock, api_mock| + captured_reference_id = nil + encoder_mock.expect(:upload_file, nil) do |_file, **kwargs| + captured_reference_id = kwargs[:reference_id] + true + end + api_mock.expect(:get_jobs, []) do |**_kwargs| + true + end + + perform_job(video, encoder_mock, api_mock) + + assert_not_nil captured_reference_id + assert_includes captured_reference_id, "-#{video.id}-", + "reference_id must contain video ID for per-record uniqueness" + end + end + test "marks video as permanently failed when S3 source file is missing" do video = create_test_video_in_processing_state @@ -180,7 +214,8 @@ def create_test_video_in_processing_state(klass: TestVideoFile) video.update!(remote_services_data: video.remote_services_data.merge( "service" => "cra_media_cloud", - "processing_state" => "full_media_processing" + "processing_state" => "full_media_processing", + "encoding_generation" => Time.current.to_i )) video end From f3d5d2aa3f71b4d32a35a9740850a8c3b27979ff Mon Sep 17 00:00:00 2001 From: jirkamotejl Date: Thu, 19 Mar 2026 17:31:08 +0100 Subject: [PATCH 19/34] docs: update reference_id format to include video ID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reflects the fix in d6532d324 — format is now {env}-{slug}-{id}-{s3_etag}-{encoding_generation} --- docs/design/cra-encoding-system.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/design/cra-encoding-system.md b/docs/design/cra-encoding-system.md index 297281ec3..3d6cc8df4 100644 --- a/docs/design/cra-encoding-system.md +++ b/docs/design/cra-encoding-system.md @@ -20,13 +20,13 @@ When a video is uploaded, the encoder generates a **presigned S3 URL** (7-day ex VoDHDAuto - prod-video-slug-a1b2c3d4-1710000000 + prod-video-slug-123-a1b2c3d4-1710000000 ``` ### Reference ID format -`{env}-{slug(truncated)}-{s3_etag[0..7]}-{encoding_generation}` +`{env}-{slug(truncated)}-{id}-{s3_etag[0..7]}-{encoding_generation}` - Total capped at **128 chars** (CRA lookup fails with longer IDs) - `encoding_generation` changes on each re-encode, ensuring CRA gets a fresh refId @@ -135,7 +135,7 @@ Multi-phase adds intermediate data (`phase_N_content_mp4_paths`, `phase_N_comple { "service": "cra_media_cloud", "processing_state": "full_media_processing", - "reference_id": "prod-video-slug-a1b2c3d4-1710000000", + "reference_id": "prod-video-slug-123-a1b2c3d4-1710000000", "remote_id": "JOB123", "encoding_generation": 1710000000, "processing_step_started_at": "2026-03-17T10:30:00Z", From 6670e22dc7d49ffe62c176520689c2f50d99f4a3 Mon Sep 17 00:00:00 2001 From: jirkamotejl Date: Thu, 19 Mar 2026 18:10:34 +0100 Subject: [PATCH 20/34] fix(cra): handle encoding_generation race condition and orphan detection timing CreateMediaJob: add reload fallback when encoding_generation is nil. When S3::CreateFileJob's transaction hasn't committed yet, the first read returns nil. A reload picks up the committed value, avoiding unnecessary Sidekiq retries. MonitorProcessingJob: add 10-minute threshold to orphan detection for videos with reference_id but no remote_id. Previously, a just-uploaded video (reference_id set, CRA manifest not yet ingested) would be incorrectly flagged as orphaned, causing state reset and duplicate manifest upload. --- app/jobs/folio/cra_media_cloud/create_media_job.rb | 7 +++++++ .../folio/cra_media_cloud/monitor_processing_job.rb | 12 +++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/jobs/folio/cra_media_cloud/create_media_job.rb b/app/jobs/folio/cra_media_cloud/create_media_job.rb index e935817dd..7d0de890e 100644 --- a/app/jobs/folio/cra_media_cloud/create_media_job.rb +++ b/app/jobs/folio/cra_media_cloud/create_media_job.rb @@ -59,6 +59,13 @@ def generate_reference_id(media_file) env_prefix = ENV.fetch("DRAGONFLY_RAILS_ENV", Rails.env) generation = media_file.encoding_generation + if generation.nil? + # encoding_generation may not be visible yet if the enclosing transaction + # (e.g. S3::CreateFileJob save) hasn't committed. Reload to get committed data. + media_file.reload + generation = media_file.encoding_generation + end + if generation.nil? fail "encoding_generation not set for video #{media_file.id} — cannot generate unique reference_id (would match stale CRA jobs)" end diff --git a/app/jobs/folio/cra_media_cloud/monitor_processing_job.rb b/app/jobs/folio/cra_media_cloud/monitor_processing_job.rb index fdf52c7a8..a3a9e9c8d 100644 --- a/app/jobs/folio/cra_media_cloud/monitor_processing_job.rb +++ b/app/jobs/folio/cra_media_cloud/monitor_processing_job.rb @@ -242,17 +242,19 @@ def handle_orphaned_videos end def find_orphaned_videos - # Find videos that are processing but might have lost track of their remote jobs + # Find videos that are processing but might have lost track of their remote jobs. + # Both conditions require a time threshold to avoid racing with just-uploaded videos + # (CRA needs time to ingest the manifest before a remote_id appears). Folio::File::Video .where(aasm_state: :processing) .where("remote_services_data ->> 'service' = ?", "cra_media_cloud") .where( - # Videos with reference_id but no remote_id, or videos that have been - # in creating_media_job state for a very long time - "(remote_services_data ->> 'reference_id' IS NOT NULL AND remote_services_data ->> 'remote_id' IS NULL) OR " \ + "(remote_services_data ->> 'reference_id' IS NOT NULL AND " \ + "remote_services_data ->> 'remote_id' IS NULL AND " \ + "(remote_services_data ->> 'processing_step_started_at')::timestamptz < ?) OR " \ "(remote_services_data ->> 'processing_state' = 'creating_media_job' AND " \ "(remote_services_data ->> 'processing_step_started_at')::timestamptz < ?)", - 30.minutes.ago + 10.minutes.ago, 30.minutes.ago ) end From 3351560bda58324853524c952597ce14703f80aa Mon Sep 17 00:00:00 2001 From: jirkamotejl Date: Thu, 19 Mar 2026 18:27:18 +0100 Subject: [PATCH 21/34] Devel 25 --- CHANGELOG.md | 8 ++++++++ lib/folio/version.rb | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a2e3601f..7c14e5443 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +## [7.5.1] - 2026-03-19 + +### Fixed + +- **CRA reference_id uniqueness**: Added video ID to reference_id format (`{env}-{slug}-{id}-{s3_etag}-{generation}`) to prevent cross-contamination between videos with identical slugs +- **CRA encoding_generation race condition**: Added reload fallback in CreateMediaJob when encoding_generation is nil due to uncommitted transaction from S3::CreateFileJob +- **CRA MonitorProcessingJob orphan detection**: Added 10-minute threshold to orphan detection for videos with reference_id but no remote_id, preventing false positives on just-uploaded videos + ## [7.5.0] - 2026-03-19 ### Added diff --git a/lib/folio/version.rb b/lib/folio/version.rb index 81cee0c1d..ac03020a0 100644 --- a/lib/folio/version.rb +++ b/lib/folio/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Folio - VERSION = "7.5.0" + VERSION = "7.5.1" end From b935acb6e1b08e3102d3ac1e2c40d0dc79769435 Mon Sep 17 00:00:00 2001 From: jirkamotejl Date: Thu, 19 Mar 2026 18:40:45 +0100 Subject: [PATCH 22/34] chore: update Gemfile.lock to match version 7.5.1 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 718a4ccc8..16e2d2721 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,7 +10,7 @@ GIT PATH remote: . specs: - folio (7.5.0) + folio (7.5.1) aasm activejob-uniqueness (>= 0.3.0) acts-as-taggable-on From ac855965d065e5106635914e99542caab6c0cbdb Mon Sep 17 00:00:00 2001 From: jirkamotejl Date: Sun, 22 Mar 2026 09:35:55 +0100 Subject: [PATCH 23/34] chore: run guard --- app/jobs/folio/files/after_save_job.rb | 1 - app/models/folio/file.rb | 2 +- test/jobs/folio/cra_media_cloud/encoder_test.rb | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/jobs/folio/files/after_save_job.rb b/app/jobs/folio/files/after_save_job.rb index 105c9cc4e..e5c76f14b 100644 --- a/app/jobs/folio/files/after_save_job.rb +++ b/app/jobs/folio/files/after_save_job.rb @@ -31,7 +31,6 @@ def perform(file, changed_attrs = {}) end private - def sync_metadata_to_placements(file, placements, changed_attrs) if changed_attrs.key?("description") old_desc, new_desc = changed_attrs["description"] diff --git a/app/models/folio/file.rb b/app/models/folio/file.rb index b0b4009a9..4b62c9147 100644 --- a/app/models/folio/file.rb +++ b/app/models/folio/file.rb @@ -484,7 +484,7 @@ def check_usage_before_destroy def set_file_track_duration if self.class.human_type == "video" # For video: handled together with dimensions in set_video_file_dimensions - return + nil elsif self.class.human_type == "audio" self.file_track_duration = Folio::File::GetFileTrackDurationJob.perform_now(file_url_or_path, "audio") self.preview_track_duration_in_seconds = self.respond_to?(:preview_duration_in_seconds) ? preview_duration_in_seconds : 0 diff --git a/test/jobs/folio/cra_media_cloud/encoder_test.rb b/test/jobs/folio/cra_media_cloud/encoder_test.rb index 610173dfe..a2bc7fde3 100644 --- a/test/jobs/folio/cra_media_cloud/encoder_test.rb +++ b/test/jobs/folio/cra_media_cloud/encoder_test.rb @@ -22,7 +22,7 @@ class Folio::CraMediaCloud::EncoderTest < ActiveSupport::TestCase ) assert_includes manifest_xml, 'src="https://s3.amazonaws.com/bucket/uploads/video.mp4' - assert_not_includes manifest_xml, 'file=' + assert_not_includes manifest_xml, "file=" assert_includes manifest_xml, 'size="123456"' assert_includes manifest_xml, 'md5="abc123def456"' assert_includes manifest_xml, "VoDSD" @@ -46,7 +46,7 @@ class Folio::CraMediaCloud::EncoderTest < ActiveSupport::TestCase ) assert_includes manifest_xml, 'file="video.mp4"' - assert_not_includes manifest_xml, 'src=' + assert_not_includes manifest_xml, "src=" end # --- upload_file --- From a07c9ce376949a4e2674f49991606d43cf2f8a1a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Mar 2026 06:43:33 +0100 Subject: [PATCH 24/34] chore(deps): bump actionview from 8.0.4 to 8.0.4.1 (#564) Bumps [actionview](https://github.com/rails/rails) from 8.0.4 to 8.0.4.1. - [Release notes](https://github.com/rails/rails/releases) - [Changelog](https://github.com/rails/rails/blob/v8.1.2.1/actionview/CHANGELOG.md) - [Commits](https://github.com/rails/rails/compare/v8.0.4...v8.0.4.1) --- updated-dependencies: - dependency-name: actionview dependency-version: 8.0.4.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 124 +++++++++++++++++++++++++-------------------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 16e2d2721..fec65dd8a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -89,29 +89,29 @@ GEM specs: aasm (5.5.2) concurrent-ruby (~> 1.0) - actioncable (8.0.4) - actionpack (= 8.0.4) - activesupport (= 8.0.4) + actioncable (8.0.4.1) + actionpack (= 8.0.4.1) + activesupport (= 8.0.4.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (8.0.4) - actionpack (= 8.0.4) - activejob (= 8.0.4) - activerecord (= 8.0.4) - activestorage (= 8.0.4) - activesupport (= 8.0.4) + actionmailbox (8.0.4.1) + actionpack (= 8.0.4.1) + activejob (= 8.0.4.1) + activerecord (= 8.0.4.1) + activestorage (= 8.0.4.1) + activesupport (= 8.0.4.1) mail (>= 2.8.0) - actionmailer (8.0.4) - actionpack (= 8.0.4) - actionview (= 8.0.4) - activejob (= 8.0.4) - activesupport (= 8.0.4) + actionmailer (8.0.4.1) + actionpack (= 8.0.4.1) + actionview (= 8.0.4.1) + activejob (= 8.0.4.1) + activesupport (= 8.0.4.1) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (8.0.4) - actionview (= 8.0.4) - activesupport (= 8.0.4) + actionpack (8.0.4.1) + actionview (= 8.0.4.1) + activesupport (= 8.0.4.1) nokogiri (>= 1.8.5) rack (>= 2.2.4) rack-session (>= 1.0.1) @@ -119,38 +119,38 @@ GEM rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actiontext (8.0.4) - actionpack (= 8.0.4) - activerecord (= 8.0.4) - activestorage (= 8.0.4) - activesupport (= 8.0.4) + actiontext (8.0.4.1) + actionpack (= 8.0.4.1) + activerecord (= 8.0.4.1) + activestorage (= 8.0.4.1) + activesupport (= 8.0.4.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (8.0.4) - activesupport (= 8.0.4) + actionview (8.0.4.1) + activesupport (= 8.0.4.1) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (8.0.4) - activesupport (= 8.0.4) + activejob (8.0.4.1) + activesupport (= 8.0.4.1) globalid (>= 0.3.6) activejob-uniqueness (0.4.0) activejob (>= 4.2, < 8.1) redlock (>= 2.0, < 3) - activemodel (8.0.4) - activesupport (= 8.0.4) - activerecord (8.0.4) - activemodel (= 8.0.4) - activesupport (= 8.0.4) + activemodel (8.0.4.1) + activesupport (= 8.0.4.1) + activerecord (8.0.4.1) + activemodel (= 8.0.4.1) + activesupport (= 8.0.4.1) timeout (>= 0.4.0) - activestorage (8.0.4) - actionpack (= 8.0.4) - activejob (= 8.0.4) - activerecord (= 8.0.4) - activesupport (= 8.0.4) + activestorage (8.0.4.1) + actionpack (= 8.0.4.1) + activejob (= 8.0.4.1) + activerecord (= 8.0.4.1) + activesupport (= 8.0.4.1) marcel (~> 1.0) - activesupport (8.0.4) + activesupport (8.0.4.1) base64 benchmark (>= 0.3) bigdecimal @@ -159,7 +159,7 @@ GEM drb i18n (>= 1.6, < 2) logger (>= 1.4.2) - minitest (>= 5.1) + minitest (>= 5.1, < 6) securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) uri (>= 0.13.1) @@ -247,8 +247,8 @@ GEM cocoon (1.2.15) coderay (1.1.3) colorize (0.8.1) - concurrent-ruby (1.3.5) - connection_pool (2.5.4) + concurrent-ruby (1.3.6) + connection_pool (2.5.5) countries (8.0.4) unaccent (~> 0.3) country_select (11.0.0) @@ -378,7 +378,7 @@ GEM multi_xml (>= 0.5.2) httpparty (0.2.0) httparty (> 0) - i18n (1.14.7) + i18n (1.14.8) concurrent-ruby (~> 1.0) i18n-tasks (1.0.15) activesupport (>= 4.0.2) @@ -427,7 +427,7 @@ GEM rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) logger (1.7.0) - loofah (2.24.1) + loofah (2.25.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) lumberjack (1.4.2) @@ -470,9 +470,9 @@ GEM net-protocol net-ssh (7.3.0) nio4r (2.7.5) - nokogiri (1.18.10-arm64-darwin) + nokogiri (1.19.2-arm64-darwin) racc (~> 1.4) - nokogiri (1.18.10-x86_64-linux-gnu) + nokogiri (1.19.2-x86_64-linux-gnu) racc (~> 1.4) notiffany (0.1.3) nenv (~> 0.1) @@ -564,33 +564,33 @@ GEM rackup (1.0.1) rack (< 3) webrick - rails (8.0.4) - actioncable (= 8.0.4) - actionmailbox (= 8.0.4) - actionmailer (= 8.0.4) - actionpack (= 8.0.4) - actiontext (= 8.0.4) - actionview (= 8.0.4) - activejob (= 8.0.4) - activemodel (= 8.0.4) - activerecord (= 8.0.4) - activestorage (= 8.0.4) - activesupport (= 8.0.4) + rails (8.0.4.1) + actioncable (= 8.0.4.1) + actionmailbox (= 8.0.4.1) + actionmailer (= 8.0.4.1) + actionpack (= 8.0.4.1) + actiontext (= 8.0.4.1) + actionview (= 8.0.4.1) + activejob (= 8.0.4.1) + activemodel (= 8.0.4.1) + activerecord (= 8.0.4.1) + activestorage (= 8.0.4.1) + activesupport (= 8.0.4.1) bundler (>= 1.15.0) - railties (= 8.0.4) + railties (= 8.0.4.1) rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.6.2) - loofah (~> 2.21) + rails-html-sanitizer (1.7.0) + loofah (~> 2.25) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) rails-i18n (8.0.2) i18n (>= 0.7, < 2) railties (>= 8.0.0, < 9) - railties (8.0.4) - actionpack (= 8.0.4) - activesupport (= 8.0.4) + railties (8.0.4.1) + actionpack (= 8.0.4.1) + activesupport (= 8.0.4.1) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) From c4495ba031a764f1ea60103852fcf476fa45f099 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Mar 2026 06:43:45 +0100 Subject: [PATCH 25/34] chore(deps): bump activestorage from 8.0.4 to 8.0.4.1 (#565) Bumps [activestorage](https://github.com/rails/rails) from 8.0.4 to 8.0.4.1. - [Release notes](https://github.com/rails/rails/releases) - [Changelog](https://github.com/rails/rails/blob/v8.1.2.1/activestorage/CHANGELOG.md) - [Commits](https://github.com/rails/rails/compare/v8.0.4...v8.0.4.1) --- updated-dependencies: - dependency-name: activestorage dependency-version: 8.0.4.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index fec65dd8a..19222822b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -551,7 +551,7 @@ GEM nio4r (~> 2.0) raabro (1.4.0) racc (1.8.1) - rack (2.2.21) + rack (2.2.22) rack-mini-profiler (4.0.1) rack (>= 1.2.0) rack-protection (3.2.0) @@ -736,7 +736,7 @@ GEM execjs (>= 0.3.0, < 3) thor (1.4.0) tilt (2.0.11) - timeout (0.4.4) + timeout (0.6.1) traco (5.3.3) activerecord (>= 4.2) trailblazer-option (0.1.2) From 91da279862e677d56ad66a4100a649e944f2b8c2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Mar 2026 06:43:52 +0100 Subject: [PATCH 26/34] chore(deps): bump activesupport from 8.0.4 to 8.0.4.1 (#566) Bumps [activesupport](https://github.com/rails/rails) from 8.0.4 to 8.0.4.1. - [Release notes](https://github.com/rails/rails/releases) - [Changelog](https://github.com/rails/rails/blob/v8.1.2.1/activesupport/CHANGELOG.md) - [Commits](https://github.com/rails/rails/compare/v8.0.4...v8.0.4.1) --- updated-dependencies: - dependency-name: activesupport dependency-version: 8.0.4.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> From 570810f952920a6bd94bec6864d9c4d5afe2395a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Mar 2026 06:44:00 +0100 Subject: [PATCH 27/34] chore(deps): bump json from 2.18.1 to 2.19.2 (#559) Bumps [json](https://github.com/ruby/json) from 2.18.1 to 2.19.2. - [Release notes](https://github.com/ruby/json/releases) - [Changelog](https://github.com/ruby/json/blob/master/CHANGES.md) - [Commits](https://github.com/ruby/json/compare/v2.18.1...v2.19.2) --- updated-dependencies: - dependency-name: json dependency-version: 2.19.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 19222822b..31dfcde1b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -405,7 +405,7 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (2.18.1) + json (2.19.2) json-jwt (1.17.0) activesupport (>= 4.2) aes_key_wrap From b00d3342eec31231831fc740fa245770f56d80f3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Mar 2026 06:44:06 +0100 Subject: [PATCH 28/34] chore(deps): bump bcrypt from 3.1.20 to 3.1.22 (#561) Bumps [bcrypt](https://github.com/bcrypt-ruby/bcrypt-ruby) from 3.1.20 to 3.1.22. - [Release notes](https://github.com/bcrypt-ruby/bcrypt-ruby/releases) - [Changelog](https://github.com/bcrypt-ruby/bcrypt-ruby/blob/master/CHANGELOG) - [Commits](https://github.com/bcrypt-ruby/bcrypt-ruby/compare/v3.1.20...v3.1.22) --- updated-dependencies: - dependency-name: bcrypt dependency-version: 3.1.22 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 31dfcde1b..10fa11c90 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -205,7 +205,7 @@ GEM babel-source (>= 4.0, < 6) execjs (~> 2.0) base64 (0.3.0) - bcrypt (3.1.20) + bcrypt (3.1.22) benchmark (0.5.0) better_errors (2.10.1) erubi (>= 1.0.0) From 1e049e4fe449ea50c5a2406e5d6454d5e6ff09d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Mar 2026 06:44:13 +0100 Subject: [PATCH 29/34] chore(deps-dev): bump minimatch from 3.1.2 to 3.1.5 (#551) Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.1.2 to 3.1.5. - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](https://github.com/isaacs/minimatch/compare/v3.1.2...v3.1.5) --- updated-dependencies: - dependency-name: minimatch dependency-version: 3.1.5 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index eee5ea858..c49da7c17 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2534,11 +2534,10 @@ } }, "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", "dev": true, - "license": "ISC", "dependencies": { "brace-expansion": "^1.1.7" }, @@ -5553,9 +5552,9 @@ "dev": true }, "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", "dev": true, "requires": { "brace-expansion": "^1.1.7" From 287dcdee9fbf989a97233dc4d07c77a91f5ddd0e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Mar 2026 06:44:46 +0100 Subject: [PATCH 30/34] chore(deps): bump rack from 2.2.21 to 2.2.22 (#534) Bumps [rack](https://github.com/rack/rack) from 2.2.21 to 2.2.22. - [Release notes](https://github.com/rack/rack/releases) - [Changelog](https://github.com/rack/rack/blob/main/CHANGELOG.md) - [Commits](https://github.com/rack/rack/compare/v2.2.21...v2.2.22) --- updated-dependencies: - dependency-name: rack dependency-version: 2.2.22 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> From bcaaecd22445920a17adee98c3d785f0e029e4af Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Mar 2026 06:45:01 +0100 Subject: [PATCH 31/34] chore(deps-dev): bump minimatch from 3.1.2 to 3.1.5 in /test/dummy (#539) Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.1.2 to 3.1.5. - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](https://github.com/isaacs/minimatch/compare/v3.1.2...v3.1.5) --- updated-dependencies: - dependency-name: minimatch dependency-version: 3.1.5 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/dummy/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/dummy/package-lock.json b/test/dummy/package-lock.json index 5a8c8369b..f8764fc3a 100644 --- a/test/dummy/package-lock.json +++ b/test/dummy/package-lock.json @@ -826,9 +826,9 @@ "license": "CC0-1.0" }, "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", "dev": true, "license": "ISC", "dependencies": { From 76216920233dd914e90f58900fed02f4dfa614fb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Mar 2026 06:45:07 +0100 Subject: [PATCH 32/34] chore(deps-dev): bump svgo from 2.8.0 to 2.8.2 in /test/dummy (#545) Bumps [svgo](https://github.com/svg/svgo) from 2.8.0 to 2.8.2. - [Release notes](https://github.com/svg/svgo/releases) - [Commits](https://github.com/svg/svgo/compare/v2.8.0...v2.8.2) --- updated-dependencies: - dependency-name: svgo dependency-version: 2.8.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/dummy/package-lock.json | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/dummy/package-lock.json b/test/dummy/package-lock.json index f8764fc3a..8648434e4 100644 --- a/test/dummy/package-lock.json +++ b/test/dummy/package-lock.json @@ -259,16 +259,6 @@ "node": ">= 10" } }, - "node_modules/@trysound/sax": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@trysound/sax/-/sax-0.2.0.tgz", - "integrity": "sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=10.13.0" - } - }, "node_modules/@types/triple-beam": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.5.tgz", @@ -971,6 +961,16 @@ "node": ">=10" } }, + "node_modules/sax": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.5.0.tgz", + "integrity": "sha512-21IYA3Q5cQf089Z6tgaUTr7lDAyzoTPx5HRtbhsME8Udispad8dC/+sziTNugOEx54ilvatQ9YCzl4KQLPcRHA==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=11.0.0" + } + }, "node_modules/simple-swizzle": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", @@ -1080,18 +1080,18 @@ } }, "node_modules/svgo": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/svgo/-/svgo-2.8.0.tgz", - "integrity": "sha512-+N/Q9kV1+F+UeWYoSiULYo4xYSDQlTgb+ayMobAXPwMnLvop7oxKMo9OzIrX5x3eS4L4f2UHhc9axXwY8DpChg==", + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/svgo/-/svgo-2.8.2.tgz", + "integrity": "sha512-TyzE4NVGLUFy+H/Uy4N6c3G0HEeprsVfge6Lmq+0FdQQ/zqoVYB62IsBZORsiL+o96s6ff/V6/3UQo/C0cgCAA==", "dev": true, "license": "MIT", "dependencies": { - "@trysound/sax": "0.2.0", "commander": "^7.2.0", "css-select": "^4.1.3", "css-tree": "^1.1.3", "csso": "^4.2.0", "picocolors": "^1.0.0", + "sax": "^1.5.0", "stable": "^0.1.8" }, "bin": { From e7fc886d4eeeb74f0aa85426ee42fe0860523252 Mon Sep 17 00:00:00 2001 From: Petr Marek Date: Tue, 24 Mar 2026 06:52:18 +0100 Subject: [PATCH 33/34] chore(guard): run --- test/jobs/folio/cra_media_cloud/create_media_job_test.rb | 3 ++- test/jobs/folio/cra_media_cloud/encoder_test.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/jobs/folio/cra_media_cloud/create_media_job_test.rb b/test/jobs/folio/cra_media_cloud/create_media_job_test.rb index 7d5a2b394..c04205829 100644 --- a/test/jobs/folio/cra_media_cloud/create_media_job_test.rb +++ b/test/jobs/folio/cra_media_cloud/create_media_job_test.rb @@ -124,9 +124,10 @@ class TestVideoFile < Folio::File::Video )) with_mocked_s3_and_encoder(video) do |encoder_mock, api_mock| - assert_raises(RuntimeError, /encoding_generation not set/) do + error = assert_raises(RuntimeError) do perform_job(video, encoder_mock, api_mock) end + assert_match(/encoding_generation not set/, error.message) end end diff --git a/test/jobs/folio/cra_media_cloud/encoder_test.rb b/test/jobs/folio/cra_media_cloud/encoder_test.rb index a2bc7fde3..7220e32fa 100644 --- a/test/jobs/folio/cra_media_cloud/encoder_test.rb +++ b/test/jobs/folio/cra_media_cloud/encoder_test.rb @@ -149,9 +149,10 @@ class Folio::CraMediaCloud::EncoderTest < ActiveSupport::TestCase raise "persistent error" end - assert_raises(RuntimeError, /persistent error/) do + error = assert_raises(RuntimeError) do encoder.send(:upload_with_retry, always_fail_sftp, StringIO.new("data"), "/dest/manifest.xml", max_retries: 2) end + assert_match(/persistent error/, error.message) assert_equal 3, attempts # 1 initial + 2 retries end From 04091b1657927c2fda81767a78706b9214291fee Mon Sep 17 00:00:00 2001 From: Petr Marek Date: Tue, 24 Mar 2026 06:59:46 +0100 Subject: [PATCH 34/34] chore(changelog): add tiptap float entry --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c14e5443..e1b1f9c30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Changed + +- tiptap float css - allow floating on mobile as well + ## [7.5.1] - 2026-03-19 ### Fixed