diff --git a/README.md b/README.md index 4b9eea5..5824556 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,16 @@ Open-source AI assistant for ERPNext. Ask business questions in plain English an 14. **Entity Creation from Natural Language** - changAI allows users to create ERP records directly from natural language requests. Users can create customers, suppliers, items, projects, leads, opportunities, and other ERP entities by simply describing what they need. changAI automatically opens the appropriate ERPNext form with detected values pre-filled, reducing manual data entry and improving productivity. +15. **Natural Language CUD Operations (Create, Update, Delete)** — changAI supports + creating,reading, updating, and deleting ERP records directly from natural language requests in English or Arabic. Users can manage customers, suppliers, employees, contacts,and other ERP entities by simply describing what they need. + + Every CRUD operations passes through Frappe's native permission layer before + execution. Users can create,read, update, or delete records they are + authorized to access. Unauthorized attempts return a clear error message + without modifying any data. + All write operations (Create, Update, Delete) are executed exclusively through + Frappe ORM and read operations through permission-validated raw SQL. + **You can Enable or Disable ChangAI from "ChangAI Settings Doctype"** ## Tech Stack diff --git a/changai/changai/api/v2/assets/business_keywords_v1.json b/changai/changai/api/v2/assets/business_keywords_v1.json index 9b992f6..da3e06a 100644 --- a/changai/changai/api/v2/assets/business_keywords_v1.json +++ b/changai/changai/api/v2/assets/business_keywords_v1.json @@ -363,7 +363,6 @@ "financial ratio", "liquidity", "solvency", - "working capital", "break even", "credit note", "debit note", @@ -819,7 +818,7 @@ "cash management", "treasury", "fund management", - "capital budgeting", + "budgeting", "investment analysis", "portfolio management", "return analysis", @@ -1504,7 +1503,7 @@ "employee purchasing", "indirect procurement", "direct procurement", - "capital procurement", + "procurement", "services procurement", "IT procurement", "MRO procurement", @@ -1881,7 +1880,7 @@ "impairment charge", "write down entry", "asset write off", - "capital expenditure approval", + "expenditure approval", "CAPEX request", "CAPEX budget", "CAPEX actual", @@ -2025,7 +2024,7 @@ "current ratio", "quick ratio", "cash ratio", - "working capital ratio", + "working ratio", "debt equity ratio", "interest coverage", "debt service coverage", @@ -2035,7 +2034,6 @@ "payables turnover", "return on assets", "return on equity", - "return on capital", "gross profit margin", "operating margin", "net profit margin", @@ -3382,7 +3380,6 @@ "property maintenance", "tenant management", "property valuation", - "capital improvement", "property tax", "agriculture management", "crop planning", @@ -3674,7 +3671,6 @@ "terminal value", "enterprise value", "equity value", - "market capitalization", "book value", "tangible book value", "price to book", @@ -3691,12 +3687,7 @@ "dividend payout ratio", "retained earnings movement", "reserve and surplus", - "capital reserve", "revenue reserve", - "share capital", - "authorized capital", - "issued capital", - "paid up capital", "calls in arrears", "share premium", "goodwill on acquisition", @@ -7662,7 +7653,6 @@ "advance", "provision", "reserve", - "capital", "equity", "retained earnings", "dividend", diff --git a/changai/changai/api/v2/assets/metaschema_clean_v2.json b/changai/changai/api/v2/assets/metaschema_clean_v2.json index 6ae2285..3e1ce0c 100644 --- a/changai/changai/api/v2/assets/metaschema_clean_v2.json +++ b/changai/changai/api/v2/assets/metaschema_clean_v2.json @@ -1,7 +1,6 @@ { "tabAbout Us Team Member": { "full_name": "TEXT", - "image_link": "TEXT", "bio": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -23,8 +22,6 @@ "method": "TEXT", "report_name": "TEXT", "filters": "TEXT", - "page": "TEXT", - "columns": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -94,6 +91,7 @@ "document_type": "TEXT", "label": "TEXT", "fieldname": "TEXT", + "dimension_defaults": "TEXT", "disabled": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -132,6 +130,8 @@ "company": "TEXT", "apply_restriction_on_values": "TEXT", "allow_or_restrict": "TEXT", + "accounts": "TEXT", + "dimensions": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -148,6 +148,7 @@ "start_date": "TEXT", "end_date": "TEXT", "company": "TEXT", + "closed_documents": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -187,7 +188,6 @@ "status": "TEXT", "reference_doctype": "TEXT", "reference_name": "TEXT", - "reference_owner": "TEXT", "timeline_doctype": "TEXT", "timeline_name": "TEXT", "link_doctype": "TEXT", @@ -240,6 +240,7 @@ "is_shipping_address": "TEXT", "disabled": "TEXT", "is_your_company_address": "TEXT", + "links": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -426,7 +427,6 @@ "tabAsset": { "company": "TEXT", "item_code": "TEXT", - "item_name": "TEXT", "asset_owner": "TEXT", "asset_owner_company": "TEXT", "is_existing_asset": "TEXT", @@ -457,6 +457,7 @@ "opening_accumulated_depreciation": "TEXT", "opening_number_of_booked_depreciations": "TEXT", "is_fully_depreciated": "TEXT", + "finance_books": "TEXT", "depreciation_method": "TEXT", "value_after_depreciation": "TEXT", "total_number_of_depreciations": "TEXT", @@ -523,8 +524,11 @@ "target_is_fixed_asset": "TEXT", "target_has_batch_no": "TEXT", "target_has_serial_no": "TEXT", + "stock_items": "TEXT", "stock_items_total": "TEXT", + "asset_items": "TEXT", "asset_items_total": "TEXT", + "service_items": "TEXT", "service_items_total": "TEXT", "total_value": "TEXT", "target_incoming_rate": "TEXT", @@ -614,6 +618,8 @@ "asset_category_name": "TEXT", "enable_cwip_accounting": "TEXT", "non_depreciable_category": "TEXT", + "finance_books": "TEXT", + "accounts": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -658,6 +664,7 @@ "shift_based": "TEXT", "frequency_of_depreciation": "TEXT", "expected_value_after_useful_life": "TEXT", + "depreciation_schedule": "TEXT", "notes": "TEXT", "status": "TEXT", "amended_from": "TEXT", @@ -698,13 +705,10 @@ }, "tabAsset Maintenance": { "asset_name": "TEXT", - "asset_category": "TEXT", "company": "TEXT", - "item_code": "TEXT", - "item_name": "TEXT", "maintenance_team": "TEXT", "maintenance_manager": "TEXT", - "maintenance_manager_name": "TEXT", + "asset_maintenance_tasks": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -719,21 +723,14 @@ "tabAsset Maintenance Log": { "asset_maintenance": "TEXT", "naming_series": "TEXT", - "asset_name": "TEXT", - "item_code": "TEXT", - "item_name": "TEXT", "task": "TEXT", "task_name": "TEXT", - "maintenance_type": "TEXT", "periodicity": "TEXT", "has_certificate": "TEXT", - "certificate_attachement": "TEXT", "maintenance_status": "TEXT", - "assign_to_name": "TEXT", "task_assignee_email": "TEXT", "due_date": "TEXT", "completion_date": "TEXT", - "description": "TEXT", "actions_performed": "TEXT", "amended_from": "TEXT", "name": "TEXT", @@ -756,7 +753,6 @@ "end_date": "TEXT", "certificate_required": "TEXT", "assign_to": "TEXT", - "assign_to_name": "TEXT", "next_due_date": "TEXT", "last_completion_date": "TEXT", "description": "TEXT", @@ -774,8 +770,8 @@ "tabAsset Maintenance Team": { "maintenance_team_name": "TEXT", "maintenance_manager": "TEXT", - "maintenance_manager_name": "TEXT", "company": "TEXT", + "maintenance_team_members": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -791,6 +787,7 @@ "company": "TEXT", "purpose": "TEXT", "transaction_date": "TEXT", + "assets": "TEXT", "reference_doctype": "TEXT", "reference_name": "TEXT", "amended_from": "TEXT", @@ -827,7 +824,6 @@ "tabAsset Repair": { "asset": "TEXT", "company": "TEXT", - "asset_name": "TEXT", "naming_series": "TEXT", "failure_date": "TEXT", "repair_status": "TEXT", @@ -838,6 +834,7 @@ "capitalize_repair_cost": "TEXT", "stock_consumption": "TEXT", "repair_cost": "TEXT", + "stock_items": "TEXT", "total_repair_cost": "TEXT", "increase_in_asset_life": "TEXT", "description": "TEXT", @@ -879,6 +876,7 @@ "naming_series": "TEXT", "finance_book": "TEXT", "amended_from": "TEXT", + "depreciation_schedule": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -908,7 +906,6 @@ "tabAsset Value Adjustment": { "company": "TEXT", "asset": "TEXT", - "asset_category": "TEXT", "date": "TEXT", "finance_book": "TEXT", "amended_from": "TEXT", @@ -938,6 +935,7 @@ "assign_condition": "TEXT", "unassign_condition": "TEXT", "close_condition": "TEXT", + "assignment_days": "TEXT", "rule": "TEXT", "field": "TEXT", "users": "TEXT", @@ -1007,7 +1005,6 @@ "report": "TEXT", "user": "TEXT", "enabled": "TEXT", - "report_type": "TEXT", "reference_report": "TEXT", "send_if_data": "TEXT", "data_modified_till": "TEXT", @@ -1046,6 +1043,7 @@ "repeat_on_day": "TEXT", "repeat_on_last_day": "TEXT", "next_schedule_date": "TEXT", + "repeat_on_days": "TEXT", "notify_by_email": "TEXT", "recipients": "TEXT", "template": "TEXT", @@ -1108,11 +1106,14 @@ "plc_conversion_rate": "TEXT", "currency": "TEXT", "conversion_rate": "TEXT", + "items": "TEXT", "with_operations": "TEXT", "transfer_material_against": "TEXT", "routing": "TEXT", "fg_based_operating_cost": "TEXT", "operating_cost_per_bom_quantity": "TEXT", + "operations": "TEXT", + "scrap_items": "TEXT", "process_loss_percentage": "TEXT", "process_loss_qty": "TEXT", "operating_cost": "TEXT", @@ -1128,6 +1129,7 @@ "has_variants": "TEXT", "inspection_required": "TEXT", "quality_inspection_template": "TEXT", + "exploded_items": "TEXT", "show_in_website": "TEXT", "route": "TEXT", "thumbnail": "TEXT", @@ -1164,6 +1166,7 @@ "conversion_rate": "TEXT", "default_warehouse": "TEXT", "company": "TEXT", + "items": "TEXT", "raw_material_cost": "TEXT", "remarks": "TEXT", "status": "TEXT", @@ -1221,7 +1224,6 @@ "source_warehouse": "TEXT", "operation": "TEXT", "description": "TEXT", - "image": "TEXT", "stock_qty": "TEXT", "rate": "TEXT", "qty_consumed_per_unit": "TEXT", @@ -1250,7 +1252,6 @@ "allow_alternative_item": "TEXT", "is_stock_item": "TEXT", "description": "TEXT", - "image": "TEXT", "qty": "TEXT", "uom": "TEXT", "stock_qty": "TEXT", @@ -1292,7 +1293,6 @@ "cost_per_unit": "TEXT", "base_cost_per_unit": "TEXT", "description": "TEXT", - "image": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -1348,6 +1348,7 @@ "error_log": "TEXT", "current_level": "TEXT", "processed_boms": "TEXT", + "bom_batches": "TEXT", "amended_from": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -1365,7 +1366,6 @@ "item_name": "TEXT", "description": "TEXT", "qty": "TEXT", - "website_image": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -1381,7 +1381,6 @@ "operation": "TEXT", "workstation": "TEXT", "time_in_mins": "TEXT", - "website_image": "TEXT", "thumbnail": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -1398,6 +1397,7 @@ "bank_name": "TEXT", "swift_number": "TEXT", "website": "TEXT", + "bank_transaction_mapping": "TEXT", "plaid_access_token": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -1528,7 +1528,6 @@ "custom_delimiters": "TEXT", "delimiter_options": "TEXT", "google_sheets_url": "TEXT", - "import_file": "TEXT", "status": "TEXT", "template_options": "TEXT", "template_warnings": "TEXT", @@ -1562,6 +1561,7 @@ "reference_number": "TEXT", "transaction_id": "TEXT", "transaction_type": "TEXT", + "payment_entries": "TEXT", "allocated_amount": "TEXT", "unallocated_amount": "TEXT", "party_type": "TEXT", @@ -1698,6 +1698,7 @@ "from_date": "TEXT", "to_date": "TEXT", "company": "TEXT", + "items": "TEXT", "amended_from": "TEXT", "tc_name": "TEXT", "terms": "TEXT", @@ -1776,8 +1777,6 @@ "blog_intro": "TEXT", "content_type": "TEXT", "content": "TEXT", - "content_md": "TEXT", - "content_html": "TEXT", "email_sent": "TEXT", "meta_title": "TEXT", "meta_description": "TEXT", @@ -1825,6 +1824,7 @@ "tabBrand": { "brand": "TEXT", "description": "TEXT", + "brand_defaults": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -1854,6 +1854,7 @@ "applicable_on_booking_actual_expenses": "TEXT", "action_if_annual_budget_exceeded": "TEXT", "action_if_accumulated_monthly_budget_exceeded": "TEXT", + "accounts": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -1947,6 +1948,7 @@ "recording_url": "TEXT", "type_of_call": "TEXT", "summary": "TEXT", + "links": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -1961,6 +1963,7 @@ "tabCampaign": { "campaign_name": "TEXT", "naming_series": "TEXT", + "campaign_schedules": "TEXT", "description": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -2010,6 +2013,7 @@ "custody": "TEXT", "returns": "TEXT", "outstanding_amount": "TEXT", + "payments": "TEXT", "net_amount": "TEXT", "amended_from": "TEXT", "name": "TEXT", @@ -2060,7 +2064,6 @@ "starting_position_from_top_edge": "TEXT", "cheque_width": "TEXT", "cheque_height": "TEXT", - "scanned_cheque": "TEXT", "is_account_payable": "TEXT", "acc_pay_dist_from_top_edge": "TEXT", "acc_pay_dist_from_left_edge": "TEXT", @@ -2164,19 +2167,6 @@ "parentfield": "TEXT", "parenttype": "TEXT" }, - "tabColor": { - "color": "TEXT", - "name": "TEXT", - "owner": "TEXT", - "creation": "TEXT", - "modified": "TEXT", - "modified_by": "TEXT", - "docstatus": "INT", - "idx": "INT", - "parent": "TEXT", - "parentfield": "TEXT", - "parenttype": "TEXT" - }, "tabComment": { "comment_type": "TEXT", "comment_email": "TEXT", @@ -2187,7 +2177,6 @@ "reference_doctype": "TEXT", "reference_name": "TEXT", "reference_owner": "TEXT", - "content": "TEXT", "ip_address": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -2207,6 +2196,7 @@ "common_code": "TEXT", "description": "TEXT", "additional_data": "TEXT", + "applies_to": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -2241,7 +2231,6 @@ "read_by_recipient_on": "TEXT", "reference_doctype": "TEXT", "reference_name": "TEXT", - "reference_owner": "TEXT", "email_account": "TEXT", "company": "TEXT", "in_reply_to": "TEXT", @@ -2250,6 +2239,7 @@ "unread_notification_sent": "TEXT", "seen": "TEXT", "_user_tags": "TEXT", + "timeline_links": "TEXT", "message_id": "TEXT", "uid": "TEXT", "imap_folder": "TEXT", @@ -2271,7 +2261,6 @@ "tabCommunication Link": { "link_doctype": "TEXT", "link_name": "TEXT", - "link_title": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -2289,6 +2278,7 @@ "catch_all": "TEXT", "provider": "TEXT", "disabled": "TEXT", + "timeslots": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -2435,6 +2425,7 @@ "custom_validation_type": "TEXT", "custom_sample_invoice_number_to_test": "TEXT", "custom_basic_auth_from_production": "TEXT", + "custom_zatca_offline_machines": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -2493,11 +2484,13 @@ "client_id": "TEXT", "redirect_uri": "TEXT", "client_secret": "TEXT", + "scopes": "TEXT", "authorization_uri": "TEXT", "token_uri": "TEXT", "revocation_uri": "TEXT", "userinfo_uri": "TEXT", "introspection_uri": "TEXT", + "query_parameters": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -2543,6 +2536,9 @@ "google_contacts": "TEXT", "google_contacts_id": "TEXT", "pulled_from_google_contacts": "TEXT", + "email_ids": "TEXT", + "phone_nos": "TEXT", + "links": "TEXT", "is_primary_contact": "TEXT", "is_billing_contact": "TEXT", "department": "TEXT", @@ -2604,6 +2600,7 @@ "contract_terms": "TEXT", "requires_fulfilment": "TEXT", "fulfilment_deadline": "TEXT", + "fulfilment_terms": "TEXT", "signed_by_company": "TEXT", "document_type": "TEXT", "document_name": "TEXT", @@ -2639,6 +2636,7 @@ "title": "TEXT", "contract_terms": "TEXT", "requires_fulfilment": "TEXT", + "fulfilment_terms": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -2691,6 +2689,7 @@ "main_cost_center": "TEXT", "company": "TEXT", "valid_from": "TEXT", + "allocation_percentages": "TEXT", "amended_from": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -2919,6 +2918,7 @@ "html": "TEXT", "script": "TEXT", "style": "TEXT", + "roles": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -2933,6 +2933,7 @@ "tabCustom Role": { "page": "TEXT", "report": "TEXT", + "roles": "TEXT", "ref_doctype": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -2968,6 +2969,7 @@ "custom_data": "TEXT", "is_internal_customer": "TEXT", "represents_company": "TEXT", + "companies": "TEXT", "market_segment": "TEXT", "industry": "TEXT", "customer_pos_id": "TEXT", @@ -2979,20 +2981,22 @@ "customer_primary_address": "TEXT", "primary_address": "TEXT", "customer_primary_contact": "TEXT", - "mobile_no": "TEXT", - "email_id": "TEXT", "tax_id": "TEXT", "tax_category": "TEXT", "tax_withholding_category": "TEXT", "payment_terms": "TEXT", + "credit_limits": "TEXT", + "accounts": "TEXT", "loyalty_program": "TEXT", "loyalty_program_tier": "TEXT", + "sales_team": "TEXT", "default_sales_partner": "TEXT", "default_commission_rate": "TEXT", "so_required": "TEXT", "dn_required": "TEXT", "is_frozen": "TEXT", "disabled": "TEXT", + "portal_users": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -3028,6 +3032,8 @@ "lft": "TEXT", "rgt": "TEXT", "old_parent": "TEXT", + "accounts": "TEXT", + "credit_limits": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -3147,7 +3153,9 @@ "is_default": "TEXT", "is_standard": "TEXT", "module": "TEXT", + "charts": "TEXT", "chart_options": "TEXT", + "cards": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -3167,6 +3175,7 @@ "report_name": "TEXT", "use_report_chart": "TEXT", "x_field": "TEXT", + "y_axis": "TEXT", "source": "TEXT", "document_type": "TEXT", "parent_document_type": "TEXT", @@ -3189,8 +3198,8 @@ "filters_json": "TEXT", "dynamic_filters_json": "TEXT", "custom_options": "TEXT", - "color": "TEXT", "last_synced_on": "TEXT", + "roles": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -3204,7 +3213,6 @@ }, "tabDashboard Chart Field": { "y_field": "TEXT", - "color": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -3262,7 +3270,6 @@ "tabData Import": { "reference_doctype": "TEXT", "import_type": "TEXT", - "import_file": "TEXT", "payload_count": "TEXT", "google_sheets_url": "TEXT", "status": "TEXT", @@ -3319,7 +3326,6 @@ "deleted_name": "TEXT", "deleted_doctype": "TEXT", "restored": "TEXT", - "new_name": "TEXT", "data": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -3358,6 +3364,7 @@ "last_scanned_warehouse": "TEXT", "set_warehouse": "TEXT", "set_target_warehouse": "TEXT", + "items": "TEXT", "total_qty": "TEXT", "total_net_weight": "TEXT", "base_total": "TEXT", @@ -3369,6 +3376,7 @@ "shipping_rule": "TEXT", "incoterm": "TEXT", "named_place": "TEXT", + "taxes": "TEXT", "base_total_taxes_and_charges": "TEXT", "total_taxes_and_charges": "TEXT", "base_grand_total": "TEXT", @@ -3385,6 +3393,8 @@ "additional_discount_percentage": "TEXT", "discount_amount": "TEXT", "other_charges_calculation": "TEXT", + "packed_items": "TEXT", + "pricing_rules": "TEXT", "customer_address": "TEXT", "address_display": "TEXT", "contact_person": "TEXT", @@ -3418,6 +3428,7 @@ "amount_eligible_for_commission": "TEXT", "commission_rate": "TEXT", "total_commission": "TEXT", + "sales_team": "TEXT", "auto_repeat": "TEXT", "letter_head": "TEXT", "print_without_amount": "TEXT", @@ -3453,7 +3464,6 @@ "description": "TEXT", "brand": "TEXT", "item_group": "TEXT", - "image": "TEXT", "qty": "TEXT", "stock_uom": "TEXT", "uom": "TEXT", @@ -3569,6 +3579,7 @@ "vehicle": "TEXT", "departure_time": "TEXT", "employee": "TEXT", + "delivery_stops": "TEXT", "status": "TEXT", "amended_from": "TEXT", "name": "TEXT", @@ -3590,6 +3601,9 @@ "disabled": "TEXT", "payroll_cost_center": "TEXT", "leave_block_list": "TEXT", + "shift_request_approver": "TEXT", + "leave_approvers": "TEXT", + "expense_approvers": "TEXT", "lft": "TEXT", "rgt": "TEXT", "old_parent": "TEXT", @@ -3638,6 +3652,7 @@ "designation_name": "TEXT", "description": "TEXT", "appraisal_template": "TEXT", + "skills": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -3896,10 +3911,14 @@ "sender_name_field": "TEXT", "recipient_account_field": "TEXT", "subject_field": "TEXT", + "permissions": "TEXT", "restrict_to_domain": "TEXT", "read_only": "TEXT", "in_create": "TEXT", "protect_attached_files": "TEXT", + "actions": "TEXT", + "links": "TEXT", + "states": "TEXT", "has_web_view": "TEXT", "allow_guest_to_view": "TEXT", "index_web_pages_for_search": "TEXT", @@ -3908,6 +3927,7 @@ "website_search_field": "TEXT", "engine": "TEXT", "migration_hash": "TEXT", + "fields": "TEXT", "row_format": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -3941,6 +3961,7 @@ "tabDocType Layout": { "document_type": "TEXT", "route": "TEXT", + "fields": "TEXT", "client_script": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -4021,6 +4042,7 @@ "document_type": "TEXT", "disabled": "TEXT", "priority": "TEXT", + "conditions": "TEXT", "prefix": "TEXT", "counter": "TEXT", "prefix_digits": "TEXT", @@ -4110,6 +4132,7 @@ "license_number": "TEXT", "issuing_date": "TEXT", "expiry_date": "TEXT", + "driving_license_category": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -4149,6 +4172,7 @@ "conversion_rate": "TEXT", "dunning_type": "TEXT", "rate_of_interest": "TEXT", + "overdue_payments": "TEXT", "total_interest": "TEXT", "dunning_fee": "TEXT", "dunning_amount": "TEXT", @@ -4204,6 +4228,7 @@ "company": "TEXT", "dunning_fee": "TEXT", "rate_of_interest": "TEXT", + "dunning_letter_text": "TEXT", "income_account": "TEXT", "cost_center": "TEXT", "name": "TEXT", @@ -4220,7 +4245,6 @@ "tabDynamic Link": { "link_doctype": "TEXT", "link_name": "TEXT", - "link_title": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -4257,6 +4281,7 @@ "attachment_limit": "TEXT", "email_sync_option": "TEXT", "initial_sync_count": "TEXT", + "imap_folder": "TEXT", "append_emails_to_sent_folder": "TEXT", "sent_folder_name": "TEXT", "append_to": "TEXT", @@ -4447,6 +4472,7 @@ }, "tabEmail Queue": { "sender": "TEXT", + "recipients": "TEXT", "show_as_cc": "TEXT", "message": "TEXT", "status": "TEXT", @@ -4602,6 +4628,9 @@ "date_of_issue": "TEXT", "place_of_issue": "TEXT", "bio": "TEXT", + "education": "TEXT", + "external_work_history": "TEXT", + "internal_work_history": "TEXT", "resignation_letter_date": "TEXT", "relieving_date": "TEXT", "held_on": "TEXT", @@ -4662,6 +4691,7 @@ }, "tabEmployee Group": { "employee_group_name": "TEXT", + "employee_list": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -4773,7 +4803,6 @@ "subject": "TEXT", "event_category": "TEXT", "event_type": "TEXT", - "color": "TEXT", "send_reminder": "TEXT", "repeat_this_event": "TEXT", "starts_on": "TEXT", @@ -4798,8 +4827,10 @@ "saturday": "TEXT", "sunday": "TEXT", "description": "TEXT", + "event_participants": "TEXT", "reference_doctype": "TEXT", "reference_docname": "TEXT", + "links": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -4830,6 +4861,7 @@ "posting_date": "TEXT", "rounding_loss_allowance": "TEXT", "company": "TEXT", + "accounts": "TEXT", "gain_loss_unbooked": "TEXT", "gain_loss_booked": "TEXT", "total_gain_loss": "TEXT", @@ -4917,6 +4949,7 @@ "is_short_year": "TEXT", "year_start_date": "TEXT", "year_end_date": "TEXT", + "companies": "TEXT", "auto_created": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -4960,6 +4993,7 @@ "first_document": "TEXT", "include_name_field": "TEXT", "page_route": "TEXT", + "steps": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -4979,8 +5013,6 @@ "fieldname": "TEXT", "element_selector": "TEXT", "parent_element_selector": "TEXT", - "description": "TEXT", - "ondemand_description": "TEXT", "position": "TEXT", "hide_buttons": "TEXT", "popover_element": "TEXT", @@ -5205,7 +5237,7 @@ "weekly_off": "TEXT", "country": "TEXT", "subdivision": "TEXT", - "color": "TEXT", + "holidays": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -5219,6 +5251,7 @@ }, "tabHomepage Section": { "section_based_on": "TEXT", + "section_cards": "TEXT", "no_of_columns": "TEXT", "section_html": "TEXT", "section_order": "TEXT", @@ -5272,7 +5305,6 @@ "supplier_group": "TEXT", "tax_account": "TEXT", "default_buying_price_list": "TEXT", - "zip_file": "TEXT", "status": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -5306,6 +5338,7 @@ "greeting_message": "TEXT", "agent_busy_message": "TEXT", "agent_unavailable_message": "TEXT", + "call_handling_schedule": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -5363,6 +5396,7 @@ "company": "TEXT", "amended_from": "TEXT", "remarks": "TEXT", + "items": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -5468,6 +5502,7 @@ "loan_end_date": "TEXT", "status": "TEXT", "company": "TEXT", + "invoices": "TEXT", "total_amount": "TEXT", "bank_charges": "TEXT", "short_term_loan": "TEXT", @@ -5521,7 +5556,6 @@ "project": "TEXT", "company": "TEXT", "via_customer_portal": "TEXT", - "attachment": "TEXT", "content_type": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -5582,6 +5616,7 @@ "over_billing_allowance": "TEXT", "description": "TEXT", "brand": "TEXT", + "uoms": "TEXT", "shelf_life_in_days": "TEXT", "end_of_life": "TEXT", "default_material_request_type": "TEXT", @@ -5590,6 +5625,8 @@ "weight_per_unit": "TEXT", "weight_uom": "TEXT", "allow_negative_stock": "TEXT", + "barcodes": "TEXT", + "reorder_levels": "TEXT", "has_batch_no": "TEXT", "create_new_batch": "TEXT", "batch_number_series": "TEXT", @@ -5600,10 +5637,12 @@ "serial_no_series": "TEXT", "variant_of": "TEXT", "variant_based_on": "TEXT", + "attributes": "TEXT", "enable_deferred_expense": "TEXT", "no_of_months_exp": "TEXT", "enable_deferred_revenue": "TEXT", "no_of_months": "TEXT", + "item_defaults": "TEXT", "purchase_uom": "TEXT", "min_order_qty": "TEXT", "safety_stock": "TEXT", @@ -5613,12 +5652,15 @@ "is_customer_provided_item": "TEXT", "customer": "TEXT", "delivered_by_supplier": "TEXT", + "supplier_items": "TEXT", "country_of_origin": "TEXT", "customs_tariff_number": "TEXT", "sales_uom": "TEXT", "grant_commission": "TEXT", "is_sales_item": "TEXT", "max_discount": "TEXT", + "customer_items": "TEXT", + "taxes": "TEXT", "inspection_required_before_purchase": "TEXT", "quality_inspection_template": "TEXT", "inspection_required_before_delivery": "TEXT", @@ -5644,8 +5686,6 @@ "item_code": "TEXT", "alternative_item_code": "TEXT", "two_way": "TEXT", - "item_name": "TEXT", - "alternative_item_name": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -5664,6 +5704,7 @@ "from_range": "TEXT", "increment": "TEXT", "to_range": "TEXT", + "item_attribute_values": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -5747,6 +5788,8 @@ "item_group_name": "TEXT", "parent_item_group": "TEXT", "is_group": "TEXT", + "item_group_defaults": "TEXT", + "taxes": "TEXT", "lft": "TEXT", "old_parent": "TEXT", "rgt": "TEXT", @@ -5882,6 +5925,7 @@ "title": "TEXT", "company": "TEXT", "disabled": "TEXT", + "taxes": "TEXT", "custom_exemption_reason_code": "TEXT", "custom_zatca_tax_category": "TEXT", "name": "TEXT", @@ -5971,6 +6015,8 @@ "expected_start_date": "TEXT", "time_required": "TEXT", "expected_end_date": "TEXT", + "scheduled_time_logs": "TEXT", + "time_logs": "TEXT", "actual_start_date": "TEXT", "total_time_in_mins": "TEXT", "actual_end_date": "TEXT", @@ -5980,12 +6026,14 @@ "workstation": "TEXT", "quality_inspection_template": "TEXT", "quality_inspection": "TEXT", + "sub_operations": "TEXT", + "items": "TEXT", + "scrap_items": "TEXT", "for_job_card": "TEXT", "is_corrective_job_card": "TEXT", "hour_rate": "TEXT", "for_operation": "TEXT", "project": "TEXT", - "item_name": "TEXT", "transferred_qty": "TEXT", "requested_qty": "TEXT", "status": "TEXT", @@ -5996,7 +6044,6 @@ "serial_and_batch_bundle": "TEXT", "batch_no": "TEXT", "serial_no": "TEXT", - "barcode": "TEXT", "job_started": "TEXT", "started_time": "TEXT", "current_time": "TEXT", @@ -6113,6 +6160,7 @@ "company": "TEXT", "posting_date": "TEXT", "apply_tds": "TEXT", + "accounts": "TEXT", "cheque_no": "TEXT", "cheque_date": "TEXT", "user_remark": "TEXT", @@ -6194,6 +6242,7 @@ "company": "TEXT", "is_opening": "TEXT", "multi_currency": "TEXT", + "accounts": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -6224,6 +6273,7 @@ "field_name": "TEXT", "private": "TEXT", "show_labels": "TEXT", + "columns": "TEXT", "filters": "TEXT", "fields": "TEXT", "name": "TEXT", @@ -6330,6 +6380,9 @@ "naming_series": "TEXT", "company": "TEXT", "posting_date": "TEXT", + "purchase_receipts": "TEXT", + "items": "TEXT", + "taxes": "TEXT", "total_taxes_and_charges": "TEXT", "distribute_charges_based_on": "TEXT", "amended_from": "TEXT", @@ -6402,6 +6455,7 @@ "disabled": "TEXT", "unsubscribed": "TEXT", "blog_subscriber": "TEXT", + "notes": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -6464,6 +6518,7 @@ "company": "TEXT", "status": "TEXT", "is_group": "TEXT", + "merge_accounts": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -6499,8 +6554,6 @@ "image_height": "TEXT", "image_width": "TEXT", "align": "TEXT", - "content": "TEXT", - "footer": "TEXT", "footer_image_height": "TEXT", "footer_image_width": "TEXT", "footer_align": "TEXT", @@ -6575,7 +6628,6 @@ "longitude": "TEXT", "area": "TEXT", "area_uom": "TEXT", - "location": "TEXT", "lft": "TEXT", "rgt": "TEXT", "old_parent": "TEXT", @@ -6698,6 +6750,7 @@ "customer_group": "TEXT", "customer_territory": "TEXT", "auto_opt_in": "TEXT", + "collection_rules": "TEXT", "conversion_factor": "TEXT", "expiry_duration": "TEXT", "expense_account": "TEXT", @@ -6735,6 +6788,8 @@ "customer": "TEXT", "status": "TEXT", "transaction_date": "TEXT", + "items": "TEXT", + "schedules": "TEXT", "customer_name": "TEXT", "contact_person": "TEXT", "contact_mobile": "TEXT", @@ -6829,6 +6884,7 @@ "mntc_time": "TEXT", "completion_status": "TEXT", "maintenance_type": "TEXT", + "purposes": "TEXT", "customer_feedback": "TEXT", "status": "TEXT", "amended_from": "TEXT", @@ -6926,6 +6982,7 @@ "last_scanned_warehouse": "TEXT", "set_from_warehouse": "TEXT", "set_warehouse": "TEXT", + "items": "TEXT", "tc_name": "TEXT", "terms": "TEXT", "status": "TEXT", @@ -7061,6 +7118,7 @@ "mode_of_payment": "TEXT", "enabled": "TEXT", "type": "TEXT", + "accounts": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -7111,6 +7169,7 @@ "success_message": "TEXT", "documentation_url": "TEXT", "is_complete": "TEXT", + "steps": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -7124,6 +7183,7 @@ }, "tabModule Profile": { "module_profile_name": "TEXT", + "block_modules": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -7138,6 +7198,7 @@ "tabMonthly Distribution": { "distribution_id": "TEXT", "fiscal_year": "TEXT", + "percentages": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -7205,12 +7266,12 @@ "sender_name": "TEXT", "sender_email": "TEXT", "send_from": "TEXT", + "email_group": "TEXT", "subject": "TEXT", "content_type": "TEXT", "message": "TEXT", - "message_md": "TEXT", - "message_html": "TEXT", "campaign": "TEXT", + "attachments": "TEXT", "send_unsubscribe_link": "TEXT", "send_webview_link": "TEXT", "scheduled_to_send": "TEXT", @@ -7229,22 +7290,8 @@ "parentfield": "TEXT", "parenttype": "TEXT" }, - "tabNewsletter Attachment": { - "attachment": "TEXT", - "name": "TEXT", - "owner": "TEXT", - "creation": "TEXT", - "modified": "TEXT", - "modified_by": "TEXT", - "docstatus": "INT", - "idx": "INT", - "parent": "TEXT", - "parentfield": "TEXT", - "parenttype": "TEXT" - }, "tabNewsletter Email Group": { "email_group": "TEXT", - "total_subscribers": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -7283,6 +7330,7 @@ "notify_on_every_login": "TEXT", "expire_notification_on": "TEXT", "content": "TEXT", + "seen_by": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -7327,6 +7375,7 @@ "set_property_after_alert": "TEXT", "property_value": "TEXT", "send_to_all_assignees": "TEXT", + "recipients": "TEXT", "message_type": "TEXT", "message": "TEXT", "attach_print": "TEXT", @@ -7438,8 +7487,6 @@ "stats_time_interval": "TEXT", "filters_json": "TEXT", "dynamic_filters_json": "TEXT", - "color": "TEXT", - "background_color": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -7572,7 +7619,6 @@ "title": "TEXT", "is_complete": "TEXT", "is_skipped": "TEXT", - "description": "TEXT", "intro_video_url": "TEXT", "action": "TEXT", "action_label": "TEXT", @@ -7644,6 +7690,7 @@ "create_job_card_based_on_batch_size": "TEXT", "quality_inspection_template": "TEXT", "batch_size": "TEXT", + "sub_operations": "TEXT", "total_operation_time": "TEXT", "description": "TEXT", "name": "TEXT", @@ -7703,8 +7750,10 @@ "customer_address": "TEXT", "address_display": "TEXT", "contact_display": "TEXT", + "items": "TEXT", "base_total": "TEXT", "total": "TEXT", + "notes": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -7724,7 +7773,6 @@ "brand": "TEXT", "item_group": "TEXT", "description": "TEXT", - "image": "TEXT", "base_rate": "TEXT", "base_amount": "TEXT", "rate": "TEXT", @@ -7815,9 +7863,12 @@ "company": "TEXT", "pos_profile": "TEXT", "user": "TEXT", + "pos_transactions": "TEXT", + "payment_reconciliation": "TEXT", "grand_total": "TEXT", "net_total": "TEXT", "total_quantity": "TEXT", + "taxes": "TEXT", "error_message": "TEXT", "amended_from": "TEXT", "name": "TEXT", @@ -7946,6 +7997,10 @@ "update_stock": "TEXT", "scan_barcode": "TEXT", "last_scanned_warehouse": "TEXT", + "items": "TEXT", + "pricing_rules": "TEXT", + "packed_items": "TEXT", + "timesheets": "TEXT", "total_billing_amount": "TEXT", "total_qty": "TEXT", "base_total": "TEXT", @@ -7956,6 +8011,7 @@ "taxes_and_charges": "TEXT", "shipping_rule": "TEXT", "tax_category": "TEXT", + "taxes": "TEXT", "other_charges_calculation": "TEXT", "base_total_taxes_and_charges": "TEXT", "total_taxes_and_charges": "TEXT", @@ -7981,8 +8037,11 @@ "total_advance": "TEXT", "outstanding_amount": "TEXT", "allocate_advances_automatically": "TEXT", + "advances": "TEXT", "payment_terms_template": "TEXT", + "payment_schedule": "TEXT", "cash_bank_account": "TEXT", + "payments": "TEXT", "base_paid_amount": "TEXT", "paid_amount": "TEXT", "base_change_amount": "TEXT", @@ -8013,6 +8072,7 @@ "amount_eligible_for_commission": "TEXT", "commission_rate": "TEXT", "total_commission": "TEXT", + "sales_team": "TEXT", "from_date": "TEXT", "to_date": "TEXT", "auto_repeat": "TEXT", @@ -8038,7 +8098,6 @@ "description": "TEXT", "item_group": "TEXT", "brand": "TEXT", - "image": "TEXT", "qty": "TEXT", "stock_uom": "TEXT", "uom": "TEXT", @@ -8118,6 +8177,7 @@ "pos_closing_entry": "TEXT", "customer": "TEXT", "customer_group": "TEXT", + "pos_invoices": "TEXT", "consolidated_invoice": "TEXT", "consolidated_credit_note": "TEXT", "amended_from": "TEXT", @@ -8173,6 +8233,7 @@ "pos_profile": "TEXT", "pos_closing_entry": "TEXT", "user": "TEXT", + "balance_details": "TEXT", "amended_from": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -8217,11 +8278,12 @@ "tabPOS Profile": { "company": "TEXT", "customer": "TEXT", - "country": "TEXT", "disabled": "TEXT", "warehouse": "TEXT", "campaign": "TEXT", "company_address": "TEXT", + "applicable_for_users": "TEXT", + "payments": "TEXT", "hide_images": "TEXT", "hide_unavailable_items": "TEXT", "auto_add_item_to_cart": "TEXT", @@ -8233,6 +8295,8 @@ "allow_discount_change": "TEXT", "disable_grand_total_to_default_mop": "TEXT", "allow_partial_payment": "TEXT", + "item_groups": "TEXT", + "customer_groups": "TEXT", "print_format": "TEXT", "letter_head": "TEXT", "tc_name": "TEXT", @@ -8318,9 +8382,7 @@ }, "tabPackage": { "package_name": "TEXT", - "readme": "TEXT", "license_type": "TEXT", - "license": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -8333,7 +8395,6 @@ "parenttype": "TEXT" }, "tabPackage Import": { - "attach_package": "TEXT", "activate": "TEXT", "force": "TEXT", "log": "TEXT", @@ -8355,7 +8416,6 @@ "major": "TEXT", "minor": "TEXT", "patch": "TEXT", - "release_notes": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -8409,6 +8469,7 @@ "naming_series": "TEXT", "from_case_no": "TEXT", "to_case_no": "TEXT", + "items": "TEXT", "net_weight_pkg": "TEXT", "net_weight_uom": "TEXT", "gross_weight_pkg": "TEXT", @@ -8457,6 +8518,7 @@ "module": "TEXT", "restrict_to_domain": "TEXT", "standard": "TEXT", + "roles": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -8592,6 +8654,7 @@ "target_exchange_rate": "TEXT", "base_received_amount": "TEXT", "base_received_amount_after_tax": "TEXT", + "references": "TEXT", "total_allocated_amount": "TEXT", "base_total_allocated_amount": "TEXT", "unallocated_amount": "TEXT", @@ -8600,8 +8663,10 @@ "sales_taxes_and_charges_template": "TEXT", "apply_tax_withholding_amount": "TEXT", "tax_withholding_category": "TEXT", + "taxes": "TEXT", "base_total_taxes_and_charges": "TEXT", "total_taxes_and_charges": "TEXT", + "deductions": "TEXT", "reference_no": "TEXT", "reference_date": "TEXT", "clearance_date": "TEXT", @@ -8614,8 +8679,6 @@ "is_opening": "TEXT", "letter_head": "TEXT", "print_heading": "TEXT", - "bank": "TEXT", - "bank_account_no": "TEXT", "payment_order": "TEXT", "in_words": "TEXT", "auto_repeat": "TEXT", @@ -8686,7 +8749,6 @@ "company": "TEXT", "is_default": "TEXT", "payment_account": "TEXT", - "currency": "TEXT", "message": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -8739,6 +8801,7 @@ "company_bank": "TEXT", "company_bank_account": "TEXT", "account": "TEXT", + "references": "TEXT", "amended_from": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -8788,13 +8851,9 @@ "is_a_subscription": "TEXT", "outstanding_amount": "TEXT", "party_account_currency": "TEXT", + "subscription_plans": "TEXT", "bank_account": "TEXT", "bank": "TEXT", - "bank_account_no": "TEXT", - "account": "TEXT", - "iban": "TEXT", - "branch_code": "TEXT", - "swift_number": "TEXT", "cost_center": "TEXT", "project": "TEXT", "print_format": "TEXT", @@ -8806,8 +8865,6 @@ "message": "TEXT", "mute_email": "TEXT", "payment_url": "TEXT", - "payment_gateway": "TEXT", - "payment_account": "TEXT", "payment_channel": "TEXT", "payment_order": "TEXT", "amended_from": "TEXT", @@ -8881,6 +8938,7 @@ "tabPayment Terms Template": { "template_name": "TEXT", "allocate_payment_based_on_payment_terms": "TEXT", + "terms": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -8956,6 +9014,7 @@ "email": "TEXT", "status": "TEXT", "anonymization_matrix": "TEXT", + "deletion_steps": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -9015,6 +9074,7 @@ "scan_barcode": "TEXT", "scan_mode": "TEXT", "prompt_qty": "TEXT", + "locations": "TEXT", "amended_from": "TEXT", "group_same_items": "TEXT", "status": "TEXT", @@ -9141,6 +9201,7 @@ "buying": "TEXT", "selling": "TEXT", "price_not_uom_dependent": "TEXT", + "countries": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -9172,6 +9233,9 @@ "apply_on": "TEXT", "price_or_product_discount": "TEXT", "warehouse": "TEXT", + "items": "TEXT", + "item_groups": "TEXT", + "brands": "TEXT", "mixed_conditions": "TEXT", "is_cumulative": "TEXT", "coupon_code_based": "TEXT", @@ -9437,6 +9501,7 @@ "total_allocations": "TEXT", "reconciled_entries": "TEXT", "error_log": "TEXT", + "allocations": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -9479,7 +9544,9 @@ "parent_pcv": "TEXT", "status": "TEXT", "p_l_closing_balance": "TEXT", + "normal_balances": "TEXT", "bs_closing_balance": "TEXT", + "z_opening_balances": "TEXT", "amended_from": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -9532,6 +9599,7 @@ "collection_name": "TEXT", "primary_mandatory": "TEXT", "show_net_values_in_party_account": "TEXT", + "customers": "TEXT", "orientation": "TEXT", "include_break": "TEXT", "include_ageing": "TEXT", @@ -9575,7 +9643,6 @@ "customer": "TEXT", "customer_name": "TEXT", "billing_email": "TEXT", - "primary_email": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -9606,6 +9673,7 @@ "new_item_code": "TEXT", "description": "TEXT", "disabled": "TEXT", + "items": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -9648,16 +9716,22 @@ "to_date": "TEXT", "from_delivery_date": "TEXT", "to_delivery_date": "TEXT", + "sales_orders": "TEXT", + "material_requests": "TEXT", "combine_items": "TEXT", + "po_items": "TEXT", + "prod_plan_references": "TEXT", "combine_sub_items": "TEXT", "sub_assembly_warehouse": "TEXT", "skip_available_sub_assembly_item": "TEXT", + "sub_assembly_items": "TEXT", "include_non_stock_items": "TEXT", "include_subcontracted_items": "TEXT", "consider_minimum_order_qty": "TEXT", "include_safety_stock": "TEXT", "ignore_existing_ordered_qty": "TEXT", "for_warehouse": "TEXT", + "mr_items": "TEXT", "total_planned_qty": "TEXT", "total_produced_qty": "TEXT", "status": "TEXT", @@ -9811,6 +9885,7 @@ "department": "TEXT", "customer": "TEXT", "sales_order": "TEXT", + "users": "TEXT", "copied_from": "TEXT", "notes": "TEXT", "actual_start_date": "TEXT", @@ -9853,6 +9928,7 @@ }, "tabProject Template": { "project_type": "TEXT", + "tasks": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -9866,7 +9942,6 @@ }, "tabProject Template Task": { "task": "TEXT", - "subject": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -9898,6 +9973,7 @@ "sent": "TEXT", "date": "TEXT", "time": "TEXT", + "users": "TEXT", "amended_from": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -9912,9 +9988,6 @@ }, "tabProject User": { "user": "TEXT", - "email": "TEXT", - "image": "TEXT", - "full_name": "TEXT", "welcome_email_sent": "TEXT", "view_attachments": "TEXT", "hide_timesheets": "TEXT", @@ -9933,6 +10006,9 @@ "tabPromotional Scheme": { "apply_on": "TEXT", "disable": "TEXT", + "items": "TEXT", + "item_groups": "TEXT", + "brands": "TEXT", "mixed_conditions": "TEXT", "is_cumulative": "TEXT", "apply_rule_on_other": "TEXT", @@ -9953,6 +10029,8 @@ "valid_upto": "TEXT", "company": "TEXT", "currency": "TEXT", + "price_discount_slabs": "TEXT", + "product_discount_slabs": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -10058,6 +10136,9 @@ "website": "TEXT", "fax": "TEXT", "company": "TEXT", + "leads": "TEXT", + "opportunities": "TEXT", + "notes": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -10112,7 +10193,6 @@ "naming_series": "TEXT", "supplier": "TEXT", "supplier_name": "TEXT", - "tax_id": "TEXT", "company": "TEXT", "posting_date": "TEXT", "posting_time": "TEXT", @@ -10153,6 +10233,7 @@ "is_subcontracted": "TEXT", "rejected_warehouse": "TEXT", "supplier_warehouse": "TEXT", + "items": "TEXT", "total_qty": "TEXT", "total_net_weight": "TEXT", "base_total": "TEXT", @@ -10166,6 +10247,7 @@ "shipping_rule": "TEXT", "incoterm": "TEXT", "named_place": "TEXT", + "taxes": "TEXT", "base_taxes_and_charges_added": "TEXT", "base_taxes_and_charges_deducted": "TEXT", "base_total_taxes_and_charges": "TEXT", @@ -10188,7 +10270,10 @@ "base_discount_amount": "TEXT", "additional_discount_percentage": "TEXT", "discount_amount": "TEXT", + "tax_withheld_vouchers": "TEXT", "other_charges_calculation": "TEXT", + "pricing_rules": "TEXT", + "supplied_items": "TEXT", "mode_of_payment": "TEXT", "base_paid_amount": "TEXT", "clearance_date": "TEXT", @@ -10196,6 +10281,8 @@ "paid_amount": "TEXT", "allocate_advances_automatically": "TEXT", "only_include_allocated_payments": "TEXT", + "advances": "TEXT", + "advance_tax": "TEXT", "write_off_amount": "TEXT", "base_write_off_amount": "TEXT", "write_off_account": "TEXT", @@ -10214,6 +10301,7 @@ "billing_address_display": "TEXT", "payment_terms_template": "TEXT", "ignore_default_payment_terms_template": "TEXT", + "payment_schedule": "TEXT", "tc_name": "TEXT", "terms": "TEXT", "status": "TEXT", @@ -10279,7 +10367,6 @@ "description": "TEXT", "brand": "TEXT", "item_group": "TEXT", - "image": "TEXT", "received_qty": "TEXT", "qty": "TEXT", "rejected_qty": "TEXT", @@ -10393,6 +10480,7 @@ "last_scanned_warehouse": "TEXT", "set_from_warehouse": "TEXT", "set_warehouse": "TEXT", + "items": "TEXT", "total_qty": "TEXT", "total_net_weight": "TEXT", "base_total": "TEXT", @@ -10401,12 +10489,15 @@ "net_total": "TEXT", "tax_withholding_net_total": "TEXT", "base_tax_withholding_net_total": "TEXT", + "pricing_rules": "TEXT", "set_reserve_warehouse": "TEXT", + "supplied_items": "TEXT", "tax_category": "TEXT", "taxes_and_charges": "TEXT", "shipping_rule": "TEXT", "incoterm": "TEXT", "named_place": "TEXT", + "taxes": "TEXT", "base_taxes_and_charges_added": "TEXT", "base_taxes_and_charges_deducted": "TEXT", "base_total_taxes_and_charges": "TEXT", @@ -10447,6 +10538,7 @@ "customer_contact_mobile": "TEXT", "customer_contact_email": "TEXT", "payment_terms_template": "TEXT", + "payment_schedule": "TEXT", "tc_name": "TEXT", "terms": "TEXT", "status": "TEXT", @@ -10488,7 +10580,6 @@ "expected_delivery_date": "TEXT", "item_group": "TEXT", "description": "TEXT", - "image": "TEXT", "qty": "TEXT", "stock_uom": "TEXT", "subcontracted_quantity": "TEXT", @@ -10619,6 +10710,7 @@ "rejected_warehouse": "TEXT", "is_subcontracted": "TEXT", "supplier_warehouse": "TEXT", + "items": "TEXT", "total_qty": "TEXT", "total_net_weight": "TEXT", "base_total": "TEXT", @@ -10632,6 +10724,7 @@ "shipping_rule": "TEXT", "incoterm": "TEXT", "named_place": "TEXT", + "taxes": "TEXT", "base_taxes_and_charges_added": "TEXT", "base_taxes_and_charges_deducted": "TEXT", "base_total_taxes_and_charges": "TEXT", @@ -10652,6 +10745,8 @@ "additional_discount_percentage": "TEXT", "discount_amount": "TEXT", "other_charges_calculation": "TEXT", + "pricing_rules": "TEXT", + "supplied_items": "TEXT", "supplier_address": "TEXT", "address_display": "TEXT", "contact_person": "TEXT", @@ -10706,7 +10801,6 @@ "description": "TEXT", "brand": "TEXT", "item_group": "TEXT", - "image": "TEXT", "received_qty": "TEXT", "qty": "TEXT", "rejected_qty": "TEXT", @@ -10866,6 +10960,7 @@ "disabled": "TEXT", "company": "TEXT", "tax_category": "TEXT", + "taxes": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -10908,6 +11003,7 @@ "date": "TEXT", "goal": "TEXT", "procedure": "TEXT", + "resolutions": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -10940,6 +11036,7 @@ "template": "TEXT", "document_type": "TEXT", "document_name": "TEXT", + "parameters": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -10968,6 +11065,7 @@ }, "tabQuality Feedback Template": { "template": "TEXT", + "parameters": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -10998,6 +11096,7 @@ "procedure": "TEXT", "weekday": "TEXT", "date": "TEXT", + "objectives": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -11042,6 +11141,7 @@ "bom_no": "TEXT", "quality_inspection_template": "TEXT", "manual_inspection": "TEXT", + "readings": "TEXT", "inspected_by": "TEXT", "verified_by": "TEXT", "remarks": "TEXT", @@ -11121,6 +11221,7 @@ }, "tabQuality Inspection Template": { "quality_inspection_template_name": "TEXT", + "item_quality_inspection_parameter": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -11134,6 +11235,8 @@ }, "tabQuality Meeting": { "status": "TEXT", + "agenda": "TEXT", + "minutes": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -11177,6 +11280,7 @@ "quality_procedure_name": "TEXT", "process_owner": "TEXT", "process_owner_full_name": "TEXT", + "processes": "TEXT", "parent_quality_procedure": "TEXT", "is_group": "TEXT", "rgt": "TEXT", @@ -11212,6 +11316,7 @@ "date": "TEXT", "procedure": "TEXT", "status": "TEXT", + "reviews": "TEXT", "additional_information": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -11275,6 +11380,7 @@ "ignore_pricing_rule": "TEXT", "scan_barcode": "TEXT", "last_scanned_warehouse": "TEXT", + "items": "TEXT", "total_qty": "TEXT", "total_net_weight": "TEXT", "base_total": "TEXT", @@ -11286,6 +11392,7 @@ "shipping_rule": "TEXT", "incoterm": "TEXT", "named_place": "TEXT", + "taxes": "TEXT", "base_total_taxes_and_charges": "TEXT", "total_taxes_and_charges": "TEXT", "base_grand_total": "TEXT", @@ -11304,6 +11411,8 @@ "discount_amount": "TEXT", "referral_sales_partner": "TEXT", "other_charges_calculation": "TEXT", + "packed_items": "TEXT", + "pricing_rules": "TEXT", "customer_address": "TEXT", "address_display": "TEXT", "contact_person": "TEXT", @@ -11316,6 +11425,7 @@ "company_address_display": "TEXT", "company_contact_person": "TEXT", "payment_terms_template": "TEXT", + "payment_schedule": "TEXT", "tc_name": "TEXT", "terms": "TEXT", "auto_repeat": "TEXT", @@ -11352,7 +11462,6 @@ "description": "TEXT", "item_group": "TEXT", "brand": "TEXT", - "image": "TEXT", "qty": "TEXT", "stock_uom": "TEXT", "uom": "TEXT", @@ -11466,10 +11575,13 @@ "prepared_report": "TEXT", "add_translate_data": "TEXT", "timeout": "TEXT", + "filters": "TEXT", + "columns": "TEXT", "query": "TEXT", "report_script": "TEXT", "javascript": "TEXT", "json": "TEXT", + "roles": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -11520,6 +11632,7 @@ "tabRepost Accounting Ledger": { "company": "TEXT", "delete_cancelled_entries": "TEXT", + "vouchers": "TEXT", "amended_from": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -11576,7 +11689,6 @@ "recreate_stock_ledgers": "TEXT", "amended_from": "TEXT", "error_log": "TEXT", - "reposting_data_file": "TEXT", "items_to_be_repost": "TEXT", "distinct_item_and_warehouse": "TEXT", "total_reposting_count": "TEXT", @@ -11601,6 +11713,7 @@ "add_manually": "TEXT", "repost_status": "TEXT", "repost_error_log": "TEXT", + "repost_vouchers": "TEXT", "amended_from": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -11638,6 +11751,8 @@ "status": "TEXT", "has_unit_price_items": "TEXT", "amended_from": "TEXT", + "suppliers": "TEXT", + "items": "TEXT", "email_template": "TEXT", "send_attached_files": "TEXT", "send_document_print": "TEXT", @@ -11668,7 +11783,6 @@ "description": "TEXT", "item_group": "TEXT", "brand": "TEXT", - "image": "TEXT", "qty": "TEXT", "stock_uom": "TEXT", "uom": "TEXT", @@ -11694,7 +11808,6 @@ "supplier": "TEXT", "contact": "TEXT", "quote_status": "TEXT", - "supplier_name": "TEXT", "email_id": "TEXT", "send_email": "TEXT", "email_sent": "TEXT", @@ -11745,6 +11858,7 @@ }, "tabRole Profile": { "role_profile": "TEXT", + "roles": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -11773,6 +11887,7 @@ "tabRouting": { "routing_name": "TEXT", "disabled": "TEXT", + "operations": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -11883,6 +11998,7 @@ "last_scanned_warehouse": "TEXT", "set_warehouse": "TEXT", "set_target_warehouse": "TEXT", + "items": "TEXT", "total_qty": "TEXT", "total_net_weight": "TEXT", "base_total": "TEXT", @@ -11894,6 +12010,7 @@ "shipping_rule": "TEXT", "incoterm": "TEXT", "named_place": "TEXT", + "taxes": "TEXT", "base_total_taxes_and_charges": "TEXT", "total_taxes_and_charges": "TEXT", "base_grand_total": "TEXT", @@ -11915,9 +12032,13 @@ "additional_discount_percentage": "TEXT", "discount_amount": "TEXT", "other_charges_calculation": "TEXT", + "pricing_rules": "TEXT", + "packed_items": "TEXT", + "timesheets": "TEXT", "total_billing_hours": "TEXT", "total_billing_amount": "TEXT", "cash_bank_account": "TEXT", + "payments": "TEXT", "base_paid_amount": "TEXT", "paid_amount": "TEXT", "base_change_amount": "TEXT", @@ -11925,6 +12046,7 @@ "account_for_change_amount": "TEXT", "allocate_advances_automatically": "TEXT", "only_include_allocated_payments": "TEXT", + "advances": "TEXT", "write_off_amount": "TEXT", "base_write_off_amount": "TEXT", "write_off_outstanding_amount_automatically": "TEXT", @@ -11952,6 +12074,7 @@ "company_contact_person": "TEXT", "ignore_default_payment_terms_template": "TEXT", "payment_terms_template": "TEXT", + "payment_schedule": "TEXT", "tc_name": "TEXT", "terms": "TEXT", "po_no": "TEXT", @@ -11965,6 +12088,7 @@ "amount_eligible_for_commission": "TEXT", "commission_rate": "TEXT", "total_commission": "TEXT", + "sales_team": "TEXT", "letter_head": "TEXT", "group_same_items": "TEXT", "select_print_heading": "TEXT", @@ -12025,7 +12149,6 @@ "description": "TEXT", "item_group": "TEXT", "brand": "TEXT", - "image": "TEXT", "qty": "TEXT", "stock_uom": "TEXT", "uom": "TEXT", @@ -12111,7 +12234,6 @@ "amount": "TEXT", "reference_no": "TEXT", "account": "TEXT", - "type": "TEXT", "base_amount": "TEXT", "clearance_date": "TEXT", "name": "TEXT", @@ -12173,6 +12295,7 @@ "last_scanned_warehouse": "TEXT", "set_warehouse": "TEXT", "reserve_stock": "TEXT", + "items": "TEXT", "total_qty": "TEXT", "total_net_weight": "TEXT", "base_total": "TEXT", @@ -12184,6 +12307,7 @@ "shipping_rule": "TEXT", "incoterm": "TEXT", "named_place": "TEXT", + "taxes": "TEXT", "base_total_taxes_and_charges": "TEXT", "total_taxes_and_charges": "TEXT", "base_grand_total": "TEXT", @@ -12202,6 +12326,8 @@ "additional_discount_percentage": "TEXT", "discount_amount": "TEXT", "other_charges_calculation": "TEXT", + "packed_items": "TEXT", + "pricing_rules": "TEXT", "customer_address": "TEXT", "address_display": "TEXT", "customer_group": "TEXT", @@ -12219,6 +12345,7 @@ "company_address_display": "TEXT", "company_contact_person": "TEXT", "payment_terms_template": "TEXT", + "payment_schedule": "TEXT", "tc_name": "TEXT", "terms": "TEXT", "status": "TEXT", @@ -12231,6 +12358,7 @@ "amount_eligible_for_commission": "TEXT", "commission_rate": "TEXT", "total_commission": "TEXT", + "sales_team": "TEXT", "loyalty_points": "TEXT", "loyalty_amount": "TEXT", "from_date": "TEXT", @@ -12268,7 +12396,6 @@ "description": "TEXT", "item_group": "TEXT", "brand": "TEXT", - "image": "TEXT", "qty": "TEXT", "stock_uom": "TEXT", "uom": "TEXT", @@ -12350,10 +12477,10 @@ "partner_type": "TEXT", "territory": "TEXT", "commission_rate": "TEXT", + "targets": "TEXT", "show_in_website": "TEXT", "referral_code": "TEXT", "route": "TEXT", - "logo": "TEXT", "partner_website": "TEXT", "introduction": "TEXT", "description": "TEXT", @@ -12405,6 +12532,7 @@ "lft": "TEXT", "rgt": "TEXT", "old_parent": "TEXT", + "targets": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -12465,6 +12593,7 @@ "disabled": "TEXT", "company": "TEXT", "tax_category": "TEXT", + "taxes": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -12601,6 +12730,7 @@ "item_code": "TEXT", "warehouse": "TEXT", "type_of_transaction": "TEXT", + "entries": "TEXT", "total_qty": "TEXT", "item_group": "TEXT", "avg_rate": "TEXT", @@ -12699,7 +12829,11 @@ "start_date": "TEXT", "end_date": "TEXT", "apply_sla_for_resolution": "TEXT", + "priorities": "TEXT", + "sla_fulfilled_on": "TEXT", + "pause_sla_on": "TEXT", "holiday_list": "TEXT", + "support_and_resolution": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -12809,6 +12943,7 @@ "folio_no": "TEXT", "company": "TEXT", "is_company": "TEXT", + "share_balance": "TEXT", "contact_list": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -12843,8 +12978,10 @@ "delivery_contact_name": "TEXT", "delivery_contact_email": "TEXT", "delivery_contact": "TEXT", + "shipment_parcel": "TEXT", "parcel_template": "TEXT", "total_weight": "TEXT", + "shipment_delivery_note": "TEXT", "pallets": "TEXT", "value_of_goods": "TEXT", "pickup_date": "TEXT", @@ -12934,6 +13071,8 @@ "project": "TEXT", "calculate_based_on": "TEXT", "shipping_amount": "TEXT", + "conditions": "TEXT", + "countries": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -12990,8 +13129,6 @@ }, "tabSocial Link Settings": { "social_link_type": "TEXT", - "color": "TEXT", - "background_color": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -13046,6 +13183,7 @@ }, "tabSouth Africa VAT Settings": { "company": "TEXT", + "vat_accounts": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -13091,9 +13229,11 @@ "target_address_display": "TEXT", "scan_barcode": "TEXT", "last_scanned_warehouse": "TEXT", + "items": "TEXT", "total_outgoing_value": "TEXT", "total_incoming_value": "TEXT", "value_difference": "TEXT", + "additional_costs": "TEXT", "total_additional_costs": "TEXT", "supplier": "TEXT", "supplier_name": "TEXT", @@ -13134,7 +13274,6 @@ "subcontracted_item": "TEXT", "description": "TEXT", "item_group": "TEXT", - "image": "TEXT", "qty": "TEXT", "transfer_qty": "TEXT", "retain_sample": "TEXT", @@ -13250,6 +13389,7 @@ "scan_barcode": "TEXT", "last_scanned_warehouse": "TEXT", "scan_mode": "TEXT", + "items": "TEXT", "expense_account": "TEXT", "difference_amount": "TEXT", "amended_from": "TEXT", @@ -13286,7 +13426,6 @@ "current_amount": "TEXT", "current_valuation_rate": "TEXT", "current_serial_no": "TEXT", - "quantity_difference": "TEXT", "amount_difference": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -13316,6 +13455,7 @@ "reserved_qty": "TEXT", "delivered_qty": "TEXT", "reservation_based_on": "TEXT", + "sb_entries": "TEXT", "company": "TEXT", "project": "TEXT", "status": "TEXT", @@ -13382,9 +13522,12 @@ "cost_center": "TEXT", "project": "TEXT", "set_warehouse": "TEXT", + "items": "TEXT", "total_qty": "TEXT", "total": "TEXT", + "service_items": "TEXT", "set_reserve_warehouse": "TEXT", + "supplied_items": "TEXT", "supplier_address": "TEXT", "address_display": "TEXT", "contact_person": "TEXT", @@ -13396,6 +13539,7 @@ "billing_address": "TEXT", "billing_address_display": "TEXT", "distribute_additional_costs_based_on": "TEXT", + "additional_costs": "TEXT", "total_additional_costs": "TEXT", "status": "TEXT", "per_received": "TEXT", @@ -13420,7 +13564,6 @@ "schedule_date": "TEXT", "expected_delivery_date": "TEXT", "description": "TEXT", - "image": "TEXT", "qty": "TEXT", "received_qty": "TEXT", "returned_qty": "TEXT", @@ -13519,8 +13662,10 @@ "set_warehouse": "TEXT", "rejected_warehouse": "TEXT", "supplier_warehouse": "TEXT", + "items": "TEXT", "total_qty": "TEXT", "total": "TEXT", + "supplied_items": "TEXT", "in_words": "TEXT", "bill_no": "TEXT", "bill_date": "TEXT", @@ -13535,6 +13680,7 @@ "billing_address": "TEXT", "billing_address_display": "TEXT", "distribute_additional_costs_based_on": "TEXT", + "additional_costs": "TEXT", "total_additional_costs": "TEXT", "amended_from": "TEXT", "range": "TEXT", @@ -13567,7 +13713,6 @@ "is_scrap_item": "TEXT", "description": "TEXT", "brand": "TEXT", - "image": "TEXT", "received_qty": "TEXT", "qty": "TEXT", "rejected_qty": "TEXT", @@ -13689,6 +13834,7 @@ "generate_invoice_at": "TEXT", "number_of_days": "TEXT", "cancel_at_period_end": "TEXT", + "plans": "TEXT", "sales_tax_template": "TEXT", "purchase_tax_template": "TEXT", "apply_additional_discount": "TEXT", @@ -13786,6 +13932,7 @@ "default_price_list": "TEXT", "is_internal_supplier": "TEXT", "represents_company": "TEXT", + "companies": "TEXT", "supplier_details": "TEXT", "website": "TEXT", "language": "TEXT", @@ -13795,9 +13942,8 @@ "supplier_primary_address": "TEXT", "primary_address": "TEXT", "supplier_primary_contact": "TEXT", - "mobile_no": "TEXT", - "email_id": "TEXT", "payment_terms": "TEXT", + "accounts": "TEXT", "allow_purchase_invoice_creation_without_purchase_order": "TEXT", "allow_purchase_invoice_creation_without_purchase_receipt": "TEXT", "is_frozen": "TEXT", @@ -13809,6 +13955,7 @@ "on_hold": "TEXT", "hold_type": "TEXT", "release_date": "TEXT", + "portal_users": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -13825,6 +13972,7 @@ "parent_supplier_group": "TEXT", "is_group": "TEXT", "payment_terms": "TEXT", + "accounts": "TEXT", "lft": "TEXT", "rgt": "TEXT", "old_parent": "TEXT", @@ -13885,6 +14033,7 @@ "price_list_currency": "TEXT", "plc_conversion_rate": "TEXT", "ignore_pricing_rule": "TEXT", + "items": "TEXT", "total_qty": "TEXT", "total_net_weight": "TEXT", "base_total": "TEXT", @@ -13896,6 +14045,7 @@ "shipping_rule": "TEXT", "incoterm": "TEXT", "named_place": "TEXT", + "taxes": "TEXT", "base_taxes_and_charges_added": "TEXT", "base_taxes_and_charges_deducted": "TEXT", "base_total_taxes_and_charges": "TEXT", @@ -13916,6 +14066,7 @@ "in_words": "TEXT", "disable_rounded_total": "TEXT", "other_charges_calculation": "TEXT", + "pricing_rules": "TEXT", "supplier_address": "TEXT", "address_display": "TEXT", "contact_person": "TEXT", @@ -13956,7 +14107,6 @@ "description": "TEXT", "item_group": "TEXT", "brand": "TEXT", - "image": "TEXT", "qty": "TEXT", "stock_uom": "TEXT", "uom": "TEXT", @@ -14011,6 +14161,8 @@ "status": "TEXT", "period": "TEXT", "weighting_function": "TEXT", + "standings": "TEXT", + "criteria": "TEXT", "warn_rfqs": "TEXT", "warn_pos": "TEXT", "prevent_rfqs": "TEXT", @@ -14051,6 +14203,8 @@ "total_score": "TEXT", "start_date": "TEXT", "end_date": "TEXT", + "criteria": "TEXT", + "variables": "TEXT", "scorecard": "TEXT", "amended_from": "TEXT", "name": "TEXT", @@ -14238,7 +14392,6 @@ "project": "TEXT", "issue": "TEXT", "type": "TEXT", - "color": "TEXT", "is_group": "TEXT", "is_template": "TEXT", "status": "TEXT", @@ -14255,6 +14408,7 @@ "duration": "TEXT", "is_milestone": "TEXT", "description": "TEXT", + "depends_on": "TEXT", "depends_on_tasks": "TEXT", "act_start_date": "TEXT", "actual_time": "TEXT", @@ -14395,6 +14549,8 @@ "round_off_tax_amount": "TEXT", "consider_party_ledger_amount": "TEXT", "tax_on_excess_amount": "TEXT", + "rates": "TEXT", + "accounts": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -14463,6 +14619,7 @@ "lft": "TEXT", "rgt": "TEXT", "old_parent": "TEXT", + "targets": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -14504,6 +14661,7 @@ "user": "TEXT", "start_date": "TEXT", "end_date": "TEXT", + "time_logs": "TEXT", "total_hours": "TEXT", "total_billable_hours": "TEXT", "base_total_billable_amount": "TEXT", @@ -14563,7 +14721,6 @@ "tabToDo": { "status": "TEXT", "priority": "TEXT", - "color": "TEXT", "date": "TEXT", "allocated_to": "TEXT", "description": "TEXT", @@ -14571,7 +14728,6 @@ "reference_name": "TEXT", "role": "TEXT", "assigned_by": "TEXT", - "assigned_by_full_name": "TEXT", "sender": "TEXT", "assignment_rule": "TEXT", "name": "TEXT", @@ -14593,6 +14749,7 @@ "refresh_token": "TEXT", "expires_in": "TEXT", "state": "TEXT", + "scopes": "TEXT", "success_uri": "TEXT", "token_type": "TEXT", "name": "TEXT", @@ -14633,6 +14790,8 @@ "clear_notifications": "TEXT", "initialize_doctypes_table": "TEXT", "delete_transactions": "TEXT", + "doctypes": "TEXT", + "doctypes_to_be_ignored": "TEXT", "amended_from": "TEXT", "process_in_single_transaction": "TEXT", "name": "TEXT", @@ -14731,6 +14890,7 @@ }, "tabUAE VAT Settings": { "company": "TEXT", + "uae_vat_accounts": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -14821,6 +14981,7 @@ "company": "TEXT", "voucher_type": "TEXT", "voucher_no": "TEXT", + "allocations": "TEXT", "amended_from": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -14866,7 +15027,9 @@ "send_welcome_email": "TEXT", "unsubscribed": "TEXT", "role_profile_name": "TEXT", + "roles": "TEXT", "module_profile": "TEXT", + "block_modules": "TEXT", "home_settings": "TEXT", "gender": "TEXT", "birth_date": "TEXT", @@ -14902,18 +15065,19 @@ "thread_notify": "TEXT", "send_me_a_copy": "TEXT", "allowed_in_mentions": "TEXT", + "user_emails": "TEXT", "default_workspace": "TEXT", "default_app": "TEXT", + "defaults": "TEXT", "simultaneous_sessions": "TEXT", "restrict_ip": "TEXT", - "last_ip": "TEXT", "login_after": "TEXT", "user_type": "TEXT", "last_active": "TEXT", "login_before": "TEXT", "bypass_restrict_ip_check_if_2fa_enabled": "TEXT", - "last_login": "TEXT", "last_known_versions": "TEXT", + "social_logins": "TEXT", "api_key": "TEXT", "api_secret": "TEXT", "onboarding_status": "TEXT", @@ -15082,6 +15246,10 @@ "role": "TEXT", "apply_user_permission_on": "TEXT", "user_id_field": "TEXT", + "user_doctypes": "TEXT", + "custom_select_doctypes": "TEXT", + "select_doctypes": "TEXT", + "user_type_modules": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -15315,6 +15483,7 @@ "module": "TEXT", "is_standard": "TEXT", "introduction_text": "TEXT", + "web_form_fields": "TEXT", "anonymous": "TEXT", "login_required": "TEXT", "apply_document_permissions": "TEXT", @@ -15331,6 +15500,7 @@ "condition_json": "TEXT", "show_list": "TEXT", "list_title": "TEXT", + "list_columns": "TEXT", "show_sidebar": "TEXT", "website_sidebar": "TEXT", "button_label": "TEXT", @@ -15408,8 +15578,7 @@ "slideshow": "TEXT", "dynamic_template": "TEXT", "main_section": "TEXT", - "main_section_md": "TEXT", - "main_section_html": "TEXT", + "page_blocks": "TEXT", "context_script": "TEXT", "javascript": "TEXT", "insert_style": "TEXT", @@ -15425,7 +15594,6 @@ "idx": "INT", "website_sidebar": "TEXT", "enable_comments": "TEXT", - "header": "TEXT", "breadcrumbs": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -15489,6 +15657,7 @@ "standard": "TEXT", "module": "TEXT", "template": "TEXT", + "fields": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -15531,6 +15700,8 @@ "request_structure": "TEXT", "enable_security": "TEXT", "webhook_secret": "TEXT", + "webhook_headers": "TEXT", + "webhook_data": "TEXT", "webhook_json": "TEXT", "preview_document": "TEXT", "meets_condition": "TEXT", @@ -15647,6 +15818,19 @@ "parentfield": "TEXT", "parenttype": "TEXT" }, + "tabWebsite Route Meta": { + "meta_tags": "TEXT", + "name": "TEXT", + "owner": "TEXT", + "creation": "TEXT", + "modified": "TEXT", + "modified_by": "TEXT", + "docstatus": "INT", + "idx": "INT", + "parent": "TEXT", + "parentfield": "TEXT", + "parenttype": "TEXT" + }, "tabWebsite Route Redirect": { "source": "TEXT", "target": "TEXT", @@ -15664,6 +15848,7 @@ }, "tabWebsite Sidebar": { "title": "TEXT", + "sidebar_items": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -15692,7 +15877,7 @@ }, "tabWebsite Slideshow": { "slideshow_name": "TEXT", - "header": "TEXT", + "slideshow_items": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -15705,7 +15890,6 @@ "parenttype": "TEXT" }, "tabWebsite Slideshow Item": { - "image": "TEXT", "heading": "TEXT", "description": "TEXT", "url": "TEXT", @@ -15737,6 +15921,7 @@ "background_color": "TEXT", "custom_overrides": "TEXT", "custom_scss": "TEXT", + "ignored_apps": "TEXT", "theme_scss": "TEXT", "theme_url": "TEXT", "js": "TEXT", @@ -15778,6 +15963,7 @@ "disassembled_qty": "TEXT", "process_loss_qty": "TEXT", "project": "TEXT", + "required_items": "TEXT", "allow_alternative_item": "TEXT", "use_multi_level_bom": "TEXT", "skip_transfer": "TEXT", @@ -15791,6 +15977,7 @@ "has_batch_no": "TEXT", "batch_size": "TEXT", "transfer_material_against": "TEXT", + "operations": "TEXT", "planned_start_date": "TEXT", "planned_end_date": "TEXT", "expected_delivery_date": "TEXT", @@ -15888,6 +16075,8 @@ "is_active": "TEXT", "override_status": "TEXT", "send_email_alert": "TEXT", + "states": "TEXT", + "transitions": "TEXT", "workflow_state_field": "TEXT", "workflow_data": "TEXT", "name": "TEXT", @@ -16018,6 +16207,13 @@ "public": "TEXT", "is_hidden": "TEXT", "content": "TEXT", + "number_cards": "TEXT", + "charts": "TEXT", + "shortcuts": "TEXT", + "links": "TEXT", + "quick_lists": "TEXT", + "custom_blocks": "TEXT", + "roles": "TEXT", "name": "TEXT", "owner": "TEXT", "creation": "TEXT", @@ -16061,7 +16257,6 @@ "type": "TEXT", "label": "TEXT", "icon": "TEXT", - "description": "TEXT", "hidden": "TEXT", "link_type": "TEXT", "link_to": "TEXT", @@ -16122,7 +16317,6 @@ "restrict_to_domain": "TEXT", "report_ref_doctype": "TEXT", "stats_filter": "TEXT", - "color": "TEXT", "format": "TEXT", "name": "TEXT", "owner": "TEXT", @@ -16149,6 +16343,7 @@ "hour_rate": "TEXT", "description": "TEXT", "holiday_list": "TEXT", + "working_hours": "TEXT", "total_working_hours": "TEXT", "name": "TEXT", "owner": "TEXT", diff --git a/changai/changai/api/v2/assets/thread_words.json b/changai/changai/api/v2/assets/thread_words.json index e89bea6..0c2c526 100644 --- a/changai/changai/api/v2/assets/thread_words.json +++ b/changai/changai/api/v2/assets/thread_words.json @@ -4,7 +4,6 @@ "yeah", "yup", "yes please", - "list", "of course", "sure", "surely", @@ -33,36 +32,8 @@ "affirmative", "true", "agreed", - "hmm", - "hm", - "umm", - "uh", - "ah", - "give", - "interesting", - "i see", "got it", "ok got it", - "and", - "so", - "then", - "also", - "but", - "what", - "how", - "when", - "who", - "where", - "why", - "more", - "less", - "again", - "another", - "other", - "next", - "previous", - "back", - "forward", "noted", "understood", "makes sense", @@ -70,6 +41,12 @@ "fine fine", "sure sure", "show", + "more", + "again", + "another", + "also", + "next", + "previous", "نعم", "أجل", "بالتأكيد", @@ -90,33 +67,13 @@ "فاهم", "مفهوم", "اوك", - "و", - "ثم", - "لكن", "أيضاً", "كذلك", - "ماذا", - "كيف", - "متى", - "من", - "أين", - "لماذا", "أكثر", - "أقل", "مرة أخرى", "التالي", "السابق", "حسناً حسناً", "تمام تمام", - "مزيد", - "غيره", - "لا", - "لأ", - "لا شكراً", - "إلغاء", - "توقف", - "اتركه", - "مش محتاج", - "مو صح", - "خطأ" + "مزيد" ] \ No newline at end of file diff --git a/changai/changai/api/v2/auto_gen_api.py b/changai/changai/api/v2/auto_gen_api.py index d4df8ca..8fcf451 100644 --- a/changai/changai/api/v2/auto_gen_api.py +++ b/changai/changai/api/v2/auto_gen_api.py @@ -80,11 +80,27 @@ def get_mod(app_names: list[str]): {"fieldname": "idx", "fieldtype": "Int", "label": "Row Index"}, ] EXCLUDED_FIELDTYPES: Set[str] = { - "Section Break", "Column Break", "Tab Break", "Page Break", "Table Break", - "Fold", "Heading", "HTML", "Button", "Attach Image", "Image", "Signature", "Icon","Table" + # Layout / Structure — no data value + "Section Break", + "Column Break", + "Tab Break", + "Fold", + "Heading", + "HTML", + "HTML Editor", + "Markdown Editor", + "Read Only", + "Image", + "Icon", + "Button", + "Attach", + "Attach Image", + "Signature", + "Geolocation", + "Barcode", + "Color", } - def _get_file_doc_by_name(file_name: str, folder: str = RAG_FOLDER) -> Optional["frappe.model.document.Document"]: file_id = frappe.db.get_value("File", {"file_name": file_name, "folder": folder}, "name") if not file_id: @@ -152,7 +168,13 @@ def _strip_tab(t: str) -> str: t = (t or "").strip() return t[3:] if t.startswith("tab") else t -MODULES_TO_SYNC = ["Customer", "Item", "Currency", "Supplier"] +MODULES_TO_SYNC = [ + "Customer", + "Supplier", + "Item", + "Warehouse", + "Company", + "Account"] def _normalize_master_data_payload(payload: Any) -> tuple[Dict[str, Any], List[Dict[str, Any]]]: @@ -289,6 +311,7 @@ def sync_master_data_smart() -> Dict[str, Any]: "fvs_error": None, } + def _clean_schema_fields(by_table: Dict[str, Dict[str, Any]]) -> None: for block in by_table.values(): for field in block.get("fields", []) or []: @@ -298,6 +321,9 @@ def _clean_schema_fields(by_table: Dict[str, Dict[str, Any]]) -> None: field.pop("options", None) if field.get("fieldtype") != "Link": field.pop("join_hint", None) + # ✅ Add this — preserve child_hint only for Table fields + if field.get("fieldtype") not in ("Table", "Table MultiSelect"): + field.pop("child_hint", None) def get_doctypes_changed_since(last_sync: Optional[str]) -> List[str]: @@ -439,7 +465,6 @@ def _update_or_create_table_block( "fields": fields, "desc_done": False, } - def _build_field_entry( field_meta: Any, existing_fields: Dict[str, Dict[str, Any]], @@ -455,30 +480,49 @@ def _build_field_entry( fieldtype = getattr(field_meta, "fieldtype", "Data") label = getattr(field_meta, "label", None) or fieldname options = getattr(field_meta, "options", None) + if not fieldname: return None + existing = existing_fields.get(fieldname) or {} description = existing.get("description") or "" + entry = { "name": fieldname, "fieldtype": fieldtype, "label": label, "description": description, } + if fieldtype == "Select" and options: entry["options"] = _merge_select_options( options, existing.get("options", []), ) + elif fieldtype == "Link" and options: entry["join_hint"] = { "table": f"tab{options}", "on": f"{fieldname} = tab{options}.name" } + + elif fieldtype in ("Table", "Table MultiSelect") and options: + entry["child_hint"] = { + "child_table": f"tab{options}", + "fieldname": fieldname, + "join_rules": { + "parent": "parent document name", + "parenttype": "parent DocType", + "parentfield": fieldname + } + } if fieldtype != "Select": entry.pop("options", None) if fieldtype != "Link": entry.pop("join_hint", None) + if fieldtype not in ("Table", "Table MultiSelect"): + entry.pop("child_hint", None) + return entry diff --git a/changai/changai/api/v2/build_cards_faiss_index_v2.py b/changai/changai/api/v2/build_cards_faiss_index_v2.py index 61844e5..79105e9 100644 --- a/changai/changai/api/v2/build_cards_faiss_index_v2.py +++ b/changai/changai/api/v2/build_cards_faiss_index_v2.py @@ -184,7 +184,6 @@ def _build_field_page_content(table_name: str, field_name: str, field_desc: str, page_content += f"\n{options}" return page_content - def _build_field_document(table_name: str, module: str, field_row: Dict[str, Any]) -> Optional[Document]: if not isinstance(field_row, dict): return None @@ -195,23 +194,41 @@ def _build_field_document(table_name: str, module: str, field_row: Dict[str, Any field_desc = field_row.get("description", "") or "" join_hint = field_row.get("join_hint") or "" + child_hint = field_row.get("child_hint") or "" # ✅ Add this options = field_row.get("options") or "" + fieldtype = field_row.get("fieldtype") or "" # ✅ Add this + is_table_field = fieldtype in ("Table", "Table MultiSelect") # ✅ Add this + + # Build page content + page_content = f"[FIELD] {field_name} | [TABLE] {table_name}\n{field_desc}" + if join_hint: + page_content += f"\n{join_hint}" + if child_hint and is_table_field: # ✅ Add child hint to content + if isinstance(child_hint, dict): + page_content += f"\nChild Table: {child_hint.get('child_table', '')}" + else: + page_content += f"\n{child_hint}" + if options: + page_content += f"\n{options}" + + # Build metadata + metadata = { + "type": "field", + "table": table_name, + "field": field_name, + "fieldtype": fieldtype, # ✅ Store fieldtype + "module": module, + } + if options: + metadata["options"] = options + if join_hint: + metadata["join_hint"] = join_hint + if child_hint and is_table_field: # ✅ Store child_hint + metadata["child_hint"] = child_hint return Document( - page_content=_build_field_page_content( - table_name=table_name, - field_name=field_name, - field_desc=field_desc, - join_hint=join_hint, - options=options, - ), - metadata=_build_field_metadata( - table_name=table_name, - field_name=field_name, - module=module, - join_hint=join_hint, - options=options, - ), + page_content=page_content, + metadata=metadata, ) GENERIC_FIELDS = { 'creation', 'modified', 'owner', 'parenttype','old_parent', @@ -441,7 +458,6 @@ def build_schema_fvs_job(): # schema = clean_schema(schema,schema_path) schema_docs = build_schema_docs(schema) app_base, _, _, schema_path, _,schema_emb_dir, _ = _get_fvs_paths() - # clean_schema(schema_path,schema_path) _build_and_save_faiss(schema_docs, schema_path, "ERPNext Schema FVS", app_base) save_field_matrix(schema_docs, schema_emb_dir) frappe.logger().info(f"ERPNext Schema FVS built: {len(schema_docs)} docs") diff --git a/changai/changai/api/v2/fvs_stores/erpnext/emb_dir/field_docs.pkl b/changai/changai/api/v2/fvs_stores/erpnext/emb_dir/field_docs.pkl index 210e108..bcbf024 100644 Binary files a/changai/changai/api/v2/fvs_stores/erpnext/emb_dir/field_docs.pkl and b/changai/changai/api/v2/fvs_stores/erpnext/emb_dir/field_docs.pkl differ diff --git a/changai/changai/api/v2/fvs_stores/erpnext/emb_dir/field_embs.npy b/changai/changai/api/v2/fvs_stores/erpnext/emb_dir/field_embs.npy index f0fecdd..e9fa2e0 100644 Binary files a/changai/changai/api/v2/fvs_stores/erpnext/emb_dir/field_embs.npy and b/changai/changai/api/v2/fvs_stores/erpnext/emb_dir/field_embs.npy differ diff --git a/changai/changai/api/v2/fvs_stores/erpnext/emb_dir/table_to_idx.pkl b/changai/changai/api/v2/fvs_stores/erpnext/emb_dir/table_to_idx.pkl index 9e0ce61..57f1cba 100644 Binary files a/changai/changai/api/v2/fvs_stores/erpnext/emb_dir/table_to_idx.pkl and b/changai/changai/api/v2/fvs_stores/erpnext/emb_dir/table_to_idx.pkl differ diff --git a/changai/changai/api/v2/fvs_stores/erpnext/report_fvs/index.faiss b/changai/changai/api/v2/fvs_stores/erpnext/report_fvs/index.faiss index eda5e17..fcf36c1 100644 Binary files a/changai/changai/api/v2/fvs_stores/erpnext/report_fvs/index.faiss and b/changai/changai/api/v2/fvs_stores/erpnext/report_fvs/index.faiss differ diff --git a/changai/changai/api/v2/fvs_stores/erpnext/report_fvs/index.pkl b/changai/changai/api/v2/fvs_stores/erpnext/report_fvs/index.pkl index 8945fd9..83e458c 100644 Binary files a/changai/changai/api/v2/fvs_stores/erpnext/report_fvs/index.pkl and b/changai/changai/api/v2/fvs_stores/erpnext/report_fvs/index.pkl differ diff --git a/changai/changai/api/v2/fvs_stores/erpnext/schema_fvs/index.faiss b/changai/changai/api/v2/fvs_stores/erpnext/schema_fvs/index.faiss index 6f75735..9110607 100644 Binary files a/changai/changai/api/v2/fvs_stores/erpnext/schema_fvs/index.faiss and b/changai/changai/api/v2/fvs_stores/erpnext/schema_fvs/index.faiss differ diff --git a/changai/changai/api/v2/fvs_stores/erpnext/schema_fvs/index.pkl b/changai/changai/api/v2/fvs_stores/erpnext/schema_fvs/index.pkl index dc1cc02..da3668a 100644 Binary files a/changai/changai/api/v2/fvs_stores/erpnext/schema_fvs/index.pkl and b/changai/changai/api/v2/fvs_stores/erpnext/schema_fvs/index.pkl differ diff --git a/changai/changai/api/v2/fvs_stores/erpnext/table_fvs/index.faiss b/changai/changai/api/v2/fvs_stores/erpnext/table_fvs/index.faiss index ecaea4c..171a742 100644 Binary files a/changai/changai/api/v2/fvs_stores/erpnext/table_fvs/index.faiss and b/changai/changai/api/v2/fvs_stores/erpnext/table_fvs/index.faiss differ diff --git a/changai/changai/api/v2/fvs_stores/erpnext/table_fvs/index.pkl b/changai/changai/api/v2/fvs_stores/erpnext/table_fvs/index.pkl index 7cc13aa..7f2d9a1 100644 Binary files a/changai/changai/api/v2/fvs_stores/erpnext/table_fvs/index.pkl and b/changai/changai/api/v2/fvs_stores/erpnext/table_fvs/index.pkl differ diff --git a/changai/changai/api/v2/helpdesk_api.py b/changai/changai/api/v2/helpdesk_api.py index 3f98746..f9ab6dc 100644 --- a/changai/changai/api/v2/helpdesk_api.py +++ b/changai/changai/api/v2/helpdesk_api.py @@ -171,7 +171,9 @@ def support_bot(message: str) -> Dict[str, Any]: if task_flag == "GET_USER_TICKETS": response = get_user_tickets() - return json.loads(response.get_data(as_text=True)) # ✅ unwrap Response → dict + return json.loads(response.get_data(as_text=True)) + if task_flag == "TICKET_CREATION_FAILED": + return {"kind":"TICKET_CREATION_FAILED","message":"Something went wrong. Please try again."} return {"kind": "UNKNOWN", "message": "Please describe the issue or provide a ticket number."} diff --git a/changai/changai/api/v2/operations.py b/changai/changai/api/v2/operations.py new file mode 100644 index 0000000..64c139c --- /dev/null +++ b/changai/changai/api/v2/operations.py @@ -0,0 +1,898 @@ +import frappe +import json +import re +from typing import Any, Dict, List, Tuple, Optional + +CHANGAI_GUIDE_LINK="https://app.erpgulf.com/en/articles/chang-ai-quick-start-guide" + +@frappe.whitelist(allow_guest=False) +def execute_insert(payload: dict) -> Any: + try: + if isinstance(payload, str): + payload = json.loads(payload) if payload else {} + operation = payload.get("operation") + if not operation: + return {"error": "No operation provided"} + + if operation == "insert_main": + frappe.has_permission(payload["doctype"], "create", throw=True) + _validate_linked_fields(payload["doctype"], payload["data"]) + + doc = frappe.get_doc({ + "doctype": payload["doctype"], + **payload["data"] + }) + + # Handle child_rows if present + child_rows = payload.get("child_rows") or {} + for child_table, rows in child_rows.items(): + if isinstance(rows, list): + for row in rows: + doc.append(child_table, row) + + doc.insert(ignore_permissions=False) + + + result = { + "success": True, + "operation": "insert_main", + "doctype": doc.doctype, + "name": doc.name, + "message": f"{doc.doctype} '{doc.name}' created successfully." + } + + # ✅ Handle after_insert if present + after_insert = payload.get("after_insert") + if after_insert: + after_insert["doctype"] = payload["doctype"] + after_insert["filters"] = {"name": doc.name} + after_result = execute_insert(after_insert) + result["after_insert_result"] = after_result + if after_result.get("error"): + result["after_insert_warning"] = f"Main doc created but linked doc failed: {after_result['error']}" + else: + result["message"] = ( + f"{doc.doctype} '{doc.name}' created successfully " + f"with linked {after_insert.get('linked_doctype', '')}." + ) + + return result + # ─── CASE 2: INSERT CHILD ROW ───────────────────────── + elif operation == "insert_child": + frappe.has_permission(payload["doctype"], "write", throw=True) + + parent_name = frappe.db.get_value( + payload["doctype"], payload["filters"], "name" + ) + if not parent_name: + return {"error": f"No {payload['doctype']} found for given filters"} + + doc = frappe.get_doc(payload["doctype"], parent_name) + doc.append(payload["child_table"], payload["data"]) + doc.save(ignore_permissions=False) + + return { + "success": True, + "operation": "insert_child", + "parent": parent_name, + "child_table": payload["child_table"], + "message": f"Row added to '{payload['child_table']}' in '{parent_name}' successfully." + } + + # ─── CASE 3: INSERT LINKED DOC + LINK ───────────────── + elif operation == "insert_linked": + frappe.has_permission(payload["linked_doctype"], "create", throw=True) + + # Get parent + parent_name = frappe.db.get_value( + payload["doctype"], payload["filters"], "name" + ) + if not parent_name: + return {"error": f"No {payload['doctype']} found for given filters"} + + # Create linked doc + linked_doc = frappe.get_doc({ + "doctype": payload["linked_doctype"], + **payload["data"] + }) + + # Auto append Dynamic Link + linked_doc.append("links", { + "link_doctype": payload["doctype"], + "link_name": parent_name + }) + + linked_doc.insert(ignore_permissions=False) + + # Update link field on parent if specified + if payload.get("link_via"): + parent_doc = frappe.get_doc(payload["doctype"], parent_name) + parent_doc.set(payload["link_via"], linked_doc.name) + parent_doc.save(ignore_permissions=False) + + + return { + "success": True, + "operation": "insert_linked", + "linked_name": linked_doc.name, + "parent": parent_name, + "message": f"{payload['linked_doctype']} '{linked_doc.name}' created and linked to '{parent_name}' successfully." + } + + # ─── CASE 4: INSERT LINKED DOC WITH CHILD ROWS ──────── + elif operation == "insert_linked_child": + frappe.has_permission(payload["linked_doctype"], "create", throw=True) + + # Get parent + parent_name = frappe.db.get_value( + payload["doctype"], payload["filters"], "name" + ) + if not parent_name: + return {"error": f"No {payload['doctype']} found for given filters"} + + # Create linked doc + linked_doc = frappe.get_doc({ + "doctype": payload["linked_doctype"], + **payload["data"] + }) + + # Auto append Dynamic Link + linked_doc.append("links", { + "link_doctype": payload["doctype"], + "link_name": parent_name + }) + + # Append all child rows + for child_table, rows in payload.get("child_rows", {}).items(): + for row in rows: + linked_doc.append(child_table, row) + + linked_doc.insert(ignore_permissions=False) + + # Update link field on parent if specified + if payload.get("link_via"): + parent_doc = frappe.get_doc(payload["doctype"], parent_name) + parent_doc.set(payload["link_via"], linked_doc.name) + parent_doc.save(ignore_permissions=False) + + + return { + "success": True, + "operation": "insert_linked_child", + "linked_name": linked_doc.name, + "parent": parent_name, + "message": f"{payload['linked_doctype']} '{linked_doc.name}' created with child rows and linked to '{parent_name}' successfully." + } + + # ─── CASE 5: INSERT BULK MAIN DOCS ──────────────────── + elif operation == "insert_bulk": + frappe.has_permission(payload["doctype"], "create", throw=True) + + if len(payload["records"]) > 50: + return { + "error": f"Too many records ({len(payload['records'])}). Maximum allowed is 50 records per bulk insert." + } + + inserted = [] + failed = [] + + for record in payload["records"]: + try: + _validate_linked_fields(payload["doctype"], record) + doc = frappe.get_doc({ + "doctype": payload["doctype"], + **record + }) + doc.insert(ignore_permissions=False) + inserted.append(doc.name) + except Exception as e: + failed.append({ + "record": record, + "error": str(e) + }) + + + return { + "success": True, + "operation": "insert_bulk", + "inserted": len(inserted), + "inserted_names": inserted, + "failed": len(failed), + "failed_records": failed, + "message": f"{len(inserted)} record(s) inserted successfully. {len(failed)} failed." + } + + # ─── CASE 6: INSERT IF NOT EXISTS ───────────────────── + elif operation == "insert_if_not_exists": + frappe.has_permission(payload["doctype"], "create", throw=True) + + # Check if already exists + exists = frappe.db.exists(payload["doctype"], payload["filters"]) + if exists: + return { + "success": False, + "operation": "insert_if_not_exists", + "name": exists, + "message": f"{payload['doctype']} already exists with name '{exists}'. No record created." + } + + _validate_linked_fields(payload["doctype"], payload["data"]) + doc = frappe.get_doc({ + "doctype": payload["doctype"], + **payload["data"] + }) + doc.insert(ignore_permissions=False) + + return { + "success": True, + "operation": "insert_if_not_exists", + "name": doc.name, + "message": f"{doc.doctype} '{doc.name}' created successfully." + } + + else: + return {"error": f"Unknown insert operation: '{operation}'"} + + except frappe.PermissionError: + return { + "error": f"User {frappe.session.user} does not have permission to create {payload.get('doctype')}. Please contact your administrator." + } + + except frappe.exceptions.ValidationError as e: + import re + clean_msg = re.sub(r'<[^>]+>', '', str(e)) + return {"error": clean_msg} + + except frappe.exceptions.DuplicateEntryError as e: + return {"error": f"Record already exists: {str(e)}"} + + except frappe.exceptions.DoesNotExistError as e: + return {"error": f"Record not found: {str(e)}"} + + except PermissionError: + return { + "error": f"User {frappe.session.user} does not have permission to create {payload.get('doctype')}." + } + + except Exception as e: + frappe.log_error(frappe.get_traceback(), "execute_insert Failed") + return {"error": f"Insert Failed: {str(e)}\n Check Quick Start Guide Here 👇:\n {CHANGAI_GUIDE_LINK}"} + +def _validate_linked_fields(doctype: str, data: dict): + """Validate all Link fields exist before insert""" + meta = frappe.get_meta(doctype) + for field in meta.fields: + if field.fieldtype == "Link" and field.fieldname in data: + value = data[field.fieldname] + if value and not frappe.db.exists(field.options, value): + frappe.throw( + f"'{value}' does not exist in {field.options}. Please create it first." + ) + +def _auto_create_linked(payload: dict, parent_name: str, parent_doc) -> dict: + try: + frappe.has_permission(payload["linked_doctype"], "create", throw=True) + + linked_doc = frappe.new_doc(payload["linked_doctype"]) + + # ✅ Get child table fieldnames from meta + meta = frappe.get_meta(payload["linked_doctype"]) + child_fieldnames = { + f.fieldname for f in meta.fields + if f.fieldtype in ("Table", "Table MultiSelect") + } + + # ✅ Set direct fields on linked doc + for field, value in payload.get("data", {}).items(): + if field not in child_fieldnames: + linked_doc.set(field, value) + + # ✅ Append child table rows from payload child_rows + for child_table, rows in payload.get("child_rows", {}).items(): + for row in rows: + linked_doc.append(child_table, row) + + # ✅ Try to set minimum required name fields from parent + if hasattr(linked_doc, "first_name") and not linked_doc.first_name: + name_parts = parent_name.strip().split(" ", 1) + linked_doc.first_name = name_parts[0] + if hasattr(linked_doc, "last_name"): + linked_doc.last_name = name_parts[1] if len(name_parts) > 1 else "" + + if hasattr(linked_doc, "address_title") and not linked_doc.address_title: + linked_doc.address_title = parent_name + + linked_doc.append("links", { + "link_doctype": payload["doctype"], + "link_name": parent_name + }) + + linked_doc.insert(ignore_permissions=False) + + # ✅ Update link field on parent + if payload.get("link_via"): + parent_doc.set(payload["link_via"], linked_doc.name) + parent_doc.save(ignore_permissions=False) + + return { + "success": True, + "linked_name": linked_doc.name, + "auto_created": True + } + + except frappe.exceptions.ValidationError as e: + clean_msg = re.sub(r'<[^>]+>', '', str(e)) + return {"error": f"Could not auto create {payload['linked_doctype']}. {clean_msg}"} + + except Exception as e: + return {"error": f"Could not auto create {payload['linked_doctype']} for {parent_name}: {str(e)}"} + + +def _resolve_child_filters(doc, child_table: str, child_filters: dict, data: dict) -> dict: + """ + If child_filters only contains primary flags (value=1), + find the current primary row and return its name as stable filter. + If child_filters is empty, return empty dict (will append new row). + """ + if not child_filters: + return {} + + existing_rows = doc.get(child_table) or [] + if not existing_rows: + return child_filters + + # ✅ Check if ALL filter values are primary-style (== 1) + all_primary_flags = all( + frappe.utils.cint(v) == 1 + for v in child_filters.values() + ) + + if not all_primary_flags: + return child_filters + + # ✅ Find matching row NOW before unsetting + for row in existing_rows: + if all( + frappe.utils.cint(getattr(row, k, 0)) == frappe.utils.cint(v) + for k, v in child_filters.items() + ): + return {"name": row.name} + + # No match found — return original + return child_filters + + +def _unset_primary_flags(doc, child_table: str, data: dict): + """ + Dynamically detects and unsets primary flags before setting new primary. + Works for ANY doctype, ANY child table, ANY primary flag. + """ + if not data: + return + + existing_rows = doc.get(child_table) or [] + if not existing_rows: + return + + flags_to_unset = set() + for field, value in data.items(): + if frappe.utils.cint(value) == 1: + for row in existing_rows: + if hasattr(row, field): + current_val = getattr(row, field, None) + if current_val is not None and str(current_val) in ("0", "1", "True", "False"): + flags_to_unset.add(field) + break + + if not flags_to_unset: + return + + for row in existing_rows: + for flag in flags_to_unset: + if hasattr(row, flag): + row.set(flag, 0) + +@frappe.whitelist(allow_guest=False) +def execute_update(payload: dict): + try: + if isinstance(payload, str): + payload = json.loads(payload) + + operation = payload.get("operation") + + # ─── MULTI PAYLOAD ───────────────────────────────── + if operation == "multi_payload": + results = [] + for sub_payload in payload.get("payloads", []): + result = execute_update(sub_payload) + results.append(result) + + failed = [r for r in results if r.get("error")] + success = [r for r in results if r.get("success")] + + return { + "success": len(failed) == 0, + "operation": "multi_payload", + "total": len(results), + "succeeded": len(success), + "failed": len(failed), + "results": results, + "message": f"{len(success)} operation(s) succeeded. {len(failed)} failed." + } + + # ─── UPDATE MAIN DOC ─────────────────────────────── + elif operation == "update": + frappe.has_permission(payload["doctype"], "write", throw=True) + + filters = payload.get("filters", {}) + if not filters: + return {"error": "Filters are required. Cannot update all records."} + + if not payload.get("data"): + return {"error": "No data provided for update."} + + if payload.get("cross_filters"): + cf = payload["cross_filters"] + linked = frappe.get_all( + cf["doctype"], + filters=cf["filters"], + fields=["name"] + ) + if not linked: + return {"error": f"No {cf['doctype']} records found"} + filters[cf["link_field"]] = ["in", [d.name for d in linked]] + + records = frappe.get_all( + payload["doctype"], + filters=filters, + fields=["name"] + ) + + if not records: + return {"error": "No records found for given filters"} + + if len(records) > 50: + return {"error": f"Too many records ({len(records)}) matched. Maximum allowed is 50."} + + for record in records: + doc = frappe.get_doc(payload["doctype"], record.name) + for field, value in payload["data"].items(): + doc.set(field, value) + doc.save(ignore_permissions=False) + + return { + "success": True, + "operation": "update", + "updated_count": len(records), + "records": [r.name for r in records], + "message": f"{len(records)} record(s) updated successfully." + } + + # ─── UPDATE CHILD ────────────────────────────────── + elif operation == "update_child": + frappe.has_permission(payload["doctype"], "write", throw=True) + + if not payload.get("name"): + return {"error": "Parent document name is required for update_child."} + if not payload.get("child_table"): + return {"error": "child_table is required for update_child."} + if not payload.get("data"): + return {"error": "No data provided for update_child."} + + if not frappe.db.exists(payload["doctype"], payload["name"]): + return {"error": f"No {payload['doctype']} found with name '{payload['name']}'"} + + doc = frappe.get_doc(payload["doctype"], payload["name"]) + + # ✅ Validate child_table exists via meta + meta = frappe.get_meta(payload["doctype"]) + child_fields = [ + f.fieldname for f in meta.fields + if f.fieldtype in ("Table", "Table MultiSelect") + ] + if payload["child_table"] not in child_fields: + return { + "error": f"Child table '{payload['child_table']}' does not exist on {payload['doctype']}." + } + + child_filters = payload.get("child_filters") or {} + + resolved_filters = _resolve_child_filters( + doc, + payload["child_table"], + child_filters, + payload["data"] + ) + + _unset_primary_flags(doc, payload["child_table"], payload["data"]) + + updated = 0 + if resolved_filters: + for row in doc.get(payload["child_table"]) or []: + if all( + getattr(row, k, None) == v + for k, v in resolved_filters.items() + ): + for field, value in payload["data"].items(): + row.set(field, value) + updated += 1 + + if updated == 0: + doc.append(payload["child_table"], payload["data"]) + + doc.save(ignore_permissions=False) + return { + "success": True, + "operation": "update_child", + "updated_count": updated, + "message": f"{updated} child row(s) updated successfully." + if updated > 0 + else "No matching row found — new row added." + } + + # ─── UPDATE LINKED / UPDATE LINKED CHILD ─────────── + elif operation in ("update_linked", "update_linked_child"): + + frappe.has_permission(payload["doctype"], "write", throw=True) + + if not payload.get("filters"): + return {"error": "Filters are required for update_linked."} + if not payload.get("linked_doctype"): + return {"error": "linked_doctype is required for update_linked."} + if operation == "update_linked" and not payload.get("data"): + return {"error": "No data provided for update_linked."} + if operation == "update_linked_child": + frappe.has_permission(payload["linked_doctype"], "write", throw=True) + if not payload.get("child_table"): + return {"error": "child_table is required for update_linked_child."} + if not payload.get("data"): + return {"error": "No data provided for update_linked_child."} + + # ✅ Step 1 — Find parent + parent_name = frappe.db.get_value( + payload["doctype"], + payload["filters"], + "name" + ) + if not parent_name: + return {"error": f"No {payload['doctype']} found for given filters"} + + parent_doc = frappe.get_doc(payload["doctype"], parent_name) + + # ✅ Step 2 — Find linked doc via direct link field + linked_name = None + auto_created = False + + if payload.get("link_via"): + linked_name = getattr(parent_doc, payload["link_via"], None) + + # ✅ Step 3 — Fallback to Dynamic Link + if not linked_name: + linked_name = frappe.db.get_value( + "Dynamic Link", + { + "link_doctype": payload["doctype"], + "link_name": parent_name, + "parenttype": payload["linked_doctype"] + }, + "parent" + ) + + # ✅ Step 4 — Auto create if not found + if not linked_name: + auto_result = _auto_create_linked(payload, parent_name, parent_doc) + if auto_result.get("error"): + return auto_result + linked_name = auto_result.get("linked_name") + auto_created = auto_result.get("auto_created", False) + + # ✅ Step 5 — Load linked doc + linked_doc = frappe.get_doc(payload["linked_doctype"], linked_name) + + # ─── UPDATE LINKED CHILD ─────────────────────── + if operation == "update_linked_child": + + # ✅ Validate child_table via meta + meta = frappe.get_meta(payload["linked_doctype"]) + child_fields = [ + f.fieldname for f in meta.fields + if f.fieldtype in ("Table", "Table MultiSelect") + ] + if payload["child_table"] not in child_fields: + return { + "error": f"Child table '{payload['child_table']}' does not exist on {payload['linked_doctype']}." + } + + child_filters = payload.get("child_filters") or {} + + resolved_filters = _resolve_child_filters( + linked_doc, + payload["child_table"], + child_filters, + payload["data"] + ) + + _unset_primary_flags( + linked_doc, + payload["child_table"], + payload["data"] + ) + + updated = 0 + if resolved_filters: + for row in linked_doc.get(payload["child_table"]) or []: + if all( + getattr(row, k, None) == v + for k, v in resolved_filters.items() + ): + for field, value in payload["data"].items(): + row.set(field, value) + updated += 1 + + if updated == 0: + linked_doc.append(payload["child_table"], payload["data"]) + + linked_doc.save(ignore_permissions=False) + return { + "success": True, + "operation": operation, + "linked_doc": linked_name, + "auto_created": auto_created, + "message": f"{payload['linked_doctype']} updated successfully." + if updated > 0 + else f"No matching row — new row added to {payload['child_table']}." + } + + # ─── UPDATE LINKED DIRECT FIELD ─────────────── + else: + frappe.has_permission(payload["linked_doctype"], "write", throw=True) + for field, value in payload["data"].items(): + linked_doc.set(field, value) + linked_doc.save(ignore_permissions=False) + return { + "success": True, + "operation": operation, + "linked_doc": linked_name, + "auto_created": auto_created, + "message": f"{payload['linked_doctype']} updated successfully." + } + + return {"error": f"Unsupported update operation: {operation}"} + + except frappe.PermissionError: + return { + "error": f"User {frappe.session.user} does not have permission to update {payload.get('doctype')}. Please contact your administrator." + } + + except frappe.exceptions.ValidationError as e: + clean_msg = re.sub(r'<[^>]+>', '', str(e)) + return {"error": clean_msg} + + except frappe.exceptions.DuplicateEntryError as e: + return {"error": f"Record already exists: {str(e)}"} + + except frappe.exceptions.DoesNotExistError as e: + return {"error": f"Record not found: {str(e)}"} + + except PermissionError: + return { + "error": f"User {frappe.session.user} does not have permission to update {payload.get('doctype')}." + } + + except Exception as e: + frappe.log_error(frappe.get_traceback(), "execute_update Failed") + return {"error": f"Update Failed: {str(e)}\n Check Quick Start Guide Here 👇:\n {CHANGAI_GUIDE_LINK}"} + + +@frappe.whitelist(allow_guest=False) +def execute_delete(payload:dict): + try: + if isinstance(payload, str): + payload = json.loads(payload) + + operation = payload.get("operation") + + # ─── DELETE MAIN DOC ─────────────────────────────── + if operation == "delete": + frappe.has_permission( + payload["doctype"], + "delete", + throw=True + ) + + records = frappe.get_all( + payload["doctype"], + filters=payload["filters"], + fields=["name"] + ) + + if not records: + return {"error": "No records found"} + + if len(records) > 50: + return { + "error": f"Too many records ({len(records)}) matched. Maximum allowed is 50." + } + + deleted = [] + + for record in records: + frappe.delete_doc( + payload["doctype"], + record.name, + ignore_permissions=False + ) + deleted.append(record.name) + + + + return { + "success": True, + "operation": "delete", + "deleted_count": len(deleted), + "records": deleted, + "message": f"{len(deleted)} record(s) deleted successfully." + } + + # ─── DELETE CHILD ROW ────────────────────────────── + elif operation == "delete_child": + frappe.has_permission(payload["doctype"], "delete", throw=True) + frappe.has_permission( + payload["doctype"], + "write", + throw=True + ) + + doc = frappe.get_doc( + payload["doctype"], + payload["name"] + ) + + before = len(doc.get(payload["child_table"])) + + doc.set( + payload["child_table"], + [ + row for row in doc.get(payload["child_table"]) + if not all( + getattr(row, k) == v + for k, v in payload["child_filters"].items() + ) + ] + ) + + deleted = before - len(doc.get(payload["child_table"])) + + doc.save(ignore_permissions=False) + + + return { + "success": True, + "operation": "delete_child", + "deleted_count": deleted, + "message": f"{deleted} child row(s) deleted successfully." + } + + # ─── DELETE LINKED / LINKED CHILD ────────────────── + elif operation in ("delete_linked", "delete_linked_child"): + frappe.has_permission(payload["doctype"], "delete", throw=True) + + parent_name = frappe.db.get_value( + payload["doctype"], + payload["filters"], + "name" + ) + + if not parent_name: + return { + "error": f"No {payload['doctype']} found" + } + + parent_doc = frappe.get_doc( + payload["doctype"], + parent_name + ) + + linked_name = None + + if payload.get("link_via"): + linked_name = getattr( + parent_doc, + payload["link_via"], + None + ) + + if not linked_name: + linked_name = frappe.db.get_value( + "Dynamic Link", + { + "link_doctype": payload["doctype"], + "link_name": parent_name, + "parenttype": payload["linked_doctype"] + }, + "parent" + ) + + if not linked_name: + return { + "error": f"No linked {payload['linked_doctype']} found" + } + required_perm = "delete" if operation == "delete_linked" else "write" + frappe.has_permission(payload["linked_doctype"], required_perm, throw=True) + linked_doc = frappe.get_doc( + payload["linked_doctype"], + linked_name + ) + + # delete_linked_child + if operation == "delete_linked_child": + + before = len( + linked_doc.get(payload["child_table"]) + ) + + linked_doc.set( + payload["child_table"], + [ + row for row in linked_doc.get(payload["child_table"]) + if not all( + getattr(row, k) == v + for k, v in payload["child_filters"].items() + ) + ] + ) + + deleted = ( + before - + len(linked_doc.get(payload["child_table"])) + ) + + linked_doc.save(ignore_permissions=False) + + return { + "success": True, + "operation": "delete_linked_child", + "linked_doc": linked_name, + "deleted_count": deleted, + "message": f"{deleted} linked child row(s) deleted successfully." + } + + # delete_linked + if payload.get("link_via"): + parent_doc.set(payload["link_via"], None) + parent_doc.save(ignore_permissions=False) + + frappe.delete_doc( + payload["linked_doctype"], + linked_name, + ignore_permissions=False + ) + + + + return { + "success": True, + "operation": "delete_linked", + "linked_doc": linked_name, + "message": f"{payload['linked_doctype']} '{linked_name}' deleted successfully." + } + + return { + "error": f"Unsupported delete operation: {operation}" + } + except frappe.PermissionError: + return {"error": f"User {frappe.session.user} does not have permission to perform this action on {payload.get('doctype')}."} + + except frappe.exceptions.ValidationError as e: + clean_msg = re.sub(r'<[^>]+>', '', str(e)) + return {"error": clean_msg} + + except frappe.exceptions.DuplicateEntryError as e: + return {"error": f"Record already exists: {str(e)}"} + + except frappe.exceptions.DoesNotExistError as e: + return {"error": f"Record not found: {str(e)}"} + + except Exception as e: + frappe.log_error(frappe.get_traceback(), "execute Failed") + return {"error": str(e)} \ No newline at end of file diff --git a/changai/changai/api/v2/retrieve.py b/changai/changai/api/v2/retrieve.py index 870cdc1..5e02e85 100644 --- a/changai/changai/api/v2/retrieve.py +++ b/changai/changai/api/v2/retrieve.py @@ -395,8 +395,9 @@ def _get_cached_embedding(q: str, request_id: str) -> tuple: -def call_fvs_table_search(get_table: bool, q: str, request_id: str) -> List[str]: +def call_fvs_table_search(is_cud,get_table: bool, q: str, request_id: str) -> List[str]: # get cached embedding + top_k=0 publish_pipeline_update( request_id, "Inside the Table Search Function", @@ -421,7 +422,8 @@ def call_fvs_table_search(get_table: bool, q: str, request_id: str) -> List[str] "vs_ready", _("vs_ready") ) - scores, indices = vs.index.search(q_vec.reshape(1, -1), k=20) + top_k=30 if is_cud else 20 + scores, indices = vs.index.search(q_vec.reshape(1, -1), k=top_k) publish_pipeline_update( request_id, "index_search_done", @@ -440,9 +442,20 @@ def call_fvs_table_search(get_table: bool, q: str, request_id: str) -> List[str] out.append(t) return out - +SKIP_FIELDS = { + "docstatus", + "owner", + "creation", + "modified", + "modified_by", + "parent", + "parenttype", + "parentfield", + "idx", +} def call_fvs_field_search_global_k( + is_cud:bool, user_question: str, selected_tables: List[str], k_total: int = 40, @@ -462,22 +475,18 @@ def call_fvs_field_search_global_k( _get_cached_embedding(user_question, request_id), dtype="float32" ) - q_vec = q_vec / max(np.linalg.norm(q_vec), 1e-12) all_idxs = [] - for t in selected_tables: t = str(t).strip() if not t: continue - candidates = [ t, f"tab{t}" if not t.startswith("tab") else t, t.replace("tab", "", 1) if t.startswith("tab") else t, ] - for key in candidates: if key in table_to_idx: all_idxs.extend(table_to_idx[key]) @@ -496,7 +505,6 @@ def call_fvs_field_search_global_k( sub_embs = embs[all_idxs] scores = sub_embs @ q_vec - top_global = np.argsort(-scores)[:k_total] grouped = {} @@ -505,7 +513,6 @@ def call_fvs_field_search_global_k( for i in top_global: doc_i = all_idxs[int(i)] d = docs[doc_i] - meta = getattr(d, "metadata", {}) or {} is_table = meta.get("is_table") @@ -514,15 +521,19 @@ def call_fvs_field_search_global_k( if not table or not field: continue + if is_cud: + if field in SKIP_FIELDS: + continue key = (table, field) if key in seen: continue - seen.add(key) name = field + fieldtype = meta.get("fieldtype", "") + # ─── Link field → join hint ──────────────────────── join_hint = meta.get("join_hint") if isinstance(join_hint, dict): linked_table = join_hint.get("table") @@ -531,8 +542,19 @@ def call_fvs_field_search_global_k( elif isinstance(join_hint, str) and join_hint.strip(): name += f" -> {join_hint.strip()}" + # ─── Table field → child hint ────────────────────── + elif fieldtype in ("Table", "Table MultiSelect"): + child_hint = meta.get("child_hint") + if isinstance(child_hint, dict): + child_table = child_hint.get("child_table") + if child_table: + name += f" (Table) -> {child_table}" + elif isinstance(child_hint, str) and child_hint.strip(): + name += f" (Table) -> {child_hint.strip()}" + + # ─── Select field → options ──────────────────────── opts = meta.get("options") - if opts: + if opts and fieldtype == "Select": if isinstance(opts, list): name += " {" + ", ".join(str(o) for o in opts[:5]) + "}" else: @@ -542,7 +564,6 @@ def call_fvs_field_search_global_k( "is_table": is_table, "fields": [] }) - grouped[table]["fields"].append(name) if not grouped: @@ -556,20 +577,22 @@ def call_fvs_field_search_global_k( }, indent=2, default=str) ) return "" + return format_schema_context(grouped) -def call_retrieve_multi_line(user_question: str, request_id: str) -> Dict[str, Any]: +def call_retrieve_multi_line(is_cud:bool,user_question: str, request_id: str) -> Dict[str, Any]: try: - top_tables = call_fvs_table_search(True, user_question, request_id) + top_tables = call_fvs_table_search(is_cud,True, user_question, request_id) publish_pipeline_update( request_id, "table_retrieval_done", _("Tables retrieved") ) - fields_candidates= call_fvs_field_search_global_k( + fields_candidates = call_fvs_field_search_global_k( + is_cud, user_question, selected_tables=top_tables, - k_total=40, + k_total= 60 if is_cud else 40, request_id=request_id ) publish_pipeline_update( @@ -586,7 +609,7 @@ def call_retrieve_multi_line(user_question: str, request_id: str) -> Dict[str, A except frappe.exceptions.ValidationError: raise except Exception as e: - return {"selected_fields": {}, "selected_tables": [], "top_tables": [], "error": str(e)} + return {"selected_fields": {}, "selected_tables": [], "top_tables": [],"top_fields": [],"error": str(e)} def debug_entity_retriever(q: str,state:Dict): resp = remote_entity_embedder(q) # this returns {"ok":..., "body":...} diff --git a/changai/changai/api/v2/schema_utils.py b/changai/changai/api/v2/schema_utils.py index 4dd5d23..945aee7 100644 --- a/changai/changai/api/v2/schema_utils.py +++ b/changai/changai/api/v2/schema_utils.py @@ -210,22 +210,39 @@ def is_doctype_schema_changed(doc, last_sync): latest = max(candidates, default=None) return bool(latest and last_sync and latest > get_datetime(last_sync)) +def is_master_data_changed_test(last_sync, stored_data: list): + for doc in MASTER_DOCTYPES: + meta = frappe.get_meta(doc) + title_field = meta.title_field or "name" + entity_type = f"tab{doc}" + + # ✅ Only compare rows matching title_field + allowed_fields = [f.fieldname for f in meta.fields] + ["name"] + if title_field not in allowed_fields: + frappe.log_error(f"Invalid title_field: {title_field}", "is_master_data_changed_test") + continue -def is_master_data_changed(last_sync): - from frappe.utils import get_datetime + live_records = frappe.get_all( + doc, + fields=[title_field], + limit_page_length=0 + ) + live_titles = set() + for rec in live_records: + if rec.get(title_field): + live_titles.add(rec.get(title_field)) - for doc in MASTER_DOCTYPES: - latest_modified = frappe.db.sql( - f"SELECT MAX(modified) FROM `tab{doc}`" - )[0][0] - if latest_modified and last_sync and get_datetime(latest_modified) > get_datetime(last_sync): + if stored_titles != live_titles: return True - return False + return False @frappe.whitelist(allow_guest=False) -def check_file_updates(file_name :str): +def check_file_updates(file_name: str): + RAG_FOLDER = "Home/RAG Sources" + from changai.changai.api.v2.build_cards_faiss_index_v2 import _read_file_doc settings = frappe.get_single("ChangAI Settings") + if file_name == "master_data.yaml": last_sync = settings.last_masterdata_sync elif file_name == "schema.yaml": @@ -241,35 +258,39 @@ def check_file_updates(file_name :str): "last_sync": None } + changed = False + if file_name == "schema.yaml": - changed = False doctypes = frappe.db.get_all("DocType", {"istable": 0}, pluck="name") for doc in doctypes: if is_doctype_schema_changed(doc, last_sync): changed = True break - elif file_name == "master_data.yaml": - changed = False - if is_master_data_changed(last_sync): + raw_content = _read_file_doc("master_data.yaml", RAG_FOLDER) + + # ✅ Extract data list from content + if isinstance(raw_content, dict): + stored_data = raw_content.get("data", []) + elif isinstance(raw_content, str): + import yaml + parsed = yaml.safe_load(raw_content) + stored_data = parsed.get("data", []) if isinstance(parsed, dict) else [] + else: + stored_data = [] + + if is_master_data_changed_test(last_sync, stored_data): changed = True days = days_diff(today(), getdate(last_sync)) - if changed == True: - return { - "is_stale": True, - "data": True, - "days": days, - "last_sync": last_sync - } - else: - return { - "is_stale":False, - "data": True, - "days": days, - "last_sync": last_sync - } + + return { + "is_stale": changed, + "data": True, + "days": days, + "last_sync": last_sync + } @frappe.whitelist() diff --git a/changai/changai/api/v2/store_chats.py b/changai/changai/api/v2/store_chats.py index b8e4779..f6eb73f 100644 --- a/changai/changai/api/v2/store_chats.py +++ b/changai/changai/api/v2/store_chats.py @@ -8,6 +8,7 @@ def save_logs( user_question: Optional[str] = None, formatted_q: Optional[str] = None, context: Optional[str] = None, + payload: Optional[dict]=None, sql: Optional[str] = None, val: Any = None, result: Any = None, @@ -27,6 +28,7 @@ def to_json_if_needed(v: Any) -> Any: MAX_LOG_LEN = 140 doc = frappe.new_doc("ChangAI Logs") doc.user_question = user_question + doc.payload = json.dumps(payload) if payload else None safe_question=(formatted_q[:137] + "..." if formatted_q and len(formatted_q) > MAX_LOG_LEN else formatted_q or "") doc.rewritten_question = safe_question doc.schema_retrieved = to_json_if_needed(context) @@ -194,34 +196,75 @@ def respond_from_cache(user_question:str): User Question: {qstn}""" - -def find_similar_log_question(new_question:str, threshold: int = 90): +def find_similar_log_question(new_question: str, threshold: int = 98): logs = frappe.get_all( "ChangAI Logs", - fields=["name", "user_question", "sql_generated","rewritten_question","fields","tables","error","entity","result","type"], + fields=[ + "name", + "user_question", + "sql_generated", + "rewritten_question", + "fields", + "tables", + "error", + "entity", + "result", + "type", + "payload" + ], limit_page_length=500 ) + best_match = None best_score = 0 + for log in logs: - score = fuzz.token_set_ratio(new_question, log.rewritten_question) + + # Skip Non-ERP + if log.type == "NonERP": + continue + + # Skip CUD operations + if log.payload: + continue + + # Skip logs with errors + if log.error: + continue + + # Skip logs without SQL + if not log.sql_generated: + continue + + result = frappe.parse_json(log.result or "{}") + + # Skip SQL execution failures + if isinstance(result, dict) and result.get("error"): + continue + + score = fuzz.token_set_ratio( + new_question, + log.user_question + ) + if score > best_score: best_score = score best_match = log - if best_score >= threshold: + if best_match and best_score >= threshold: return { "matched": True, + "payload": best_match.payload, "score": best_score, "log_name": best_match.name, "question": best_match.user_question, "sql": best_match.sql_generated, - "rewritten_question":best_match.rewritten_question, - "fields":best_match.fields, - "tables":best_match.tables, - "entity_debug":best_match.entity, - "result":best_match.result, - "error":best_match.error, + "rewritten_question": best_match.rewritten_question, + "fields": best_match.fields, + "tables": best_match.tables, + "entity_debug": best_match.entity, + "result": best_match.result, + "error": best_match.error, "type":best_match.type } diff --git a/changai/changai/api/v2/text2sql_pipeline_v2.py b/changai/changai/api/v2/text2sql_pipeline_v2.py index 66cede8..43941e3 100644 --- a/changai/changai/api/v2/text2sql_pipeline_v2.py +++ b/changai/changai/api/v2/text2sql_pipeline_v2.py @@ -4,6 +4,7 @@ import requests import json import base64 +from changai.changai.api.v2.operations import execute_insert,execute_update,execute_delete import os from frappe.utils.jinja import render_template from changai.changai.api.v2.schema_utils import match_report_intent, get_report_filter_fields @@ -83,6 +84,46 @@ THREAD_WORDS = set(read_asset("thread_words.json", base="assets")) SQL_REWRITE_SYS_PROMPT = read_asset("sql_rewrite_sys_prompt.txt", base="prompts") SQL_REWRITE_USER_PROMPT = read_asset("sql_rewrite_user_prompt.txt", base="prompts") + +INSERT_PROMPT = read_asset("insert_prompt.txt", base="prompts") +INSERT_USER_PROMPT = read_asset("insert_user_prompt.txt",base="prompts") +UPDATE_PROMPT = read_asset("update_prompt.txt", base="prompts") +UPDATE_USER_PROMPT = read_asset("update_user_prompt.txt", base="prompts") +DELETE_PROMPT = read_asset("delete_prompt.txt", base="prompts") +DELETE_USER_PROMPT = read_asset("delete_user_prompt.txt", base="prompts") + +def get_cud_prompt(cud_type, formatted_q, context): + if cud_type == "insert": + return ( + INSERT_PROMPT, + INSERT_USER_PROMPT.format( + question=formatted_q, + context=context + ) + ) + + elif cud_type == "update": + return ( + UPDATE_PROMPT, + UPDATE_USER_PROMPT.format( + question=formatted_q, + context=context + ) + ) + + elif cud_type == "delete": + return ( + DELETE_PROMPT, + DELETE_USER_PROMPT.format( + question=formatted_q, + context=context + ) + ) + + raise ValueError(f"Unsupported CUD type: {cud_type}") + + + @frappe.whitelist(allow_guest=True) # nosemgrep: security.guest-whitelisted-method - intentional, validates credentials via OAuth client lookup and Frappe password grant before returning a token def generate_token_secure(api_key: str, api_secret: str, app_key: str): try: @@ -185,6 +226,10 @@ def _safe_strip(v): # Shared State class SQLState(TypedDict, total=False): + payload_res :dict + is_cud:bool + cud_type:str + payload:dict filters:str entity_type_list:List[str] create_entity:bool @@ -234,6 +279,9 @@ def route_action(state: SQLState) -> str: return "CONTINUE" +def cud_router_node(state: SQLState): + return state + def fill_sql_prompt(question: str, context: str) -> str: return SQL_PROMPT.format(question=question, context=context) @@ -275,7 +323,7 @@ def guardrail_router(state: SQLState) -> SQLState: chat_id = state.get("session_id") raw_q = state.get("question") or "" try: - is_erp= is_erp_query(False,raw_q,BUSINESS_KEYWORDS,80) + is_erp= is_erp_query(False,raw_q,BUSINESS_KEYWORDS,98) if is_erp: query_type = "ERP" elif is_thread_erp(raw_q, chat_id): @@ -308,6 +356,8 @@ def _parse_rewrite_response(raw: Any, user_qstn: str) -> Tuple[str, bool]: create_entity = False report_intent = None message=None + is_cud=None + cud_type=None if isinstance(raw, dict): obj = raw elif isinstance(raw, str): @@ -333,9 +383,12 @@ def _parse_rewrite_response(raw: Any, user_qstn: str) -> Tuple[str, bool]: stop_followup = bool(obj.get("stop_followup")) if stop_followup: message = obj.get("message") + is_cud = bool(obj.get("is_cud")) + if is_cud: + cud_type = obj.get("cud_type") elif isinstance(obj, list) and not standalone: standalone = json.dumps(obj) - return standalone or user_qstn.strip(), contains_values, entity_words,create_entity, doc,entity_name,report_name,open_report,report_intent,stop_followup,message + return standalone or user_qstn.strip(), contains_values, entity_words,create_entity, doc,entity_name,report_name,open_report,report_intent,stop_followup,message,is_cud,cud_type def rewrite_question(state: SQLState) -> SQLState: report_intent = None @@ -348,7 +401,7 @@ def rewrite_question(state: SQLState) -> SQLState: report_name_new=None try: raw = call_model(prompt, "llm",sys_prompt) - standalone, contains_values,entity_words,create_entity, doc,entity_name,report_name,open_report,report_intent,stop_followup,message = _parse_rewrite_response(raw, user_qstn) + standalone, contains_values,entity_words,create_entity, doc,entity_name,report_name,open_report,report_intent,stop_followup,message,is_cud,cud_type = _parse_rewrite_response(raw, user_qstn) if report_intent: report_name_new = match_report_intent(report_intent) publish_pipeline_update( @@ -359,6 +412,8 @@ def rewrite_question(state: SQLState) -> SQLState: ) return { **state, + "payload":{}, + "payload_res":None, "report_name":report_name_new or report_name or "", "report_intent": report_intent, "open_report":open_report, @@ -371,7 +426,9 @@ def rewrite_question(state: SQLState) -> SQLState: "formatting_prompt": prompt, "error": None, "message":message if stop_followup else None, - "stop_followup": stop_followup + "stop_followup": stop_followup, + "is_cud":is_cud, + "cud_type":cud_type } except frappe.exceptions.ValidationError: raise @@ -386,15 +443,6 @@ def rewrite_question(state: SQLState) -> SQLState: return {**state, "error": str(e)} -@frappe.whitelist(allow_guest=False) -def rewrite_question_dup(user_question: str, session_id: str = "test_session") -> dict: - state: SQLState = { - "question": user_question, - "session_id": session_id, - "request_id": f"test_{frappe.generate_hash(length=10)}", - } - return rewrite_question(state) - ENTITY_CREATION_PROMPT = read_asset("create_entity_prompt.txt", base="prompts") def create_entity(state:SQLState): request_id = state.get("request_id") @@ -423,6 +471,113 @@ def _parse_json_list(raw: str) -> List[Any]: return [] +def get_payload(prompt:str,user_prompt:str,state:SQLState): + payload={} + response=call_model(prompt,"llm",user_prompt) + response = re.sub(r"^```(?:json)?\s*", "", response) + response = re.sub(r"\s*```$", "", response) + if not response: + return {**state, "error": "Empty response from LLM", "sql_prompt": prompt} + if isinstance(response, str): + try: + response = json.loads(response) + except json.JSONDecodeError: + return {} + return response.get("payload", {}) + + + +def check_update(res:dict): + if not res.get("data"): + frappe.throw(_( + "Master Data does not exist. Because of this, results may not be accurate. " + "For better accuracy, please open " + "Go to Settings Page " + "and click on the Update Master Data button in the Training tab.

" + "Check Quick Start Guide Here 👇:
" + "Click here
" + "ERPGulf.com" + ).format(settingsUrl, CHANGAI_GUIDE_LINK, ERPGULF_LINK)) + + if res.get("is_stale"): + frappe.throw(_( + "Master Data not updated." + "Because of this, results may not be accurate. " + "For better accuracy, please open " + "Go to Settings Page " + "and click on the Update Master Data button in the Training tab.

" + "Check Quick Start Guide Here 👇:
" + "Click here
" + "ERPGulf.com" + ).format(res.get("days"), settingsUrl, CHANGAI_GUIDE_LINK, ERPGULF_LINK)) + +def generate_orm(state: SQLState) -> SQLState: + from changai.changai.api.v2.auto_gen_api import update_masterdata + attempt = 0 + MAX_TRIES = 4 + payload = {} + request_id = state.get("request_id") + cud_type = state.get("cud_type") + fields = _safe_strip(state.get("selected_fields") or "") + entity_cards = state.get("entity_cards") or [] + entity_block = "" + config = ChangAIConfig.get() + formatted_q = state.get("formatted_q") + prompt = None + if not formatted_q: + return {**state, "sql": "", "orm": "", "error": "No question to generate SQL for", "sql_prompt": ""} + if entity_cards: + entity_block = "\n\nENTITY_CARDS:\n" + "\n".join(str(c) for c in entity_cards) + if config["retriever_structure"]=="multi line": + context = fields + (entity_block or "") + context = re.sub( + r'\btab([A-Za-z0-9_ ]+)', + r'\1', + context + ) + try: + prompt, user_prompt = get_cud_prompt(cud_type,formatted_q,context) + except ValueError as e: + return { + **state, + "error": str(e) + } + try: + while(attempt < MAX_TRIES): + payload = get_payload(prompt, user_prompt,state) + if payload and payload!={}: + break + attempt += 1 + frappe.log_error(f"Empty payload received. Retrying... attempt {attempt}/{MAX_TRIES}") + if not payload or payload == {}: + frappe.log_error(f"Empty payload received. After all {MAX_TRIES} Tries.") + return {"error":f"Failed to generate the payload for {cud_type}"} + publish_pipeline_update( + request_id, + "Payload_generated", + "Payload generated" + ) + if cud_type == "insert": + response = execute_insert(payload) + return {**state,"sql":"","final_prompt":prompt,"payload":payload, "payload_res": response} + elif cud_type == "update": + response = execute_update(payload) + return {**state,"sql":"","final_prompt":prompt,"payload":payload, "payload_res": response} + elif cud_type == "delete": + response = execute_delete(payload) + return {**state,"sql":"","final_prompt":prompt,"payload":payload, "payload_res": response} + else: + return { + **state, + "error": f"Unsupported CUD type: {cud_type}" + } + except frappe.exceptions.ValidationError: + raise + except Exception as e: + return {**state,"error": f"LLM call failed: {e}","sql_prompt":prompt} + + + # Node 1: Retrive with Fiass Vector Store. def schema_retriever(state: SQLState) -> SQLState: config = ChangAIConfig.get() @@ -431,7 +586,7 @@ def schema_retriever(state: SQLState) -> SQLState: hits = remote_embedder_request(state.get("formatted_q", "") or state.get("question", "")) return {**state, "hits": hits} else: - out = call_retrieve_multi_line(state.get("formatted_q") or state.get("question") or "",state.get("request_id"),) + out = call_retrieve_multi_line(state.get("is_cud"),state.get("formatted_q") or state.get("question") or "",state.get("request_id"),) return { **state, "retrieval_mode": "multi", @@ -471,12 +626,12 @@ def generate_sql(state:SQLState) -> SQLState: config = ChangAIConfig.get() formatted_q = state.get("formatted_q") if not formatted_q: - return {**state, "sql": "", "orm": "", "error": "No question to generate SQL for", "sql_prompt": ""} + return {**state,"payload":{},"payload_res":None, "sql": "", "orm": "", "error": "No question to generate SQL for", "sql_prompt": ""} if entity_cards: entity_block = "\n\nENTITY_CARDS:\n" + "\n".join(str(c) for c in entity_cards) if config["retriever_structure"]=="multi line": context = fields + (entity_block or "") - prompt = fill_sql_prompt(formatted_q, context) + prompt = SQL_PROMPT.format(question=formatted_q, context=context) state["final_prompt"] = prompt else: prompt=fill_sql_prompt(formatted_q,state["context"]) @@ -485,21 +640,25 @@ def generate_sql(state:SQLState) -> SQLState: if not response: return {**state, "error": "Empty response from LLM", "sql_prompt": prompt} if isinstance(response, str): - response = json.loads(response) + try: + response = json.loads(response) + except json.JSONDecodeError: + return { + **state, + "error": "Invalid JSON returned by LLM" + } sql = response.get("sql", "") - orm = response.get("orm", "") + payload = response.get("payload", {}) publish_pipeline_update( request_id, "sql_generated", "SQL generated" ) - return {**state,"sql_prompt":prompt,"sql":sql,"orm":orm,"error":None} + return {**state,"sql_prompt":prompt,"sql":sql,"payload":payload,"error":None,"payload_res": None} except frappe.exceptions.ValidationError: raise except Exception as e: return {**state,"error": f"LLM call failed: {e}","sql_prompt":prompt} - - # # Node 4:Validate the SQL Generate with meta schema mapping using SQLGlot def validate_sql(state: SQLState) -> SQLState: sql = clean_sql(state.get("sql") or "") @@ -520,6 +679,14 @@ def validate_sql(state: SQLState) -> SQLState: val = validate_sql_against_mapping(sql, mapping_data, dialect="mysql") return {**state, "validation": val} + +def route_is_cud(state:SQLState): + if state.get("is_cud"): + return "IS_CUD" + else: + return "NOT_CUD" + + # # Node 5:Repair Loop :Simple prompt for one more try. def repair_sqlquery(state: SQLState) -> SQLState: hints: List[str] = [] @@ -566,33 +733,16 @@ def detect_specific_entities(state: SQLState) -> SQLState: q = (state.get("formatted_q") or "").strip() if not q: return {**state, "entity_cards": [], "entity_raw": None} + if state.get("is_cud") and state.get("cud_type") == "insert": + return { + **state, + "entity_cards": [], + # "entity_raw": out.get("raw"), + } try: res = check_file_updates("master_data.yaml") - - if not res.get("data"): - frappe.throw(_( - "Master Data does not exist. Because of this, results may not be accurate. " - "For better accuracy, please open " - "Go to Settings Page " - "and click on the Update Master Data button in the Training tab.

" - "Check Quick Start Guide Here 👇:
" - "Click here
" - "ERPGulf.com" - ).format(settingsUrl, CHANGAI_GUIDE_LINK, ERPGULF_LINK)) - - if res.get("is_stale") and res.get("days", 0) > 0: - frappe.throw(_( - "Your master data is {0} days old. " - "Because of this, results may not be accurate. " - "For better accuracy, please open " - "Go to Settings Page " - "and click on the Update Master Data button in the Training tab.

" - "Check Quick Start Guide Here 👇:
" - "Click here
" - "ERPGulf.com" - ).format(res.get("days"), settingsUrl, CHANGAI_GUIDE_LINK, ERPGULF_LINK)) - + check_update(res) out = call_entity_retriever(False, q, state) return { **state, @@ -683,7 +833,6 @@ def prepare_report_action(state: SQLState) -> SQLState: response = call_model(prompt, "llm", "") raw_response = str(response or "").strip() raw_response = raw_response.replace("```json", "").replace("```", "").strip() - frappe.logger().info(f"prepare_report_action raw response: {repr(raw_response)}") if not raw_response: response = {"report_name": "", "filters": {}} else: @@ -728,6 +877,8 @@ def prepare_report_action(state: SQLState) -> SQLState: workflow.add_node("prepare_report_action", prepare_report_action) workflow.add_node("create_entity", create_entity) workflow.set_entry_point("guardrail_router") +workflow.add_node("generate_orm", generate_orm) +workflow.add_node("cud_router_node", cud_router_node) workflow.add_conditional_edges("guardrail_router",route_guardrail,{"ERP":"rewrite_question","NON_ERP":"routeNonErpToAI"}) workflow.add_edge("routeNonErpToAI", END) workflow.add_conditional_edges( @@ -737,21 +888,19 @@ def prepare_report_action(state: SQLState) -> SQLState: "CREATE_ENTITY": "create_entity", "OPEN_REPORT": "prepare_report_action", "STOP_FOLLOW":END, - "CONTINUE": "retrieve", + "CONTINUE": "retrieve" } ) workflow.add_edge("prepare_report_action", END) workflow.add_edge("create_entity", END) -# workflow.add_edge("stop_follow_msg_api", END) workflow.add_edge("retrieve","detect_entities") -workflow.add_conditional_edges("detect_entities", route_after_entities, {"CONTEXT":"build_context","DIRECT":"generate_sql"}) -workflow.add_edge("build_context", "generate_sql") +workflow.add_conditional_edges("detect_entities", route_after_entities, {"CONTEXT":"build_context","DIRECT":"cud_router_node"}) +workflow.add_edge("build_context", "cud_router_node") +workflow.add_conditional_edges("cud_router_node", route_is_cud, {"IS_CUD":"generate_orm","NOT_CUD":"generate_sql"}) workflow.add_edge("generate_sql",END) -# workflow.add_conditional_edges("validate_sql",router,{"repair":"repair_sql","end":END}) -# workflow.add_edge("repair_sql","validate_sql") +workflow.add_edge("generate_orm",END) checkpointer=MemorySaver() app=workflow.compile(checkpointer=checkpointer) - def _build_match_conditions(doctypes: List[str]) -> str: conditions = [] for t in doctypes: @@ -772,15 +921,15 @@ def execute_query(sql: str, doctypes: List[str]) -> Any: try: if not sql: return [] - if not str(sql).lower().strip().startswith("select"): - frappe.throw(_("Only SELECT queries are allowed." - "Check Quick Start Guide Here 👇:\n {0}").format(CHANGAI_GUIDE_LINK)) + # if not str(sql).lower().strip().startswith("select"): + # frappe.throw(_("Only SELECT queries are allowed." + # "Check Quick Start Guide Here 👇:\n {0}").format(CHANGAI_GUIDE_LINK)) sql = sql.rstrip().rstrip(';') combined = _build_match_conditions(doctypes) if combined: sql = _append_conditions(sql, combined) return frappe.db.sql(sql, as_dict=True) - except PermissionError: + except frappe.PermissionError: return { "error": _("You do not have permission to access this data. Check the Quick Start Guide here 👇: {0}").format( f'Click here

ERPGulf.com' @@ -841,7 +990,6 @@ def _handle_sql_result( sql_prompt: Optional[str], final: Optional[Dict], sql: str, - orm: Optional[str], formatted_q: Optional[str], fields: Optional[str], selected_tables: Optional[List], @@ -856,12 +1004,20 @@ def _handle_sql_result( selected_tables = selected_tables or [] fields = fields or "" formatted_q = formatted_q or user_question + sql_result=[] + extracted_tables=[] + formatted_result ="" + payload = {} try: request_id = request_id or final.get("request_id") org_sql = final.get("sql") or sql - extracted_tables = extract_tables_from_sql(sql) + payload = final.get("payload") or {} + payload_res = final.get("payload_res") + if org_sql: + extracted_tables = extract_tables_from_sql(org_sql) try: - sql_result = execute_query(sql, extracted_tables) + if sql: + sql_result = execute_query(sql, extracted_tables) except Exception as e: # err = str(e) final["error"] = str(e) @@ -873,7 +1029,70 @@ def _handle_sql_result( context = (final.get("context") or final.get("selected_fields") or fields or "")[:800] contains_values = final.get("contains_values") or entity_debug.get("contains_values") or "" err = final.get("error") - formatted_result = format_data(user_question, sql_result) + + payload_res = final.get("payload_res") + + if payload_res: + # ✅ Check if it's an error response + if payload_res.get("error") and not payload_res.get("success"): + error_msg = payload_res.get("error", "Unknown error occurred") + # Clean HTML tags if any + clean_msg = re.sub(r'<[^>]+>', '', error_msg) + publish_pipeline_update( + request_id, + "format_data_completed", + "Completed Formatting Result", + done=True + ) + save_turn_2( + session_id=chat_id, + user_text=formatted_q, + bot_text=f"❌ {clean_msg}", + type_="erp" + ) + save_logs( + user_question=user_question, + formatted_q=formatted_q, + context=context, + payload=payload, + sql=sql, + val=val, + err=clean_msg, + result=[], + formatted_result=f"❌ {clean_msg}", + tables=selected_tables, + fields=fields, + entity_debug=entity_debug, + type_="ERP" + ) + return { + "Model returned SQL": "", + "context": context, + "payload": payload, + "entity_words": [], + "Question": user_question, + "payload_res": payload_res, + "Formated Question": formatted_q, + "Cleaned SQL": "", + "Tables": selected_tables, + "Fields": fields, + "Entity Values present ?": "", + "Validation": {}, + "Error": clean_msg, + "result": [], + "EntityDebug": entity_debug, + "Bot": { + "answer": f"❌ {clean_msg}" + } + } + + # ✅ Normal success case + formatted_result = format_data(user_question, payload_res) + elif sql: + formatted_result = format_data( + user_question, + sql_result + ) publish_pipeline_update( request_id, "format_data_completed", @@ -891,6 +1110,7 @@ def _handle_sql_result( except Exception as e: save_logs( user_question=user_question, + payload=payload, formatted_q=formatted_q, context=context, sql=sql, @@ -908,6 +1128,7 @@ def _handle_sql_result( user_question=user_question, formatted_q=formatted_q, context=context, + payload=payload, sql=sql, val=val, err=err if err else "", @@ -921,11 +1142,12 @@ def _handle_sql_result( return { "Model returned SQL": org_sql, "context": context, + "payload":payload, "entity_words": entity_words, "Question": user_question, + "payload_res":final.get("payload_res"), "Formated Question": formatted_q, "Cleaned SQL": sql, - "ORM": orm, "Tables": selected_tables, "Fields": fields, "Entity Values present ?": contains_values, @@ -933,7 +1155,7 @@ def _handle_sql_result( "Error": err, "result": sql_result, "EntityDebug": entity_debug if entity_debug.get("contains_values") else None, - "Bot": formatted_result, + "Bot": formatted_result } RETRY_PROMPT = read_asset("retry_sys_prompt.txt",base="prompts") RETRY_USER_PROMPT = read_asset("retry_user_prompt.txt",base="prompts") @@ -946,158 +1168,325 @@ def retry_sql(sql, error, formatted_q, sql_prompt): retried_sql = clean_sql(rewritten_json.get("sql") or "") retried_orm = clean_sql(rewritten_json.get("orm") or "") except Exception: - return "", "", {"ok": False, "error": "Retry failed to parse response"} + return "",{"ok": False, "error": "Retry failed to parse response"} if not retried_sql: - return "", "", {"ok": False, "error": "Retry returned empty SQL"} + return "",{"ok": False, "error": "Retry returned empty SQL"} val_res = validate_sql_schema(retried_sql) - return retried_sql, retried_orm, val_res + return retried_sql, val_res def is_thread_erp(q:str,chat_id:str): msg_type = get_last_thread_message(chat_id) - if msg_type == "erp" and is_erp_query(False,q, THREAD_WORDS,90): + if msg_type == "erp" and is_erp_query(False,q, THREAD_WORDS,98): return True else: return False @frappe.whitelist(allow_guest=False) -def run_text2sql_pipeline(user_question: str, chat_id: str, request_id: str, sendNonErptoAI: bool = False) -> Dict: - err = "" +def run_text2sql_pipeline( + user_question: str, + chat_id: str, + request_id: str, + sendNonErptoAI: bool = False +) -> Dict: + memory_status = check_memory_status() + + # -------------------------------------------------- + # CACHE + # -------------------------------------------------- logs = find_similar_log_question(user_question) - if logs.get("matched") and logs["error"] == "" and logs.get("type") != "NonERP": - publish_pipeline_update(request_id, "cache_hit", "Using cached result") - # return True,logs - # if logs.get("rewritten_question") == "Not formatted as its NONERP": - # return _handle_non_erp_(logs.get("result"),logs.get("rewritten_question"),logs.get("error"), user_question, chat_id) + + if logs.get("matched"): + publish_pipeline_update( + request_id, + "cache_hit", + "Using cached result" + ) + formatted_q = logs.get("rewritten_question") sql = logs.get("sql") + tables = json.loads(logs.get("tables") or "[]") - fields =logs.get("fields") or "" + fields = logs.get("fields") or "" entity_debug = json.loads(logs.get("entity_debug") or "{}") + return _handle_sql_result( - memory_status, - request_id, - None, - {}, - sql, - None, - formatted_q, - fields, - tables, - {"ok": True, "from_cache": True}, - entity_debug, - user_question, - chat_id -) - else: - final, err_response = _invoke_pipeline(user_question, chat_id, request_id, sendNonErptoAI) - if err_response: - return err_response + memory_status, + request_id, + None, + {}, + sql, + formatted_q, + fields, + tables, + {"ok": True, "from_cache": True}, + entity_debug, + user_question, + chat_id + ) + + # -------------------------------------------------- + # PIPELINE INVOCATION + # -------------------------------------------------- + final, err_response = _invoke_pipeline( + user_question, + chat_id, + request_id, + sendNonErptoAI + ) + if err_response: + return err_response - entity_debug = { - "contains_values": final.get("contains_values"), - "entity_cards": final.get("entity_cards") or [], + if not final: + return { + "error": "Pipeline returned empty state" } + if (final.get("query_type") or "NON_ERP") == "NON_ERP": - if (final.get("query_type") or "NON_ERP") == "NON_ERP": - non_erp_res = _safe_strip(final.get("non_erp_res", "")) - formatted_q = _safe_strip(final.get("formatted_q", "")) - err = final.get("error") - return _handle_non_erp_(non_erp_res,formatted_q,err, user_question,request_id, chat_id) + non_erp_res = _safe_strip(final.get("non_erp_res", "")) + formatted_q = _safe_strip(final.get("formatted_q", "")) + err = final.get("error") - sql = clean_sql(final.get("sql")) or "" - orm = clean_sql(final.get("orm") or "") - formatted_q = _safe_strip(final.get("formatted_q") or "") - if final.get("create_entity") is True: - return { - "create_entity":True, - "doc": final.get("doc"), - "entity_name": final.get("entity_name") - } - if final.get("open_report") is True: - return { - "open_report": True, - "report_name": final.get("report_name"), - "filters": final.get("filters") or {}, - "reports_filter_before_call": final.get("reports_filter_before_call"), - "entity_raw": final.get("entity_raw"), - "question_rewritten": formatted_q - } - formatted_q = formatted_q or "" + return _handle_non_erp_( + non_erp_res, + formatted_q, + err, + user_question, + request_id, + chat_id + ) - if final.get("stop_followup"): - save_turn_2(session_id=chat_id, user_text=user_question, bot_text=final.get("message"),type_="non_erp") - save_logs( - user_question=user_question, - formatted_q="", - context=None, - sql=None, - val=None, - err=err if err else "", - result=None, - formatted_result=final.get("message"), - tables=None, - fields=None, - entity_debug=None, - type_="NonERP" - ) - publish_pipeline_update( - request_id, - "Stop follow-up detected", - "Stop follow-up detected", - data={"message": final.get("message")}, - done=True) - return { - "Model returned SQL": None, - "context": None, - "entity_words": None, - "Question": user_question, - "Formated Question": formatted_q, - "Cleaned SQL": None, - "stop_followup": True, - "ORM": None, - "Tables": None, - "Fields": None, - "Entity Values present ?": None, - "Validation": None, - "Error": err, - "result": None, - "EntityDebug": None, - "Bot": final.get("message"), + if final.get("create_entity") is True: + return { + "create_entity": True, + "doc": final.get("doc"), + "entity_name": final.get("entity_name") + } + + if final.get("open_report") is True: + return { + "open_report": True, + "report_name": final.get("report_name"), + "filters": final.get("filters") or {}, + "reports_filter_before_call": final.get("reports_filter_before_call"), + "entity_raw": final.get("entity_raw"), + "question_rewritten": _safe_strip(final.get("formatted_q") or "") + } + + if final.get("stop_followup"): + + save_turn_2( + session_id=chat_id, + user_text=user_question, + bot_text=final.get("message"), + type_="non_erp" + ) + + save_logs( + user_question=user_question, + formatted_q="", + context=None, + payload=final.get("payload") or None, + sql=None, + val=None, + err=final.get("error") or "", + result=None, + formatted_result=final.get("message"), + tables=None, + fields=None, + entity_debug=None, + type_="NonERP" + ) + + publish_pipeline_update( + request_id, + "Stop follow-up detected", + "Stop follow-up detected", + data={"message": final.get("message")}, + done=True + ) + + return { + "Model returned SQL": None, + "context": None, + "entity_words": None, + "Question": user_question, + "Formated Question": _safe_strip(final.get("formatted_q") or ""), + "Cleaned SQL": None, + "stop_followup": True, + "ORM": None, + "Tables": None, + "Fields": None, + "Entity Values present ?": None, + "Validation": None, + "Error": final.get("error"), + "result": None, + "EntityDebug": None, + "Bot": final.get("message"), + } + payload = final.get("payload") or {} + payload_res = final.get("payload_res") + sql = clean_sql(final.get("sql")) or "" + formatted_q = _safe_strip(final.get("formatted_q") or "") + context = final.get("context") or "" + selected_tables = final.get("selected_tables") or [] + fields = _safe_strip(final.get("selected_fields") or "") + sql_prompt = _safe_strip(final.get("sql_prompt") or "") + entity_debug = { + "contains_values": final.get("contains_values"), + "entity_cards": final.get("entity_cards") or [], } - selected_tables = final.get("selected_tables") or [] - fields = _safe_strip(final.get("selected_fields") or "") - sql_prompt = _safe_strip(final.get("sql_prompt") or "") - final_prompt = final.get("final_prompt") or "" - entity_words=final.get("entity_words") or [] - try: - context = final.get("context") - except Exception as e: - frappe.log_error(e, "Error occurred while fetching final values") - err = final.get("error") + err = final.get("error") + res = {} + if payload_res: + return _handle_sql_result( + memory_status, + request_id, + sql_prompt, + final, + sql, + formatted_q, + fields, + selected_tables, + res, + entity_debug, + user_question, + chat_id + ) + if sql: res = validate_sql_schema(sql) - publish_pipeline_update(request_id, "sql_validated", _("SQL validation Completed")) - # valid on first try - if res.get("ok") and sql.upper().startswith("SELECT"): - return _handle_sql_result(memory_status,request_id, sql_prompt, final, sql, orm, - formatted_q, fields, selected_tables, res, - entity_debug, user_question, chat_id) - # retry 2 - retried_sql2, retried_orm2, retry2_val_res = retry_sql(sql, res.get("error"), formatted_q, sql_prompt) + publish_pipeline_update( + request_id, + "sql_validated", + _("SQL validation Completed") + ) + if res.get("ok"): + return _handle_sql_result( + memory_status, + request_id, + sql_prompt, + final, + sql, + formatted_q, + fields, + selected_tables, + res, + entity_debug, + user_question, + chat_id + ) + + retried_sql2, retry2_val_res = retry_sql( + sql, + res.get("error"), + formatted_q, + sql_prompt + ) + if retry2_val_res.get("ok"): - return _handle_sql_result(memory_status,request_id, sql_prompt, final, retried_sql2, retried_orm2, - formatted_q, fields, selected_tables, retry2_val_res, - entity_debug, user_question, chat_id) + return _handle_sql_result( + memory_status, + request_id, + sql_prompt, + final, + retried_sql2, + formatted_q, + fields, + selected_tables, + retry2_val_res, + entity_debug, + user_question, + chat_id + ) + + retried_sql3, retry3_val_res = retry_sql( + retried_sql2, + retry2_val_res.get("error"), + formatted_q, + sql_prompt + ) - # retry 3 - retried_sql3, retried_orm3, retry3_val_res = retry_sql(retried_sql2, retry2_val_res.get("error"), formatted_q, sql_prompt) if retry3_val_res.get("ok"): - return _handle_sql_result(memory_status,request_id, sql_prompt, final, retried_sql3, retried_orm3, - formatted_q, fields, selected_tables, retry3_val_res, - entity_debug, user_question, chat_id) - - # all retries failed - final_error = retry2_val_res.get("error") or retry3_val_res.get("error") or res.get("error") or "SQL not valid or missing" - return _error_response(memory_status, user_question, formatted_q, context, - selected_tables, fields, retried_sql2 or sql, - retry2_val_res, entity_debug, 2, final_error, err) + return _handle_sql_result( + memory_status, + request_id, + sql_prompt, + final, + retried_sql3, + formatted_q, + fields, + selected_tables, + retry3_val_res, + entity_debug, + user_question, + chat_id + ) + + final_error = ( + retry3_val_res.get("error") + or retry2_val_res.get("error") + or res.get("error") + or "SQL not valid or missing" + ) + return _error_response( + memory_status, + user_question, + formatted_q, + context, + selected_tables, + fields, + retried_sql3 or retried_sql2 or sql, + retry3_val_res, + entity_debug, + 2, + final_error, + err + ) + return _error_response( + memory_status, + user_question, + formatted_q, + context, + selected_tables, + fields, + sql, + {}, + entity_debug, + 1, + "No SQL or Payload generated", + err + ) + + + +@frappe.whitelist(allow_guest=False) +def guardrail_router_test( + question: str, + chat_id: str = None, + request_id: str = "test_001" +): + try: + is_erp = is_erp_query(False, question, BUSINESS_KEYWORDS, 98) + if is_erp: + query_type = "ERP" + elif chat_id and is_thread_erp(question, chat_id): + query_type = "ERP" + else: + query_type = "NON_ERP" + + return { + "success": True, + "question": question, + "query_type": query_type, + "is_erp_match": bool(is_erp), + "is_thread_erp": bool(chat_id and is_thread_erp(question, chat_id)) + } + + except Exception as e: + frappe.log_error(frappe.get_traceback(), "Guardrail Router Test Error") + return { + "success": False, + "question": question, + "query_type": "NON_ERP", + "error": str(e) + } \ No newline at end of file diff --git a/changai/changai/doctype/changai_logs/changai_logs.json b/changai/changai/doctype/changai_logs/changai_logs.json index aece98c..0cc74e8 100644 --- a/changai/changai/doctype/changai_logs/changai_logs.json +++ b/changai/changai/doctype/changai_logs/changai_logs.json @@ -6,19 +6,22 @@ "engine": "InnoDB", "field_order": [ "user_question", - "rewritten_question", "schema_retrieved", + "payload", + "formatted_result", + "column_break_gzja", + "rewritten_question", "sql_generated", "result", - "formatted_result", "validation_and_error_section", "error", - "validation", "tries", + "type", + "validation", + "column_break_dbio", "fields", "tables", - "entity", - "type" + "entity" ], "fields": [ { @@ -91,12 +94,25 @@ "fieldtype": "Select", "label": "Type", "options": "ERP\nNonERP" + }, + { + "fieldname": "payload", + "fieldtype": "Long Text", + "label": "Payload for Create,update,delete" + }, + { + "fieldname": "column_break_gzja", + "fieldtype": "Column Break" + }, + { + "fieldname": "column_break_dbio", + "fieldtype": "Column Break" } ], "grid_page_length": 50, "index_web_pages_for_search": 1, "links": [], - "modified": "2026-06-04 12:40:18.522183", + "modified": "2026-06-17 13:36:19.283794", "modified_by": "Administrator", "module": "Changai", "name": "ChangAI Logs", diff --git a/changai/changai/doctype/changai_settings/changai_settings.js b/changai/changai/doctype/changai_settings/changai_settings.js index 82c086b..81a31a6 100644 --- a/changai/changai/doctype/changai_settings/changai_settings.js +++ b/changai/changai/doctype/changai_settings/changai_settings.js @@ -280,25 +280,25 @@ async function check_updates(file_name) { }); const is_stale = r.message?.is_stale; const data = r.message?.data; - const days = r.message?.days ?? 0; const last_sync = r.message?.last_sync; - const date = frappe.datetime.str_to_obj(last_sync); - const formatted_date = date.toLocaleString(); + const date = new Date(last_sync); // no " UTC" suffix + const formatted_date = date.toLocaleString(undefined, { + year: "numeric", + month: "short", + day: "numeric", + hour: "2-digit", + minute: "2-digit", + hour12: false + }); let badge_class = "badge-yellow"; let badge_text = "Unknown"; if (is_stale === true) { - if (days > 1) { - badge_class = "badge-yellow"; - badge_text = `${formatted_date}` - } - else { - badge_class = "badge-green"; - badge_text = `${formatted_date}` - } - + badge_class = "badge-yellow"; + badge_text = `${formatted_date}` } + if (is_stale === false) { if (data) { badge_class = "badge-green"; @@ -312,7 +312,6 @@ async function check_updates(file_name) { return { badge_class, badge_text, - days, formatted_date - }; -} \ No newline at end of file + } +} diff --git a/changai/changai/doctype/changai_settings/changai_settings.json b/changai/changai/doctype/changai_settings/changai_settings.json index df9b4a7..e1af778 100644 --- a/changai/changai/doctype/changai_settings/changai_settings.json +++ b/changai/changai/doctype/changai_settings/changai_settings.json @@ -5,13 +5,14 @@ "doctype": "DocType", "engine": "InnoDB", "field_order": [ - "server_section", + "section_break_ubdl", "enable_changai", + "gemini_authentication_free_tier", + "gemini_api_key", + "server_section", "remote", "from_language", "to_language", - "gemini_authentication_free_tier_section", - "gemini_api_key", "models_section", "embedder", "qwen3_4b_instruct", @@ -32,6 +33,8 @@ "result_formatting", "remote_server_tab", "replicate_section", + "column_break_enbc", + "column_break_nomz", "prediction_url", "deploy_url", "llm_version_id", @@ -301,11 +304,6 @@ "label": "To Language", "options": "Language" }, - { - "fieldname": "gemini_authentication_free_tier_section", - "fieldtype": "Section Break", - "label": "Gemini Authentication (Free Tier)" - }, { "fieldname": "section_break_qwlc", "fieldtype": "Section Break", @@ -386,13 +384,30 @@ "fieldname": "enable_changai", "fieldtype": "Check", "label": "Enable changAI" + }, + { + "fieldname": "section_break_ubdl", + "fieldtype": "Section Break" + }, + { + "fieldname": "column_break_enbc", + "fieldtype": "Column Break" + }, + { + "fieldname": "column_break_nomz", + "fieldtype": "Column Break" + }, + { + "fieldname": "gemini_authentication_free_tier", + "fieldtype": "Section Break", + "label": "Gemini Authentication (Free Tier)" } ], "grid_page_length": 50, "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2026-05-21 16:38:55.838611", + "modified": "2026-06-15 07:18:36.158706", "modified_by": "Administrator", "module": "Changai", "name": "ChangAI Settings", diff --git a/changai/changai/prompts/create_entity_prompt.txt b/changai/changai/prompts/create_entity_prompt.txt index bf155ab..2bddc24 100644 --- a/changai/changai/prompts/create_entity_prompt.txt +++ b/changai/changai/prompts/create_entity_prompt.txt @@ -13,6 +13,18 @@ Rules: - Return only valid JSON. - Do not return explanations or extra text. - If no suitable DocType is found, return {{"doctype": ""}} +- If entity names/values are present in the question (like customer names, supplier names, item codes, project names etc.), extract them into entity_words list. +- If no entity values are found, return an empty list for entity_words. Output format: -{{"doctype": "chosen_doctype_name"}} \ No newline at end of file +{{ + "doctype": "chosen_doctype_name", + "entity_words": ["value1", "value2"] +}} + +Examples: +- "Create a new customer John Doe" → {{"doctype": "Customer", "entity_words": ["John Doe"]}} +- "Add supplier ABC Trading LLC" → {{"doctype": "Supplier", "entity_words": ["ABC Trading LLC"]}} +- "Create quotation for Customer ABC with item X" → {{"doctype": "Quotation", "entity_words": ["ABC", "X"]}} +- "Create a new lead" → {{"doctype": "Lead", "entity_words": []}} +- "Add a new item" → {{"doctype": "Item", "entity_words": []}} \ No newline at end of file diff --git a/changai/changai/prompts/cud_prompt.txt b/changai/changai/prompts/cud_prompt.txt new file mode 100644 index 0000000..35d063d --- /dev/null +++ b/changai/changai/prompts/cud_prompt.txt @@ -0,0 +1,321 @@ +You are a RESTRICTED Frappe ORM payload generator. +You have NO knowledge of ERPNext, databases, or any schema beyond what is written in SCHEMA CONTEXT. +SCHEMA CONTEXT is your entire universe. Nothing outside it exists. +ABSOLUTE LAW: Only use fields and tables from SCHEMA CONTEXT. +Empty payload = critical failure. + +═══ FIELD & TABLE LAW (ABSOLUTE — ZERO EXCEPTIONS) ═══ +BEFORE writing any field or table name, locate it physically in SCHEMA CONTEXT. + FOUND → you may use it, only under the table it is listed. + NOT FOUND → it does not exist. Do not write it. Do not guess it. Do not remember it. + +- A field listed under tabCustomer CANNOT appear in a payload for tabEmployee unless + an explicit link field (→) exists in SCHEMA CONTEXT. +- Do NOT assume any relationship between tables. If no link field exists → no cross reference. +- Never use any fields or tables that are not given in SCHEMA CONTEXT. +- Never assume fields. Only use the fields and tables that exist in SCHEMA CONTEXT. +- NEVER return empty payload. Always generate the best possible payload using the closest available fields and tables from SCHEMA CONTEXT. + +═══ SELF-CHECK PROTOCOL (MANDATORY BEFORE OUTPUT) ═══ +For every field in your payload, answer internally: + Q: Is this field listed under THIS exact table in SCHEMA CONTEXT? + YES → keep it. + NO → remove it immediately. No exceptions. + +For every doctype in your payload, answer internally: + Q: Is this table present in SCHEMA CONTEXT? + YES → keep it. + NO → remove it immediately. No exceptions. + +═══ OPERATION DETECTION LAW ═══ +Detect the correct operation from the user question: + - "create", "add", "insert", "new" → INSERT operation + - "update", "change", "set", "modify" → UPDATE operation + - "delete", "remove", "cancel" → DELETE operation + +Never mix operations. One payload = one operation only. +Never generate SELECT payloads. This prompt is strictly for INSERT, UPDATE, DELETE. + +═══ PAYLOAD OPERATIONS & FORMAT ═══ + +── INSERT OPERATIONS ────────────────────────────────────── + +CASE 1 — insert_main (single doc insert): +Use when: user wants to create a new main document. +{ + "operation": "insert_main", + "doctype": "", + "data": { + "": "" + } +} + +CASE 2 — insert_child (add row to existing doc child table): +Use when: user wants to add a row to an existing document's child table. +{ + "operation": "insert_child", + "doctype": "", + "filters": {"name": ""}, + "child_table": "", + "data": { + "": "" + } +} + +CASE 3 — insert_linked (create linked doc and link to parent): +Use when: user wants to create a Contact, Address, or similar linked doc and attach it to a parent. +{ + "operation": "insert_linked", + "doctype": "", + "filters": {"": ""}, + "linked_doctype": "", + "link_via": "", + "data": { + "": "" + } +} + +CASE 4 — insert_linked_child (create linked doc with its own child rows and link to parent): +Use when: user wants to create a Contact/Address with phone, email, or other child rows and link it. +{ + "operation": "insert_linked_child", + "doctype": "", + "filters": {"": ""}, + "linked_doctype": "", + "link_via": "", + "data": { + "": "" + }, + "child_rows": { + "": [ + {"": ""} + ] + } +} + +CASE 5 — insert_bulk (insert multiple main docs): +Use when: user wants to create multiple records at once. +Max 50 records allowed. If more than 50 → return error payload. +{ + "operation": "insert_bulk", + "doctype": "", + "records": [ + {"": ""}, + {"": ""} + ] +} + +CASE 6 — insert_if_not_exists (insert only if record does not already exist): +Use when: user says "only if not exists", "if not already", or similar. +{ + "operation": "insert_if_not_exists", + "doctype": "", + "filters": {"": ""}, + "data": { + "": "" + } +} + +── UPDATE OPERATIONS ────────────────────────────────────── + +CASE 1 — update (single or bulk update, max 50 records): +Use when: user wants to update one or more main documents. +{ + "operation": "update", + "doctype": "", + "filters": {"": ""}, + "data": { + "": "" + }, + "bulk": true/false +} + +CASE 2 — update with cross_filters (JOIN-based update): +Use when: user wants to update records based on a condition from another linked table. +{ + "operation": "update", + "doctype": "", + "filters": {}, + "cross_filters": { + "doctype": "", + "filters": {"": ""}, + "link_field": "" + }, + "data": { + "": "" + }, + "bulk": true +} + +CASE 3 — update_child (update specific child table rows): +Use when: user wants to update a specific row inside a child table of a document. +{ + "operation": "update_child", + "doctype": "", + "name": "", + "child_table": "", + "child_filters": {"": ""}, + "data": { + "": "" + } +} + +CASE 4 — update_linked (update a linked doc like Contact or Address): +Use when: user wants to update a field on a linked document (Contact, Address) attached to a parent. +{ + "operation": "update_linked", + "doctype": "", + "filters": {"": ""}, + "linked_doctype": "", + "link_via": "", + "data": { + "": "" + } +} + +CASE 5 — update_linked_child (update child row inside a linked doc): +Use when: user wants to update a specific row (phone, email) inside a linked doc's child table. +{ + "operation": "update_linked", + "doctype": "", + "filters": {"": ""}, + "linked_doctype": "", + "link_via": "", + "child_table": "", + "child_filters": {"": ""}, + "data": { + "": "" + } +} + +── DELETE OPERATIONS ────────────────────────────────────── + +CASE 1 — delete (single or bulk delete, max 50 records): +Use when: user wants to delete one or more main documents. +{ + "operation": "delete", + "doctype": "", + "filters": {"": ""} +} + +CASE 2 — delete_child (remove specific child table rows): +Use when: user wants to remove a specific row from a child table inside a document. +{ + "operation": "delete_child", + "doctype": "", + "name": "", + "child_table": "", + "child_filters": {"": ""} +} + +CASE 3 — delete_linked (delete a linked doc like Contact or Address): +Use when: user wants to delete a Contact, Address, or similar linked doc attached to a parent. +{ + "operation": "delete_linked", + "doctype": "", + "filters": {"": ""}, + "linked_doctype": "", + "link_via": "" +} + +CASE 4 — delete_linked_child (remove a child row from a linked doc): +Use when: user wants to remove a specific phone, email, or row from a linked doc's child table. +{ + "operation": "delete_linked", + "doctype": "", + "filters": {"": ""}, + "linked_doctype": "", + "link_via": "", + "child_table": "", + "child_filters": {"": ""} +} + +═══ ENTITY FILTERING LAW ═══ +- If ENTITY_CARDS exist, use ONLY those exact entity values in entity card (no spelling/case changes). +- NEVER use entity string literals directly from the user question in payload values. +- Match user-mentioned names to the closest ENTITY_CARD using typos, phonetic matching, fuzzy matching, abbreviations, and partial names. +- Always use the exact entity card filter_field and filter_value in filters. +- Consider very bad typos, pronunciation similarity, sound-alike names, abbreviations, and partial matches when matching user entity text with entity cards. +- Always use the filter_field given in entity cards for filtering with that entity value. + +═══ DATE RESOLUTION LAW (ABSOLUTE — ZERO EXCEPTIONS) ═══ +NEVER hardcode or guess dates. NEVER imagine a date value. +Always resolve relative date references dynamically using Frappe utils: + + "today" → frappe.utils.today() + "yesterday" → frappe.utils.add_days(frappe.utils.today(), -1) + "tomorrow" → frappe.utils.add_days(frappe.utils.today(), 1) + "next week" → frappe.utils.add_days(frappe.utils.today(), 7) + "last week" → frappe.utils.add_days(frappe.utils.today(), -7) + "next month" → frappe.utils.add_months(frappe.utils.today(), 1) + "last month" → frappe.utils.add_months(frappe.utils.today(), -1) + +Always write the Frappe util expression as the value — never a hardcoded date string. + +═══ LINKED FIELD VALIDATION LAW ═══ +Before setting any Link field value in a payload: +- Verify the linked doctype exists in SCHEMA CONTEXT. +- Never set a Link field to a value that cannot be verified. +- If a linked value does not exist in SCHEMA CONTEXT, flag it clearly. +- Never invent linked document names or codes. + +═══ BULK LIMIT LAW ═══ +- insert_bulk: maximum 50 records. If user requests more → return error. +- update bulk: maximum 50 records matched. If more → instruct user to narrow filters. +- delete bulk: maximum 50 records matched. If more → instruct user to narrow filters. + +═══ CHILD TABLE LAW ═══ +- Child table fieldname must exist in SCHEMA CONTEXT under the parent doctype. +- Child table row fields must exist in SCHEMA CONTEXT under the child table. +- Never assume child table names or fields. +- For child table operations always include parent, parenttype, parentfield implicitly — the ORM handles this. + +═══ SCHEMA RANKING AWARENESS ═══ +- SCHEMA CONTEXT is retrieved via semantic search — relevant tables/fields may appear + low in the list due to weak retrieval ranking. Do NOT treat rank as relevance. +- Scan the ENTIRE SCHEMA CONTEXT before selecting any table or field. +- Choose the most semantically correct table/field for the question + even if it appears last in SCHEMA CONTEXT. +- Ranking is a retrieval artifact. Correctness is your responsibility. + +═══ DOCSTATUS LAW ═══ +- Never set docstatus manually in INSERT payloads — Frappe handles this automatically. +- For UPDATE: only set docstatus if user explicitly asks to submit or cancel a document. + submit → docstatus = 1 + cancel → docstatus = 2 +- Never set docstatus on master/setup doctypes: + Customer, Supplier, Item, Employee, Warehouse, Territory, Address, Contact, + User, Item Group, Customer Group, Company, Country, Currency, UOM, + Cost Center, Department, Project, Lead, Opportunity. + +═══ STRICT RULES ═══ +- Never generate SELECT payloads. This prompt is for INSERT, UPDATE, DELETE only. +- Never return SQL. Return ONLY Frappe ORM payload JSON. +- Never leave payload data empty for INSERT or UPDATE operations. +- Never invent field names, doctype names, or child table names. +- Never mix two operations in one payload. +- Always pick the most specific operation case that matches the user question. +- If user question is ambiguous between cases, pick the most complete matching case. +- Always include all fields mentioned by the user in the payload. +- Never drop any field the user explicitly mentioned. +- Never add fields the user did not mention unless required by the operation structure. + +═══ OUTPUT LAW ═══ +- Output ONLY raw JSON. No explanation. No markdown. No extra keys. +- Never return empty payload. Always generate the best possible payload. +- The response must start with '{' and end with '}'. +- All keys and string values must use double quotes. +- Never return text before or after the JSON. +- Output Format: +{{ + "payload": { ... } +}} + +FINAL CHECK: + 1. Did you verify every field exists in SCHEMA CONTEXT? + 2. Did you resolve all date references using Frappe utils? + 3. Did you use entity card values and not raw user text? + 4. Did you pick the correct operation case? + 5. Is the payload complete with no missing fields the user mentioned? + 6. Is the bulk limit respected? +If payload is empty → you have failed. Output best partial payload instead. \ No newline at end of file diff --git a/changai/changai/prompts/delete_prompt.txt b/changai/changai/prompts/delete_prompt.txt new file mode 100644 index 0000000..c062550 --- /dev/null +++ b/changai/changai/prompts/delete_prompt.txt @@ -0,0 +1,249 @@ +You are a RESTRICTED Frappe ORM DELETE payload generator. +You have NO knowledge beyond SCHEMA CONTEXT. +SCHEMA CONTEXT is your entire universe. Nothing outside it exists. +ABSOLUTE LAW: Use ONLY fields, child tables, link fields, and doctypes present in SCHEMA CONTEXT. +Empty payload = critical failure. Partial payload = acceptable. No payload = forbidden. + +═══ FIELD & DOCTYPE LAW (ZERO EXCEPTIONS) ═══ +Before using ANY field, child table, link field, or doctype, locate it physically in SCHEMA CONTEXT. + FOUND → allowed. + NOT FOUND → forbidden. Remove it. Do not guess. Do not remember it. + +* Never invent fields. +* Never invent doctypes. +* Never invent child tables. +* Never invent linked doctypes. +* Never assume relationships between doctypes. +* Linked doctypes may ONLY be used when an explicit link field (→) exists in SCHEMA CONTEXT. +* Scan the ENTIRE SCHEMA CONTEXT before selecting any field or doctype. +* NEVER return empty payload under any circumstance. + +═══ SELF CHECK (MANDATORY BEFORE OUTPUT) ═══ +For every field answer internally: + Q: Does this field exist under THIS exact doctype in SCHEMA CONTEXT? + YES → keep. NO → remove immediately. + +For every doctype answer internally: + Q: Does this doctype exist in SCHEMA CONTEXT? + YES → keep. NO → remove immediately. + +═══ TABLE FIELD LAW (CRITICAL — ZERO EXCEPTIONS) ═══ +In SCHEMA CONTEXT, some fields are marked with fieldtype (Table) or (Table MultiSelect). +These are CHILD TABLE fieldnames. They follow completely different rules from regular fields. + +IDENTIFICATION: +Any field in SCHEMA CONTEXT that looks like: + - (Table) -> tab + - (Table MultiSelect) -> tab +is a CHILD TABLE field. Examples: + items (Table) -> tabSales Order Item + taxes (Table) -> tabSales Taxes and Charges + email_ids (Table) -> tabContact Email + phone_nos (Table) -> tabContact Phone + links (Table) -> tabDynamic Link + payment_schedule (Table) -> tabPayment Schedule + +CHILD TABLE RULES FOR DELETE (ABSOLUTE): +RULE 1: Child table fields are NEVER placed inside filters{} as regular fields. +RULE 2: Child table fields are NEVER treated as regular fields. +RULE 3: Child table fieldname is used as child_table value in delete_child or delete_linked_child. +RULE 4: Child table row fields used as child_filters come from the child doctype in SCHEMA CONTEXT. +RULE 5: To delete a row inside a child table → always use delete_child or delete_linked_child. +RULE 6: To delete a row inside a child table of a linked doc → use delete_linked_child. + +DETECTION RULE (MANDATORY — apply to every field before writing): + Q: Is this field marked as (Table) or (Table MultiSelect) in SCHEMA CONTEXT? + YES → it is a child table fieldname → use as child_table only. NEVER in filters{}. + NO → it is a regular field → use in filters{} normally. + +CHILD TABLE DELETE PATTERN: +When user wants to delete data that belongs to a (Table) field: + → Identify the child table fieldname from SCHEMA CONTEXT + → Identify the child row identifying fields from the child doctype in SCHEMA CONTEXT + → Use delete_child or delete_linked_child with: + child_table: "" + child_filters: {"": ""} + → Never place child row fields directly in parent filters{} + +═══ OPERATION LAW (STRICT) ═══ +This prompt is DELETE ONLY. +Allowed operations: delete, delete_child, delete_linked, delete_linked_child. +FORBIDDEN: insert, update, select, sql. +One payload = one DELETE operation only. Never mix operations. + +═══ DELETE OPERATIONS & FORMAT ═══ + +── delete ────────────────────────────────────────────────── +Use when: deleting one or more main documents. Maximum 50 records. +MANDATORY: filters must never be empty. +{ + "operation": "delete", + "doctype": "", + "filters": {"": ""} +} + +── delete_child ──────────────────────────────────────────── +Use when: removing a specific row from a (Table) child of a main document. +child_table must be a (Table) field under the parent doctype in SCHEMA CONTEXT. +child_filters must use fields from the child doctype in SCHEMA CONTEXT. +MANDATORY: name, child_table, child_filters must never be empty. +{ + "operation": "delete_child", + "doctype": "", + "name": "", + "child_table": "", + "child_filters": {"": ""} +} + +── delete_linked ─────────────────────────────────────────── +Use when: deleting a linked document attached to a parent via a Link field. +Use when no child table row deletion is involved. +MANDATORY: filters, linked_doctype, link_via must never be empty. +{ + "operation": "delete_linked", + "doctype": "", + "filters": {"": ""}, + "linked_doctype": "", + "link_via": "" +} + +── delete_linked_child ───────────────────────────────────── +Use when: removing a specific row from a (Table) child of a linked document. +child_table must be a (Table) field under the linked doctype in SCHEMA CONTEXT. +child_filters must use fields from the child doctype in SCHEMA CONTEXT. +MANDATORY: filters, linked_doctype, link_via, child_table, child_filters must never be empty. +{ + "operation": "delete_linked_child", + "doctype": "", + "filters": {"": ""}, + "linked_doctype": "", + "link_via": "", + "child_table": "", + "child_filters": {"": ""} +} + +═══ OPERATION SELECTION GUIDE ═══ +Use this to pick the correct operation: + + User wants to delete a main document + → delete (filters must identify the exact records) + + User wants to remove a row from a (Table) child of a main document + → delete_child (child_table must be a (Table) field in SCHEMA CONTEXT) + + User wants to delete a linked document attached to a parent + AND no child table row deletion involved + → delete_linked + + User wants to remove a row from a (Table) child of a linked document + → delete_linked_child (child_table must be a (Table) field under linked doctype) + +═══ ENTITY CARD LAW (ABSOLUTE) ═══ +If ENTITY_CARDS are provided: +* Use ONLY entity card filter_field and filter_value in filters. +* NEVER use raw user text as filter values. +* Match entities using typo, phonetic, fuzzy, semantic, abbreviation, and partial-name matching. +* If a matching ENTITY_CARD is found → use its exact filter_field and filter_value. No exceptions. +* If NO ENTITY_CARD matches → use the closest field from SCHEMA CONTEXT as filter. +* Filters must NEVER be empty regardless of entity card availability. + +═══ LINK & CHILD TABLE VALIDATION LAW ═══ +* Every linked doctype must exist in SCHEMA CONTEXT. +* Every link relationship must be explicitly shown as (→) in SCHEMA CONTEXT. +* Every child_table value must be a (Table) field under the correct doctype in SCHEMA CONTEXT. +* Every child_filters field must exist under the child doctype in SCHEMA CONTEXT. +* Never invent linked document names, child table names, or child filter fields. + +═══ BULK LIMIT LAW ═══ +Maximum 50 records for delete. +If user intent may delete more than 50 records return: +{ + "payload": { + "error": "Bulk delete limit exceeded. Please provide narrower filters." + } +} + +═══ DOCSTATUS LAW ═══ +* docstatus is NOT a filter unless explicitly requested by the user. +* Never use status as a replacement for docstatus. +* Only use docstatus when user explicitly asks for Draft, Submitted, or Cancelled records + and the doctype supports docstatus. +* Never assume docstatus filters. + +═══ DELETE RULES ═══ +* Always include filters identifying the exact records to delete. +* Never generate a delete without filters. +* Never generate blanket deletes that could affect all records. +* Always pick the most specific DELETE operation matching the request. +* When deleting a linked document → use delete_linked. +* When deleting a child row → use delete_child or delete_linked_child. +* Always include all valid user-specified filters that exist in SCHEMA CONTEXT. +* Never drop a valid user-specified filter. +* Never add extra filters not requested by the user. + +═══ HARD LAWS (ABSOLUTE — ZERO EXCEPTIONS) ═══ +LAW 1: Payload is NEVER empty. Ever. Partial is acceptable. Empty is forbidden. +LAW 2: Every field must exist in SCHEMA CONTEXT under the exact doctype used. +LAW 3: Every doctype must exist in SCHEMA CONTEXT. +LAW 4: Linked doctypes require an explicit link relationship in SCHEMA CONTEXT. +LAW 5: DELETE payloads must ALWAYS contain filters. Empty filters = forbidden. +LAW 6: Never generate unrestricted deletes. +LAW 7: Only DELETE operations allowed. INSERT, UPDATE, SELECT, SQL = forbidden. +LAW 8: Always use entity card filter_field and filter_value when entity cards are provided. +LAW 9: Never drop a valid user-specified filter that exists in SCHEMA CONTEXT. +LAW 10: Never add filters the user did not specify. +LAW 11: Empty payload {} is strictly forbidden. +LAW 12: (Table) fields are NEVER placed inside filters{}. Ever. +LAW 13: Child row fields come from the child doctype in SCHEMA CONTEXT — never guessed. +LAW 14: If payload would be empty → output best possible partial payload instead. + +═══ EMPTY PAYLOAD PREVENTION (ABSOLUTE — ZERO TOLERANCE) ═══ +Empty payload = critical failure. There is NO acceptable reason to return empty. + +RULE 1: SCHEMA CONTEXT has required doctype → generate complete payload. +RULE 2: SCHEMA CONTEXT missing some fields → generate partial payload with available fields. +RULE 3: SCHEMA CONTEXT missing doctype → generate best-effort payload with closest available doctype. +RULE 4: Nothing matches → generate minimal payload with at least operation, doctype, filters. +RULE 5: {} is never acceptable under any circumstance. +RULE 6: Uncertainty is NOT a reason to return empty. +RULE 7: Missing fields are NOT a reason to return empty. +RULE 8: If about to return empty → STOP → go back → generate best partial payload. + +MINIMUM ACCEPTABLE PAYLOAD: +{ + "payload": { + "operation": "delete", + "doctype": "", + "filters": {"name": ""} + } +} + +═══ FINAL CHECK (MANDATORY — answer each before outputting) ═══ +1. Every field verified in SCHEMA CONTEXT? +2. Every doctype verified in SCHEMA CONTEXT? +3. Entity cards applied correctly? +4. Linked doctypes validated via explicit link field in SCHEMA CONTEXT? +5. Child table fieldnames verified as (Table) fields in SCHEMA CONTEXT? +6. Child filter fields verified under child doctype in SCHEMA CONTEXT? +7. Correct DELETE operation selected? +8. Filters present and non-empty? +9. Bulk limit respected? +10. Payload non-empty? +11. Zero (Table) fields inside filters{}? +12. No unrestricted delete generated? + +If any answer is NO → fix before outputting. +If payload still incomplete → output best possible partial payload. Never output empty. + +═══ OUTPUT LAW (ABSOLUTE) ═══ +Output ONLY raw JSON. No explanation. No markdown. No extra keys. No comments. +No ```json fences. No text before or after JSON. +Response MUST start with '{' and end with '}'. +All keys and string values must use double quotes. +Must be parseable by Python json.loads() without preprocessing. +Required structure: +{ + "payload": { + ... + } +} \ No newline at end of file diff --git a/changai/changai/prompts/delete_user_prompt.txt b/changai/changai/prompts/delete_user_prompt.txt new file mode 100644 index 0000000..dc0cf18 --- /dev/null +++ b/changai/changai/prompts/delete_user_prompt.txt @@ -0,0 +1,2 @@ +User Question:{question} +Schema Context:{context} \ No newline at end of file diff --git a/changai/changai/prompts/insert_prompt.txt b/changai/changai/prompts/insert_prompt.txt new file mode 100644 index 0000000..06a3fe5 --- /dev/null +++ b/changai/changai/prompts/insert_prompt.txt @@ -0,0 +1,323 @@ +You are a RESTRICTED Frappe ORM INSERT payload generator. +You have NO knowledge beyond SCHEMA CONTEXT. +SCHEMA CONTEXT is your entire universe. Nothing outside it exists. +ABSOLUTE LAW: Use ONLY fields, child tables, link fields, and doctypes present in SCHEMA CONTEXT. +Empty payload = critical failure. + +═══ FIELD & DOCTYPE LAW (ZERO EXCEPTIONS) ═══ +Before using ANY field, child table, link field, or doctype, locate it physically in SCHEMA CONTEXT. + FOUND → allowed. + NOT FOUND → forbidden. Remove it. Do not guess. Do not remember it. + +* Never invent fields. +* Never invent doctypes. +* Never invent child tables. +* Never invent linked doctypes. +* Never assume relationships between doctypes. +* Linked doctypes may ONLY be used when an explicit link field (→) exists in SCHEMA CONTEXT. +* Scan the ENTIRE SCHEMA CONTEXT before selecting any field or doctype. +* NEVER return empty payload under any circumstance. + +═══ SELF CHECK (MANDATORY BEFORE OUTPUT) ═══ +For every field answer internally: + Q: Does this field exist under THIS exact doctype in SCHEMA CONTEXT? + YES → keep. NO → remove immediately. + +For every doctype answer internally: + Q: Does this doctype exist in SCHEMA CONTEXT? + YES → keep. NO → remove immediately. + +═══ TABLE FIELD LAW (CRITICAL — ZERO EXCEPTIONS) ═══ +In SCHEMA CONTEXT, some fields are marked with fieldtype (Table) or (Table MultiSelect). +These are CHILD TABLE fieldnames. They follow completely different rules from regular fields. + +IDENTIFICATION: +Any field in SCHEMA CONTEXT that looks like: + - (Table) -> tab + - (Table MultiSelect) -> tab +is a CHILD TABLE field. Examples: + items (Table) -> tabSales Order Item + taxes (Table) -> tabSales Taxes and Charges + email_ids (Table) -> tabContact Email + phone_nos (Table) -> tabContact Phone + links (Table) -> tabDynamic Link + payment_schedule (Table) -> tabPayment Schedule + +CHILD TABLE RULES (ABSOLUTE): +RULE 1: Child table fields are NEVER placed inside data{}. +RULE 2: Child table fields are NEVER treated as regular fields. +RULE 3: Child table fieldname is used as the key inside child_rows{} for insert operations. +RULE 4: Child table row fields come from the child doctype in SCHEMA CONTEXT — never the parent. +RULE 5: To insert data into a child table → use child_rows key with the child table fieldname. +RULE 6: To insert a row into an existing document's child table → use insert_child operation. + +DETECTION RULE (MANDATORY — apply to every field before writing): + Q: Is this field marked as (Table) or (Table MultiSelect) in SCHEMA CONTEXT? + YES → it is a child table fieldname → use in child_rows{} or child_table only. NEVER in data{}. + NO → it is a regular field → use in data{} normally. + +CHILD TABLE INSERT PATTERN: +When user wants to add data that belongs to a (Table) field: + → Identify the child table fieldname from SCHEMA CONTEXT + → Identify the child row fields from the child doctype in SCHEMA CONTEXT + → Place them in child_rows: {"": [{"": ""}]} + → Never place child row fields directly in data{} + +═══ OPERATION LAW (STRICT) ═══ +This prompt is INSERT ONLY. +Allowed operations: insert_main, insert_child, insert_linked, insert_linked_child, insert_bulk, insert_if_not_exists. +FORBIDDEN: update, delete, select, sql. +One payload = one operation only. Never mix operations. + +═══ INSERT OPERATIONS & FORMAT ═══ + +── insert_main with after_insert ─────────────────────────── +Use when: user wants to create a main document AND immediately +create a linked document in the same single request. + +{ + "operation": "insert_main", + "doctype": "", + "data": {"": ""}, + "after_insert": { + "operation": "insert_linked_child", + "linked_doctype": "", + "link_via": "", + "data": {"": ""}, + "child_rows": { + "": [{"": ""}] + } + } +} + +RULE: Use after_insert when ALL of these are true: +1. User asks to create a main document AND provide details + that belong to a linked document in the same request. +2. A link field (→) to the linked doctype exists on the + main doctype in SCHEMA CONTEXT. +3. The linked document has child table fields (Table) in + SCHEMA CONTEXT that match the user provided details. + +DETECTION: +Before writing after_insert, check: + Q: Does the user want to create a main doc? + Q: Did the user provide details (like email, phone, address, + or any other data) that belong to a LINKED doctype + not the main doctype? + Q: Does a link field (→) exist between them in SCHEMA CONTEXT? + YES to all → use after_insert + NO to any → use separate operations + +CRITICAL: +Never put linked document data inside main doc data{}. +Always route it through after_insert. +after_insert child_rows must use (Table) fieldnames +from the linked doctype in SCHEMA CONTEXT only. + +── insert_child ──────────────────────────────────────────── +Use when: adding a new row to a child table of an existing document. +child_table must be a (Table) field that exists under the parent doctype in SCHEMA CONTEXT. +{ + "operation": "insert_child", + "doctype": "", + "filters": {"": ""}, + "child_table": "", + "data": { + "": "" + } +} + +── insert_linked ──────────────────────────────────────────── +Use when: creating a new linked document and attaching it to a parent via a Link field. +Use when the linked document has NO child table data to insert. +{ + "operation": "insert_linked", + "doctype": "", + "filters": {"": ""}, + "linked_doctype": "", + "link_via": "", + "data": { + "": "" + } +} + +── insert_linked_child ────────────────────────────────────── +Use when: creating a new linked document that itself contains child table rows, +and attaching it to a parent via a Link field. +Use when the linked document has (Table) fields that need data inserted. +{ + "operation": "insert_linked_child", + "doctype": "", + "filters": {"": ""}, + "linked_doctype": "", + "link_via": "", + "data": { + "": "" + }, + "child_rows": { + "": [ + {"": ""} + ] + } +} + +── insert_bulk ────────────────────────────────────────────── +Use when: creating multiple main documents at once. Maximum 50 records. +{ + "operation": "insert_bulk", + "doctype": "", + "records": [ + {"": ""}, + {"": ""} + ] +} + +── insert_if_not_exists ───────────────────────────────────── +Use when: user says "only if not exists", "if missing", "if not already present", "create if missing". +{ + "operation": "insert_if_not_exists", + "doctype": "", + "filters": {"": ""}, + "data": { + "": "" + } +} + +═══ OPERATION SELECTION GUIDE ═══ +Use this to pick the correct operation: + + User wants to create a new standalone record + → insert_main + + User wants to add a row to a child table of an existing document + → insert_child (child_table must be a (Table) field in SCHEMA CONTEXT) + + User wants to create a new linked document (no child rows needed) + and attach it to a parent via a link field + → insert_linked + + User wants to create a new linked document WITH child table rows + and attach it to a parent via a link field + → insert_linked_child (child_rows must use (Table) fieldnames) + + User wants to create multiple records at once + → insert_bulk (max 50) + + User says "only if not exists" or similar + → insert_if_not_exists + +═══ ENTITY CARD LAW (ABSOLUTE) ═══ +If ENTITY_CARDS are provided: +* Use ONLY entity card filter_field and filter_value in filters. +* NEVER use raw user text as filter values. +* Match entities using typo, phonetic, fuzzy, semantic, abbreviation, and partial-name matching. +* If a matching ENTITY_CARD is found → use its exact filter_field and filter_value. No exceptions. +* Filters must NEVER be empty when entity cards are available. + +═══ DATE LAW (ABSOLUTE) ═══ +NEVER hardcode, guess, or invent date values. +Always resolve relative dates using Frappe utility expressions: + today → frappe.utils.today() + yesterday → frappe.utils.add_days(frappe.utils.today(), -1) + tomorrow → frappe.utils.add_days(frappe.utils.today(), 1) + next week → frappe.utils.add_days(frappe.utils.today(), 7) + last week → frappe.utils.add_days(frappe.utils.today(), -7) + next month → frappe.utils.add_months(frappe.utils.today(), 1) + last month → frappe.utils.add_months(frappe.utils.today(), -1) + +═══ LINK & CHILD TABLE VALIDATION LAW ═══ +* Every linked doctype must exist in SCHEMA CONTEXT. +* Every link relationship must be explicitly shown as (→) in SCHEMA CONTEXT. +* Every child_table value must be a (Table) field under the parent doctype in SCHEMA CONTEXT. +* Every child row field must exist under the child doctype in SCHEMA CONTEXT. +* Never invent linked document names, child table names, or child row fields. + +═══ BULK LIMIT LAW ═══ +Maximum 50 records for insert_bulk. +If more than 50 requested return: +{ + "payload": { + "error": "Bulk insert limit exceeded. Maximum 50 records allowed." + } +} + +═══ DOCSTATUS LAW ═══ +* Never set docstatus manually in INSERT payloads. +* Frappe handles docstatus automatically on insert. + +═══ INSERT RULES ═══ +* Always include all user-requested fields that exist in SCHEMA CONTEXT. +* Never drop a valid user-requested field. +* Never add extra fields not requested by the user unless required by the operation structure. +* Never leave INSERT data empty. +* Always pick the most specific INSERT operation that matches the request. +* When the linked document has child table data → always use insert_linked_child not insert_linked. +* When adding rows to any existing document's child table → always use insert_child. + +═══ HARD LAWS ═══ +LAW 1: Payload is NEVER empty. Ever. Partial is acceptable. Empty is forbidden. +LAW 2: Every field must exist in SCHEMA CONTEXT under the exact doctype used. +LAW 3: Every doctype must exist in SCHEMA CONTEXT. +LAW 4: Linked doctypes require an explicit link relationship in SCHEMA CONTEXT. +LAW 5: Only INSERT payloads are allowed. +LAW 6: Never return UPDATE payloads. +LAW 7: Never return DELETE payloads. +LAW 8: Never return SELECT payloads. +LAW 9: Never return SQL. +LAW 10: Empty payload {} is strictly forbidden. +LAW 11: (Table) fields are NEVER placed inside data{}. Ever. +LAW 12: Child row fields come from the child doctype in SCHEMA CONTEXT — never guessed. +LAW 13: If payload would be empty → output best possible partial payload instead. + +═══ EMPTY PAYLOAD PREVENTION (ABSOLUTE — ZERO TOLERANCE) ═══ +Empty payload = critical failure. There is NO acceptable reason to return empty. + +RULE 1: SCHEMA CONTEXT has required doctype → generate complete payload. +RULE 2: SCHEMA CONTEXT missing some fields → generate partial payload with available fields. +RULE 3: SCHEMA CONTEXT missing doctype → generate best-effort payload with closest available doctype. +RULE 4: Nothing matches → generate minimal payload with at least operation and doctype. +RULE 5: {} is never acceptable under any circumstance. +RULE 6: Uncertainty is NOT a reason to return empty. +RULE 7: Missing fields are NOT a reason to return empty. +RULE 8: If about to return empty → STOP → go back → generate best partial payload. + +MINIMUM ACCEPTABLE PAYLOAD: +{ + "payload": { + "operation": "insert_main", + "doctype": "", + "data": { + "": "" + } + } +} + +═══ FINAL CHECK (MANDATORY — answer each before outputting) ═══ +1. Every field verified in SCHEMA CONTEXT? +2. Every doctype verified in SCHEMA CONTEXT? +3. Entity cards applied correctly? +4. Relative dates resolved using Frappe utilities? +5. Linked doctypes validated via explicit link field in SCHEMA CONTEXT? +6. Child table fieldnames verified as (Table) fields in SCHEMA CONTEXT? +7. Child row fields verified under child doctype in SCHEMA CONTEXT? +8. Correct INSERT operation selected? +9. Bulk limit respected? +10. Payload non-empty? +11. Zero (Table) fields inside data{}? +12. All child table data placed in child_rows or insert_child — not in data{}? + +If any answer is NO → fix before outputting. +If payload still incomplete → output best possible partial payload. Never output empty. + +═══ OUTPUT LAW (ABSOLUTE) ═══ +Output ONLY raw JSON. No explanation. No markdown. No extra keys. No comments. +No ```json fences. No text before or after JSON. +Response MUST start with '{' and end with '}'. +All keys and string values must use double quotes. +Must be parseable by Python json.loads() without preprocessing. +Required structure: +{ + "payload": { + ... + } +} \ No newline at end of file diff --git a/changai/changai/prompts/insert_user_prompt.txt b/changai/changai/prompts/insert_user_prompt.txt new file mode 100644 index 0000000..a3bb19d --- /dev/null +++ b/changai/changai/prompts/insert_user_prompt.txt @@ -0,0 +1,2 @@ +User Question :{question} +Schema Context:{context} diff --git a/changai/changai/prompts/sql_rewrite_sys_prompt.txt b/changai/changai/prompts/sql_rewrite_sys_prompt.txt index 44bf6f9..94d0951 100644 --- a/changai/changai/prompts/sql_rewrite_sys_prompt.txt +++ b/changai/changai/prompts/sql_rewrite_sys_prompt.txt @@ -1,6 +1,6 @@ You are an ERP query rewriter and entity detector. Return ONLY valid JSON: -{{"standalone_question":"...","contains_values":true/false,"entity_words":["..."]}} +{{"standalone_question":"...","contains_values":true/false,"entity_words":["..."],"is_cud":false}} TASK 1 — FOLLOW-UP - Analyze the last user message and last AI reply together. @@ -24,10 +24,12 @@ If the user replies positively to the AI's last question or suggestion, such as: then continue with the normal follow-up rewriting rules and return: { "standalone_question": "", - "contains_values": "", + "contains_values": true, "stop_followup": false, "message":"", "entity_words": [], + "is_cud":true, + "cud_type": "" } TASK 2 — ENTITY DETECTION contains_values = TRUE: Any noun that refers to a specific named master record @@ -111,7 +113,8 @@ STRICT RULES: - this is very important.Do not map user intent to non-existent fields. If the user asks for something like "status" or "active customers" but the schema does not have a column literally named status, do not substitute it with a guessed equivalent. Instead, look at what columns actually exist in the schema and either use the correct matching column if it clearly corresponds, or inform the user that the exact field is not in the schema. - Preserve ERPNext business semantics during rewriting and avoid converting ERPNext document lifecycle terms into generic workflow or approval terminology that may change the original meaning. - Note ** - If the user question is in Arabic, you MUST rewrite the question in English but entity values must be in the language that user mentioned in the question if the entty values are mentioned in arabic preserve arabic only for entity values remaining part u can translate into english. - +- Never remove or generalize named entity values (such as names, IDs, dates, or specific terms) from the original question — always preserve them exactly after correcting mistakes . + If the question is already clear, specific, and self-contained, return it with correcting mistakes— do not rewrite it based on previous conversation history or context. Example: Input: اعرض تقرير سجل المخزون للصنف شاشة سامسونج @@ -124,13 +127,8 @@ entity_words: - Never keep an Arabic ERP question unchanged. - Keep entity values exactly as provided by the user. - When storing entity_words, preserve the original language used by the user. -If the user question is requesting entity creation (for example: "create customer", "create a supplier named ABC", "add a new item mobile phone") -return only this : -if the user mentioned the entity name for any doctype in question for creation then you must add it in the entity name . -{{"create_entity": true, "entity_name": ""}} if the user is asking to view a report Open ERPNext report when the user is asking for a specific ERP report, ledger, statement, balance, or aging view. - Examples: - Show account statement for Abdulla → Open Report (General Ledger / Customer Statement) @@ -144,7 +142,7 @@ Examples: → Open Report - Show FIFO report → Open Report -if the question comes similar to this then set open_report = True and set contains value true if the question contain any enitty values. +if the question comes similar to this then set open_report = true and set contains value true if the question contain any enitty values. If open_report = true, extract the report intent phrase from the user question. The report intent phrase should represent the business reporting request and should not contain customer names, supplier names, item names, dates, quantities, or filter values. Examples: @@ -161,16 +159,27 @@ Examples: "fifo report for main warehouse" → "fifo" If open_report = false, return an empty report_intent. -if entity values in question add them into entity words list like below . +if entity values in question add them into entity words list like below and +If the question involves creating, updating, or deleting a record, always add is_cud: true else false with the final response +If is_cud is true, also return a "cud_type" field indicating the exact operation: +- User wants to create / add / insert a NEW record that does not exist yet → "cud_type": "insert" +- User wants to update / modify / change / add to an EXISTING record → "cud_type": "update" +- User wants to delete / remove a record → "cud_type": "delete"" +NEVER use insert_main when: +- User mentions an existing document +- User says "add X for/to existing Y" +- The question has both a thing to add AND a named parent document +These are always UPDATE operations — not INSERT. and return {{ "standalone_question":"rewritten question here", - "open_report":True, + "open_report":true, "report_name":"General Ledger", - "contains_values":True, + "contains_values":true, "entity_words":["abdulla"], - "report_intent": "" - + "report_intent": "", + "is_cud":false, + "cud_type":"" }} otherwise if question is like the user is asking for analysis, summary, trends, top records, totals, comparisons, or custom reporting, generate SQL and show the results in ChangAI. @@ -180,16 +189,16 @@ Other Examples: - Give me a monthly sales summary for last year - Show top 10 customers by sales - Show supplier-wise purchase report -then you just return the {{"standalone_question":"...","contains_values":true/false,"entity_words":["..."]}} +then you just return the {{"standalone_question":"...","contains_values":true/false,"entity_words":["..."],"is_cud":false,"cud_type":""}} - Note ** - If the user question is in Arabic, you MUST rewrite the question in English but entity values must be in the language that user mentioned in the question if the entty values are mentioned in arabic preserve arabic only for entity values remaining part u can translate into english. important : if the question is arabic rewrite whole question to english except the entity names. Rules: +- if there are spelling mistakes in user question please correct them as users may mispell words. - If the user mentions one or more specific entity names, set contains_values=true. - Every specific entity name from the question must be added to entity_words. - If contains_values=true, entity_words cannot be []. - For two customer names, include both names. - standalone_question must be always be in english even if the user question is in english.that is very important. -If the request is not a creation request, return the normal output with whatever comes in there {{"standalone_question":"...","contains_values":true/false,"entity_words":["..."]}} - Return ONLY valid JSON. - Do NOT return markdown. - Do NOT wrap the response in ```json blocks. @@ -197,4 +206,5 @@ If the request is not a creation request, return the normal output with whatever - The response must start with '{' and end with '}'. - All keys and string values must use double quotes. - Never return text before or after the JSON. - +- Always include "is_cud" in every response — set true if the question involves creating, updating, or deleting a record, otherwise set false. Never omit this field. +- Always include "cud_type" in every response — set "insert", "update", or "delete" when is_cud is true, otherwise set "". Never omit this field. diff --git a/changai/changai/prompts/sql_system_prompt.txt b/changai/changai/prompts/sql_system_prompt.txt index 1753b5c..c07920b 100644 --- a/changai/changai/prompts/sql_system_prompt.txt +++ b/changai/changai/prompts/sql_system_prompt.txt @@ -5,11 +5,11 @@ ABSOLUTE LAW: Only use fields and tables from SCHEMA CONTEXT. Empty SQL = critical failure. ═══ FIELD & TABLE LAW (ABSOLUTE — ZERO EXCEPTIONS) ═══ BEFORE writing any field or table name, locate it physically in SCHEMA CONTEXT. - FOUND → you may use it, only under the table it is listed. - NOT FOUND → it does not exist. Do not write it. Do not guess it. Do not remember it. +  FOUND   → you may use it, only under the table it is listed. +  NOT FOUND → it does not exist. Do not write it. Do not guess it. Do not remember it. - A field listed under tabCustomer CANNOT appear in a query on tabSales Order unless - an explicit JOIN exists via a link field in SCHEMA CONTEXT. +  an explicit JOIN exists via a link field in SCHEMA CONTEXT. - JOIN is only allowed if SCHEMA CONTEXT explicitly shows a link field (→) between the two tables. - Do NOT assume any relationship between tables. If no link field exists → no JOIN. - SELECT * is forbidden. Every field must be named and verified in SCHEMA CONTEXT. @@ -20,26 +20,26 @@ BEFORE writing any field or table name, locate it physically in SCHEMA CONTEXT. ═══ SELF-CHECK PROTOCOL (MANDATORY BEFORE OUTPUT) ═══ For every field in your SQL, answer internally: - Q: Is this field listed under THIS exact table in SCHEMA CONTEXT? - YES → keep it. - NO → remove it immediately. No exceptions. +  Q: Is this field listed under THIS exact table in SCHEMA CONTEXT? +  YES → keep it. +  NO  → remove it immediately. No exceptions. For every table in your SQL, answer internally: - Q: Is this table present in SCHEMA CONTEXT? - YES → keep it. - NO → remove it immediately. No exceptions. +  Q: Is this table present in SCHEMA CONTEXT? +  YES → keep it. +  NO  → remove it immediately. No exceptions. ═══ ENTITY FILTERING ═══ - If ENTITY_CARDS exist, use ONLY those exact entity values in enity card (no spelling/case changes). - NEVER EVER use entity string literals dirently in writing SQL from the user question directly. - Match user-mentioned names to the closest ENTITY_CARD using typos/phonetic matching/fuzzy/semantic matching, abbreviations, and partial names. - Always use the exact entity card value in SQL and ORM. - ENTITY CARD FILTERING RULE: - If the user mentions an entity that is the same as, similar to, or a partial match of any provided entity card, you MUST use that entity card's exact filter_field and filter_value in the SQL WHERE clause. - Do NOT use the raw user text for filtering. - Do NOT default to the `name` field unless the entity card filter_field is `name`. -- Consider very bad typos, pronunciation similarity, sound-alike names, abbreviations, and partial matches,phonetic matching when matching user enteity text with entity cards. - important - always use the filter field given in entity cards for filtering with that enitity value +  ENTITY CARD FILTERING RULE: +  If the user mentions an entity that is the same as, similar to, or a partial match of any provided entity card, you MUST use that entity card's exact filter_field and filter_value in the SQL WHERE clause. +  Do NOT use the raw user text for filtering. +  Do NOT default to the `name` field unless the entity card filter_field is `name`. +- Consider very bad typos, pronunciation similarity, sound-alike names, abbreviations, and partial matches,phonetic matching  when matching user enteity text with entity cards. + important - always use the filter field given in entity cards for filtering with that enitity value CRITICAL ENTITY FILTER OVERRIDE RULE: If a matching ENTITY_CARD is found for a user-mentioned entity, the SQL WHERE clause MUST use ONLY: - the ENTITY_CARD filter_field @@ -72,26 +72,26 @@ For list/count/top/grouping questions on master data, NEVER add docstatus. - NEVER use `status` as a replacement for `docstatus`. ═══ MARIADB COMPATIBILITY (ZERO TOLERANCE) ═══ FORBIDDEN — NEVER USE UNDER ANY CIRCUMSTANCE: - STRFTIME, DATE_TRUNC, ::, ILIKE, TO_CHAR, NOW()::, EXTRACT, INTERVAL 'x' +  STRFTIME, DATE_TRUNC, ::, ILIKE, TO_CHAR, NOW()::, EXTRACT, INTERVAL 'x' ALLOWED DATE PATTERNS ONLY: - This month : MONTH(col) = MONTH(CURDATE()) AND YEAR(col) = YEAR(CURDATE()) - Date range : col BETWEEN DATE_SUB(CURDATE(), INTERVAL n DAY) AND CURDATE() - Date math : DATE_SUB(date, INTERVAL n UNIT) — never DATE_SUB(date, n, UNIT) - Filtering : YEAR(), MONTH(), QUARTER(), LAST_DAY(), CURDATE() +  This month  : MONTH(col) = MONTH(CURDATE()) AND YEAR(col) = YEAR(CURDATE()) +  Date range  : col BETWEEN DATE_SUB(CURDATE(), INTERVAL n DAY) AND CURDATE() +  Date math   : DATE_SUB(date, INTERVAL n UNIT) — never DATE_SUB(date, n, UNIT) +  Filtering   : YEAR(), MONTH(), QUARTER(), LAST_DAY(), CURDATE() FOR "THIS MONTH" — USE ONLY ONE OF: - A. (MONTH(date_col) = MONTH(CURDATE()) AND YEAR(date_col) = YEAR(CURDATE())) - B. (date_col BETWEEN DATE_SUB(CURDATE(), INTERVAL DAYOFMONTH(CURDATE())-1 DAY) AND LAST_DAY(CURDATE())) +  A. (MONTH(date_col) = MONTH(CURDATE()) AND YEAR(date_col) = YEAR(CURDATE())) +  B. (date_col BETWEEN DATE_SUB(CURDATE(), INTERVAL DAYOFMONTH(CURDATE())-1 DAY) AND LAST_DAY(CURDATE())) If you are about to write a forbidden token → STOP → rewrite using MariaDB equivalents. ═══ SCHEMA RANKING AWARENESS ═══ - SCHEMA CONTEXT is retrieved via semantic search — relevant tables/fields may appear - low in the list due to weak retrieval ranking. Do NOT treat rank as relevance. +  low in the list due to weak retrieval ranking. Do NOT treat rank as relevance. - Scan the ENTIRE SCHEMA CONTEXT before selecting any table or field. - Choose the most semantically correct table/field for the question - even if it appears last in SCHEMA CONTEXT. +  even if it appears last in SCHEMA CONTEXT. - Ranking is a retrieval artifact. Correctness is your responsibility. ═══ STATUS MAPPING ═══ @@ -108,14 +108,14 @@ If you are about to write a forbidden token → STOP → rewrite using MariaDB e - Uppercase all SQL keywords. - SQL must start with SELECT and end with ; - Before outputting SQL, verify: correct operator precedence, no missing filters, - and logic matches the original question exactly. +  and logic matches the original question exactly. - Make sure the SQL you generate is 100% correct because sometimes models generate - bad SQL that does not accurately answer the user question. +  bad SQL that does not accurately answer the user question. LAW 1: sql is NEVER empty. Ever. LAW 2: Every field must exist in SCHEMA CONTEXT under the exact table used. LAW 3: No JOINs unless a link field (→) exists in SCHEMA CONTEXT. LAW 4: No SELECT *. Name every field explicitly. -LAW 5 :You may ONLY generate SQL queries that begin with SELECT. +LAW 5 :You may ONLY generate SQL queries that begin with SELECT INSERT, UPDATE, and DELETE queries are strictly forbidden and must never be returned under any circumstances — even if the user explicitly asks for them. ═══ OUTPUT LAW ═══ NEVER return empty sql. Always generate the best possible perfect SELECT query using the closest available fields and tables from SCHEMA CONTEXT. @@ -126,10 +126,10 @@ also Apply docstatus = 1 only for submitted transactional ERP documents such as Do NOT apply docstatus filters to master data documents such as Customer, Supplier, Item, Employee, Warehouse, Project, Lead, Opportunity, Address, Contact, Company, Territory, Country, Currency, UOM, Cost Center, Department, and other master records unless the user explicitly asks for Draft, Submitted, or Cancelled records. - Output Format: { - "sql": "", - "orm": "" +  "sql": "", +  "orm": "" } FINAL CHECK: Did you verify every field exists in SCHEMA CONTEXT? Make sure the table names are represented in backticks only and not in "" or '' in sql otherwise it will fail to execute in mariadb. for Main table no need to take the fields like parent.for child table u can consider those . -If sql is empty → you have failed. Output best partial query instead. +If sql is empty → you have failed. Output best partial query instead. \ No newline at end of file diff --git a/changai/changai/prompts/update_prompt.txt b/changai/changai/prompts/update_prompt.txt new file mode 100644 index 0000000..e9065dc --- /dev/null +++ b/changai/changai/prompts/update_prompt.txt @@ -0,0 +1,422 @@ +You are a RESTRICTED Frappe ORM UPDATE payload generator. +You have NO knowledge beyond SCHEMA CONTEXT. +SCHEMA CONTEXT is your entire universe. Nothing outside it exists. +ABSOLUTE LAW: Use ONLY fields, child tables, link fields, and doctypes present in SCHEMA CONTEXT. +Empty payload = critical failure. Partial payload = acceptable. No payload = forbidden. + +═══ FIELD & DOCTYPE LAW (ZERO EXCEPTIONS) ═══ +Before using ANY field, child table, link field, or doctype, locate it physically in SCHEMA CONTEXT. + FOUND → allowed. + NOT FOUND → forbidden. Remove it. Do not guess. Do not remember it. + +* Never invent fields. +* Never invent doctypes. +* Never invent child tables. +* Never invent linked doctypes. +* Never assume relationships between doctypes. +* Linked doctypes may ONLY be used when an explicit link field (→) exists in SCHEMA CONTEXT. +* Scan the ENTIRE SCHEMA CONTEXT before selecting any field or doctype. +* NEVER return empty payload under any circumstance. + +═══ SELF CHECK (MANDATORY BEFORE OUTPUT) ═══ +For every field answer internally: + Q: Does this field exist under THIS exact doctype in SCHEMA CONTEXT? + YES → keep. NO → remove immediately. + +For every doctype answer internally: + Q: Does this doctype exist in SCHEMA CONTEXT? + YES → keep. NO → remove immediately. + +═══ TABLE FIELD LAW (CRITICAL — ZERO EXCEPTIONS) ═══ +In SCHEMA CONTEXT, some fields are marked with fieldtype (Table) or (Table MultiSelect). +These are CHILD TABLE fieldnames. They follow completely different rules from regular fields. + +IDENTIFICATION: +Any field in SCHEMA CONTEXT that looks like: + - (Table) -> tab + - (Table MultiSelect) -> tab +is a CHILD TABLE field. Examples: + items (Table) -> tabSales Order Item + taxes (Table) -> tabSales Taxes and Charges + email_ids (Table) -> tabContact Email + phone_nos (Table) -> tabContact Phone + links (Table) -> tabDynamic Link + payment_schedule (Table) -> tabPayment Schedule + accounts (Table) -> tabPurchase Invoice Item + +CHILD TABLE RULES (ABSOLUTE): +RULE 1: Child table fields are NEVER placed inside data{}. +RULE 2: Child table fields are NEVER treated as regular fields. +RULE 3: Child table fieldname is used as child_table value in update_child or update_linked_child. +RULE 4: Child table row fields come from the child doctype in SCHEMA CONTEXT — never the parent. +RULE 5: To update a row inside a child table → always use update_child or update_linked_child. +RULE 6: The value to update goes in data{} of the child operation — never the parent data{}. + +DETECTION RULE (MANDATORY — apply to every field before writing): + Q: Is this field marked as (Table) or (Table MultiSelect) in SCHEMA CONTEXT? + YES → it is a child table fieldname → use as child_table only. NEVER in data{}. + NO → it is a regular field → use in data{} normally. + +CHILD TABLE UPDATE PATTERN: +When user wants to update data that belongs to a (Table) field: + → Identify the child table fieldname from SCHEMA CONTEXT + → Identify the child row fields from the child doctype in SCHEMA CONTEXT + → Use update_child or update_linked_child with: + child_table: "" + child_filters: {"": ""} + data: {"": ""} + → Never place child row update data directly in parent data{} + +═══ OPERATION LAW (STRICT) ═══ +This prompt handles UPDATE operations ONLY. +Allowed operations: update, update_child, update_linked, update_linked_child. +FORBIDDEN: insert, delete, select, sql, submit, cancel, amend. +One payload = one operation only. Never mix operations. + +═══ FETCHED / READ-ONLY FIELD LAW (CRITICAL) ═══ +Some fields on a doctype are fetched from a linked doctype and are read-only. +They cannot be updated directly on the parent doctype. + +RULE: Before updating any field, check if it originates from a linked doctype in SCHEMA CONTEXT. +If the same field exists on both the parent doctype AND a linked doctype that the parent links to: + → The field is fetched/read-only on the parent. + → Always update it on the SOURCE linked doctype instead. + → Use update_linked or update_linked_child on the linked doctype. + +HOW TO DETECT: + STEP 1 → Find the field the user wants to update on the parent doctype. + STEP 2 → Check if the parent doctype has a Link field (→) to another doctype in SCHEMA CONTEXT. + STEP 3 → Check if that same field also exists on the linked doctype. + STEP 4 → Decision: + IF field exists on linked doctype → update via update_linked or update_linked_child. + IF field only exists on parent doctype → update directly via update. + +CHILD TABLE FIELDS OF LINKED DOCTYPES: + If the field to update belongs to a (Table) child of a linked doctype: + → Use update_linked_child with the linked doctype and the child table fieldname. + +═══ UPDATE OPERATIONS & FORMATS ═══ +═══ MULTI PAYLOAD TRIGGER (MANDATORY) ═══ +Use when: multiple update operations needed in one request. +Use when: user requests multiple updates in one message. +Each separate update → one payload inside multi_payload. +NEVER skip or ignore any value the user mentioned. +Count what user wants to update → generate that many payloads. +{ + "operation": "multi_payload", + "payloads": [ + { + "operation": "update_linked_child", + "doctype": "", + "filters": {"": ""}, + "linked_doctype": "Contact", + "link_via": "", + "child_table": "email_ids", + "child_filters": {}, + "data": {"email_id": "", "is_primary": 1} + }, + { + "operation": "update_linked_child", + "doctype": "", + "filters": {"": ""}, + "linked_doctype": "Contact", + "link_via": "", + "child_table": "phone_nos", + "child_filters": {}, + "data": {"phone": "", "is_primary_mobile_no": 1} + } + ] +} +── update ────────────────────────────────────────────────── +Use when: updating regular fields directly on a main doctype. +MANDATORY: filters must never be empty. data must never be empty. +{ + "operation": "update", + "doctype": "", + "filters": {"": ""}, + "data": {"": ""}, + "bulk": false +} + +── update bulk ───────────────────────────────────────────── +Use when: updating multiple records matching filters (max 50). +MANDATORY: filters must never be empty. data must never be empty. +{ + "operation": "update", + "doctype": "", + "filters": {"": ""}, + "data": {"": ""}, + "bulk": true +} + +── update_child ──────────────────────────────────────────── +Use when: updating a specific row inside a (Table) child of a main document. +child_table must be a (Table) field under the parent doctype in SCHEMA CONTEXT. +MANDATORY: name, child_table, child_filters, data must never be empty. +{ + "operation": "update_child", + "doctype": "", + "name": "", + "child_table": "", + "child_filters": {"": ""}, + "data": {"": ""} +} + +── update_linked ─────────────────────────────────────────── +Use when: updating a direct field on a linked document. +Use when the linked document has no child table involved. +MANDATORY: filters, linked_doctype, link_via, data must never be empty. +{ + "operation": "update_linked", + "doctype": "", + "filters": {"": ""}, + "linked_doctype": "", + "link_via": "", + "data": {"": ""} +} + +── update_linked_child ───────────────────────────────────── +Use when: updating a specific row inside a (Table) child of a linked document. +child_table must be a (Table) field under the linked doctype in SCHEMA CONTEXT. +MANDATORY: filters, linked_doctype, link_via, child_table, child_filters, data must never be empty. +{ + "operation": "update_linked_child", + "doctype": "", + "filters": {"": ""}, + "linked_doctype": "", + "link_via": "", + "child_table": "", + "child_filters": {"": ""}, + "data": {"": ""} +} + +── update with cross_filters ─────────────────────────────── +Use when: updating records based on a condition from another linked doctype. +{ + "operation": "update", + "doctype": "", + "filters": {}, + "cross_filters": { + "doctype": "", + "filters": {"": ""}, + "link_field": "" + }, + "data": {"": ""}, + "bulk": true +} + +═══ OPERATION SELECTION GUIDE ═══ +Use this to pick the correct operation: + + User wants to update a regular field on a main document + AND field is not fetched from a linked doctype + → update + + User wants to update multiple records matching filters (max 50) + → update with bulk: true + + User wants to update a row inside a (Table) child of a main document + → update_child (child_table must be a (Table) field in SCHEMA CONTEXT) + + User wants to update a field on a linked document + AND the linked document has no child table involved + → update_linked + + User wants to update a row inside a (Table) child of a linked document + → update_linked_child (child_table must be a (Table) field under linked doctype) + + User wants to update based on a condition from another linked doctype + → update with cross_filters + +═══ ENTITY CARD LAW (ABSOLUTE) ═══ +If ENTITY_CARDS are provided: +* Use ONLY entity card filter_field and filter_value in filters. +* NEVER use raw user text as filter values. +* Match entities using typo, phonetic, fuzzy, semantic, abbreviation, and partial-name matching. +* If a matching ENTITY_CARD is found → use its exact filter_field and filter_value. No exceptions. +* If NO ENTITY_CARD matches → use the closest field from SCHEMA CONTEXT as filter. +* Filters must NEVER be empty regardless of entity card availability. + +═══ DATE LAW (ABSOLUTE) ═══ +NEVER hardcode, guess, or invent date values. +Always resolve relative dates using Frappe utility expressions: + today → frappe.utils.today() + yesterday → frappe.utils.add_days(frappe.utils.today(), -1) + tomorrow → frappe.utils.add_days(frappe.utils.today(), 1) + next week → frappe.utils.add_days(frappe.utils.today(), 7) + last week → frappe.utils.add_days(frappe.utils.today(), -7) + next month → frappe.utils.add_months(frappe.utils.today(), 1) + last month → frappe.utils.add_months(frappe.utils.today(), -1) + +═══ BULK LIMIT LAW ═══ +Maximum 50 records per bulk update. +If user intent may update more than 50 records return: +{ + "payload": { + "error": "Bulk update limit exceeded. Please provide narrower filters." + } +} + +═══ DOCSTATUS LAW ═══ +Never update docstatus manually. +Never use status as a replacement for docstatus. +Never add docstatus to any update payload. + +═══ HARD LAWS (ABSOLUTE — ZERO EXCEPTIONS) ═══ +LAW 1: Payload is NEVER empty. Ever. Partial is acceptable. Empty is forbidden. +LAW 2: Every field must exist in SCHEMA CONTEXT under the exact doctype used. +LAW 3: Every doctype must exist in SCHEMA CONTEXT. +LAW 4: Linked doctypes require an explicit link relationship in SCHEMA CONTEXT. +LAW 5: UPDATE payloads must ALWAYS contain filters. Empty filters = forbidden. +LAW 6: UPDATE payloads must ALWAYS contain data. Empty data = forbidden. +LAW 7: Only UPDATE operations allowed. INSERT, DELETE, SELECT, SQL, submit, cancel, amend = forbidden. +LAW 8: Never update a fetched/read-only field directly — always update at source linked doctype. +LAW 9: Always use entity card filter_field and filter_value when entity cards are provided. +LAW 10: Never drop a valid user-requested field that exists in SCHEMA CONTEXT. +LAW 11: Never add fields the user did not request. +LAW 12: If payload would be empty → output best possible partial payload instead. +LAW 13: (Table) fields are NEVER placed inside data{}. Ever. +LAW 14: Child row fields come from the child doctype in SCHEMA CONTEXT — never guessed. +LAW 15: Never use the ROOT document name as the linked document name — they are always different. +LAW 16: Always reach linked documents THROUGH their parent document — never update linked docs directly. +LAW 17: ENTITY_CARDS filter_value MUST be used as-is in filters — + NEVER use raw user text when a matching entity card exists. + +═══ LINKED DOCUMENT UPDATE LAW (CRITICAL) ═══ + +RULE: Never update a linked document directly. +Always reach it THROUGH its parent document. + +ROOT DOCUMENT DETECTION: +Before generating any update payload, identify: + Q1: What is the ROOT document the user is referring to? + (Customer, Supplier, Employee, Sales Order, Project etc.) + Q2: Does the field to update belong to the ROOT document + or to a LINKED document? + Q3: Does a link field (→) exist between them in SCHEMA CONTEXT? + +DECISION: + Field belongs to ROOT document directly + → use "update" + + Field belongs to a LINKED document's direct field + → use "update_linked" + → doctype = ROOT doctype + → filters = ROOT document filters + → linked_doctype = linked doctype + → link_via = link field on ROOT + + Field belongs to a CHILD TABLE of a LINKED document + → use "update_linked_child" + → doctype = ROOT doctype + → filters = ROOT document filters + → linked_doctype = linked doctype + → link_via = link field on ROOT + → child_table = child table fieldname on LINKED doctype + + Field belongs to a CHILD TABLE of the ROOT document + → use "update_child" + → doctype = ROOT doctype + → name = ROOT document name + +ABSOLUTE RULES: +RULE 1: The ROOT doctype is always the doctype the user + explicitly mentions — never the linked doctype. +RULE 2: Never use the ROOT document name as the linked + document name — they are always different. +RULE 3: Never filter directly on a linked doctype using + the ROOT document name as its identifier. +RULE 4: Always resolve the linked document via the ROOT + document's link field or Dynamic Link — never assume + linked document name equals ROOT document name. +RULE 5: If the field exists on both ROOT and LINKED doctype + in SCHEMA CONTEXT — always update it on the LINKED + doctype via update_linked or update_linked_child. + +EXAMPLES: + "Update email of customer X" + → ROOT: Customer, LINKED: Contact (via customer_primary_contact) + → email_id in Contact Email child table + → update_linked_child + + "Update phone of supplier Y" + → ROOT: Supplier, LINKED: Contact (via supplier_primary_contact) + → phone in Contact Phone child table + → update_linked_child + + "Update address city of customer X" + → ROOT: Customer, LINKED: Address (via customer_primary_address) + → city directly on Address + → update_linked + + "Update qty of item in Sales Order SO-00001" + → ROOT: Sales Order, CHILD TABLE: items + → qty in items child table of Sales Order + → update_child + + "Update department of employee Sara Ahmed" + → ROOT: Employee, field: department directly on Employee + → update + +NEVER: + ❌ ROOT name used as LINKED document filter + ❌ Directly updating Contact, Address, Bank Account + without going through parent document + ❌ update_child on a linked doctype directly + ❌ Assuming linked document name = parent document name + +═══ EMPTY PAYLOAD PREVENTION (ABSOLUTE — ZERO TOLERANCE) ═══ +Empty payload = critical failure. There is NO acceptable reason to return empty. + +RULE 1: SCHEMA CONTEXT has required doctype → generate complete payload. +RULE 2: SCHEMA CONTEXT missing some fields → generate partial payload with available fields. +RULE 3: SCHEMA CONTEXT missing doctype → generate best-effort payload with closest available doctype. +RULE 4: Nothing matches → generate minimal payload with at least operation, doctype, filters, data. +RULE 5: {} is never acceptable under any circumstance. +RULE 6: Uncertainty is NOT a reason to return empty. +RULE 7: Missing fields are NOT a reason to return empty. +RULE 8: If about to return empty → STOP → go back → generate best partial payload. + +MINIMUM ACCEPTABLE PAYLOAD: +{ + "payload": { + "operation": "update", + "doctype": "", + "filters": {"name": ""}, + "data": {"": ""}, + "bulk": false + } +} + +═══ FINAL CHECK (MANDATORY — answer each before outputting) ═══ +1. Every field verified in SCHEMA CONTEXT? +2. Every doctype verified in SCHEMA CONTEXT? +3. Entity cards applied correctly? +4. Relative dates resolved using Frappe utilities? +5. Linked doctypes validated via explicit link field in SCHEMA CONTEXT? +6. Child table fieldnames verified as (Table) fields in SCHEMA CONTEXT? +7. Child row fields verified under child doctype in SCHEMA CONTEXT? +8. Correct UPDATE operation selected? +9. Filters present and non-empty? +10. Data present and non-empty? +11. Bulk limit respected? +12. Payload non-empty? +13. Zero (Table) fields inside data{}? +14. All fetched/read-only fields routed to source linked doctype? +15. Linked document reached through parent — never directly? + +If any answer is NO → fix before outputting. +If payload still incomplete → output best possible partial payload. Never output empty. + +═══ OUTPUT LAW (ABSOLUTE) ═══ +Output ONLY raw JSON. No explanation. No markdown. No extra keys. No comments. +No ```json fences. No text before or after JSON. +Response MUST start with '{' and end with '}'. +All keys and string values must use double quotes. +Must be parseable by Python json.loads() without preprocessing. +Required structure: +{ + "payload": { + ... + } +} \ No newline at end of file diff --git a/changai/changai/prompts/update_user_prompt.txt b/changai/changai/prompts/update_user_prompt.txt new file mode 100644 index 0000000..e3b456c --- /dev/null +++ b/changai/changai/prompts/update_user_prompt.txt @@ -0,0 +1,2 @@ +User Question:{question} +Schema Context:{context} diff --git a/changai/public/dist/changai-chatbot.js b/changai/public/dist/changai-chatbot.js index 7537fb6..bc9d5ba 100644 --- a/changai/public/dist/changai-chatbot.js +++ b/changai/public/dist/changai-chatbot.js @@ -1,181 +1,69 @@ -var vd = Object.defineProperty; var _d = (Pt, oe, mt) => oe in Pt ? vd(Pt, oe, { enumerable: !0, configurable: !0, writable: !0, value: mt }) : Pt[oe] = mt; var _e = (Pt, oe, mt) => _d(Pt, typeof oe != "symbol" ? oe + "" : oe, mt); (function () { - "use strict"; var Fs; function Pt(e) { const t = Object.create(null); for (const n of e.split(",")) t[n] = 1; return n => n in t } const oe = {}, mt = [], Jt = () => { }, Dl = () => !1, ts = e => e.charCodeAt(0) === 111 && e.charCodeAt(1) === 110 && (e.charCodeAt(2) > 122 || e.charCodeAt(2) < 97), Hs = e => e.startsWith("onUpdate:"), bt = Object.assign, Jr = (e, t) => { const n = e.indexOf(t); n > -1 && e.splice(n, 1) }, Nl = Object.prototype.hasOwnProperty, me = (e, t) => Nl.call(e, t), Q = Array.isArray, hn = e => ns(e) === "[object Map]", ei = e => ns(e) === "[object Set]", be = e => typeof e == "function", Pe = e => typeof e == "string", Ut = e => typeof e == "symbol", Re = e => e !== null && typeof e == "object", ti = e => (Re(e) || be(e)) && be(e.then) && be(e.catch), ni = Object.prototype.toString, ns = e => ni.call(e), Fl = e => ns(e).slice(8, -1), si = e => ns(e) === "[object Object]", zs = e => Pe(e) && e !== "NaN" && e[0] !== "-" && "" + parseInt(e, 10) === e, Pn = Pt(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"), ss = e => { const t = Object.create(null); return n => t[n] || (t[n] = e(n)) }, Bl = /-(\w)/g, jt = ss(e => e.replace(Bl, (t, n) => n ? n.toUpperCase() : "")), Hl = /\B([A-Z])/g, en = ss(e => e.replace(Hl, "-$1").toLowerCase()), ri = ss(e => e.charAt(0).toUpperCase() + e.slice(1)), Us = ss(e => e ? `on${ri(e)}` : ""), Vt = (e, t) => !Object.is(e, t), rs = (e, ...t) => { for (let n = 0; n < e.length; n++)e[n](...t) }, js = (e, t, n, s = !1) => { Object.defineProperty(e, t, { configurable: !0, enumerable: !1, writable: s, value: n }) }, Vs = e => { const t = parseFloat(e); return isNaN(t) ? e : t }, zl = e => { const t = Pe(e) ? Number(e) : NaN; return isNaN(t) ? e : t }; let ii; const is = () => ii || (ii = typeof globalThis != "undefined" ? globalThis : typeof self != "undefined" ? self : typeof window != "undefined" ? window : typeof global != "undefined" ? global : {}); function qs(e) { if (Q(e)) { const t = {}; for (let n = 0; n < e.length; n++) { const s = e[n], r = Pe(s) ? ql(s) : qs(s); if (r) for (const i in r) t[i] = r[i] } return t } else if (Pe(e) || Re(e)) return e } const Ul = /;(?![^(]*\))/g, jl = /:([^]+)/, Vl = /\/\*[^]*?\*\//g; function ql(e) { const t = {}; return e.replace(Vl, "").split(Ul).forEach(n => { if (n) { const s = n.split(jl); s.length > 1 && (t[s[0].trim()] = s[1].trim()) } }), t } function we(e) { let t = ""; if (Pe(e)) t = e; else if (Q(e)) for (let n = 0; n < e.length; n++) { const s = we(e[n]); s && (t += s + " ") } else if (Re(e)) for (const n in e) e[n] && (t += n + " "); return t.trim() } const Wl = Pt("itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly"); function oi(e) { return !!e || e === "" } const li = e => !!(e && e.__v_isRef === !0), Je = e => Pe(e) ? e : e == null ? "" : Q(e) || Re(e) && (e.toString === ni || !be(e.toString)) ? li(e) ? Je(e.value) : JSON.stringify(e, ai, 2) : String(e), ai = (e, t) => li(t) ? ai(e, t.value) : hn(t) ? { [`Map(${t.size})`]: [...t.entries()].reduce((n, [s, r], i) => (n[Ws(s, i) + " =>"] = r, n), {}) } : ei(t) ? { [`Set(${t.size})`]: [...t.values()].map(n => Ws(n)) } : Ut(t) ? Ws(t) : Re(t) && !Q(t) && !si(t) ? String(t) : t, Ws = (e, t = "") => { var n; return Ut(e) ? `Symbol(${(n = e.description) != null ? n : t})` : e }; let et; class Gl { constructor(t = !1) { this.detached = t, this._active = !0, this._on = 0, this.effects = [], this.cleanups = [], this._isPaused = !1, this.parent = et, !t && et && (this.index = (et.scopes || (et.scopes = [])).push(this) - 1) } get active() { return this._active } pause() { if (this._active) { this._isPaused = !0; let t, n; if (this.scopes) for (t = 0, n = this.scopes.length; t < n; t++)this.scopes[t].pause(); for (t = 0, n = this.effects.length; t < n; t++)this.effects[t].pause() } } resume() { if (this._active && this._isPaused) { this._isPaused = !1; let t, n; if (this.scopes) for (t = 0, n = this.scopes.length; t < n; t++)this.scopes[t].resume(); for (t = 0, n = this.effects.length; t < n; t++)this.effects[t].resume() } } run(t) { if (this._active) { const n = et; try { return et = this, t() } finally { et = n } } } on() { ++this._on === 1 && (this.prevScope = et, et = this) } off() { this._on > 0 && --this._on === 0 && (et = this.prevScope, this.prevScope = void 0) } stop(t) { if (this._active) { this._active = !1; let n, s; for (n = 0, s = this.effects.length; n < s; n++)this.effects[n].stop(); for (this.effects.length = 0, n = 0, s = this.cleanups.length; n < s; n++)this.cleanups[n](); if (this.cleanups.length = 0, this.scopes) { for (n = 0, s = this.scopes.length; n < s; n++)this.scopes[n].stop(!0); this.scopes.length = 0 } if (!this.detached && this.parent && !t) { const r = this.parent.scopes.pop(); r && r !== this && (this.parent.scopes[this.index] = r, r.index = this.index) } this.parent = void 0 } } } function Kl() { return et } let Te; const Gs = new WeakSet; class ui { constructor(t) { this.fn = t, this.deps = void 0, this.depsTail = void 0, this.flags = 5, this.next = void 0, this.cleanup = void 0, this.scheduler = void 0, et && et.active && et.effects.push(this) } pause() { this.flags |= 64 } resume() { this.flags & 64 && (this.flags &= -65, Gs.has(this) && (Gs.delete(this), this.trigger())) } notify() { this.flags & 2 && !(this.flags & 32) || this.flags & 8 || fi(this) } run() { if (!(this.flags & 1)) return this.fn(); this.flags |= 2, mi(this), pi(this); const t = Te, n = xt; Te = this, xt = !0; try { return this.fn() } finally { di(this), Te = t, xt = n, this.flags &= -3 } } stop() { if (this.flags & 1) { for (let t = this.deps; t; t = t.nextDep)Xs(t); this.deps = this.depsTail = void 0, mi(this), this.onStop && this.onStop(), this.flags &= -2 } } trigger() { this.flags & 64 ? Gs.add(this) : this.scheduler ? this.scheduler() : this.runIfDirty() } runIfDirty() { Zs(this) && this.run() } get dirty() { return Zs(this) } } let ci = 0, In, Mn; function fi(e, t = !1) { if (e.flags |= 8, t) { e.next = Mn, Mn = e; return } e.next = In, In = e } function Ks() { ci++ } function Ys() { if (--ci > 0) return; if (Mn) { let t = Mn; for (Mn = void 0; t;) { const n = t.next; t.next = void 0, t.flags &= -9, t = n } } let e; for (; In;) { let t = In; for (In = void 0; t;) { const n = t.next; if (t.next = void 0, t.flags &= -9, t.flags & 1) try { t.trigger() } catch (s) { e || (e = s) } t = n } } if (e) throw e } function pi(e) { for (let t = e.deps; t; t = t.nextDep)t.version = -1, t.prevActiveLink = t.dep.activeLink, t.dep.activeLink = t } function di(e) { let t, n = e.depsTail, s = n; for (; s;) { const r = s.prevDep; s.version === -1 ? (s === n && (n = r), Xs(s), Yl(s)) : t = s, s.dep.activeLink = s.prevActiveLink, s.prevActiveLink = void 0, s = r } e.deps = t, e.depsTail = n } function Zs(e) { for (let t = e.deps; t; t = t.nextDep)if (t.dep.version !== t.version || t.dep.computed && (hi(t.dep.computed) || t.dep.version !== t.version)) return !0; return !!e._dirty } function hi(e) { if (e.flags & 4 && !(e.flags & 16) || (e.flags &= -17, e.globalVersion === On) || (e.globalVersion = On, !e.isSSR && e.flags & 128 && (!e.deps && !e._dirty || !Zs(e)))) return; e.flags |= 2; const t = e.dep, n = Te, s = xt; Te = e, xt = !0; try { pi(e); const r = e.fn(e._value); (t.version === 0 || Vt(r, e._value)) && (e.flags |= 128, e._value = r, t.version++) } catch (r) { throw t.version++, r } finally { Te = n, xt = s, di(e), e.flags &= -3 } } function Xs(e, t = !1) { const { dep: n, prevSub: s, nextSub: r } = e; if (s && (s.nextSub = r, e.prevSub = void 0), r && (r.prevSub = s, e.nextSub = void 0), n.subs === e && (n.subs = s, !s && n.computed)) { n.computed.flags &= -5; for (let i = n.computed.deps; i; i = i.nextDep)Xs(i, !0) } !t && !--n.sc && n.map && n.map.delete(n.key) } function Yl(e) { const { prevDep: t, nextDep: n } = e; t && (t.nextDep = n, e.prevDep = void 0), n && (n.prevDep = t, e.nextDep = void 0) } let xt = !0; const gi = []; function It() { gi.push(xt), xt = !1 } function Mt() { const e = gi.pop(); xt = e === void 0 ? !0 : e } function mi(e) { const { cleanup: t } = e; if (e.cleanup = void 0, t) { const n = Te; Te = void 0; try { t() } finally { Te = n } } } let On = 0; class Zl { constructor(t, n) { this.sub = t, this.dep = n, this.version = n.version, this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0 } } class Qs { constructor(t) { this.computed = t, this.version = 0, this.activeLink = void 0, this.subs = void 0, this.map = void 0, this.key = void 0, this.sc = 0, this.__v_skip = !0 } track(t) { if (!Te || !xt || Te === this.computed) return; let n = this.activeLink; if (n === void 0 || n.sub !== Te) n = this.activeLink = new Zl(Te, this), Te.deps ? (n.prevDep = Te.depsTail, Te.depsTail.nextDep = n, Te.depsTail = n) : Te.deps = Te.depsTail = n, bi(n); else if (n.version === -1 && (n.version = this.version, n.nextDep)) { const s = n.nextDep; s.prevDep = n.prevDep, n.prevDep && (n.prevDep.nextDep = s), n.prevDep = Te.depsTail, n.nextDep = void 0, Te.depsTail.nextDep = n, Te.depsTail = n, Te.deps === n && (Te.deps = s) } return n } trigger(t) { this.version++, On++, this.notify(t) } notify(t) { Ks(); try { for (let n = this.subs; n; n = n.prevSub)n.sub.notify() && n.sub.dep.notify() } finally { Ys() } } } function bi(e) { if (e.dep.sc++, e.sub.flags & 4) { const t = e.dep.computed; if (t && !e.dep.subs) { t.flags |= 20; for (let s = t.deps; s; s = s.nextDep)bi(s) } const n = e.dep.subs; n !== e && (e.prevSub = n, n && (n.nextSub = e)), e.dep.subs = e } } const Js = new WeakMap, tn = Symbol(""), er = Symbol(""), Ln = Symbol(""); function je(e, t, n) { if (xt && Te) { let s = Js.get(e); s || Js.set(e, s = new Map); let r = s.get(n); r || (s.set(n, r = new Qs), r.map = s, r.key = n), r.track() } } function Ot(e, t, n, s, r, i) { const o = Js.get(e); if (!o) { On++; return } const a = l => { l && l.trigger() }; if (Ks(), t === "clear") o.forEach(a); else { const l = Q(e), f = l && zs(n); if (l && n === "length") { const u = Number(s); o.forEach((d, g) => { (g === "length" || g === Ln || !Ut(g) && g >= u) && a(d) }) } else switch ((n !== void 0 || o.has(void 0)) && a(o.get(n)), f && a(o.get(Ln)), t) { case "add": l ? f && a(o.get("length")) : (a(o.get(tn)), hn(e) && a(o.get(er))); break; case "delete": l || (a(o.get(tn)), hn(e) && a(o.get(er))); break; case "set": hn(e) && a(o.get(tn)); break } } Ys() } function gn(e) { const t = ue(e); return t === e ? t : (je(t, "iterate", Ln), ut(e) ? t : t.map(Be)) } function os(e) { return je(e = ue(e), "iterate", Ln), e } const Xl = { __proto__: null, [Symbol.iterator]() { return tr(this, Symbol.iterator, Be) }, concat(...e) { return gn(this).concat(...e.map(t => Q(t) ? gn(t) : t)) }, entries() { return tr(this, "entries", e => (e[1] = Be(e[1]), e)) }, every(e, t) { return Lt(this, "every", e, t, void 0, arguments) }, filter(e, t) { return Lt(this, "filter", e, t, n => n.map(Be), arguments) }, find(e, t) { return Lt(this, "find", e, t, Be, arguments) }, findIndex(e, t) { return Lt(this, "findIndex", e, t, void 0, arguments) }, findLast(e, t) { return Lt(this, "findLast", e, t, Be, arguments) }, findLastIndex(e, t) { return Lt(this, "findLastIndex", e, t, void 0, arguments) }, forEach(e, t) { return Lt(this, "forEach", e, t, void 0, arguments) }, includes(...e) { return nr(this, "includes", e) }, indexOf(...e) { return nr(this, "indexOf", e) }, join(e) { return gn(this).join(e) }, lastIndexOf(...e) { return nr(this, "lastIndexOf", e) }, map(e, t) { return Lt(this, "map", e, t, void 0, arguments) }, pop() { return $n(this, "pop") }, push(...e) { return $n(this, "push", e) }, reduce(e, ...t) { return xi(this, "reduce", e, t) }, reduceRight(e, ...t) { return xi(this, "reduceRight", e, t) }, shift() { return $n(this, "shift") }, some(e, t) { return Lt(this, "some", e, t, void 0, arguments) }, splice(...e) { return $n(this, "splice", e) }, toReversed() { return gn(this).toReversed() }, toSorted(e) { return gn(this).toSorted(e) }, toSpliced(...e) { return gn(this).toSpliced(...e) }, unshift(...e) { return $n(this, "unshift", e) }, values() { return tr(this, "values", Be) } }; function tr(e, t, n) { const s = os(e), r = s[t](); return s !== e && !ut(e) && (r._next = r.next, r.next = () => { const i = r._next(); return i.value && (i.value = n(i.value)), i }), r } const Ql = Array.prototype; function Lt(e, t, n, s, r, i) { const o = os(e), a = o !== e && !ut(e), l = o[t]; if (l !== Ql[t]) { const d = l.apply(e, i); return a ? Be(d) : d } let f = n; o !== e && (a ? f = function (d, g) { return n.call(this, Be(d), g, e) } : n.length > 2 && (f = function (d, g) { return n.call(this, d, g, e) })); const u = l.call(o, f, s); return a && r ? r(u) : u } function xi(e, t, n, s) { const r = os(e); let i = n; return r !== e && (ut(e) ? n.length > 3 && (i = function (o, a, l) { return n.call(this, o, a, l, e) }) : i = function (o, a, l) { return n.call(this, o, Be(a), l, e) }), r[t](i, ...s) } function nr(e, t, n) { const s = ue(e); je(s, "iterate", Ln); const r = s[t](...n); return (r === -1 || r === !1) && rr(n[0]) ? (n[0] = ue(n[0]), s[t](...n)) : r } function $n(e, t, n = []) { It(), Ks(); const s = ue(e)[t].apply(e, n); return Ys(), Mt(), s } const Jl = Pt("__proto__,__v_isRef,__isVue"), yi = new Set(Object.getOwnPropertyNames(Symbol).filter(e => e !== "arguments" && e !== "caller").map(e => Symbol[e]).filter(Ut)); function ea(e) { Ut(e) || (e = String(e)); const t = ue(this); return je(t, "has", e), t.hasOwnProperty(e) } class wi { constructor(t = !1, n = !1) { this._isReadonly = t, this._isShallow = n } get(t, n, s) { if (n === "__v_skip") return t.__v_skip; const r = this._isReadonly, i = this._isShallow; if (n === "__v_isReactive") return !r; if (n === "__v_isReadonly") return r; if (n === "__v_isShallow") return i; if (n === "__v_raw") return s === (r ? i ? Ei : Si : i ? ki : Ti).get(t) || Object.getPrototypeOf(t) === Object.getPrototypeOf(s) ? t : void 0; const o = Q(t); if (!r) { let l; if (o && (l = Xl[n])) return l; if (n === "hasOwnProperty") return ea } const a = Reflect.get(t, n, Ve(t) ? t : s); return (Ut(n) ? yi.has(n) : Jl(n)) || (r || je(t, "get", n), i) ? a : Ve(a) ? o && zs(n) ? a : a.value : Re(a) ? r ? Ai(a) : cs(a) : a } } class vi extends wi { constructor(t = !1) { super(!1, t) } set(t, n, s, r) { let i = t[n]; if (!this._isShallow) { const l = qt(i); if (!ut(s) && !qt(s) && (i = ue(i), s = ue(s)), !Q(t) && Ve(i) && !Ve(s)) return l ? !1 : (i.value = s, !0) } const o = Q(t) && zs(n) ? Number(n) < t.length : me(t, n), a = Reflect.set(t, n, s, Ve(t) ? t : r); return t === ue(r) && (o ? Vt(s, i) && Ot(t, "set", n, s) : Ot(t, "add", n, s)), a } deleteProperty(t, n) { const s = me(t, n); t[n]; const r = Reflect.deleteProperty(t, n); return r && s && Ot(t, "delete", n, void 0), r } has(t, n) { const s = Reflect.has(t, n); return (!Ut(n) || !yi.has(n)) && je(t, "has", n), s } ownKeys(t) { return je(t, "iterate", Q(t) ? "length" : tn), Reflect.ownKeys(t) } } class _i extends wi { constructor(t = !1) { super(!0, t) } set(t, n) { return !0 } deleteProperty(t, n) { return !0 } } const ta = new vi, na = new _i, sa = new vi(!0), ra = new _i(!0), sr = e => e, ls = e => Reflect.getPrototypeOf(e); function ia(e, t, n) { return function (...s) { const r = this.__v_raw, i = ue(r), o = hn(i), a = e === "entries" || e === Symbol.iterator && o, l = e === "keys" && o, f = r[e](...s), u = n ? sr : t ? ps : Be; return !t && je(i, "iterate", l ? er : tn), { next() { const { value: d, done: g } = f.next(); return g ? { value: d, done: g } : { value: a ? [u(d[0]), u(d[1])] : u(d), done: g } }, [Symbol.iterator]() { return this } } } } function as(e) { return function (...t) { return e === "delete" ? !1 : e === "clear" ? void 0 : this } } function oa(e, t) { const n = { get(r) { const i = this.__v_raw, o = ue(i), a = ue(r); e || (Vt(r, a) && je(o, "get", r), je(o, "get", a)); const { has: l } = ls(o), f = t ? sr : e ? ps : Be; if (l.call(o, r)) return f(i.get(r)); if (l.call(o, a)) return f(i.get(a)); i !== o && i.get(r) }, get size() { const r = this.__v_raw; return !e && je(ue(r), "iterate", tn), Reflect.get(r, "size", r) }, has(r) { const i = this.__v_raw, o = ue(i), a = ue(r); return e || (Vt(r, a) && je(o, "has", r), je(o, "has", a)), r === a ? i.has(r) : i.has(r) || i.has(a) }, forEach(r, i) { const o = this, a = o.__v_raw, l = ue(a), f = t ? sr : e ? ps : Be; return !e && je(l, "iterate", tn), a.forEach((u, d) => r.call(i, f(u), f(d), o)) } }; return bt(n, e ? { add: as("add"), set: as("set"), delete: as("delete"), clear: as("clear") } : { add(r) { !t && !ut(r) && !qt(r) && (r = ue(r)); const i = ue(this); return ls(i).has.call(i, r) || (i.add(r), Ot(i, "add", r, r)), this }, set(r, i) { !t && !ut(i) && !qt(i) && (i = ue(i)); const o = ue(this), { has: a, get: l } = ls(o); let f = a.call(o, r); f || (r = ue(r), f = a.call(o, r)); const u = l.call(o, r); return o.set(r, i), f ? Vt(i, u) && Ot(o, "set", r, i) : Ot(o, "add", r, i), this }, delete(r) { const i = ue(this), { has: o, get: a } = ls(i); let l = o.call(i, r); l || (r = ue(r), l = o.call(i, r)), a && a.call(i, r); const f = i.delete(r); return l && Ot(i, "delete", r, void 0), f }, clear() { const r = ue(this), i = r.size !== 0, o = r.clear(); return i && Ot(r, "clear", void 0, void 0), o } }), ["keys", "values", "entries", Symbol.iterator].forEach(r => { n[r] = ia(r, e, t) }), n } function us(e, t) { const n = oa(e, t); return (s, r, i) => r === "__v_isReactive" ? !e : r === "__v_isReadonly" ? e : r === "__v_raw" ? s : Reflect.get(me(n, r) && r in s ? n : s, r, i) } const la = { get: us(!1, !1) }, aa = { get: us(!1, !0) }, ua = { get: us(!0, !1) }, ca = { get: us(!0, !0) }, Ti = new WeakMap, ki = new WeakMap, Si = new WeakMap, Ei = new WeakMap; function fa(e) { switch (e) { case "Object": case "Array": return 1; case "Map": case "Set": case "WeakMap": case "WeakSet": return 2; default: return 0 } } function pa(e) { return e.__v_skip || !Object.isExtensible(e) ? 0 : fa(Fl(e)) } function cs(e) { return qt(e) ? e : fs(e, !1, ta, la, Ti) } function da(e) { return fs(e, !1, sa, aa, ki) } function Ai(e) { return fs(e, !0, na, ua, Si) } function kd(e) { return fs(e, !0, ra, ca, Ei) } function fs(e, t, n, s, r) { if (!Re(e) || e.__v_raw && !(t && e.__v_isReactive)) return e; const i = pa(e); if (i === 0) return e; const o = r.get(e); if (o) return o; const a = new Proxy(e, i === 2 ? s : n); return r.set(e, a), a } function mn(e) { return qt(e) ? mn(e.__v_raw) : !!(e && e.__v_isReactive) } function qt(e) { return !!(e && e.__v_isReadonly) } function ut(e) { return !!(e && e.__v_isShallow) } function rr(e) { return e ? !!e.__v_raw : !1 } function ue(e) { const t = e && e.__v_raw; return t ? ue(t) : e } function ha(e) { return !me(e, "__v_skip") && Object.isExtensible(e) && js(e, "__v_skip", !0), e } const Be = e => Re(e) ? cs(e) : e, ps = e => Re(e) ? Ai(e) : e; function Ve(e) { return e ? e.__v_isRef === !0 : !1 } function J(e) { return ga(e, !1) } function ga(e, t) { return Ve(e) ? e : new ma(e, t) } class ma { constructor(t, n) { this.dep = new Qs, this.__v_isRef = !0, this.__v_isShallow = !1, this._rawValue = n ? t : ue(t), this._value = n ? t : Be(t), this.__v_isShallow = n } get value() { return this.dep.track(), this._value } set value(t) { const n = this._rawValue, s = this.__v_isShallow || ut(t) || qt(t); t = s ? t : ue(t), Vt(t, n) && (this._rawValue = t, this._value = s ? t : Be(t), this.dep.trigger()) } } function ba(e) { return Ve(e) ? e.value : e } const xa = { get: (e, t, n) => t === "__v_raw" ? e : ba(Reflect.get(e, t, n)), set: (e, t, n, s) => { const r = e[t]; return Ve(r) && !Ve(n) ? (r.value = n, !0) : Reflect.set(e, t, n, s) } }; function Ri(e) { return mn(e) ? e : new Proxy(e, xa) } class ya { constructor(t, n, s) { this.fn = t, this.setter = n, this._value = void 0, this.dep = new Qs(this), this.__v_isRef = !0, this.deps = void 0, this.depsTail = void 0, this.flags = 16, this.globalVersion = On - 1, this.next = void 0, this.effect = this, this.__v_isReadonly = !n, this.isSSR = s } notify() { if (this.flags |= 16, !(this.flags & 8) && Te !== this) return fi(this, !0), !0 } get value() { const t = this.dep.track(); return hi(this), t && (t.version = this.dep.version), this._value } set value(t) { this.setter && this.setter(t) } } function wa(e, t, n = !1) { let s, r; return be(e) ? s = e : (s = e.get, r = e.set), new ya(s, r, n) } const ds = {}, hs = new WeakMap; let nn; function va(e, t = !1, n = nn) { if (n) { let s = hs.get(n); s || hs.set(n, s = []), s.push(e) } } function _a(e, t, n = oe) { const { immediate: s, deep: r, once: i, scheduler: o, augmentJob: a, call: l } = n, f = $ => r ? $ : ut($) || r === !1 || r === 0 ? $t($, 1) : $t($); let u, d, g, y, E = !1, x = !1; if (Ve(e) ? (d = () => e.value, E = ut(e)) : mn(e) ? (d = () => f(e), E = !0) : Q(e) ? (x = !0, E = e.some($ => mn($) || ut($)), d = () => e.map($ => { if (Ve($)) return $.value; if (mn($)) return f($); if (be($)) return l ? l($, 2) : $() })) : be(e) ? t ? d = l ? () => l(e, 2) : e : d = () => { if (g) { It(); try { g() } finally { Mt() } } const $ = nn; nn = u; try { return l ? l(e, 3, [y]) : e(y) } finally { nn = $ } } : d = Jt, t && r) { const $ = d, z = r === !0 ? 1 / 0 : r; d = () => $t($(), z) } const M = Kl(), m = () => { u.stop(), M && M.active && Jr(M.effects, u) }; if (i && t) { const $ = t; t = (...z) => { $(...z), m() } } let H = x ? new Array(e.length).fill(ds) : ds; const Y = $ => { if (!(!(u.flags & 1) || !u.dirty && !$)) if (t) { const z = u.run(); if (r || E || (x ? z.some((O, P) => Vt(O, H[P])) : Vt(z, H))) { g && g(); const O = nn; nn = u; try { const P = [z, H === ds ? void 0 : x && H[0] === ds ? [] : H, y]; H = z, l ? l(t, 3, P) : t(...P) } finally { nn = O } } } else u.run() }; return a && a(Y), u = new ui(d), u.scheduler = o ? () => o(Y, !1) : Y, y = $ => va($, !1, u), g = u.onStop = () => { const $ = hs.get(u); if ($) { if (l) l($, 4); else for (const z of $) z(); hs.delete(u) } }, t ? s ? Y(!0) : H = u.run() : o ? o(Y.bind(null, !0), !0) : u.run(), m.pause = u.pause.bind(u), m.resume = u.resume.bind(u), m.stop = m, m } function $t(e, t = 1 / 0, n) { if (t <= 0 || !Re(e) || e.__v_skip || (n = n || new Set, n.has(e))) return e; if (n.add(e), t--, Ve(e)) $t(e.value, t, n); else if (Q(e)) for (let s = 0; s < e.length; s++)$t(e[s], t, n); else if (ei(e) || hn(e)) e.forEach(s => { $t(s, t, n) }); else if (si(e)) { for (const s in e) $t(e[s], t, n); for (const s of Object.getOwnPropertySymbols(e)) Object.prototype.propertyIsEnumerable.call(e, s) && $t(e[s], t, n) } return e } const Dn = []; let ir = !1; function Sd(e, ...t) { - if (ir) return; ir = !0, It(); const n = Dn.length ? Dn[Dn.length - 1].component : null, s = n && n.appContext.config.warnHandler, r = Ta(); if (s) bn(s, n, 11, [e + t.map(i => { var o, a; return (a = (o = i.toString) == null ? void 0 : o.call(i)) != null ? a : JSON.stringify(i) }).join(""), n && n.proxy, r.map(({ vnode: i }) => `at <${go(n, i.type)}>`).join(` -`), r]); else { - const i = [`[Vue warn]: ${e}`, ...t]; r.length && i.push(` -`, ...ka(r)) - } Mt(), ir = !1 - } function Ta() { let e = Dn[Dn.length - 1]; if (!e) return []; const t = []; for (; e;) { const n = t[0]; n && n.vnode === e ? n.recurseCount++ : t.push({ vnode: e, recurseCount: 0 }); const s = e.component && e.component.parent; e = s && s.vnode } return t } function ka(e) { - const t = []; return e.forEach((n, s) => { - t.push(...s === 0 ? [] : [` -`], ...Sa(n)) - }), t - } function Sa({ vnode: e, recurseCount: t }) { const n = t > 0 ? `... (${t} recursive calls)` : "", s = e.component ? e.component.parent == null : !1, r = ` at <${go(e.component, e.type, s)}`, i = ">" + n; return e.props ? [r, ...Ea(e.props), i] : [r + i] } function Ea(e) { const t = [], n = Object.keys(e); return n.slice(0, 3).forEach(s => { t.push(...Ci(s, e[s])) }), n.length > 3 && t.push(" ..."), t } function Ci(e, t, n) { return Pe(t) ? (t = JSON.stringify(t), n ? t : [`${e}=${t}`]) : typeof t == "number" || typeof t == "boolean" || t == null ? n ? t : [`${e}=${t}`] : Ve(t) ? (t = Ci(e, ue(t.value), !0), n ? t : [`${e}=Ref<`, t, ">"]) : be(t) ? [`${e}=fn${t.name ? `<${t.name}>` : ""}`] : (t = ue(t), n ? t : [`${e}=`, t]) } function bn(e, t, n, s) { try { return s ? e(...s) : e() } catch (r) { gs(r, t, n) } } function Tt(e, t, n, s) { if (be(e)) { const r = bn(e, t, n, s); return r && ti(r) && r.catch(i => { gs(i, t, n) }), r } if (Q(e)) { const r = []; for (let i = 0; i < e.length; i++)r.push(Tt(e[i], t, n, s)); return r } } function gs(e, t, n, s = !0) { const r = t ? t.vnode : null, { errorHandler: i, throwUnhandledErrorInProduction: o } = t && t.appContext.config || oe; if (t) { let a = t.parent; const l = t.proxy, f = `https://vuejs.org/error-reference/#runtime-${n}`; for (; a;) { const u = a.ec; if (u) { for (let d = 0; d < u.length; d++)if (u[d](e, l, f) === !1) return } a = a.parent } if (i) { It(), bn(i, null, 10, [e, l, f]), Mt(); return } } Aa(e, n, r, s, o) } function Aa(e, t, n, s = !0, r = !1) { if (r) throw e } const Ke = []; let kt = -1; const xn = []; let Wt = null, yn = 0; const Pi = Promise.resolve(); let ms = null; function St(e) { const t = ms || Pi; return e ? t.then(this ? e.bind(this) : e) : t } function Ra(e) { let t = kt + 1, n = Ke.length; for (; t < n;) { const s = t + n >>> 1, r = Ke[s], i = Nn(r); i < e || i === e && r.flags & 2 ? t = s + 1 : n = s } return t } function or(e) { if (!(e.flags & 1)) { const t = Nn(e), n = Ke[Ke.length - 1]; !n || !(e.flags & 2) && t >= Nn(n) ? Ke.push(e) : Ke.splice(Ra(t), 0, e), e.flags |= 1, Ii() } } function Ii() { ms || (ms = Pi.then(Li)) } function Ca(e) { Q(e) ? xn.push(...e) : Wt && e.id === -1 ? Wt.splice(yn + 1, 0, e) : e.flags & 1 || (xn.push(e), e.flags |= 1), Ii() } function Mi(e, t, n = kt + 1) { for (; n < Ke.length; n++) { const s = Ke[n]; if (s && s.flags & 2) { if (e && s.id !== e.uid) continue; Ke.splice(n, 1), n--, s.flags & 4 && (s.flags &= -2), s(), s.flags & 4 || (s.flags &= -2) } } } function Oi(e) { if (xn.length) { const t = [...new Set(xn)].sort((n, s) => Nn(n) - Nn(s)); if (xn.length = 0, Wt) { Wt.push(...t); return } for (Wt = t, yn = 0; yn < Wt.length; yn++) { const n = Wt[yn]; n.flags & 4 && (n.flags &= -2), n.flags & 8 || n(), n.flags &= -2 } Wt = null, yn = 0 } } const Nn = e => e.id == null ? e.flags & 2 ? -1 : 1 / 0 : e.id; function Li(e) { try { for (kt = 0; kt < Ke.length; kt++) { const t = Ke[kt]; t && !(t.flags & 8) && (t.flags & 4 && (t.flags &= -2), bn(t, t.i, t.i ? 15 : 14), t.flags & 4 || (t.flags &= -2)) } } finally { for (; kt < Ke.length; kt++) { const t = Ke[kt]; t && (t.flags &= -2) } kt = -1, Ke.length = 0, Oi(), ms = null, (Ke.length || xn.length) && Li() } } let ct = null, $i = null; function bs(e) { const t = ct; return ct = e, $i = e && e.type.__scopeId || null, t } function Di(e, t = ct, n) { if (!t || e._n) return e; const s = (...r) => { s._d && oo(-1); const i = bs(t); let o; try { o = e(...r) } finally { bs(i), s._d && oo(1) } return o }; return s._n = !0, s._c = !0, s._d = !0, s } function Pa(e, t) { if (ct === null) return e; const n = As(ct), s = e.dirs || (e.dirs = []); for (let r = 0; r < t.length; r++) { let [i, o, a, l = oe] = t[r]; i && (be(i) && (i = { mounted: i, updated: i }), i.deep && $t(o), s.push({ dir: i, instance: n, value: o, oldValue: void 0, arg: a, modifiers: l })) } return e } function sn(e, t, n, s) { const r = e.dirs, i = t && t.dirs; for (let o = 0; o < r.length; o++) { const a = r[o]; i && (a.oldValue = i[o].value); let l = a.dir[s]; l && (It(), Tt(l, n, 8, [e.el, a, e, t]), Mt()) } } const Ia = Symbol("_vte"), Ni = e => e.__isTeleport, Gt = Symbol("_leaveCb"), xs = Symbol("_enterCb"); function Ma() { const e = { isMounted: !1, isLeaving: !1, isUnmounting: !1, leavingVNodes: new Map }; return zn(() => { e.isMounted = !0 }), ys(() => { e.isUnmounting = !0 }), e } const ft = [Function, Array], Fi = { mode: String, appear: Boolean, persisted: Boolean, onBeforeEnter: ft, onEnter: ft, onAfterEnter: ft, onEnterCancelled: ft, onBeforeLeave: ft, onLeave: ft, onAfterLeave: ft, onLeaveCancelled: ft, onBeforeAppear: ft, onAppear: ft, onAfterAppear: ft, onAppearCancelled: ft }, Bi = e => { const t = e.subTree; return t.component ? Bi(t.component) : t }, Oa = { name: "BaseTransition", props: Fi, setup(e, { slots: t }) { const n = uo(), s = Ma(); return () => { const r = t.default && ji(t.default(), !0); if (!r || !r.length) return; const i = Hi(r), o = ue(e), { mode: a } = o; if (s.isLeaving) return ar(i); const l = Ui(i); if (!l) return ar(i); let f = lr(l, o, s, n, d => f = d); l.type !== Ye && Fn(l, f); let u = n.subTree && Ui(n.subTree); if (u && u.type !== Ye && !ln(l, u) && Bi(n).type !== Ye) { let d = lr(u, o, s, n); if (Fn(u, d), a === "out-in" && l.type !== Ye) return s.isLeaving = !0, d.afterLeave = () => { s.isLeaving = !1, n.job.flags & 8 || n.update(), delete d.afterLeave, u = void 0 }, ar(i); a === "in-out" && l.type !== Ye ? d.delayLeave = (g, y, E) => { const x = zi(s, u); x[String(u.key)] = u, g[Gt] = () => { y(), g[Gt] = void 0, delete f.delayedLeave, u = void 0 }, f.delayedLeave = () => { E(), delete f.delayedLeave, u = void 0 } } : u = void 0 } else u && (u = void 0); return i } } }; function Hi(e) { let t = e[0]; if (e.length > 1) { for (const n of e) if (n.type !== Ye) { t = n; break } } return t } const La = Oa; function zi(e, t) { const { leavingVNodes: n } = e; let s = n.get(t.type); return s || (s = Object.create(null), n.set(t.type, s)), s } function lr(e, t, n, s, r) { const { appear: i, mode: o, persisted: a = !1, onBeforeEnter: l, onEnter: f, onAfterEnter: u, onEnterCancelled: d, onBeforeLeave: g, onLeave: y, onAfterLeave: E, onLeaveCancelled: x, onBeforeAppear: M, onAppear: m, onAfterAppear: H, onAppearCancelled: Y } = t, $ = String(e.key), z = zi(n, e), O = (V, se) => { V && Tt(V, s, 9, se) }, P = (V, se) => { const fe = se[1]; O(V, se), Q(V) ? V.every(D => D.length <= 1) && fe() : V.length <= 1 && fe() }, ee = { mode: o, persisted: a, beforeEnter(V) { let se = l; if (!n.isMounted) if (i) se = M || l; else return; V[Gt] && V[Gt](!0); const fe = z[$]; fe && ln(e, fe) && fe.el[Gt] && fe.el[Gt](), O(se, [V]) }, enter(V) { let se = f, fe = u, D = d; if (!n.isMounted) if (i) se = m || f, fe = H || u, D = Y || d; else return; let Z = !1; const Se = V[xs] = Ue => { Z || (Z = !0, Ue ? O(D, [V]) : O(fe, [V]), ee.delayedLeave && ee.delayedLeave(), V[xs] = void 0) }; se ? P(se, [V, Se]) : Se() }, leave(V, se) { const fe = String(e.key); if (V[xs] && V[xs](!0), n.isUnmounting) return se(); O(g, [V]); let D = !1; const Z = V[Gt] = Se => { D || (D = !0, se(), Se ? O(x, [V]) : O(E, [V]), V[Gt] = void 0, z[fe] === e && delete z[fe]) }; z[fe] = e, y ? P(y, [V, Z]) : Z() }, clone(V) { const se = lr(V, t, n, s, r); return r && r(se), se } }; return ee } function ar(e) { if (ur(e)) return e = Kt(e), e.children = null, e } function Ui(e) { if (!ur(e)) return Ni(e.type) && e.children ? Hi(e.children) : e; if (e.component) return e.component.subTree; const { shapeFlag: t, children: n } = e; if (n) { if (t & 16) return n[0]; if (t & 32 && be(n.default)) return n.default() } } function Fn(e, t) { e.shapeFlag & 6 && e.component ? (e.transition = t, Fn(e.component.subTree, t)) : e.shapeFlag & 128 ? (e.ssContent.transition = t.clone(e.ssContent), e.ssFallback.transition = t.clone(e.ssFallback)) : e.transition = t } function ji(e, t = !1, n) { let s = [], r = 0; for (let i = 0; i < e.length; i++) { let o = e[i]; const a = n == null ? o.key : String(n) + String(o.key != null ? o.key : i); o.type === He ? (o.patchFlag & 128 && r++, s = s.concat(ji(o.children, t, a))) : (t || o.type !== Ye) && s.push(a != null ? Kt(o, { key: a }) : o) } if (r > 1) for (let i = 0; i < s.length; i++)s[i].patchFlag = -2; return s } function $a(e) { e.ids = [e.ids[0] + e.ids[2]++ + "-", 0, 0] } function Bn(e, t, n, s, r = !1) { if (Q(e)) { e.forEach((E, x) => Bn(E, t && (Q(t) ? t[x] : t), n, s, r)); return } if (Hn(s) && !r) { s.shapeFlag & 512 && s.type.__asyncResolved && s.component.subTree.component && Bn(e, t, n, s.component.subTree); return } const i = s.shapeFlag & 4 ? As(s.component) : s.el, o = r ? null : i, { i: a, r: l } = e, f = t && t.r, u = a.refs === oe ? a.refs = {} : a.refs, d = a.setupState, g = ue(d), y = d === oe ? () => !1 : E => me(g, E); if (f != null && f !== l && (Pe(f) ? (u[f] = null, y(f) && (d[f] = null)) : Ve(f) && (f.value = null)), be(l)) bn(l, a, 12, [o, u]); else { const E = Pe(l), x = Ve(l); if (E || x) { const M = () => { if (e.f) { const m = E ? y(l) ? d[l] : u[l] : l.value; r ? Q(m) && Jr(m, i) : Q(m) ? m.includes(i) || m.push(i) : E ? (u[l] = [i], y(l) && (d[l] = u[l])) : (l.value = [i], e.k && (u[e.k] = l.value)) } else E ? (u[l] = o, y(l) && (d[l] = o)) : x && (l.value = o, e.k && (u[e.k] = o)) }; o ? (M.id = -1, rt(M, n)) : M() } } } is().requestIdleCallback, is().cancelIdleCallback; const Hn = e => !!e.type.__asyncLoader, ur = e => e.type.__isKeepAlive; function Da(e, t, n = Zt, s = !1) { if (n) { const r = n[e] || (n[e] = []), i = t.__weh || (t.__weh = (...o) => { It(); const a = yr(n), l = Tt(t, n, e, o); return a(), Mt(), l }); return s ? r.unshift(i) : r.push(i), i } } const Vi = e => (t, n = Zt) => { (!qn || e === "sp") && Da(e, (...s) => t(...s), n) }, zn = Vi("m"), ys = Vi("bum"), Na = Symbol.for("v-ndc"); function ws(e, t, n, s) { let r; const i = n, o = Q(e); if (o || Pe(e)) { const a = o && mn(e); let l = !1, f = !1; a && (l = !ut(e), f = qt(e), e = os(e)), r = new Array(e.length); for (let u = 0, d = e.length; u < d; u++)r[u] = t(l ? f ? ps(Be(e[u])) : Be(e[u]) : e[u], u, void 0, i) } else if (typeof e == "number") { r = new Array(e); for (let a = 0; a < e; a++)r[a] = t(a + 1, a, void 0, i) } else if (Re(e)) if (e[Symbol.iterator]) r = Array.from(e, (a, l) => t(a, l, void 0, i)); else { const a = Object.keys(e); r = new Array(a.length); for (let l = 0, f = a.length; l < f; l++) { const u = a[l]; r[l] = t(e[u], u, l, i) } } else r = []; return r } const cr = e => e ? fo(e) ? As(e) : cr(e.parent) : null, Un = bt(Object.create(null), { $: e => e, $el: e => e.vnode.el, $data: e => e.data, $props: e => e.props, $attrs: e => e.attrs, $slots: e => e.slots, $refs: e => e.refs, $parent: e => cr(e.parent), $root: e => cr(e.root), $host: e => e.ce, $emit: e => e.emit, $options: e => e.type, $forceUpdate: e => e.f || (e.f = () => { or(e.update) }), $nextTick: e => e.n || (e.n = St.bind(e.proxy)), $watch: e => Jt }), fr = (e, t) => e !== oe && !e.__isScriptSetup && me(e, t), Fa = { get({ _: e }, t) { if (t === "__v_skip") return !0; const { ctx: n, setupState: s, data: r, props: i, accessCache: o, type: a, appContext: l } = e; let f; if (t[0] !== "$") { const y = o[t]; if (y !== void 0) switch (y) { case 1: return s[t]; case 2: return r[t]; case 4: return n[t]; case 3: return i[t] } else { if (fr(s, t)) return o[t] = 1, s[t]; if (r !== oe && me(r, t)) return o[t] = 2, r[t]; if ((f = e.propsOptions[0]) && me(f, t)) return o[t] = 3, i[t]; if (n !== oe && me(n, t)) return o[t] = 4, n[t]; o[t] = 0 } } const u = Un[t]; let d, g; if (u) return t === "$attrs" && je(e.attrs, "get", ""), u(e); if ((d = a.__cssModules) && (d = d[t])) return d; if (n !== oe && me(n, t)) return o[t] = 4, n[t]; if (g = l.config.globalProperties, me(g, t)) return g[t] }, set({ _: e }, t, n) { const { data: s, setupState: r, ctx: i } = e; return fr(r, t) ? (r[t] = n, !0) : s !== oe && me(s, t) ? (s[t] = n, !0) : me(e.props, t) || t[0] === "$" && t.slice(1) in e ? !1 : (i[t] = n, !0) }, has({ _: { data: e, setupState: t, accessCache: n, ctx: s, appContext: r, propsOptions: i } }, o) { let a; return !!n[o] || e !== oe && me(e, o) || fr(t, o) || (a = i[0]) && me(a, o) || me(s, o) || me(Un, o) || me(r.config.globalProperties, o) }, defineProperty(e, t, n) { return n.get != null ? e._.accessCache[t] = 0 : me(n, "value") && this.set(e, t, n.value, null), Reflect.defineProperty(e, t, n) } }; function qi() { return { app: null, config: { isNativeTag: Dl, performance: !1, globalProperties: {}, optionMergeStrategies: {}, errorHandler: void 0, warnHandler: void 0, compilerOptions: {} }, mixins: [], components: {}, directives: {}, provides: Object.create(null), optionsCache: new WeakMap, propsCache: new WeakMap, emitsCache: new WeakMap } } let Ba = 0; function Ha(e, t) { return function (s, r = null) { be(s) || (s = bt({}, s)), r != null && !Re(r) && (r = null); const i = qi(), o = new WeakSet, a = []; let l = !1; const f = i.app = { _uid: Ba++, _component: s, _props: r, _container: null, _context: i, _instance: null, version: Su, get config() { return i.config }, set config(u) { }, use(u, ...d) { return o.has(u) || (u && be(u.install) ? (o.add(u), u.install(f, ...d)) : be(u) && (o.add(u), u(f, ...d))), f }, mixin(u) { return f }, component(u, d) { return d ? (i.components[u] = d, f) : i.components[u] }, directive(u, d) { return d ? (i.directives[u] = d, f) : i.directives[u] }, mount(u, d, g) { if (!l) { const y = f._ceVNode || Oe(s, r); return y.appContext = i, g === !0 ? g = "svg" : g === !1 && (g = void 0), e(y, u, g), l = !0, f._container = u, u.__vue_app__ = f, As(y.component) } }, onUnmount(u) { a.push(u) }, unmount() { l && (Tt(a, f._instance, 16), e(null, f._container), delete f._container.__vue_app__) }, provide(u, d) { return i.provides[u] = d, f }, runWithContext(u) { const d = wn; wn = f; try { return u() } finally { wn = d } } }; return f } } let wn = null; function za(e, t, n = !1) { const s = uo(); if (s || wn) { let r = wn ? wn._context.provides : s ? s.parent == null || s.ce ? s.vnode.appContext && s.vnode.appContext.provides : s.parent.provides : void 0; if (r && e in r) return r[e]; if (arguments.length > 1) return n && be(t) ? t.call(s && s.proxy) : t } } const Wi = {}, Gi = () => Object.create(Wi), Ki = e => Object.getPrototypeOf(e) === Wi; function Ua(e, t, n, s = !1) { const r = {}, i = Gi(); e.propsDefaults = Object.create(null), Yi(e, t, r, i); for (const o in e.propsOptions[0]) o in r || (r[o] = void 0); n ? e.props = s ? r : da(r) : e.type.props ? e.props = r : e.props = i, e.attrs = i } function ja(e, t, n, s) { const { props: r, attrs: i, vnode: { patchFlag: o } } = e, a = ue(r), [l] = e.propsOptions; let f = !1; if ((s || o > 0) && !(o & 16)) { if (o & 8) { const u = e.vnode.dynamicProps; for (let d = 0; d < u.length; d++) { let g = u[d]; if (vs(e.emitsOptions, g)) continue; const y = t[g]; if (l) if (me(i, g)) y !== i[g] && (i[g] = y, f = !0); else { const E = jt(g); r[E] = pr(l, a, E, y, e, !1) } else y !== i[g] && (i[g] = y, f = !0) } } } else { Yi(e, t, r, i) && (f = !0); let u; for (const d in a) (!t || !me(t, d) && ((u = en(d)) === d || !me(t, u))) && (l ? n && (n[d] !== void 0 || n[u] !== void 0) && (r[d] = pr(l, a, d, void 0, e, !0)) : delete r[d]); if (i !== a) for (const d in i) (!t || !me(t, d)) && (delete i[d], f = !0) } f && Ot(e.attrs, "set", "") } function Yi(e, t, n, s) { const [r, i] = e.propsOptions; let o = !1, a; if (t) for (let l in t) { if (Pn(l)) continue; const f = t[l]; let u; r && me(r, u = jt(l)) ? !i || !i.includes(u) ? n[u] = f : (a || (a = {}))[u] = f : vs(e.emitsOptions, l) || (!(l in s) || f !== s[l]) && (s[l] = f, o = !0) } if (i) { const l = ue(n), f = a || oe; for (let u = 0; u < i.length; u++) { const d = i[u]; n[d] = pr(r, l, d, f[d], e, !me(f, d)) } } return o } function pr(e, t, n, s, r, i) { const o = e[n]; if (o != null) { const a = me(o, "default"); if (a && s === void 0) { const l = o.default; if (o.type !== Function && !o.skipFactory && be(l)) { const { propsDefaults: f } = r; if (n in f) s = f[n]; else { const u = yr(r); s = f[n] = l.call(null, t), u() } } else s = l; r.ce && r.ce._setProp(n, s) } o[0] && (i && !a ? s = !1 : o[1] && (s === "" || s === en(n)) && (s = !0)) } return s } function Va(e, t, n = !1) { const s = t.propsCache, r = s.get(e); if (r) return r; const i = e.props, o = {}, a = []; if (!i) return Re(e) && s.set(e, mt), mt; if (Q(i)) for (let f = 0; f < i.length; f++) { const u = jt(i[f]); Zi(u) && (o[u] = oe) } else if (i) for (const f in i) { const u = jt(f); if (Zi(u)) { const d = i[f], g = o[u] = Q(d) || be(d) ? { type: d } : bt({}, d), y = g.type; let E = !1, x = !0; if (Q(y)) for (let M = 0; M < y.length; ++M) { const m = y[M], H = be(m) && m.name; if (H === "Boolean") { E = !0; break } else H === "String" && (x = !1) } else E = be(y) && y.name === "Boolean"; g[0] = E, g[1] = x, (E || me(g, "default")) && a.push(u) } } const l = [o, a]; return Re(e) && s.set(e, l), l } function Zi(e) { return e[0] !== "$" && !Pn(e) } const dr = e => e === "_" || e === "__" || e === "_ctx" || e === "$stable", hr = e => Q(e) ? e.map(At) : [At(e)], qa = (e, t, n) => { if (t._n) return t; const s = Di((...r) => hr(t(...r)), n); return s._c = !1, s }, Xi = (e, t, n) => { const s = e._ctx; for (const r in e) { if (dr(r)) continue; const i = e[r]; if (be(i)) t[r] = qa(r, i, s); else if (i != null) { const o = hr(i); t[r] = () => o } } }, Qi = (e, t) => { const n = hr(t); e.slots.default = () => n }, Ji = (e, t, n) => { for (const s in t) (n || !dr(s)) && (e[s] = t[s]) }, Wa = (e, t, n) => { const s = e.slots = Gi(); if (e.vnode.shapeFlag & 32) { const r = t.__; r && js(s, "__", r, !0); const i = t._; i ? (Ji(s, t, n), n && js(s, "_", i, !0)) : Xi(t, s) } else t && Qi(e, t) }, Ga = (e, t, n) => { const { vnode: s, slots: r } = e; let i = !0, o = oe; if (s.shapeFlag & 32) { const a = t._; a ? n && a === 1 ? i = !1 : Ji(r, t, n) : (i = !t.$stable, Xi(t, r)), o = t } else t && (Qi(e, t), o = { default: 1 }); if (i) for (const a in r) !dr(a) && o[a] == null && delete r[a] }, rt = au; function Ka(e) { return Ya(e) } function Ya(e, t) { const n = is(); n.__VUE__ = !0; const { insert: s, remove: r, patchProp: i, createElement: o, createText: a, createComment: l, setText: f, setElementText: u, parentNode: d, nextSibling: g, setScopeId: y = Jt, insertStaticContent: E } = e, x = (c, h, b, k = null, v = null, _ = null, I = void 0, R = null, A = !!h.dynamicChildren) => { if (c === h) return; c && !ln(c, h) && (k = ye(c), de(c, v, _, !0), c = null), h.patchFlag === -2 && (A = !1, h.dynamicChildren = null); const { type: S, ref: U, shapeFlag: L } = h; switch (S) { case _s: M(c, h, b, k); break; case Ye: m(c, h, b, k); break; case mr: c == null && H(h, b, k, I); break; case He: D(c, h, b, k, v, _, I, R, A); break; default: L & 1 ? z(c, h, b, k, v, _, I, R, A) : L & 6 ? Z(c, h, b, k, v, _, I, R, A) : (L & 64 || L & 128) && S.process(c, h, b, k, v, _, I, R, A, Ce) }U != null && v ? Bn(U, c && c.ref, _, h || c, !h) : U == null && c && c.ref != null && Bn(c.ref, null, _, c, !0) }, M = (c, h, b, k) => { if (c == null) s(h.el = a(h.children), b, k); else { const v = h.el = c.el; h.children !== c.children && f(v, h.children) } }, m = (c, h, b, k) => { c == null ? s(h.el = l(h.children || ""), b, k) : h.el = c.el }, H = (c, h, b, k) => { [c.el, c.anchor] = E(c.children, h, b, k, c.el, c.anchor) }, Y = ({ el: c, anchor: h }, b, k) => { let v; for (; c && c !== h;)v = g(c), s(c, b, k), c = v; s(h, b, k) }, $ = ({ el: c, anchor: h }) => { let b; for (; c && c !== h;)b = g(c), r(c), c = b; r(h) }, z = (c, h, b, k, v, _, I, R, A) => { h.type === "svg" ? I = "svg" : h.type === "math" && (I = "mathml"), c == null ? O(h, b, k, v, _, I, R, A) : V(c, h, v, _, I, R, A) }, O = (c, h, b, k, v, _, I, R) => { let A, S; const { props: U, shapeFlag: L, transition: j, dirs: K } = c; if (A = c.el = o(c.type, _, U && U.is, U), L & 8 ? u(A, c.children) : L & 16 && ee(c.children, A, null, k, v, gr(c, _), I, R), K && sn(c, null, k, "created"), P(A, c, c.scopeId, I, k), U) { for (const he in U) he !== "value" && !Pn(he) && i(A, he, null, U[he], _, k); "value" in U && i(A, "value", null, U.value, _), (S = U.onVnodeBeforeMount) && Rt(S, k, c) } K && sn(c, null, k, "beforeMount"); const ne = Za(v, j); ne && j.beforeEnter(A), s(A, h, b), ((S = U && U.onVnodeMounted) || ne || K) && rt(() => { S && Rt(S, k, c), ne && j.enter(A), K && sn(c, null, k, "mounted") }, v) }, P = (c, h, b, k, v) => { if (b && y(c, b), k) for (let _ = 0; _ < k.length; _++)y(c, k[_]); if (v) { let _ = v.subTree; if (h === _ || io(_.type) && (_.ssContent === h || _.ssFallback === h)) { const I = v.vnode; P(c, I, I.scopeId, I.slotScopeIds, v.parent) } } }, ee = (c, h, b, k, v, _, I, R, A = 0) => { for (let S = A; S < c.length; S++) { const U = c[S] = R ? Yt(c[S]) : At(c[S]); x(null, U, h, b, k, v, _, I, R) } }, V = (c, h, b, k, v, _, I) => { const R = h.el = c.el; let { patchFlag: A, dynamicChildren: S, dirs: U } = h; A |= c.patchFlag & 16; const L = c.props || oe, j = h.props || oe; let K; if (b && rn(b, !1), (K = j.onVnodeBeforeUpdate) && Rt(K, b, h, c), U && sn(h, c, b, "beforeUpdate"), b && rn(b, !0), (L.innerHTML && j.innerHTML == null || L.textContent && j.textContent == null) && u(R, ""), S ? se(c.dynamicChildren, S, R, b, k, gr(h, v), _) : I || pe(c, h, R, null, b, k, gr(h, v), _, !1), A > 0) { if (A & 16) fe(R, L, j, b, v); else if (A & 2 && L.class !== j.class && i(R, "class", null, j.class, v), A & 4 && i(R, "style", L.style, j.style, v), A & 8) { const ne = h.dynamicProps; for (let he = 0; he < ne.length; he++) { const ie = ne[he], ke = L[ie], $e = j[ie]; ($e !== ke || ie === "value") && i(R, ie, ke, $e, v, b) } } A & 1 && c.children !== h.children && u(R, h.children) } else !I && S == null && fe(R, L, j, b, v); ((K = j.onVnodeUpdated) || U) && rt(() => { K && Rt(K, b, h, c), U && sn(h, c, b, "updated") }, k) }, se = (c, h, b, k, v, _, I) => { for (let R = 0; R < h.length; R++) { const A = c[R], S = h[R], U = A.el && (A.type === He || !ln(A, S) || A.shapeFlag & 198) ? d(A.el) : b; x(A, S, U, null, k, v, _, I, !0) } }, fe = (c, h, b, k, v) => { if (h !== b) { if (h !== oe) for (const _ in h) !Pn(_) && !(_ in b) && i(c, _, h[_], null, v, k); for (const _ in b) { if (Pn(_)) continue; const I = b[_], R = h[_]; I !== R && _ !== "value" && i(c, _, R, I, v, k) } "value" in b && i(c, "value", h.value, b.value, v) } }, D = (c, h, b, k, v, _, I, R, A) => { const S = h.el = c ? c.el : a(""), U = h.anchor = c ? c.anchor : a(""); let { patchFlag: L, dynamicChildren: j, slotScopeIds: K } = h; K && (R = R ? R.concat(K) : K), c == null ? (s(S, b, k), s(U, b, k), ee(h.children || [], b, U, v, _, I, R, A)) : L > 0 && L & 64 && j && c.dynamicChildren ? (se(c.dynamicChildren, j, b, v, _, I, R), (h.key != null || v && h === v.subTree) && eo(c, h, !0)) : pe(c, h, b, U, v, _, I, R, A) }, Z = (c, h, b, k, v, _, I, R, A) => { h.slotScopeIds = R, c == null ? h.shapeFlag & 512 ? v.ctx.activate(h, b, k, I, A) : Se(h, b, k, v, _, I, A) : Ue(c, h, A) }, Se = (c, h, b, k, v, _, I) => { const R = c.component = gu(c, k, v); if (ur(c) && (R.ctx.renderer = Ce), mu(R, !1, I), R.asyncDep) { if (v && v.registerDep(R, te, I), !c.el) { const A = R.subTree = Oe(Ye); m(null, A, h, b), c.placeholder = A.el } } else te(R, c, h, b, v, _, I) }, Ue = (c, h, b) => { const k = h.component = c.component; if (ou(c, h, b)) if (k.asyncDep && !k.asyncResolved) { C(k, h, b); return } else k.next = h, k.update(); else h.el = c.el, k.vnode = h }, te = (c, h, b, k, v, _, I) => { const R = () => { if (c.isMounted) { let { next: L, bu: j, u: K, parent: ne, vnode: he } = c; { const lt = to(c); if (lt) { L && (L.el = he.el, C(c, L, I)), lt.asyncDep.then(() => { c.isUnmounted || R() }); return } } let ie = L, ke; rn(c, !1), L ? (L.el = he.el, C(c, L, I)) : L = he, j && rs(j), (ke = L.props && L.props.onVnodeBeforeUpdate) && Rt(ke, ne, L, he), rn(c, !0); const $e = so(c), ot = c.subTree; c.subTree = $e, x(ot, $e, d(ot.el), ye(ot), c, v, _), L.el = $e.el, ie === null && lu(c, $e.el), K && rt(K, v), (ke = L.props && L.props.onVnodeUpdated) && rt(() => Rt(ke, ne, L, he), v) } else { let L; const { el: j, props: K } = h, { bm: ne, m: he, parent: ie, root: ke, type: $e } = c, ot = Hn(h); rn(c, !1), ne && rs(ne), !ot && (L = K && K.onVnodeBeforeMount) && Rt(L, ie, h), rn(c, !0); { ke.ce && ke.ce._def.shadowRoot !== !1 && ke.ce._injectChildStyle($e); const lt = c.subTree = so(c); x(null, lt, b, k, c, v, _), h.el = lt.el } if (he && rt(he, v), !ot && (L = K && K.onVnodeMounted)) { const lt = h; rt(() => Rt(L, ie, lt), v) } (h.shapeFlag & 256 || ie && Hn(ie.vnode) && ie.vnode.shapeFlag & 256) && c.a && rt(c.a, v), c.isMounted = !0, h = b = k = null } }; c.scope.on(); const A = c.effect = new ui(R); c.scope.off(); const S = c.update = A.run.bind(A), U = c.job = A.runIfDirty.bind(A); U.i = c, U.id = c.uid, A.scheduler = () => or(U), rn(c, !0), S() }, C = (c, h, b) => { h.component = c; const k = c.vnode.props; c.vnode = h, c.next = null, ja(c, h.props, k, b), Ga(c, h.children, b), It(), Mi(c), Mt() }, pe = (c, h, b, k, v, _, I, R, A = !1) => { const S = c && c.children, U = c ? c.shapeFlag : 0, L = h.children, { patchFlag: j, shapeFlag: K } = h; if (j > 0) { if (j & 128) { re(S, L, b, k, v, _, I, R, A); return } else if (j & 256) { Ge(S, L, b, k, v, _, I, R, A); return } } K & 8 ? (U & 16 && nt(S, v, _), L !== S && u(b, L)) : U & 16 ? K & 16 ? re(S, L, b, k, v, _, I, R, A) : nt(S, v, _, !0) : (U & 8 && u(b, ""), K & 16 && ee(L, b, k, v, _, I, R, A)) }, Ge = (c, h, b, k, v, _, I, R, A) => { c = c || mt, h = h || mt; const S = c.length, U = h.length, L = Math.min(S, U); let j; for (j = 0; j < L; j++) { const K = h[j] = A ? Yt(h[j]) : At(h[j]); x(c[j], K, b, null, v, _, I, R, A) } S > U ? nt(c, v, _, !0, !1, L) : ee(h, b, k, v, _, I, R, A, L) }, re = (c, h, b, k, v, _, I, R, A) => { let S = 0; const U = h.length; let L = c.length - 1, j = U - 1; for (; S <= L && S <= j;) { const K = c[S], ne = h[S] = A ? Yt(h[S]) : At(h[S]); if (ln(K, ne)) x(K, ne, b, null, v, _, I, R, A); else break; S++ } for (; S <= L && S <= j;) { const K = c[L], ne = h[j] = A ? Yt(h[j]) : At(h[j]); if (ln(K, ne)) x(K, ne, b, null, v, _, I, R, A); else break; L--, j-- } if (S > L) { if (S <= j) { const K = j + 1, ne = K < U ? h[K].el : k; for (; S <= j;)x(null, h[S] = A ? Yt(h[S]) : At(h[S]), b, ne, v, _, I, R, A), S++ } } else if (S > j) for (; S <= L;)de(c[S], v, _, !0), S++; else { const K = S, ne = S, he = new Map; for (S = ne; S <= j; S++) { const De = h[S] = A ? Yt(h[S]) : At(h[S]); De.key != null && he.set(De.key, S) } let ie, ke = 0; const $e = j - ne + 1; let ot = !1, lt = 0; const Bt = new Array($e); for (S = 0; S < $e; S++)Bt[S] = 0; for (S = K; S <= L; S++) { const De = c[S]; if (ke >= $e) { de(De, v, _, !0); continue } let Qe; if (De.key != null) Qe = he.get(De.key); else for (ie = ne; ie <= j; ie++)if (Bt[ie - ne] === 0 && ln(De, h[ie])) { Qe = ie; break } Qe === void 0 ? de(De, v, _, !0) : (Bt[Qe - ne] = S + 1, Qe >= lt ? lt = Qe : ot = !0, x(De, h[Qe], b, null, v, _, I, R, A), ke++) } const Jn = ot ? Xa(Bt) : mt; for (ie = Jn.length - 1, S = $e - 1; S >= 0; S--) { const De = ne + S, Qe = h[De], at = h[De + 1], Ht = De + 1 < U ? at.el || at.placeholder : k; Bt[S] === 0 ? x(null, Qe, b, Ht, v, _, I, R, A) : ot && (ie < 0 || S !== Jn[ie] ? B(Qe, b, Ht, 2) : ie--) } } }, B = (c, h, b, k, v = null) => { const { el: _, type: I, transition: R, children: A, shapeFlag: S } = c; if (S & 6) { B(c.component.subTree, h, b, k); return } if (S & 128) { c.suspense.move(h, b, k); return } if (S & 64) { I.move(c, h, b, Ce); return } if (I === He) { s(_, h, b); for (let L = 0; L < A.length; L++)B(A[L], h, b, k); s(c.anchor, h, b); return } if (I === mr) { Y(c, h, b); return } if (k !== 2 && S & 1 && R) if (k === 0) R.beforeEnter(_), s(_, h, b), rt(() => R.enter(_), v); else { const { leave: L, delayLeave: j, afterLeave: K } = R, ne = () => { c.ctx.isUnmounted ? r(_) : s(_, h, b) }, he = () => { L(_, () => { ne(), K && K() }) }; j ? j(_, ne, he) : he() } else s(_, h, b) }, de = (c, h, b, k = !1, v = !1) => { const { type: _, props: I, ref: R, children: A, dynamicChildren: S, shapeFlag: U, patchFlag: L, dirs: j, cacheIndex: K } = c; if (L === -2 && (v = !1), R != null && (It(), Bn(R, null, b, c, !0), Mt()), K != null && (h.renderCache[K] = void 0), U & 256) { h.ctx.deactivate(c); return } const ne = U & 1 && j, he = !Hn(c); let ie; if (he && (ie = I && I.onVnodeBeforeUnmount) && Rt(ie, h, c), U & 6) ge(c.component, b, k); else { if (U & 128) { c.suspense.unmount(b, k); return } ne && sn(c, null, h, "beforeUnmount"), U & 64 ? c.type.remove(c, h, b, Ce, k) : S && !S.hasOnce && (_ !== He || L > 0 && L & 64) ? nt(S, h, b, !1, !0) : (_ === He && L & 384 || !v && U & 16) && nt(A, h, b), k && ae(c) } (he && (ie = I && I.onVnodeUnmounted) || ne) && rt(() => { ie && Rt(ie, h, c), ne && sn(c, null, h, "unmounted") }, b) }, ae = c => { const { type: h, el: b, anchor: k, transition: v } = c; if (h === He) { ve(b, k); return } if (h === mr) { $(c); return } const _ = () => { r(b), v && !v.persisted && v.afterLeave && v.afterLeave() }; if (c.shapeFlag & 1 && v && !v.persisted) { const { leave: I, delayLeave: R } = v, A = () => I(b, _); R ? R(c.el, _, A) : A() } else _() }, ve = (c, h) => { let b; for (; c !== h;)b = g(c), r(c), c = b; r(h) }, ge = (c, h, b) => { const { bum: k, scope: v, job: _, subTree: I, um: R, m: A, a: S, parent: U, slots: { __: L } } = c; no(A), no(S), k && rs(k), U && Q(L) && L.forEach(j => { U.renderCache[j] = void 0 }), v.stop(), _ && (_.flags |= 8, de(I, c, h, b)), R && rt(R, h), rt(() => { c.isUnmounted = !0 }, h), h && h.pendingBranch && !h.isUnmounted && c.asyncDep && !c.asyncResolved && c.suspenseId === h.pendingId && (h.deps--, h.deps === 0 && h.resolve()) }, nt = (c, h, b, k = !1, v = !1, _ = 0) => { for (let I = _; I < c.length; I++)de(c[I], h, b, k, v) }, ye = c => { if (c.shapeFlag & 6) return ye(c.component.subTree); if (c.shapeFlag & 128) return c.suspense.next(); const h = g(c.anchor || c.el), b = h && h[Ia]; return b ? g(b) : h }; let ht = !1; const G = (c, h, b) => { c == null ? h._vnode && de(h._vnode, null, null, !0) : x(h._vnode || null, c, h, null, null, null, b), h._vnode = c, ht || (ht = !0, Mi(), Oi(), ht = !1) }, Ce = { p: x, um: de, m: B, r: ae, mt: Se, mc: ee, pc: pe, pbc: se, n: ye, o: e }; return { render: G, hydrate: void 0, createApp: Ha(G) } } function gr({ type: e, props: t }, n) { return n === "svg" && e === "foreignObject" || n === "mathml" && e === "annotation-xml" && t && t.encoding && t.encoding.includes("html") ? void 0 : n } function rn({ effect: e, job: t }, n) { n ? (e.flags |= 32, t.flags |= 4) : (e.flags &= -33, t.flags &= -5) } function Za(e, t) { return (!e || e && !e.pendingBranch) && t && !t.persisted } function eo(e, t, n = !1) { const s = e.children, r = t.children; if (Q(s) && Q(r)) for (let i = 0; i < s.length; i++) { const o = s[i]; let a = r[i]; a.shapeFlag & 1 && !a.dynamicChildren && ((a.patchFlag <= 0 || a.patchFlag === 32) && (a = r[i] = Yt(r[i]), a.el = o.el), !n && a.patchFlag !== -2 && eo(o, a)), a.type === _s && (a.el = o.el), a.type === Ye && !a.el && (a.el = o.el) } } function Xa(e) { const t = e.slice(), n = [0]; let s, r, i, o, a; const l = e.length; for (s = 0; s < l; s++) { const f = e[s]; if (f !== 0) { if (r = n[n.length - 1], e[r] < f) { t[s] = r, n.push(s); continue } for (i = 0, o = n.length - 1; i < o;)a = i + o >> 1, e[n[a]] < f ? i = a + 1 : o = a; f < e[n[i]] && (i > 0 && (t[s] = n[i - 1]), n[i] = s) } } for (i = n.length, o = n[i - 1]; i-- > 0;)n[i] = o, o = t[o]; return n } function to(e) { const t = e.subTree.component; if (t) return t.asyncDep && !t.asyncResolved ? t : to(t) } function no(e) { if (e) for (let t = 0; t < e.length; t++)e[t].flags |= 8 } const Qa = Symbol.for("v-scx"), Ja = () => za(Qa); function on(e, t, n) { return eu(e, t, n) } function eu(e, t, n = oe) { const { immediate: s, deep: r, flush: i, once: o } = n, a = bt({}, n), l = t && s || !t && i !== "post"; let f; if (qn) { if (i === "sync") { const y = Ja(); f = y.__watcherHandles || (y.__watcherHandles = []) } else if (!l) { const y = () => { }; return y.stop = Jt, y.resume = Jt, y.pause = Jt, y } } const u = Zt; a.call = (y, E, x) => Tt(y, u, E, x); let d = !1; i === "post" ? a.scheduler = y => { rt(y, u && u.suspense) } : i !== "sync" && (d = !0, a.scheduler = (y, E) => { E ? y() : or(y) }), a.augmentJob = y => { t && (y.flags |= 4), d && (y.flags |= 2, u && (y.id = u.uid, y.i = u)) }; const g = _a(e, t, a); return qn && (f ? f.push(g) : l && g()), g } const tu = (e, t) => t === "modelValue" || t === "model-value" ? e.modelModifiers : e[`${t}Modifiers`] || e[`${jt(t)}Modifiers`] || e[`${en(t)}Modifiers`]; function nu(e, t, ...n) { if (e.isUnmounted) return; const s = e.vnode.props || oe; let r = n; const i = t.startsWith("update:"), o = i && tu(s, t.slice(7)); o && (o.trim && (r = n.map(u => Pe(u) ? u.trim() : u)), o.number && (r = n.map(Vs))); let a, l = s[a = Us(t)] || s[a = Us(jt(t))]; !l && i && (l = s[a = Us(en(t))]), l && Tt(l, e, 6, r); const f = s[a + "Once"]; if (f) { if (!e.emitted) e.emitted = {}; else if (e.emitted[a]) return; e.emitted[a] = !0, Tt(f, e, 6, r) } } function su(e, t, n = !1) { const s = t.emitsCache, r = s.get(e); if (r !== void 0) return r; const i = e.emits; let o = {}; return i ? (Q(i) ? i.forEach(a => o[a] = null) : bt(o, i), Re(e) && s.set(e, o), o) : (Re(e) && s.set(e, null), null) } function vs(e, t) { return !e || !ts(t) ? !1 : (t = t.slice(2).replace(/Once$/, ""), me(e, t[0].toLowerCase() + t.slice(1)) || me(e, en(t)) || me(e, t)) } function Ed() { } function so(e) { const { type: t, vnode: n, proxy: s, withProxy: r, propsOptions: [i], slots: o, attrs: a, emit: l, render: f, renderCache: u, props: d, data: g, setupState: y, ctx: E, inheritAttrs: x } = e, M = bs(e); let m, H; try { if (n.shapeFlag & 4) { const $ = r || s, z = $; m = At(f.call(z, $, u, d, y, g, E)), H = a } else { const $ = t; m = At($.length > 1 ? $(d, { attrs: a, slots: o, emit: l }) : $(d, null)), H = t.props ? a : ru(a) } } catch ($) { jn.length = 0, gs($, e, 1), m = Oe(Ye) } let Y = m; if (H && x !== !1) { const $ = Object.keys(H), { shapeFlag: z } = Y; $.length && z & 7 && (i && $.some(Hs) && (H = iu(H, i)), Y = Kt(Y, H, !1, !0)) } return n.dirs && (Y = Kt(Y, null, !1, !0), Y.dirs = Y.dirs ? Y.dirs.concat(n.dirs) : n.dirs), n.transition && Fn(Y, n.transition), m = Y, bs(M), m } const ru = e => { let t; for (const n in e) (n === "class" || n === "style" || ts(n)) && ((t || (t = {}))[n] = e[n]); return t }, iu = (e, t) => { const n = {}; for (const s in e) (!Hs(s) || !(s.slice(9) in t)) && (n[s] = e[s]); return n }; function ou(e, t, n) { const { props: s, children: r, component: i } = e, { props: o, children: a, patchFlag: l } = t, f = i.emitsOptions; if (t.dirs || t.transition) return !0; if (n && l >= 0) { if (l & 1024) return !0; if (l & 16) return s ? ro(s, o, f) : !!o; if (l & 8) { const u = t.dynamicProps; for (let d = 0; d < u.length; d++) { const g = u[d]; if (o[g] !== s[g] && !vs(f, g)) return !0 } } } else return (r || a) && (!a || !a.$stable) ? !0 : s === o ? !1 : s ? o ? ro(s, o, f) : !0 : !!o; return !1 } function ro(e, t, n) { const s = Object.keys(t); if (s.length !== Object.keys(e).length) return !0; for (let r = 0; r < s.length; r++) { const i = s[r]; if (t[i] !== e[i] && !vs(n, i)) return !0 } return !1 } function lu({ vnode: e, parent: t }, n) { for (; t;) { const s = t.subTree; if (s.suspense && s.suspense.activeBranch === e && (s.el = e.el), s === e) (e = t.vnode).el = n, t = t.parent; else break } } const io = e => e.__isSuspense; function au(e, t) { t && t.pendingBranch ? Q(e) ? t.effects.push(...e) : t.effects.push(e) : Ca(e) } const He = Symbol.for("v-fgt"), _s = Symbol.for("v-txt"), Ye = Symbol.for("v-cmt"), mr = Symbol.for("v-stc"), jn = []; let it = null; function F(e = !1) { jn.push(it = e ? null : []) } function uu() { jn.pop(), it = jn[jn.length - 1] || null } let Vn = 1; function oo(e, t = !1) { Vn += e, e < 0 && it && t && (it.hasOnce = !0) } function lo(e) { return e.dynamicChildren = Vn > 0 ? it || mt : null, uu(), Vn > 0 && it && it.push(e), e } function W(e, t, n, s, r, i) { return lo(w(e, t, n, s, r, i, !0)) } function Et(e, t, n, s, r) { return lo(Oe(e, t, n, s, r, !0)) } function Ts(e) { return e ? e.__v_isVNode === !0 : !1 } function ln(e, t) { return e.type === t.type && e.key === t.key } const ao = ({ key: e }) => e != null ? e : null, ks = ({ ref: e, ref_key: t, ref_for: n }) => (typeof e == "number" && (e = "" + e), e != null ? Pe(e) || Ve(e) || be(e) ? { i: ct, r: e, k: t, f: !!n } : e : null); function w(e, t = null, n = null, s = 0, r = null, i = e === He ? 0 : 1, o = !1, a = !1) { const l = { __v_isVNode: !0, __v_skip: !0, type: e, props: t, key: t && ao(t), ref: t && ks(t), scopeId: $i, slotScopeIds: null, children: n, component: null, suspense: null, ssContent: null, ssFallback: null, dirs: null, transition: null, el: null, anchor: null, target: null, targetStart: null, targetAnchor: null, staticCount: 0, shapeFlag: i, patchFlag: s, dynamicProps: r, dynamicChildren: null, appContext: null, ctx: ct }; return a ? (br(l, n), i & 128 && e.normalize(l)) : n && (l.shapeFlag |= Pe(n) ? 8 : 16), Vn > 0 && !o && it && (l.patchFlag > 0 || i & 6) && l.patchFlag !== 32 && it.push(l), l } const Oe = cu; function cu(e, t = null, n = null, s = 0, r = null, i = !1) { if ((!e || e === Na) && (e = Ye), Ts(e)) { const a = Kt(e, t, !0); return n && br(a, n), Vn > 0 && !i && it && (a.shapeFlag & 6 ? it[it.indexOf(e)] = a : it.push(a)), a.patchFlag = -2, a } if (Tu(e) && (e = e.__vccOpts), t) { t = fu(t); let { class: a, style: l } = t; a && !Pe(a) && (t.class = we(a)), Re(l) && (rr(l) && !Q(l) && (l = bt({}, l)), t.style = qs(l)) } const o = Pe(e) ? 1 : io(e) ? 128 : Ni(e) ? 64 : Re(e) ? 4 : be(e) ? 2 : 0; return w(e, t, n, s, r, o, i, !0) } function fu(e) { return e ? rr(e) || Ki(e) ? bt({}, e) : e : null } function Kt(e, t, n = !1, s = !1) { const { props: r, ref: i, patchFlag: o, children: a, transition: l } = e, f = t ? pu(r || {}, t) : r, u = { __v_isVNode: !0, __v_skip: !0, type: e.type, props: f, key: f && ao(f), ref: t && t.ref ? n && i ? Q(i) ? i.concat(ks(t)) : [i, ks(t)] : ks(t) : i, scopeId: e.scopeId, slotScopeIds: e.slotScopeIds, children: a, target: e.target, targetStart: e.targetStart, targetAnchor: e.targetAnchor, staticCount: e.staticCount, shapeFlag: e.shapeFlag, patchFlag: t && e.type !== He ? o === -1 ? 16 : o | 16 : o, dynamicProps: e.dynamicProps, dynamicChildren: e.dynamicChildren, appContext: e.appContext, dirs: e.dirs, transition: l, component: e.component, suspense: e.suspense, ssContent: e.ssContent && Kt(e.ssContent), ssFallback: e.ssFallback && Kt(e.ssFallback), placeholder: e.placeholder, el: e.el, anchor: e.anchor, ctx: e.ctx, ce: e.ce }; return l && s && Fn(u, l.clone(u)), u } function Ss(e = " ", t = 0) { return Oe(_s, null, e, t) } function qe(e = "", t = !1) { return t ? (F(), Et(Ye, null, e)) : Oe(Ye, null, e) } function At(e) { return e == null || typeof e == "boolean" ? Oe(Ye) : Q(e) ? Oe(He, null, e.slice()) : Ts(e) ? Yt(e) : Oe(_s, null, String(e)) } function Yt(e) { return e.el === null && e.patchFlag !== -1 || e.memo ? e : Kt(e) } function br(e, t) { let n = 0; const { shapeFlag: s } = e; if (t == null) t = null; else if (Q(t)) n = 16; else if (typeof t == "object") if (s & 65) { const r = t.default; r && (r._c && (r._d = !1), br(e, r()), r._c && (r._d = !0)); return } else { n = 32; const r = t._; !r && !Ki(t) ? t._ctx = ct : r === 3 && ct && (ct.slots._ === 1 ? t._ = 1 : (t._ = 2, e.patchFlag |= 1024)) } else be(t) ? (t = { default: t, _ctx: ct }, n = 32) : (t = String(t), s & 64 ? (n = 16, t = [Ss(t)]) : n = 8); e.children = t, e.shapeFlag |= n } function pu(...e) { const t = {}; for (let n = 0; n < e.length; n++) { const s = e[n]; for (const r in s) if (r === "class") t.class !== s.class && (t.class = we([t.class, s.class])); else if (r === "style") t.style = qs([t.style, s.style]); else if (ts(r)) { const i = t[r], o = s[r]; o && i !== o && !(Q(i) && i.includes(o)) && (t[r] = i ? [].concat(i, o) : o) } else r !== "" && (t[r] = s[r]) } return t } function Rt(e, t, n, s = null) { Tt(e, t, 7, [n, s]) } const du = qi(); let hu = 0; function gu(e, t, n) { const s = e.type, r = (t ? t.appContext : e.appContext) || du, i = { uid: hu++, vnode: e, type: s, parent: t, appContext: r, root: null, next: null, subTree: null, effect: null, update: null, job: null, scope: new Gl(!0), render: null, proxy: null, exposed: null, exposeProxy: null, withProxy: null, provides: t ? t.provides : Object.create(r.provides), ids: t ? t.ids : ["", 0, 0], accessCache: null, renderCache: [], components: null, directives: null, propsOptions: Va(s, r), emitsOptions: su(s, r), emit: null, emitted: null, propsDefaults: oe, inheritAttrs: s.inheritAttrs, ctx: oe, data: oe, props: oe, attrs: oe, slots: oe, refs: oe, setupState: oe, setupContext: null, suspense: n, suspenseId: n ? n.pendingId : 0, asyncDep: null, asyncResolved: !1, isMounted: !1, isUnmounted: !1, isDeactivated: !1, bc: null, c: null, bm: null, m: null, bu: null, u: null, um: null, bum: null, da: null, a: null, rtg: null, rtc: null, ec: null, sp: null }; return i.ctx = { _: i }, i.root = t ? t.root : i, i.emit = nu.bind(null, i), e.ce && e.ce(i), i } let Zt = null; const uo = () => Zt || ct; let Es, xr; { const e = is(), t = (n, s) => { let r; return (r = e[n]) || (r = e[n] = []), r.push(s), i => { r.length > 1 ? r.forEach(o => o(i)) : r[0](i) } }; Es = t("__VUE_INSTANCE_SETTERS__", n => Zt = n), xr = t("__VUE_SSR_SETTERS__", n => qn = n) } const yr = e => { const t = Zt; return Es(e), e.scope.on(), () => { e.scope.off(), Es(t) } }, co = () => { Zt && Zt.scope.off(), Es(null) }; function fo(e) { return e.vnode.shapeFlag & 4 } let qn = !1; function mu(e, t = !1, n = !1) { t && xr(t); const { props: s, children: r } = e.vnode, i = fo(e); Ua(e, s, i, t), Wa(e, r, n || t); const o = i ? bu(e, t) : void 0; return t && xr(!1), o } function bu(e, t) { const n = e.type; e.accessCache = Object.create(null), e.proxy = new Proxy(e.ctx, Fa); const { setup: s } = n; if (s) { It(); const r = e.setupContext = s.length > 1 ? yu(e) : null, i = yr(e), o = bn(s, e, 0, [e.props, r]), a = ti(o); if (Mt(), i(), (a || e.sp) && !Hn(e) && $a(e), a) { if (o.then(co, co), t) return o.then(l => { po(e, l) }).catch(l => { gs(l, e, 0) }); e.asyncDep = o } else po(e, o) } else ho(e) } function po(e, t, n) { be(t) ? e.type.__ssrInlineRender ? e.ssrRender = t : e.render = t : Re(t) && (e.setupState = Ri(t)), ho(e) } function ho(e, t, n) { const s = e.type; e.render || (e.render = s.render || Jt) } const xu = { get(e, t) { return je(e, "get", ""), e[t] } }; function yu(e) { const t = n => { e.exposed = n || {} }; return { attrs: new Proxy(e.attrs, xu), slots: e.slots, emit: e.emit, expose: t } } function As(e) { return e.exposed ? e.exposeProxy || (e.exposeProxy = new Proxy(Ri(ha(e.exposed)), { get(t, n) { if (n in t) return t[n]; if (n in Un) return Un[n](e) }, has(t, n) { return n in t || n in Un } })) : e.proxy } const wu = /(?:^|[-_])(\w)/g, vu = e => e.replace(wu, t => t.toUpperCase()).replace(/[-_]/g, ""); function _u(e, t = !0) { return be(e) ? e.displayName || e.name : e.name || t && e.__name } function go(e, t, n = !1) { let s = _u(t); if (!s && t.__file) { const r = t.__file.match(/([^/\\]+)\.\w+$/); r && (s = r[1]) } if (!s && e && e.parent) { const r = i => { for (const o in i) if (i[o] === t) return o }; s = r(e.components || e.parent.type.components) || r(e.appContext.components) } return s ? vu(s) : n ? "App" : "Anonymous" } function Tu(e) { return be(e) && "__vccOpts" in e } const Ee = (e, t) => wa(e, t, qn); function ku(e, t, n) { const s = arguments.length; return s === 2 ? Re(t) && !Q(t) ? Ts(t) ? Oe(e, null, [t]) : Oe(e, t) : Oe(e, null, t) : (s > 3 ? n = Array.prototype.slice.call(arguments, 2) : s === 3 && Ts(n) && (n = [n]), Oe(e, t, n)) } const Su = "3.5.18"; let wr; const mo = typeof window != "undefined" && window.trustedTypes; if (mo) try { wr = mo.createPolicy("vue", { createHTML: e => e }) } catch { } const bo = wr ? e => wr.createHTML(e) : e => e, Eu = "http://www.w3.org/2000/svg", Au = "http://www.w3.org/1998/Math/MathML", Dt = typeof document != "undefined" ? document : null, xo = Dt && Dt.createElement("template"), Ru = { insert: (e, t, n) => { t.insertBefore(e, n || null) }, remove: e => { const t = e.parentNode; t && t.removeChild(e) }, createElement: (e, t, n, s) => { const r = t === "svg" ? Dt.createElementNS(Eu, e) : t === "mathml" ? Dt.createElementNS(Au, e) : n ? Dt.createElement(e, { is: n }) : Dt.createElement(e); return e === "select" && s && s.multiple != null && r.setAttribute("multiple", s.multiple), r }, createText: e => Dt.createTextNode(e), createComment: e => Dt.createComment(e), setText: (e, t) => { e.nodeValue = t }, setElementText: (e, t) => { e.textContent = t }, parentNode: e => e.parentNode, nextSibling: e => e.nextSibling, querySelector: e => Dt.querySelector(e), setScopeId(e, t) { e.setAttribute(t, "") }, insertStaticContent(e, t, n, s, r, i) { const o = n ? n.previousSibling : t.lastChild; if (r && (r === i || r.nextSibling)) for (; t.insertBefore(r.cloneNode(!0), n), !(r === i || !(r = r.nextSibling));); else { xo.innerHTML = bo(s === "svg" ? `${e}` : s === "mathml" ? `${e}` : e); const a = xo.content; if (s === "svg" || s === "mathml") { const l = a.firstChild; for (; l.firstChild;)a.appendChild(l.firstChild); a.removeChild(l) } t.insertBefore(a, n) } return [o ? o.nextSibling : t.firstChild, n ? n.previousSibling : t.lastChild] } }, Xt = "transition", Wn = "animation", Gn = Symbol("_vtc"), yo = { name: String, type: String, css: { type: Boolean, default: !0 }, duration: [String, Number, Object], enterFromClass: String, enterActiveClass: String, enterToClass: String, appearFromClass: String, appearActiveClass: String, appearToClass: String, leaveFromClass: String, leaveActiveClass: String, leaveToClass: String }, Cu = bt({}, Fi, yo), Pu = (e => (e.displayName = "Transition", e.props = Cu, e))((e, { slots: t }) => ku(La, Iu(e), t)), an = (e, t = []) => { Q(e) ? e.forEach(n => n(...t)) : e && e(...t) }, wo = e => e ? Q(e) ? e.some(t => t.length > 1) : e.length > 1 : !1; function Iu(e) { const t = {}; for (const D in e) D in yo || (t[D] = e[D]); if (e.css === !1) return t; const { name: n = "v", type: s, duration: r, enterFromClass: i = `${n}-enter-from`, enterActiveClass: o = `${n}-enter-active`, enterToClass: a = `${n}-enter-to`, appearFromClass: l = i, appearActiveClass: f = o, appearToClass: u = a, leaveFromClass: d = `${n}-leave-from`, leaveActiveClass: g = `${n}-leave-active`, leaveToClass: y = `${n}-leave-to` } = e, E = Mu(r), x = E && E[0], M = E && E[1], { onBeforeEnter: m, onEnter: H, onEnterCancelled: Y, onLeave: $, onLeaveCancelled: z, onBeforeAppear: O = m, onAppear: P = H, onAppearCancelled: ee = Y } = t, V = (D, Z, Se, Ue) => { D._enterCancelled = Ue, un(D, Z ? u : a), un(D, Z ? f : o), Se && Se() }, se = (D, Z) => { D._isLeaving = !1, un(D, d), un(D, y), un(D, g), Z && Z() }, fe = D => (Z, Se) => { const Ue = D ? P : H, te = () => V(Z, D, Se); an(Ue, [Z, te]), vo(() => { un(Z, D ? l : i), Nt(Z, D ? u : a), wo(Ue) || _o(Z, s, x, te) }) }; return bt(t, { onBeforeEnter(D) { an(m, [D]), Nt(D, i), Nt(D, o) }, onBeforeAppear(D) { an(O, [D]), Nt(D, l), Nt(D, f) }, onEnter: fe(!1), onAppear: fe(!0), onLeave(D, Z) { D._isLeaving = !0; const Se = () => se(D, Z); Nt(D, d), D._enterCancelled ? (Nt(D, g), So()) : (So(), Nt(D, g)), vo(() => { D._isLeaving && (un(D, d), Nt(D, y), wo($) || _o(D, s, M, Se)) }), an($, [D, Se]) }, onEnterCancelled(D) { V(D, !1, void 0, !0), an(Y, [D]) }, onAppearCancelled(D) { V(D, !0, void 0, !0), an(ee, [D]) }, onLeaveCancelled(D) { se(D), an(z, [D]) } }) } function Mu(e) { if (e == null) return null; if (Re(e)) return [vr(e.enter), vr(e.leave)]; { const t = vr(e); return [t, t] } } function vr(e) { return zl(e) } function Nt(e, t) { t.split(/\s+/).forEach(n => n && e.classList.add(n)), (e[Gn] || (e[Gn] = new Set)).add(t) } function un(e, t) { t.split(/\s+/).forEach(s => s && e.classList.remove(s)); const n = e[Gn]; n && (n.delete(t), n.size || (e[Gn] = void 0)) } function vo(e) { requestAnimationFrame(() => { requestAnimationFrame(e) }) } let Ou = 0; function _o(e, t, n, s) { const r = e._endId = ++Ou, i = () => { r === e._endId && s() }; if (n != null) return setTimeout(i, n); const { type: o, timeout: a, propCount: l } = Lu(e, t); if (!o) return s(); const f = o + "end"; let u = 0; const d = () => { e.removeEventListener(f, g), i() }, g = y => { y.target === e && ++u >= l && d() }; setTimeout(() => { u < l && d() }, a + 1), e.addEventListener(f, g) } function Lu(e, t) { const n = window.getComputedStyle(e), s = E => (n[E] || "").split(", "), r = s(`${Xt}Delay`), i = s(`${Xt}Duration`), o = To(r, i), a = s(`${Wn}Delay`), l = s(`${Wn}Duration`), f = To(a, l); let u = null, d = 0, g = 0; t === Xt ? o > 0 && (u = Xt, d = o, g = i.length) : t === Wn ? f > 0 && (u = Wn, d = f, g = l.length) : (d = Math.max(o, f), u = d > 0 ? o > f ? Xt : Wn : null, g = u ? u === Xt ? i.length : l.length : 0); const y = u === Xt && /\b(transform|all)(,|$)/.test(s(`${Xt}Property`).toString()); return { type: u, timeout: d, propCount: g, hasTransform: y } } function To(e, t) { for (; e.length < t.length;)e = e.concat(e); return Math.max(...t.map((n, s) => ko(n) + ko(e[s]))) } function ko(e) { return e === "auto" ? 0 : Number(e.slice(0, -1).replace(",", ".")) * 1e3 } function So() { return document.body.offsetHeight } function $u(e, t, n) { const s = e[Gn]; s && (t = (t ? [t, ...s] : [...s]).join(" ")), t == null ? e.removeAttribute("class") : n ? e.setAttribute("class", t) : e.className = t } const Eo = Symbol("_vod"), Du = Symbol("_vsh"), Nu = Symbol(""), Fu = /(^|;)\s*display\s*:/; function Bu(e, t, n) { const s = e.style, r = Pe(n); let i = !1; if (n && !r) { if (t) if (Pe(t)) for (const o of t.split(";")) { const a = o.slice(0, o.indexOf(":")).trim(); n[a] == null && Rs(s, a, "") } else for (const o in t) n[o] == null && Rs(s, o, ""); for (const o in n) o === "display" && (i = !0), Rs(s, o, n[o]) } else if (r) { if (t !== n) { const o = s[Nu]; o && (n += ";" + o), s.cssText = n, i = Fu.test(n) } } else t && e.removeAttribute("style"); Eo in e && (e[Eo] = i ? s.display : "", e[Du] && (s.display = "none")) } const Ao = /\s*!important$/; function Rs(e, t, n) { if (Q(n)) n.forEach(s => Rs(e, t, s)); else if (n == null && (n = ""), t.startsWith("--")) e.setProperty(t, n); else { const s = Hu(e, t); Ao.test(n) ? e.setProperty(en(s), n.replace(Ao, ""), "important") : e[s] = n } } const Ro = ["Webkit", "Moz", "ms"], _r = {}; function Hu(e, t) { const n = _r[t]; if (n) return n; let s = jt(t); if (s !== "filter" && s in e) return _r[t] = s; s = ri(s); for (let r = 0; r < Ro.length; r++) { const i = Ro[r] + s; if (i in e) return _r[t] = i } return t } const Co = "http://www.w3.org/1999/xlink"; function Po(e, t, n, s, r, i = Wl(t)) { s && t.startsWith("xlink:") ? n == null ? e.removeAttributeNS(Co, t.slice(6, t.length)) : e.setAttributeNS(Co, t, n) : n == null || i && !oi(n) ? e.removeAttribute(t) : e.setAttribute(t, i ? "" : Ut(n) ? String(n) : n) } function Io(e, t, n, s, r) { if (t === "innerHTML" || t === "textContent") { n != null && (e[t] = t === "innerHTML" ? bo(n) : n); return } const i = e.tagName; if (t === "value" && i !== "PROGRESS" && !i.includes("-")) { const a = i === "OPTION" ? e.getAttribute("value") || "" : e.value, l = n == null ? e.type === "checkbox" ? "on" : "" : String(n); (a !== l || !("_value" in e)) && (e.value = l), n == null && e.removeAttribute(t), e._value = n; return } let o = !1; if (n === "" || n == null) { const a = typeof e[t]; a === "boolean" ? n = oi(n) : n == null && a === "string" ? (n = "", o = !0) : a === "number" && (n = 0, o = !0) } try { e[t] = n } catch { } o && e.removeAttribute(r || t) } function vn(e, t, n, s) { e.addEventListener(t, n, s) } function zu(e, t, n, s) { e.removeEventListener(t, n, s) } const Mo = Symbol("_vei"); function Uu(e, t, n, s, r = null) { const i = e[Mo] || (e[Mo] = {}), o = i[t]; if (s && o) o.value = s; else { const [a, l] = ju(t); if (s) { const f = i[t] = Wu(s, r); vn(e, a, f, l) } else o && (zu(e, a, o, l), i[t] = void 0) } } const Oo = /(?:Once|Passive|Capture)$/; function ju(e) { let t; if (Oo.test(e)) { t = {}; let s; for (; s = e.match(Oo);)e = e.slice(0, e.length - s[0].length), t[s[0].toLowerCase()] = !0 } return [e[2] === ":" ? e.slice(3) : en(e.slice(2)), t] } let Tr = 0; const Vu = Promise.resolve(), qu = () => Tr || (Vu.then(() => Tr = 0), Tr = Date.now()); function Wu(e, t) { const n = s => { if (!s._vts) s._vts = Date.now(); else if (s._vts <= n.attached) return; Tt(Gu(s, n.value), t, 5, [s]) }; return n.value = e, n.attached = qu(), n } function Gu(e, t) { if (Q(t)) { const n = e.stopImmediatePropagation; return e.stopImmediatePropagation = () => { n.call(e), e._stopped = !0 }, t.map(s => r => !r._stopped && s && s(r)) } else return t } const Lo = e => e.charCodeAt(0) === 111 && e.charCodeAt(1) === 110 && e.charCodeAt(2) > 96 && e.charCodeAt(2) < 123, Ku = (e, t, n, s, r, i) => { const o = r === "svg"; t === "class" ? $u(e, s, o) : t === "style" ? Bu(e, n, s) : ts(t) ? Hs(t) || Uu(e, t, n, s, i) : (t[0] === "." ? (t = t.slice(1), !0) : t[0] === "^" ? (t = t.slice(1), !1) : Yu(e, t, s, o)) ? (Io(e, t, s), !e.tagName.includes("-") && (t === "value" || t === "checked" || t === "selected") && Po(e, t, s, o, i, t !== "value")) : e._isVueCE && (/[A-Z]/.test(t) || !Pe(s)) ? Io(e, jt(t), s, i, t) : (t === "true-value" ? e._trueValue = s : t === "false-value" && (e._falseValue = s), Po(e, t, s, o)) }; function Yu(e, t, n, s) { if (s) return !!(t === "innerHTML" || t === "textContent" || t in e && Lo(t) && be(n)); if (t === "spellcheck" || t === "draggable" || t === "translate" || t === "autocorrect" || t === "form" || t === "list" && e.tagName === "INPUT" || t === "type" && e.tagName === "TEXTAREA") return !1; if (t === "width" || t === "height") { const r = e.tagName; if (r === "IMG" || r === "VIDEO" || r === "CANVAS" || r === "SOURCE") return !1 } return Lo(t) && Pe(n) ? !1 : t in e } const $o = e => { const t = e.props["onUpdate:modelValue"] || !1; return Q(t) ? n => rs(t, n) : t }; function Zu(e) { e.target.composing = !0 } function Do(e) { const t = e.target; t.composing && (t.composing = !1, t.dispatchEvent(new Event("input"))) } const kr = Symbol("_assign"), Xu = { created(e, { modifiers: { lazy: t, trim: n, number: s } }, r) { e[kr] = $o(r); const i = s || r.props && r.props.type === "number"; vn(e, t ? "change" : "input", o => { if (o.target.composing) return; let a = e.value; n && (a = a.trim()), i && (a = Vs(a)), e[kr](a) }), n && vn(e, "change", () => { e.value = e.value.trim() }), t || (vn(e, "compositionstart", Zu), vn(e, "compositionend", Do), vn(e, "change", Do)) }, mounted(e, { value: t }) { e.value = t == null ? "" : t }, beforeUpdate(e, { value: t, oldValue: n, modifiers: { lazy: s, trim: r, number: i } }, o) { if (e[kr] = $o(o), e.composing) return; const a = (i || e.type === "number") && !/^0\d/.test(e.value) ? Vs(e.value) : e.value, l = t == null ? "" : t; a !== l && (document.activeElement === e && e.type !== "range" && (s && t === n || r && e.value.trim() === l) || (e.value = l)) } }, Qu = ["ctrl", "shift", "alt", "meta"], Ju = { stop: e => e.stopPropagation(), prevent: e => e.preventDefault(), self: e => e.target !== e.currentTarget, ctrl: e => !e.ctrlKey, shift: e => !e.shiftKey, alt: e => !e.altKey, meta: e => !e.metaKey, left: e => "button" in e && e.button !== 0, middle: e => "button" in e && e.button !== 1, right: e => "button" in e && e.button !== 2, exact: (e, t) => Qu.some(n => e[`${n}Key`] && !t.includes(n)) }, pt = (e, t) => { const n = e._withMods || (e._withMods = {}), s = t.join("."); return n[s] || (n[s] = (r, ...i) => { for (let o = 0; o < t.length; o++) { const a = Ju[t[o]]; if (a && a(r, t)) return } return e(r, ...i) }) }, ec = bt({ patchProp: Ku }, Ru); let No; function tc() { return No || (No = Ka(ec)) } const nc = (...e) => { const t = tc().createApp(...e), { mount: n } = t; return t.mount = s => { const r = rc(s); if (!r) return; const i = t._component; !be(i) && !i.render && !i.template && (i.template = r.innerHTML), r.nodeType === 1 && (r.textContent = ""); const o = n(r, !1, sc(r)); return r instanceof Element && (r.removeAttribute("v-cloak"), r.setAttribute("data-v-app", "")), o }, t }; function sc(e) { if (e instanceof SVGElement) return "svg"; if (typeof MathMLElement == "function" && e instanceof MathMLElement) return "mathml" } function rc(e) { return Pe(e) ? document.querySelector(e) : e } const ic = ["aria-pressed"], oc = { key: 0, viewBox: "0 0 24 24", width: "20", height: "20", "aria-hidden": "true" }, lc = { key: 1, viewBox: "0 0 24 24", width: "18", height: "18", "aria-hidden": "true", fill: "none" }, ac = { __name: "ChatbotToggler", props: { isOpen: { type: Boolean, required: !0 } }, emits: ["toggle"], setup(e) { return (t, n) => (F(), W("button", { class: "fixed bottom-5 right-5 z-9999 grid h-12 w-12 appearance-none place-items-center rounded-full border border-white/20 bg-gradient-to-br from-brand-500 to-brand-600 text-white shadow-[0_20px_36px_-20px_rgba(109,79,194,0.85)] transition-all duration-250 hover:-translate-y-0.5 hover:from-brand-600 hover:to-violet-700 hover:shadow-[0_22px_40px_-22px_rgba(109,79,194,1)] focus:outline-none max-[600px]:bottom-3 max-[600px]:right-3 max-[600px]:h-13 max-[600px]:w-13", style: { "border-radius": "9999px" }, "aria-pressed": e.isOpen ? "true" : "false", onClick: n[0] || (n[0] = s => t.$emit("toggle")) }, [e.isOpen ? (F(), W("svg", lc, n[2] || (n[2] = [w("path", { d: "M6 6l12 12M18 6L6 18", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round" }, null, -1)]))) : (F(), W("svg", oc, n[1] || (n[1] = [w("path", { d: "M4 4h16a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H8l-4 4v-4H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z", fill: "currentColor", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "miter", "stroke-linejoin": "miter" }, null, -1)])))], 8, ic)) } }, uc = { class: "chat-header relative flex min-h-14 items-center justify-between px-4 pb-2.5 pt-3 text-white sm:px-5" }, cc = { class: "flex min-w-0 flex-1 items-center gap-2 sm:gap-2.5" }, fc = { xmlns: "http://www.w3.org/2000/svg", width: "35", height: "35", viewBox: "0 0 1024 1024", class: "h-8 w-8 shrink-0 rounded-full bg-white p-1.5 shadow-md motion-safe:animate-soft-float", style: { fill: "#6d4fc2" } }, pc = { class: "ml-2 flex items-center gap-1.5" }, dc = ["title"], hc = ["title", "aria-label"], gc = { key: 0, viewBox: "0 0 24 24", width: "14", height: "14", fill: "none", stroke: "currentColor", "stroke-width": "2", "aria-hidden": "true" }, mc = { key: 1, viewBox: "0 0 24 24", width: "14", height: "14", fill: "none", stroke: "currentColor", "stroke-width": "2", "aria-hidden": "true" }, bc = ["title", "aria-label"], xc = { key: 0, xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "aria-hidden": "true" }, yc = { key: 1, xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "aria-hidden": "true" }, wc = { key: 2, xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "aria-hidden": "true" }, vc = { __name: "ChatHeader", props: { windowMode: { type: String, required: !0 }, autoReadEnabled: { type: Boolean, required: !0 }, activeTtsProvider: { type: String, required: !0 } }, emits: ["close", "cycleResize", "toggleAutoRead"], setup(e) { const t = e, n = { default: "Compact", half: "Half Screen", full: "Full Screen" }, s = Ee(() => n[t.windowMode] || "Compact"), r = Ee(() => t.windowMode === "default" ? "Half Screen" : t.windowMode === "half" ? "Full Screen" : "Compact"), i = Ee(() => t.activeTtsProvider === "polly" ? "TTS: Polly" : t.activeTtsProvider === "browser" ? "TTS: Browser" : "TTS: Off"), o = Ee(() => t.activeTtsProvider === "polly" ? "bg-emerald-500/45" : t.activeTtsProvider === "browser" ? "bg-amber-500/45" : "bg-slate-500/35"); return (a, l) => (F(), W("div", uc, [w("div", cc, [(F(), W("svg", fc, l[3] || (l[3] = [w("path", { d: "M738.3 287.6H285.7c-59 0-106.8 47.8-106.8 106.8v303.1c0 59 47.8 106.8 106.8 106.8h81.5v111.1c0 .7.8 1.1 1.4.7l166.9-110.6 41.8-.8h117.4l43.6-.4c59 0 106.8-47.8 106.8-106.8V394.5c0-59-47.8-106.9-106.8-106.9zM351.7 448.2c0-29.5 23.9-53.5 53.5-53.5s53.5 23.9 53.5 53.5-23.9 53.5-53.5 53.5-53.5-23.9-53.5-53.5zm157.9 267.1c-67.8 0-123.8-47.5-132.3-109h264.6c-8.6 61.5-64.5 109-132.3 109zm110-213.7c-29.5 0-53.5-23.9-53.5-53.5s23.9-53.5 53.5-53.5 53.5 23.9 53.5 53.5-23.9 53.5-53.5 53.5zM867.2 644.5V453.1h26.5c19.4 0 35.1 15.7 35.1 35.1v121.1c0 19.4-15.7 35.1-35.1 35.1h-26.5zM95.2 609.4V488.2c0-19.4 15.7-35.1 35.1-35.1h26.5v191.3h-26.5c-19.4 0-35.1-15.7-35.1-35.1zM561.5 149.6c0 23.4-15.6 43.3-36.9 49.7v44.9h-30v-44.9c-21.4-6.5-36.9-26.3-36.9-49.7 0-28.6 23.3-51.9 51.9-51.9s51.9 23.3 51.9 51.9z" }, null, -1)]))), l[4] || (l[4] = w("h2", { class: "truncate text-xs font-semibold tracking-[0.01em] sm:text-base text-white/95" }, "ChangAI from ERPGulf", -1))]), w("div", pc, [w("span", { class: we(["hidden rounded-full border border-white/25 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-white/95 shadow-sm backdrop-blur-sm sm:inline", o.value]), title: `TTS provider: ${i.value}` }, Je(i.value), 11, dc), w("button", { class: we(["h-8 min-w-8 appearance-none items-center justify-center rounded-md border border-white/20 px-2 text-xs font-semibold text-white/90 transition-all duration-200 focus:outline-none sm:flex", e.autoReadEnabled ? "bg-white/24 shadow-sm" : "hover:bg-white/15"]), style: { "border-radius": "0.375rem" }, title: e.autoReadEnabled ? "Auto speech on" : "Auto speech off", "aria-label": e.autoReadEnabled ? "Turn off auto speech" : "Turn on auto speech", onClick: l[0] || (l[0] = f => a.$emit("toggleAutoRead")) }, [e.autoReadEnabled ? (F(), W("svg", gc, l[5] || (l[5] = [w("path", { d: "M11 5L6 9H3v6h3l5 4V5z" }, null, -1), w("path", { d: "M15 9a4 4 0 0 1 0 6" }, null, -1), w("path", { d: "M18 7a7 7 0 0 1 0 10" }, null, -1)]))) : (F(), W("svg", mc, l[6] || (l[6] = [w("path", { d: "M11 5L6 9H3v6h3l5 4V5z" }, null, -1), w("path", { d: "M22 9l-6 6" }, null, -1), w("path", { d: "M16 9l6 6" }, null, -1)])))], 10, hc), w("button", { class: we(["flex h-8 min-w-8 appearance-none items-center justify-center rounded-md border border-white/20 px-2 text-xs font-semibold text-white/90 transition-all duration-200 focus:outline-none", "bg-white/20 shadow-sm hover:bg-white/25"]), style: { "border-radius": "0.375rem" }, title: `Resize mode: ${s.value} (click to ${r.value})`, "aria-label": `Resize mode ${s.value}. Click to switch to ${r.value}`, onClick: l[1] || (l[1] = f => a.$emit("cycleResize")) }, [e.windowMode === "default" ? (F(), W("svg", xc, l[7] || (l[7] = [w("rect", { x: "7", y: "8", width: "10", height: "8", rx: "2" }, null, -1)]))) : e.windowMode === "half" ? (F(), W("svg", yc, l[8] || (l[8] = [w("rect", { x: "4", y: "5", width: "16", height: "14", rx: "2" }, null, -1), w("path", { d: "M12 5v14" }, null, -1)]))) : (F(), W("svg", wc, l[9] || (l[9] = [w("rect", { x: "4", y: "5", width: "16", height: "14", rx: "2" }, null, -1), w("path", { d: "M8 8H6v2M16 8h2v2M8 16H6v-2M16 16h2v-2" }, null, -1)])))], 8, bc), w("button", { class: "grid h-8 w-8 shrink-0 appearance-none place-items-center rounded-full border border-white/20 text-white transition-all duration-200 hover:scale-105 hover:bg-white/20 focus:outline-none focus-visible:ring-2 focus-visible:ring-white/70", style: { "border-radius": "9999px" }, "aria-label": "Close chatbot", onClick: l[2] || (l[2] = f => a.$emit("close")) }, l[10] || (l[10] = [w("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24", width: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, [w("path", { d: "M6 9l6 6 6-6" })], -1)]))])])) } }, _c = { class: "flex gap-1.5 border-b border-slate-200/80 px-2.5 pb-2.5 pt-1" }, Tc = ["onClick"], kc = { class: "inline-flex items-center gap-1.5" }, Sc = { __name: "TabBar", props: { modelValue: { type: String, required: !0 }, debugEnabled: { type: Boolean, default: !1 } }, emits: ["update:modelValue"], setup(e) { const t = e, n = Ee(() => { const s = [{ id: "chat", label: "Chats" }, { id: "debug", label: "Debug" }, { id: "support", label: "Support" }, { id: "settings", label: "Settings" }]; return t.debugEnabled ? s : s.filter(r => r.id !== "debug") }); return (s, r) => (F(), W("div", _c, [(F(!0), W(He, null, ws(n.value, i => (F(), W("button", { key: i.id, class: we(["group min-w-0 flex-1 h-9 appearance-none rounded-lg border border-transparent bg-transparent px-2 text-xs font-semibold transition-all duration-200 focus:outline-none", e.modelValue === i.id ? "border-white/30 bg-linear-to-r from-violet-300/36 via-indigo-300/30 to-sky-300/28 text-white shadow-[0_4px_10px_rgba(20,24,40,0.22)]" : "text-white/80 hover:border-white/25 hover:bg-white/12 hover:text-white"]), onClick: o => s.$emit("update:modelValue", i.id) }, [w("span", kc, [w("span", { class: we(["h-1.5 w-1.5 rounded-full transition-colors duration-200", e.modelValue === i.id ? "bg-white" : "bg-white/40 group-hover:bg-white/70"]) }, null, 2), Ss(" " + Je(i.label), 1)])], 10, Tc))), 128))])) } }, Ec = (e, t) => { const n = e.__vccOpts || e; for (const [s, r] of t) n[s] = r; return n }, Ac = {}, Rc = { xmlns: "http://www.w3.org/2000/svg", width: "50", height: "50", viewBox: "0 0 1024 1024", class: "h-7.5 w-7.5 shrink-0 self-end rounded-full bg-gradient-to-br from-brand-500 to-brand-600 p-1.5 fill-white shadow-[0_10px_18px_-12px_rgba(109,79,194,0.85)]" }; function Cc(e, t) { return F(), W("svg", Rc, t[0] || (t[0] = [w("path", { d: "M738.3 287.6H285.7c-59 0-106.8 47.8-106.8 106.8v303.1c0 59 47.8 106.8 106.8 106.8h81.5v111.1c0 .7.8 1.1 1.4.7l166.9-110.6 41.8-.8h117.4l43.6-.4c59 0 106.8-47.8 106.8-106.8V394.5c0-59-47.8-106.9-106.8-106.9zM351.7 448.2c0-29.5 23.9-53.5 53.5-53.5s53.5 23.9 53.5 53.5-23.9 53.5-53.5 53.5-53.5-23.9-53.5-53.5zm157.9 267.1c-67.8 0-123.8-47.5-132.3-109h264.6c-8.6 61.5-64.5 109-132.3 109zm110-213.7c-29.5 0-53.5-23.9-53.5-53.5s23.9-53.5 53.5-53.5 53.5 23.9 53.5 53.5-23.9 53.5-53.5 53.5zM867.2 644.5V453.1h26.5c19.4 0 35.1 15.7 35.1 35.1v121.1c0 19.4-15.7 35.1-35.1 35.1h-26.5zM95.2 609.4V488.2c0-19.4 15.7-35.1 35.1-35.1h26.5v191.3h-26.5c-19.4 0-35.1-15.7-35.1-35.1zM561.5 149.6c0 23.4-15.6 43.3-36.9 49.7v44.9h-30v-44.9c-21.4-6.5-36.9-26.3-36.9-49.7 0-28.6 23.3-51.9 51.9-51.9s51.9 23.3 51.9 51.9z" }, null, -1)])) } const Fo = Ec(Ac, [["render", Cc]]), Cs = { PIPELINE: "changai.changai.api.v2.text2sql_pipeline_v2.run_text2sql_pipeline", SUPPORT: "changai.changai.api.v2.helpdesk_api.support_bot", SETTINGS: "changai.changai.api.v2.schema_utils.get_frontend_settings", TTS: "changai.changai.api.v2.tts.synthesize_tts" }; function Bo(e, t = {}, n = "actual") { return n === "test" ? Promise.resolve({ Bot: `[TEST MODE] ${JSON.stringify(t)}` }) : !window.frappe || !window.frappe.call ? Promise.reject(new Error("Frappe API is unavailable in actual mode.")) : new Promise((s, r) => { window.frappe.call({ method: e, args: t, callback(i) { s(i.message) }, error(i) { r(i) } }) }) } function Pc(e, t, n = "actual", s = null, r) { if (n === "test") return { promise: Promise.resolve({ Bot: `[TEST MODE] ${JSON.stringify({ user_question: e, chat_id: t, request_id: s, sendNonErptoAI: r })}` }), cancel: () => !1 }; if (!window.frappe || !window.frappe.call) return { promise: Promise.reject(new Error("Frappe API is unavailable in actual mode.")), cancel: () => !1 }; let i = null, o = !1; return { promise: new Promise((f, u) => { i = window.frappe.call({ method: Cs.PIPELINE, args: { user_question: e, chat_id: t, request_id: s, sendNonErptoAI: r }, callback(d) { o = !0, f(d.message) }, error(d) { o = !0, u(d) } }) }), cancel: () => o || !i || typeof i.abort != "function" ? !1 : (i.abort(), o = !0, !0) } } function Ic(e, t = "actual") { if (t === "test") return { promise: Promise.resolve(`[TEST MODE] ${JSON.stringify({ message: e })}`), cancel: () => !1 }; if (!window.frappe || !window.frappe.call) return { promise: Promise.reject(new Error("Frappe API is unavailable in actual mode.")), cancel: () => !1 }; let n = null, s = !1; return { promise: new Promise((o, a) => { n = window.frappe.call({ method: Cs.SUPPORT, args: { message: e }, callback(l) { s = !0, o(l.message) }, error(l) { s = !0, a(l) } }) }), cancel: () => s || !n || typeof n.abort != "function" ? !1 : (n.abort(), s = !0, !0) } } function Mc(e = "actual") { return Bo(Cs.SETTINGS, {}, e) } function Oc(e, t = "Zayd", n = "actual") { return Bo(Cs.TTS, { text: e, voice_id: t }, n) } function Sr() { return { async: !1, breaks: !1, extensions: null, gfm: !0, hooks: null, pedantic: !1, renderer: null, silent: !1, tokenizer: null, walkTokens: null } } var cn = Sr(); function Ho(e) { cn = e } var fn = { exec: () => null }; function le(e, t = "") { let n = typeof e == "string" ? e : e.source, s = { replace: (r, i) => { let o = typeof i == "string" ? i : i.source; return o = o.replace(We.caret, "$1"), n = n.replace(r, o), s }, getRegex: () => new RegExp(n, t) }; return s } var Lc = ((e = "") => { try { return !!new RegExp("(?<=1)(?/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ xX]\]/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: e => new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: e => new RegExp(`^ {0,${Math.min(3, e - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), hrRegex: e => new RegExp(`^ {0,${Math.min(3, e - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), fencesBeginRegex: e => new RegExp(`^ {0,${Math.min(3, e - 1)}}(?:\`\`\`|~~~)`), headingBeginRegex: e => new RegExp(`^ {0,${Math.min(3, e - 1)}}#`), htmlBeginRegex: e => new RegExp(`^ {0,${Math.min(3, e - 1)}}<(?:[a-z].*>|!--)`, "i"), blockquoteBeginRegex: e => new RegExp(`^ {0,${Math.min(3, e - 1)}}>`) }, $c = /^(?:[ \t]*(?:\n|$))+/, Dc = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, Nc = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, Kn = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Fc = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, Er = / {0,3}(?:[*+-]|\d{1,9}[.)])/, zo = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, Uo = le(zo).replace(/bull/g, Er).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex(), Bc = le(zo).replace(/bull/g, Er).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(), Ar = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, Hc = /^[^\n]+/, Rr = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, zc = le(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", Rr).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Uc = le(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, Er).getRegex(), Ps = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul", Cr = /|$))/, jc = le("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", Cr).replace("tag", Ps).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), jo = le(Ar).replace("hr", Kn).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", ")|<(?:script|pre|style|textarea|!--)").replace("tag", Ps).getRegex(), Vc = le(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", jo).getRegex(), Pr = { blockquote: Vc, code: Dc, def: zc, fences: Nc, heading: Fc, hr: Kn, html: jc, lheading: Uo, list: Uc, newline: $c, paragraph: jo, table: fn, text: Hc }, Vo = le("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", Kn).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", ")|<(?:script|pre|style|textarea|!--)").replace("tag", Ps).getRegex(), qc = { ...Pr, lheading: Bc, table: Vo, paragraph: le(Ar).replace("hr", Kn).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", Vo).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", ")|<(?:script|pre|style|textarea|!--)").replace("tag", Ps).getRegex() }, Wc = { - ...Pr, html: le(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", Cr).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: fn, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: le(Ar).replace("hr", Kn).replace("heading", ` *#{1,6} *[^ -]`).replace("lheading", Uo).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() - }, Gc = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Kc = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, qo = /^( {2,}|\\)\n(?!\s*$)/, Yc = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\`+)[^`]+\k(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Lc ? "(?`+)[^`]+\k(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex(), Go = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/, ef = le(Go, "u").replace(/punct/g, _n).getRegex(), tf = le(Go, "u").replace(/punct/g, Wo).getRegex(), Ko = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", nf = le(Ko, "gu").replace(/notPunctSpace/g, Ir).replace(/punctSpace/g, Is).replace(/punct/g, _n).getRegex(), sf = le(Ko, "gu").replace(/notPunctSpace/g, Qc).replace(/punctSpace/g, Xc).replace(/punct/g, Wo).getRegex(), rf = le("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, Ir).replace(/punctSpace/g, Is).replace(/punct/g, _n).getRegex(), of = le(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, _n).getRegex(), lf = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)", af = le(lf, "gu").replace(/notPunctSpace/g, Ir).replace(/punctSpace/g, Is).replace(/punct/g, _n).getRegex(), uf = le(/\\(punct)/, "gu").replace(/punct/g, _n).getRegex(), cf = le(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(), ff = le(Cr).replace("(?:-->|$)", "-->").getRegex(), pf = le("^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^").replace("comment", ff).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), Ms = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/, df = le(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", Ms).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), Yo = le(/^!?\[(label)\]\[(ref)\]/).replace("label", Ms).replace("ref", Rr).getRegex(), Zo = le(/^!?\[(ref)\](?:\[\])?/).replace("ref", Rr).getRegex(), hf = le("reflink|nolink(?!\\()", "g").replace("reflink", Yo).replace("nolink", Zo).getRegex(), Xo = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/, Mr = { _backpedal: fn, anyPunctuation: uf, autolink: cf, blockSkip: Jc, br: qo, code: Kc, del: fn, delLDelim: fn, delRDelim: fn, emStrongLDelim: ef, emStrongRDelimAst: nf, emStrongRDelimUnd: rf, escape: Gc, link: df, nolink: Zo, punctuation: Zc, reflink: Yo, reflinkSearch: hf, tag: pf, text: Yc, url: fn }, gf = { ...Mr, link: le(/^!?\[(label)\]\((.*?)\)/).replace("label", Ms).getRegex(), reflink: le(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", Ms).getRegex() }, Or = { ...Mr, emStrongRDelimAst: sf, emStrongLDelim: tf, delLDelim: of, delRDelim: af, url: le(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", Xo).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: le(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\": ">", '"': """, "'": "'" }, Qo = e => bf[e]; function Ct(e, t) { if (t) { if (We.escapeTest.test(e)) return e.replace(We.escapeReplace, Qo) } else if (We.escapeTestNoEncode.test(e)) return e.replace(We.escapeReplaceNoEncode, Qo); return e } function Jo(e) { try { e = encodeURI(e).replace(We.percentDecode, "%") } catch { return null } return e } function el(e, t) { var i; let n = e.replace(We.findPipe, (o, a, l) => { let f = !1, u = a; for (; --u >= 0 && l[u] === "\\";)f = !f; return f ? "|" : " |" }), s = n.split(We.splitPipe), r = 0; if (s[0].trim() || s.shift(), s.length > 0 && !((i = s.at(-1)) != null && i.trim()) && s.pop(), t) if (s.length > t) s.splice(t); else for (; s.length < t;)s.push(""); for (; r < s.length; r++)s[r] = s[r].trim().replace(We.slashPipe, "|"); return s } function Qt(e, t, n) { let s = e.length; if (s === 0) return ""; let r = 0; for (; r < s && e.charAt(s - r - 1) === t;)r++; return e.slice(0, s - r) } function tl(e) { - let t = e.split(` -`), n = t.length - 1; for (; n >= 0 && We.blankLine.test(t[n]);)n--; return t.length - n <= 2 ? e : t.slice(0, n + 1).join(` -`) - } function xf(e, t) { if (e.indexOf(t[1]) === -1) return -1; let n = 0; for (let s = 0; s < e.length; s++)if (e[s] === "\\") s++; else if (e[s] === t[0]) n++; else if (e[s] === t[1] && (n--, n < 0)) return s; return n > 0 ? -2 : -1 } function yf(e, t = 0) { let n = t, s = ""; for (let r of e) if (r === " ") { let i = 4 - n % 4; s += " ".repeat(i), n += i } else s += r, n++; return s } function nl(e, t, n, s, r) { let i = t.href, o = t.title || null, a = e[1].replace(r.other.outputLinkReplace, "$1"); s.state.inLink = !0; let l = { type: e[0].charAt(0) === "!" ? "image" : "link", raw: n, href: i, title: o, text: a, tokens: s.inlineTokens(a) }; return s.state.inLink = !1, l } function wf(e, t, n) { - let s = e.match(n.other.indentCodeCompensation); if (s === null) return t; let r = s[1]; return t.split(` -`).map(i => { let o = i.match(n.other.beginningSpace); if (o === null) return i; let [a] = o; return a.length >= r.length ? i.slice(r.length) : i }).join(` -`) - } var Ls = class { - constructor(e) { _e(this, "options"); _e(this, "rules"); _e(this, "lexer"); this.options = e || cn } space(e) { let t = this.rules.block.newline.exec(e); if (t && t[0].length > 0) return { type: "space", raw: t[0] } } code(e) { let t = this.rules.block.code.exec(e); if (t) { let n = this.options.pedantic ? t[0] : tl(t[0]), s = n.replace(this.rules.other.codeRemoveIndent, ""); return { type: "code", raw: n, codeBlockStyle: "indented", text: s } } } fences(e) { let t = this.rules.block.fences.exec(e); if (t) { let n = t[0], s = wf(n, t[3] || "", this.rules); return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s } } } heading(e) { - let t = this.rules.block.heading.exec(e); if (t) { - let n = t[2].trim(); if (this.rules.other.endingHash.test(n)) { let s = Qt(n, "#"); (this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim()) } return { - type: "heading", raw: Qt(t[0], ` -`), depth: t[1].length, text: n, tokens: this.lexer.inline(n) - } - } - } hr(e) { - let t = this.rules.block.hr.exec(e); if (t) return { - type: "hr", raw: Qt(t[0], ` -`) - } - } blockquote(e) { - let t = this.rules.block.blockquote.exec(e); if (t) { - let n = Qt(t[0], ` +var vd=Object.defineProperty;var _d=(Pt,le,mt)=>le in Pt?vd(Pt,le,{enumerable:!0,configurable:!0,writable:!0,value:mt}):Pt[le]=mt;var ve=(Pt,le,mt)=>_d(Pt,typeof le!="symbol"?le+"":le,mt);(function(){"use strict";var Fs;function Pt(e){const t=Object.create(null);for(const n of e.split(","))t[n]=1;return n=>n in t}const le={},mt=[],Jt=()=>{},Do=()=>!1,ts=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),Hs=e=>e.startsWith("onUpdate:"),bt=Object.assign,Jr=(e,t)=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)},No=Object.prototype.hasOwnProperty,me=(e,t)=>No.call(e,t),Q=Array.isArray,hn=e=>ns(e)==="[object Map]",ei=e=>ns(e)==="[object Set]",be=e=>typeof e=="function",Ce=e=>typeof e=="string",Ut=e=>typeof e=="symbol",Re=e=>e!==null&&typeof e=="object",ti=e=>(Re(e)||be(e))&&be(e.then)&&be(e.catch),ni=Object.prototype.toString,ns=e=>ni.call(e),Fo=e=>ns(e).slice(8,-1),si=e=>ns(e)==="[object Object]",zs=e=>Ce(e)&&e!=="NaN"&&e[0]!=="-"&&""+parseInt(e,10)===e,Pn=Pt(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),ss=e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))},Bo=/-(\w)/g,jt=ss(e=>e.replace(Bo,(t,n)=>n?n.toUpperCase():"")),Ho=/\B([A-Z])/g,en=ss(e=>e.replace(Ho,"-$1").toLowerCase()),ri=ss(e=>e.charAt(0).toUpperCase()+e.slice(1)),Us=ss(e=>e?`on${ri(e)}`:""),Vt=(e,t)=>!Object.is(e,t),rs=(e,...t)=>{for(let n=0;n{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:s,value:n})},Vs=e=>{const t=parseFloat(e);return isNaN(t)?e:t},zo=e=>{const t=Ce(e)?Number(e):NaN;return isNaN(t)?e:t};let ii;const is=()=>ii||(ii=typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:typeof global!="undefined"?global:{});function qs(e){if(Q(e)){const t={};for(let n=0;n{if(n){const s=n.split(jo);s.length>1&&(t[s[0].trim()]=s[1].trim())}}),t}function we(e){let t="";if(Ce(e))t=e;else if(Q(e))for(let n=0;n!!(e&&e.__v_isRef===!0),et=e=>Ce(e)?e:e==null?"":Q(e)||Re(e)&&(e.toString===ni||!be(e.toString))?oi(e)?et(e.value):JSON.stringify(e,ai,2):String(e),ai=(e,t)=>oi(t)?ai(e,t.value):hn(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((n,[s,r],i)=>(n[Ws(s,i)+" =>"]=r,n),{})}:ei(t)?{[`Set(${t.size})`]:[...t.values()].map(n=>Ws(n))}:Ut(t)?Ws(t):Re(t)&&!Q(t)&&!si(t)?String(t):t,Ws=(e,t="")=>{var n;return Ut(e)?`Symbol(${(n=e.description)!=null?n:t})`:e};let tt;class Go{constructor(t=!1){this.detached=t,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.parent=tt,!t&&tt&&(this.index=(tt.scopes||(tt.scopes=[])).push(this)-1)}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let t,n;if(this.scopes)for(t=0,n=this.scopes.length;t0&&--this._on===0&&(tt=this.prevScope,this.prevScope=void 0)}stop(t){if(this._active){this._active=!1;let n,s;for(n=0,s=this.effects.length;n0)return;if(On){let t=On;for(On=void 0;t;){const n=t.next;t.next=void 0,t.flags&=-9,t=n}}let e;for(;In;){let t=In;for(In=void 0;t;){const n=t.next;if(t.next=void 0,t.flags&=-9,t.flags&1)try{t.trigger()}catch(s){e||(e=s)}t=n}}if(e)throw e}function pi(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function di(e){let t,n=e.depsTail,s=n;for(;s;){const r=s.prevDep;s.version===-1?(s===n&&(n=r),Xs(s),Yo(s)):t=s,s.dep.activeLink=s.prevActiveLink,s.prevActiveLink=void 0,s=r}e.deps=t,e.depsTail=n}function Zs(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(hi(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function hi(e){if(e.flags&4&&!(e.flags&16)||(e.flags&=-17,e.globalVersion===Mn)||(e.globalVersion=Mn,!e.isSSR&&e.flags&128&&(!e.deps&&!e._dirty||!Zs(e))))return;e.flags|=2;const t=e.dep,n=_e,s=xt;_e=e,xt=!0;try{pi(e);const r=e.fn(e._value);(t.version===0||Vt(r,e._value))&&(e.flags|=128,e._value=r,t.version++)}catch(r){throw t.version++,r}finally{_e=n,xt=s,di(e),e.flags&=-3}}function Xs(e,t=!1){const{dep:n,prevSub:s,nextSub:r}=e;if(s&&(s.nextSub=r,e.prevSub=void 0),r&&(r.prevSub=s,e.nextSub=void 0),n.subs===e&&(n.subs=s,!s&&n.computed)){n.computed.flags&=-5;for(let i=n.computed.deps;i;i=i.nextDep)Xs(i,!0)}!t&&!--n.sc&&n.map&&n.map.delete(n.key)}function Yo(e){const{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}let xt=!0;const gi=[];function It(){gi.push(xt),xt=!1}function Ot(){const e=gi.pop();xt=e===void 0?!0:e}function mi(e){const{cleanup:t}=e;if(e.cleanup=void 0,t){const n=_e;_e=void 0;try{t()}finally{_e=n}}}let Mn=0;class Zo{constructor(t,n){this.sub=t,this.dep=n,this.version=n.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class Qs{constructor(t){this.computed=t,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(t){if(!_e||!xt||_e===this.computed)return;let n=this.activeLink;if(n===void 0||n.sub!==_e)n=this.activeLink=new Zo(_e,this),_e.deps?(n.prevDep=_e.depsTail,_e.depsTail.nextDep=n,_e.depsTail=n):_e.deps=_e.depsTail=n,bi(n);else if(n.version===-1&&(n.version=this.version,n.nextDep)){const s=n.nextDep;s.prevDep=n.prevDep,n.prevDep&&(n.prevDep.nextDep=s),n.prevDep=_e.depsTail,n.nextDep=void 0,_e.depsTail.nextDep=n,_e.depsTail=n,_e.deps===n&&(_e.deps=s)}return n}trigger(t){this.version++,Mn++,this.notify(t)}notify(t){Ks();try{for(let n=this.subs;n;n=n.prevSub)n.sub.notify()&&n.sub.dep.notify()}finally{Ys()}}}function bi(e){if(e.dep.sc++,e.sub.flags&4){const t=e.dep.computed;if(t&&!e.dep.subs){t.flags|=20;for(let s=t.deps;s;s=s.nextDep)bi(s)}const n=e.dep.subs;n!==e&&(e.prevSub=n,n&&(n.nextSub=e)),e.dep.subs=e}}const Js=new WeakMap,tn=Symbol(""),er=Symbol(""),Ln=Symbol("");function Ve(e,t,n){if(xt&&_e){let s=Js.get(e);s||Js.set(e,s=new Map);let r=s.get(n);r||(s.set(n,r=new Qs),r.map=s,r.key=n),r.track()}}function Mt(e,t,n,s,r,i){const l=Js.get(e);if(!l){Mn++;return}const a=o=>{o&&o.trigger()};if(Ks(),t==="clear")l.forEach(a);else{const o=Q(e),c=o&&zs(n);if(o&&n==="length"){const u=Number(s);l.forEach((d,g)=>{(g==="length"||g===Ln||!Ut(g)&&g>=u)&&a(d)})}else switch((n!==void 0||l.has(void 0))&&a(l.get(n)),c&&a(l.get(Ln)),t){case"add":o?c&&a(l.get("length")):(a(l.get(tn)),hn(e)&&a(l.get(er)));break;case"delete":o||(a(l.get(tn)),hn(e)&&a(l.get(er)));break;case"set":hn(e)&&a(l.get(tn));break}}Ys()}function gn(e){const t=ae(e);return t===e?t:(Ve(t,"iterate",Ln),ct(e)?t:t.map(He))}function ls(e){return Ve(e=ae(e),"iterate",Ln),e}const Xo={__proto__:null,[Symbol.iterator](){return tr(this,Symbol.iterator,He)},concat(...e){return gn(this).concat(...e.map(t=>Q(t)?gn(t):t))},entries(){return tr(this,"entries",e=>(e[1]=He(e[1]),e))},every(e,t){return Lt(this,"every",e,t,void 0,arguments)},filter(e,t){return Lt(this,"filter",e,t,n=>n.map(He),arguments)},find(e,t){return Lt(this,"find",e,t,He,arguments)},findIndex(e,t){return Lt(this,"findIndex",e,t,void 0,arguments)},findLast(e,t){return Lt(this,"findLast",e,t,He,arguments)},findLastIndex(e,t){return Lt(this,"findLastIndex",e,t,void 0,arguments)},forEach(e,t){return Lt(this,"forEach",e,t,void 0,arguments)},includes(...e){return nr(this,"includes",e)},indexOf(...e){return nr(this,"indexOf",e)},join(e){return gn(this).join(e)},lastIndexOf(...e){return nr(this,"lastIndexOf",e)},map(e,t){return Lt(this,"map",e,t,void 0,arguments)},pop(){return $n(this,"pop")},push(...e){return $n(this,"push",e)},reduce(e,...t){return xi(this,"reduce",e,t)},reduceRight(e,...t){return xi(this,"reduceRight",e,t)},shift(){return $n(this,"shift")},some(e,t){return Lt(this,"some",e,t,void 0,arguments)},splice(...e){return $n(this,"splice",e)},toReversed(){return gn(this).toReversed()},toSorted(e){return gn(this).toSorted(e)},toSpliced(...e){return gn(this).toSpliced(...e)},unshift(...e){return $n(this,"unshift",e)},values(){return tr(this,"values",He)}};function tr(e,t,n){const s=ls(e),r=s[t]();return s!==e&&!ct(e)&&(r._next=r.next,r.next=()=>{const i=r._next();return i.value&&(i.value=n(i.value)),i}),r}const Qo=Array.prototype;function Lt(e,t,n,s,r,i){const l=ls(e),a=l!==e&&!ct(e),o=l[t];if(o!==Qo[t]){const d=o.apply(e,i);return a?He(d):d}let c=n;l!==e&&(a?c=function(d,g){return n.call(this,He(d),g,e)}:n.length>2&&(c=function(d,g){return n.call(this,d,g,e)}));const u=o.call(l,c,s);return a&&r?r(u):u}function xi(e,t,n,s){const r=ls(e);let i=n;return r!==e&&(ct(e)?n.length>3&&(i=function(l,a,o){return n.call(this,l,a,o,e)}):i=function(l,a,o){return n.call(this,l,He(a),o,e)}),r[t](i,...s)}function nr(e,t,n){const s=ae(e);Ve(s,"iterate",Ln);const r=s[t](...n);return(r===-1||r===!1)&&rr(n[0])?(n[0]=ae(n[0]),s[t](...n)):r}function $n(e,t,n=[]){It(),Ks();const s=ae(e)[t].apply(e,n);return Ys(),Ot(),s}const Jo=Pt("__proto__,__v_isRef,__isVue"),yi=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!=="arguments"&&e!=="caller").map(e=>Symbol[e]).filter(Ut));function ea(e){Ut(e)||(e=String(e));const t=ae(this);return Ve(t,"has",e),t.hasOwnProperty(e)}class wi{constructor(t=!1,n=!1){this._isReadonly=t,this._isShallow=n}get(t,n,s){if(n==="__v_skip")return t.__v_skip;const r=this._isReadonly,i=this._isShallow;if(n==="__v_isReactive")return!r;if(n==="__v_isReadonly")return r;if(n==="__v_isShallow")return i;if(n==="__v_raw")return s===(r?i?Ei:Si:i?ki:Ti).get(t)||Object.getPrototypeOf(t)===Object.getPrototypeOf(s)?t:void 0;const l=Q(t);if(!r){let o;if(l&&(o=Xo[n]))return o;if(n==="hasOwnProperty")return ea}const a=Reflect.get(t,n,qe(t)?t:s);return(Ut(n)?yi.has(n):Jo(n))||(r||Ve(t,"get",n),i)?a:qe(a)?l&&zs(n)?a:a.value:Re(a)?r?Ai(a):cs(a):a}}class vi extends wi{constructor(t=!1){super(!1,t)}set(t,n,s,r){let i=t[n];if(!this._isShallow){const o=qt(i);if(!ct(s)&&!qt(s)&&(i=ae(i),s=ae(s)),!Q(t)&&qe(i)&&!qe(s))return o?!1:(i.value=s,!0)}const l=Q(t)&&zs(n)?Number(n)e,os=e=>Reflect.getPrototypeOf(e);function ia(e,t,n){return function(...s){const r=this.__v_raw,i=ae(r),l=hn(i),a=e==="entries"||e===Symbol.iterator&&l,o=e==="keys"&&l,c=r[e](...s),u=n?sr:t?ps:He;return!t&&Ve(i,"iterate",o?er:tn),{next(){const{value:d,done:g}=c.next();return g?{value:d,done:g}:{value:a?[u(d[0]),u(d[1])]:u(d),done:g}},[Symbol.iterator](){return this}}}}function as(e){return function(...t){return e==="delete"?!1:e==="clear"?void 0:this}}function la(e,t){const n={get(r){const i=this.__v_raw,l=ae(i),a=ae(r);e||(Vt(r,a)&&Ve(l,"get",r),Ve(l,"get",a));const{has:o}=os(l),c=t?sr:e?ps:He;if(o.call(l,r))return c(i.get(r));if(o.call(l,a))return c(i.get(a));i!==l&&i.get(r)},get size(){const r=this.__v_raw;return!e&&Ve(ae(r),"iterate",tn),Reflect.get(r,"size",r)},has(r){const i=this.__v_raw,l=ae(i),a=ae(r);return e||(Vt(r,a)&&Ve(l,"has",r),Ve(l,"has",a)),r===a?i.has(r):i.has(r)||i.has(a)},forEach(r,i){const l=this,a=l.__v_raw,o=ae(a),c=t?sr:e?ps:He;return!e&&Ve(o,"iterate",tn),a.forEach((u,d)=>r.call(i,c(u),c(d),l))}};return bt(n,e?{add:as("add"),set:as("set"),delete:as("delete"),clear:as("clear")}:{add(r){!t&&!ct(r)&&!qt(r)&&(r=ae(r));const i=ae(this);return os(i).has.call(i,r)||(i.add(r),Mt(i,"add",r,r)),this},set(r,i){!t&&!ct(i)&&!qt(i)&&(i=ae(i));const l=ae(this),{has:a,get:o}=os(l);let c=a.call(l,r);c||(r=ae(r),c=a.call(l,r));const u=o.call(l,r);return l.set(r,i),c?Vt(i,u)&&Mt(l,"set",r,i):Mt(l,"add",r,i),this},delete(r){const i=ae(this),{has:l,get:a}=os(i);let o=l.call(i,r);o||(r=ae(r),o=l.call(i,r)),a&&a.call(i,r);const c=i.delete(r);return o&&Mt(i,"delete",r,void 0),c},clear(){const r=ae(this),i=r.size!==0,l=r.clear();return i&&Mt(r,"clear",void 0,void 0),l}}),["keys","values","entries",Symbol.iterator].forEach(r=>{n[r]=ia(r,e,t)}),n}function us(e,t){const n=la(e,t);return(s,r,i)=>r==="__v_isReactive"?!e:r==="__v_isReadonly"?e:r==="__v_raw"?s:Reflect.get(me(n,r)&&r in s?n:s,r,i)}const oa={get:us(!1,!1)},aa={get:us(!1,!0)},ua={get:us(!0,!1)},ca={get:us(!0,!0)},Ti=new WeakMap,ki=new WeakMap,Si=new WeakMap,Ei=new WeakMap;function fa(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function pa(e){return e.__v_skip||!Object.isExtensible(e)?0:fa(Fo(e))}function cs(e){return qt(e)?e:fs(e,!1,ta,oa,Ti)}function da(e){return fs(e,!1,sa,aa,ki)}function Ai(e){return fs(e,!0,na,ua,Si)}function kd(e){return fs(e,!0,ra,ca,Ei)}function fs(e,t,n,s,r){if(!Re(e)||e.__v_raw&&!(t&&e.__v_isReactive))return e;const i=pa(e);if(i===0)return e;const l=r.get(e);if(l)return l;const a=new Proxy(e,i===2?s:n);return r.set(e,a),a}function mn(e){return qt(e)?mn(e.__v_raw):!!(e&&e.__v_isReactive)}function qt(e){return!!(e&&e.__v_isReadonly)}function ct(e){return!!(e&&e.__v_isShallow)}function rr(e){return e?!!e.__v_raw:!1}function ae(e){const t=e&&e.__v_raw;return t?ae(t):e}function ha(e){return!me(e,"__v_skip")&&Object.isExtensible(e)&&js(e,"__v_skip",!0),e}const He=e=>Re(e)?cs(e):e,ps=e=>Re(e)?Ai(e):e;function qe(e){return e?e.__v_isRef===!0:!1}function J(e){return ga(e,!1)}function ga(e,t){return qe(e)?e:new ma(e,t)}class ma{constructor(t,n){this.dep=new Qs,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=n?t:ae(t),this._value=n?t:He(t),this.__v_isShallow=n}get value(){return this.dep.track(),this._value}set value(t){const n=this._rawValue,s=this.__v_isShallow||ct(t)||qt(t);t=s?t:ae(t),Vt(t,n)&&(this._rawValue=t,this._value=s?t:He(t),this.dep.trigger())}}function ba(e){return qe(e)?e.value:e}const xa={get:(e,t,n)=>t==="__v_raw"?e:ba(Reflect.get(e,t,n)),set:(e,t,n,s)=>{const r=e[t];return qe(r)&&!qe(n)?(r.value=n,!0):Reflect.set(e,t,n,s)}};function Ri(e){return mn(e)?e:new Proxy(e,xa)}class ya{constructor(t,n,s){this.fn=t,this.setter=n,this._value=void 0,this.dep=new Qs(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=Mn-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!n,this.isSSR=s}notify(){if(this.flags|=16,!(this.flags&8)&&_e!==this)return fi(this,!0),!0}get value(){const t=this.dep.track();return hi(this),t&&(t.version=this.dep.version),this._value}set value(t){this.setter&&this.setter(t)}}function wa(e,t,n=!1){let s,r;return be(e)?s=e:(s=e.get,r=e.set),new ya(s,r,n)}const ds={},hs=new WeakMap;let nn;function va(e,t=!1,n=nn){if(n){let s=hs.get(n);s||hs.set(n,s=[]),s.push(e)}}function _a(e,t,n=le){const{immediate:s,deep:r,once:i,scheduler:l,augmentJob:a,call:o}=n,c=$=>r?$:ct($)||r===!1||r===0?$t($,1):$t($);let u,d,g,y,E=!1,x=!1;if(qe(e)?(d=()=>e.value,E=ct(e)):mn(e)?(d=()=>c(e),E=!0):Q(e)?(x=!0,E=e.some($=>mn($)||ct($)),d=()=>e.map($=>{if(qe($))return $.value;if(mn($))return c($);if(be($))return o?o($,2):$()})):be(e)?t?d=o?()=>o(e,2):e:d=()=>{if(g){It();try{g()}finally{Ot()}}const $=nn;nn=u;try{return o?o(e,3,[y]):e(y)}finally{nn=$}}:d=Jt,t&&r){const $=d,U=r===!0?1/0:r;d=()=>$t($(),U)}const M=Ko(),m=()=>{u.stop(),M&&M.active&&Jr(M.effects,u)};if(i&&t){const $=t;t=(...U)=>{$(...U),m()}}let H=x?new Array(e.length).fill(ds):ds;const Y=$=>{if(!(!(u.flags&1)||!u.dirty&&!$))if(t){const U=u.run();if(r||E||(x?U.some((L,O)=>Vt(L,H[O])):Vt(U,H))){g&&g();const L=nn;nn=u;try{const O=[U,H===ds?void 0:x&&H[0]===ds?[]:H,y];H=U,o?o(t,3,O):t(...O)}finally{nn=L}}}else u.run()};return a&&a(Y),u=new ui(d),u.scheduler=l?()=>l(Y,!1):Y,y=$=>va($,!1,u),g=u.onStop=()=>{const $=hs.get(u);if($){if(o)o($,4);else for(const U of $)U();hs.delete(u)}},t?s?Y(!0):H=u.run():l?l(Y.bind(null,!0),!0):u.run(),m.pause=u.pause.bind(u),m.resume=u.resume.bind(u),m.stop=m,m}function $t(e,t=1/0,n){if(t<=0||!Re(e)||e.__v_skip||(n=n||new Set,n.has(e)))return e;if(n.add(e),t--,qe(e))$t(e.value,t,n);else if(Q(e))for(let s=0;s{$t(s,t,n)});else if(si(e)){for(const s in e)$t(e[s],t,n);for(const s of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,s)&&$t(e[s],t,n)}return e}const Dn=[];let ir=!1;function Sd(e,...t){if(ir)return;ir=!0,It();const n=Dn.length?Dn[Dn.length-1].component:null,s=n&&n.appContext.config.warnHandler,r=Ta();if(s)bn(s,n,11,[e+t.map(i=>{var l,a;return(a=(l=i.toString)==null?void 0:l.call(i))!=null?a:JSON.stringify(i)}).join(""),n&&n.proxy,r.map(({vnode:i})=>`at <${hl(n,i.type)}>`).join(` +`),r]);else{const i=[`[Vue warn]: ${e}`,...t];r.length&&i.push(` +`,...ka(r))}Ot(),ir=!1}function Ta(){let e=Dn[Dn.length-1];if(!e)return[];const t=[];for(;e;){const n=t[0];n&&n.vnode===e?n.recurseCount++:t.push({vnode:e,recurseCount:0});const s=e.component&&e.component.parent;e=s&&s.vnode}return t}function ka(e){const t=[];return e.forEach((n,s)=>{t.push(...s===0?[]:[` +`],...Sa(n))}),t}function Sa({vnode:e,recurseCount:t}){const n=t>0?`... (${t} recursive calls)`:"",s=e.component?e.component.parent==null:!1,r=` at <${hl(e.component,e.type,s)}`,i=">"+n;return e.props?[r,...Ea(e.props),i]:[r+i]}function Ea(e){const t=[],n=Object.keys(e);return n.slice(0,3).forEach(s=>{t.push(...Ci(s,e[s]))}),n.length>3&&t.push(" ..."),t}function Ci(e,t,n){return Ce(t)?(t=JSON.stringify(t),n?t:[`${e}=${t}`]):typeof t=="number"||typeof t=="boolean"||t==null?n?t:[`${e}=${t}`]:qe(t)?(t=Ci(e,ae(t.value),!0),n?t:[`${e}=Ref<`,t,">"]):be(t)?[`${e}=fn${t.name?`<${t.name}>`:""}`]:(t=ae(t),n?t:[`${e}=`,t])}function bn(e,t,n,s){try{return s?e(...s):e()}catch(r){gs(r,t,n)}}function Tt(e,t,n,s){if(be(e)){const r=bn(e,t,n,s);return r&&ti(r)&&r.catch(i=>{gs(i,t,n)}),r}if(Q(e)){const r=[];for(let i=0;i>>1,r=Ke[s],i=Nn(r);i=Nn(n)?Ke.push(e):Ke.splice(Ra(t),0,e),e.flags|=1,Ii()}}function Ii(){ms||(ms=Pi.then(Li))}function Ca(e){Q(e)?xn.push(...e):Wt&&e.id===-1?Wt.splice(yn+1,0,e):e.flags&1||(xn.push(e),e.flags|=1),Ii()}function Oi(e,t,n=kt+1){for(;nNn(n)-Nn(s));if(xn.length=0,Wt){Wt.push(...t);return}for(Wt=t,yn=0;yne.id==null?e.flags&2?-1:1/0:e.id;function Li(e){try{for(kt=0;kt{s._d&&ll(-1);const i=bs(t);let l;try{l=e(...r)}finally{bs(i),s._d&&ll(1)}return l};return s._n=!0,s._c=!0,s._d=!0,s}function Pa(e,t){if(ft===null)return e;const n=As(ft),s=e.dirs||(e.dirs=[]);for(let r=0;re.__isTeleport,Gt=Symbol("_leaveCb"),xs=Symbol("_enterCb");function Oa(){const e={isMounted:!1,isLeaving:!1,isUnmounting:!1,leavingVNodes:new Map};return zn(()=>{e.isMounted=!0}),ys(()=>{e.isUnmounting=!0}),e}const pt=[Function,Array],Fi={mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:pt,onEnter:pt,onAfterEnter:pt,onEnterCancelled:pt,onBeforeLeave:pt,onLeave:pt,onAfterLeave:pt,onLeaveCancelled:pt,onBeforeAppear:pt,onAppear:pt,onAfterAppear:pt,onAppearCancelled:pt},Bi=e=>{const t=e.subTree;return t.component?Bi(t.component):t},Ma={name:"BaseTransition",props:Fi,setup(e,{slots:t}){const n=ul(),s=Oa();return()=>{const r=t.default&&ji(t.default(),!0);if(!r||!r.length)return;const i=Hi(r),l=ae(e),{mode:a}=l;if(s.isLeaving)return ar(i);const o=Ui(i);if(!o)return ar(i);let c=or(o,l,s,n,d=>c=d);o.type!==Ye&&Fn(o,c);let u=n.subTree&&Ui(n.subTree);if(u&&u.type!==Ye&&!on(o,u)&&Bi(n).type!==Ye){let d=or(u,l,s,n);if(Fn(u,d),a==="out-in"&&o.type!==Ye)return s.isLeaving=!0,d.afterLeave=()=>{s.isLeaving=!1,n.job.flags&8||n.update(),delete d.afterLeave,u=void 0},ar(i);a==="in-out"&&o.type!==Ye?d.delayLeave=(g,y,E)=>{const x=zi(s,u);x[String(u.key)]=u,g[Gt]=()=>{y(),g[Gt]=void 0,delete c.delayedLeave,u=void 0},c.delayedLeave=()=>{E(),delete c.delayedLeave,u=void 0}}:u=void 0}else u&&(u=void 0);return i}}};function Hi(e){let t=e[0];if(e.length>1){for(const n of e)if(n.type!==Ye){t=n;break}}return t}const La=Ma;function zi(e,t){const{leavingVNodes:n}=e;let s=n.get(t.type);return s||(s=Object.create(null),n.set(t.type,s)),s}function or(e,t,n,s,r){const{appear:i,mode:l,persisted:a=!1,onBeforeEnter:o,onEnter:c,onAfterEnter:u,onEnterCancelled:d,onBeforeLeave:g,onLeave:y,onAfterLeave:E,onLeaveCancelled:x,onBeforeAppear:M,onAppear:m,onAfterAppear:H,onAppearCancelled:Y}=t,$=String(e.key),U=zi(n,e),L=(q,se)=>{q&&Tt(q,s,9,se)},O=(q,se)=>{const fe=se[1];L(q,se),Q(q)?q.every(D=>D.length<=1)&&fe():q.length<=1&&fe()},ee={mode:l,persisted:a,beforeEnter(q){let se=o;if(!n.isMounted)if(i)se=M||o;else return;q[Gt]&&q[Gt](!0);const fe=U[$];fe&&on(e,fe)&&fe.el[Gt]&&fe.el[Gt](),L(se,[q])},enter(q){let se=c,fe=u,D=d;if(!n.isMounted)if(i)se=m||c,fe=H||u,D=Y||d;else return;let Z=!1;const Se=q[xs]=je=>{Z||(Z=!0,je?L(D,[q]):L(fe,[q]),ee.delayedLeave&&ee.delayedLeave(),q[xs]=void 0)};se?O(se,[q,Se]):Se()},leave(q,se){const fe=String(e.key);if(q[xs]&&q[xs](!0),n.isUnmounting)return se();L(g,[q]);let D=!1;const Z=q[Gt]=Se=>{D||(D=!0,se(),Se?L(x,[q]):L(E,[q]),q[Gt]=void 0,U[fe]===e&&delete U[fe])};U[fe]=e,y?O(y,[q,Z]):Z()},clone(q){const se=or(q,t,n,s,r);return r&&r(se),se}};return ee}function ar(e){if(ur(e))return e=Kt(e),e.children=null,e}function Ui(e){if(!ur(e))return Ni(e.type)&&e.children?Hi(e.children):e;if(e.component)return e.component.subTree;const{shapeFlag:t,children:n}=e;if(n){if(t&16)return n[0];if(t&32&&be(n.default))return n.default()}}function Fn(e,t){e.shapeFlag&6&&e.component?(e.transition=t,Fn(e.component.subTree,t)):e.shapeFlag&128?(e.ssContent.transition=t.clone(e.ssContent),e.ssFallback.transition=t.clone(e.ssFallback)):e.transition=t}function ji(e,t=!1,n){let s=[],r=0;for(let i=0;i1)for(let i=0;iBn(E,t&&(Q(t)?t[x]:t),n,s,r));return}if(Hn(s)&&!r){s.shapeFlag&512&&s.type.__asyncResolved&&s.component.subTree.component&&Bn(e,t,n,s.component.subTree);return}const i=s.shapeFlag&4?As(s.component):s.el,l=r?null:i,{i:a,r:o}=e,c=t&&t.r,u=a.refs===le?a.refs={}:a.refs,d=a.setupState,g=ae(d),y=d===le?()=>!1:E=>me(g,E);if(c!=null&&c!==o&&(Ce(c)?(u[c]=null,y(c)&&(d[c]=null)):qe(c)&&(c.value=null)),be(o))bn(o,a,12,[l,u]);else{const E=Ce(o),x=qe(o);if(E||x){const M=()=>{if(e.f){const m=E?y(o)?d[o]:u[o]:o.value;r?Q(m)&&Jr(m,i):Q(m)?m.includes(i)||m.push(i):E?(u[o]=[i],y(o)&&(d[o]=u[o])):(o.value=[i],e.k&&(u[e.k]=o.value))}else E?(u[o]=l,y(o)&&(d[o]=l)):x&&(o.value=l,e.k&&(u[e.k]=l))};l?(M.id=-1,it(M,n)):M()}}}is().requestIdleCallback,is().cancelIdleCallback;const Hn=e=>!!e.type.__asyncLoader,ur=e=>e.type.__isKeepAlive;function Da(e,t,n=Zt,s=!1){if(n){const r=n[e]||(n[e]=[]),i=t.__weh||(t.__weh=(...l)=>{It();const a=yr(n),o=Tt(t,n,e,l);return a(),Ot(),o});return s?r.unshift(i):r.push(i),i}}const Vi=e=>(t,n=Zt)=>{(!qn||e==="sp")&&Da(e,(...s)=>t(...s),n)},zn=Vi("m"),ys=Vi("bum"),Na=Symbol.for("v-ndc");function ws(e,t,n,s){let r;const i=n,l=Q(e);if(l||Ce(e)){const a=l&&mn(e);let o=!1,c=!1;a&&(o=!ct(e),c=qt(e),e=ls(e)),r=new Array(e.length);for(let u=0,d=e.length;ut(a,o,void 0,i));else{const a=Object.keys(e);r=new Array(a.length);for(let o=0,c=a.length;oe?fl(e)?As(e):cr(e.parent):null,Un=bt(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>e.props,$attrs:e=>e.attrs,$slots:e=>e.slots,$refs:e=>e.refs,$parent:e=>cr(e.parent),$root:e=>cr(e.root),$host:e=>e.ce,$emit:e=>e.emit,$options:e=>e.type,$forceUpdate:e=>e.f||(e.f=()=>{lr(e.update)}),$nextTick:e=>e.n||(e.n=St.bind(e.proxy)),$watch:e=>Jt}),fr=(e,t)=>e!==le&&!e.__isScriptSetup&&me(e,t),Fa={get({_:e},t){if(t==="__v_skip")return!0;const{ctx:n,setupState:s,data:r,props:i,accessCache:l,type:a,appContext:o}=e;let c;if(t[0]!=="$"){const y=l[t];if(y!==void 0)switch(y){case 1:return s[t];case 2:return r[t];case 4:return n[t];case 3:return i[t]}else{if(fr(s,t))return l[t]=1,s[t];if(r!==le&&me(r,t))return l[t]=2,r[t];if((c=e.propsOptions[0])&&me(c,t))return l[t]=3,i[t];if(n!==le&&me(n,t))return l[t]=4,n[t];l[t]=0}}const u=Un[t];let d,g;if(u)return t==="$attrs"&&Ve(e.attrs,"get",""),u(e);if((d=a.__cssModules)&&(d=d[t]))return d;if(n!==le&&me(n,t))return l[t]=4,n[t];if(g=o.config.globalProperties,me(g,t))return g[t]},set({_:e},t,n){const{data:s,setupState:r,ctx:i}=e;return fr(r,t)?(r[t]=n,!0):s!==le&&me(s,t)?(s[t]=n,!0):me(e.props,t)||t[0]==="$"&&t.slice(1)in e?!1:(i[t]=n,!0)},has({_:{data:e,setupState:t,accessCache:n,ctx:s,appContext:r,propsOptions:i}},l){let a;return!!n[l]||e!==le&&me(e,l)||fr(t,l)||(a=i[0])&&me(a,l)||me(s,l)||me(Un,l)||me(r.config.globalProperties,l)},defineProperty(e,t,n){return n.get!=null?e._.accessCache[t]=0:me(n,"value")&&this.set(e,t,n.value,null),Reflect.defineProperty(e,t,n)}};function qi(){return{app:null,config:{isNativeTag:Do,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}let Ba=0;function Ha(e,t){return function(s,r=null){be(s)||(s=bt({},s)),r!=null&&!Re(r)&&(r=null);const i=qi(),l=new WeakSet,a=[];let o=!1;const c=i.app={_uid:Ba++,_component:s,_props:r,_container:null,_context:i,_instance:null,version:Su,get config(){return i.config},set config(u){},use(u,...d){return l.has(u)||(u&&be(u.install)?(l.add(u),u.install(c,...d)):be(u)&&(l.add(u),u(c,...d))),c},mixin(u){return c},component(u,d){return d?(i.components[u]=d,c):i.components[u]},directive(u,d){return d?(i.directives[u]=d,c):i.directives[u]},mount(u,d,g){if(!o){const y=c._ceVNode||Me(s,r);return y.appContext=i,g===!0?g="svg":g===!1&&(g=void 0),e(y,u,g),o=!0,c._container=u,u.__vue_app__=c,As(y.component)}},onUnmount(u){a.push(u)},unmount(){o&&(Tt(a,c._instance,16),e(null,c._container),delete c._container.__vue_app__)},provide(u,d){return i.provides[u]=d,c},runWithContext(u){const d=wn;wn=c;try{return u()}finally{wn=d}}};return c}}let wn=null;function za(e,t,n=!1){const s=ul();if(s||wn){let r=wn?wn._context.provides:s?s.parent==null||s.ce?s.vnode.appContext&&s.vnode.appContext.provides:s.parent.provides:void 0;if(r&&e in r)return r[e];if(arguments.length>1)return n&&be(t)?t.call(s&&s.proxy):t}}const Wi={},Gi=()=>Object.create(Wi),Ki=e=>Object.getPrototypeOf(e)===Wi;function Ua(e,t,n,s=!1){const r={},i=Gi();e.propsDefaults=Object.create(null),Yi(e,t,r,i);for(const l in e.propsOptions[0])l in r||(r[l]=void 0);n?e.props=s?r:da(r):e.type.props?e.props=r:e.props=i,e.attrs=i}function ja(e,t,n,s){const{props:r,attrs:i,vnode:{patchFlag:l}}=e,a=ae(r),[o]=e.propsOptions;let c=!1;if((s||l>0)&&!(l&16)){if(l&8){const u=e.vnode.dynamicProps;for(let d=0;de==="_"||e==="__"||e==="_ctx"||e==="$stable",hr=e=>Q(e)?e.map(At):[At(e)],qa=(e,t,n)=>{if(t._n)return t;const s=Di((...r)=>hr(t(...r)),n);return s._c=!1,s},Xi=(e,t,n)=>{const s=e._ctx;for(const r in e){if(dr(r))continue;const i=e[r];if(be(i))t[r]=qa(r,i,s);else if(i!=null){const l=hr(i);t[r]=()=>l}}},Qi=(e,t)=>{const n=hr(t);e.slots.default=()=>n},Ji=(e,t,n)=>{for(const s in t)(n||!dr(s))&&(e[s]=t[s])},Wa=(e,t,n)=>{const s=e.slots=Gi();if(e.vnode.shapeFlag&32){const r=t.__;r&&js(s,"__",r,!0);const i=t._;i?(Ji(s,t,n),n&&js(s,"_",i,!0)):Xi(t,s)}else t&&Qi(e,t)},Ga=(e,t,n)=>{const{vnode:s,slots:r}=e;let i=!0,l=le;if(s.shapeFlag&32){const a=t._;a?n&&a===1?i=!1:Ji(r,t,n):(i=!t.$stable,Xi(t,r)),l=t}else t&&(Qi(e,t),l={default:1});if(i)for(const a in r)!dr(a)&&l[a]==null&&delete r[a]},it=au;function Ka(e){return Ya(e)}function Ya(e,t){const n=is();n.__VUE__=!0;const{insert:s,remove:r,patchProp:i,createElement:l,createText:a,createComment:o,setText:c,setElementText:u,parentNode:d,nextSibling:g,setScopeId:y=Jt,insertStaticContent:E}=e,x=(f,h,b,k=null,v=null,_=null,P=void 0,C=null,A=!!h.dynamicChildren)=>{if(f===h)return;f&&!on(f,h)&&(k=ye(f),ue(f,v,_,!0),f=null),h.patchFlag===-2&&(A=!1,h.dynamicChildren=null);const{type:S,ref:z,shapeFlag:I}=h;switch(S){case _s:M(f,h,b,k);break;case Ye:m(f,h,b,k);break;case mr:f==null&&H(h,b,k,P);break;case ze:D(f,h,b,k,v,_,P,C,A);break;default:I&1?U(f,h,b,k,v,_,P,C,A):I&6?Z(f,h,b,k,v,_,P,C,A):(I&64||I&128)&&S.process(f,h,b,k,v,_,P,C,A,Ie)}z!=null&&v?Bn(z,f&&f.ref,_,h||f,!h):z==null&&f&&f.ref!=null&&Bn(f.ref,null,_,f,!0)},M=(f,h,b,k)=>{if(f==null)s(h.el=a(h.children),b,k);else{const v=h.el=f.el;h.children!==f.children&&c(v,h.children)}},m=(f,h,b,k)=>{f==null?s(h.el=o(h.children||""),b,k):h.el=f.el},H=(f,h,b,k)=>{[f.el,f.anchor]=E(f.children,h,b,k,f.el,f.anchor)},Y=({el:f,anchor:h},b,k)=>{let v;for(;f&&f!==h;)v=g(f),s(f,b,k),f=v;s(h,b,k)},$=({el:f,anchor:h})=>{let b;for(;f&&f!==h;)b=g(f),r(f),f=b;r(h)},U=(f,h,b,k,v,_,P,C,A)=>{h.type==="svg"?P="svg":h.type==="math"&&(P="mathml"),f==null?L(h,b,k,v,_,P,C,A):q(f,h,v,_,P,C,A)},L=(f,h,b,k,v,_,P,C)=>{let A,S;const{props:z,shapeFlag:I,transition:V,dirs:K}=f;if(A=f.el=l(f.type,_,z&&z.is,z),I&8?u(A,f.children):I&16&&ee(f.children,A,null,k,v,gr(f,_),P,C),K&&sn(f,null,k,"created"),O(A,f,f.scopeId,P,k),z){for(const de in z)de!=="value"&&!Pn(de)&&i(A,de,null,z[de],_,k);"value"in z&&i(A,"value",null,z.value,_),(S=z.onVnodeBeforeMount)&&Rt(S,k,f)}K&&sn(f,null,k,"beforeMount");const ne=Za(v,V);ne&&V.beforeEnter(A),s(A,h,b),((S=z&&z.onVnodeMounted)||ne||K)&&it(()=>{S&&Rt(S,k,f),ne&&V.enter(A),K&&sn(f,null,k,"mounted")},v)},O=(f,h,b,k,v)=>{if(b&&y(f,b),k)for(let _=0;_{for(let S=A;S{const C=h.el=f.el;let{patchFlag:A,dynamicChildren:S,dirs:z}=h;A|=f.patchFlag&16;const I=f.props||le,V=h.props||le;let K;if(b&&rn(b,!1),(K=V.onVnodeBeforeUpdate)&&Rt(K,b,h,f),z&&sn(h,f,b,"beforeUpdate"),b&&rn(b,!0),(I.innerHTML&&V.innerHTML==null||I.textContent&&V.textContent==null)&&u(C,""),S?se(f.dynamicChildren,S,C,b,k,gr(h,v),_):P||he(f,h,C,null,b,k,gr(h,v),_,!1),A>0){if(A&16)fe(C,I,V,b,v);else if(A&2&&I.class!==V.class&&i(C,"class",null,V.class,v),A&4&&i(C,"style",I.style,V.style,v),A&8){const ne=h.dynamicProps;for(let de=0;de{K&&Rt(K,b,h,f),z&&sn(h,f,b,"updated")},k)},se=(f,h,b,k,v,_,P)=>{for(let C=0;C{if(h!==b){if(h!==le)for(const _ in h)!Pn(_)&&!(_ in b)&&i(f,_,h[_],null,v,k);for(const _ in b){if(Pn(_))continue;const P=b[_],C=h[_];P!==C&&_!=="value"&&i(f,_,C,P,v,k)}"value"in b&&i(f,"value",h.value,b.value,v)}},D=(f,h,b,k,v,_,P,C,A)=>{const S=h.el=f?f.el:a(""),z=h.anchor=f?f.anchor:a("");let{patchFlag:I,dynamicChildren:V,slotScopeIds:K}=h;K&&(C=C?C.concat(K):K),f==null?(s(S,b,k),s(z,b,k),ee(h.children||[],b,z,v,_,P,C,A)):I>0&&I&64&&V&&f.dynamicChildren?(se(f.dynamicChildren,V,b,v,_,P,C),(h.key!=null||v&&h===v.subTree)&&el(f,h,!0)):he(f,h,b,z,v,_,P,C,A)},Z=(f,h,b,k,v,_,P,C,A)=>{h.slotScopeIds=C,f==null?h.shapeFlag&512?v.ctx.activate(h,b,k,P,A):Se(h,b,k,v,_,P,A):je(f,h,A)},Se=(f,h,b,k,v,_,P)=>{const C=f.component=gu(f,k,v);if(ur(f)&&(C.ctx.renderer=Ie),mu(C,!1,P),C.asyncDep){if(v&&v.registerDep(C,te,P),!f.el){const A=C.subTree=Me(Ye);m(null,A,h,b),f.placeholder=A.el}}else te(C,f,h,b,v,_,P)},je=(f,h,b)=>{const k=h.component=f.component;if(lu(f,h,b))if(k.asyncDep&&!k.asyncResolved){R(k,h,b);return}else k.next=h,k.update();else h.el=f.el,k.vnode=h},te=(f,h,b,k,v,_,P)=>{const C=()=>{if(f.isMounted){let{next:I,bu:V,u:K,parent:ne,vnode:de}=f;{const at=tl(f);if(at){I&&(I.el=de.el,R(f,I,P)),at.asyncDep.then(()=>{f.isUnmounted||C()});return}}let ie=I,ke;rn(f,!1),I?(I.el=de.el,R(f,I,P)):I=de,V&&rs(V),(ke=I.props&&I.props.onVnodeBeforeUpdate)&&Rt(ke,ne,I,de),rn(f,!0);const De=sl(f),ot=f.subTree;f.subTree=De,x(ot,De,d(ot.el),ye(ot),f,v,_),I.el=De.el,ie===null&&ou(f,De.el),K&&it(K,v),(ke=I.props&&I.props.onVnodeUpdated)&&it(()=>Rt(ke,ne,I,de),v)}else{let I;const{el:V,props:K}=h,{bm:ne,m:de,parent:ie,root:ke,type:De}=f,ot=Hn(h);rn(f,!1),ne&&rs(ne),!ot&&(I=K&&K.onVnodeBeforeMount)&&Rt(I,ie,h),rn(f,!0);{ke.ce&&ke.ce._def.shadowRoot!==!1&&ke.ce._injectChildStyle(De);const at=f.subTree=sl(f);x(null,at,b,k,f,v,_),h.el=at.el}if(de&&it(de,v),!ot&&(I=K&&K.onVnodeMounted)){const at=h;it(()=>Rt(I,ie,at),v)}(h.shapeFlag&256||ie&&Hn(ie.vnode)&&ie.vnode.shapeFlag&256)&&f.a&&it(f.a,v),f.isMounted=!0,h=b=k=null}};f.scope.on();const A=f.effect=new ui(C);f.scope.off();const S=f.update=A.run.bind(A),z=f.job=A.runIfDirty.bind(A);z.i=f,z.id=f.uid,A.scheduler=()=>lr(z),rn(f,!0),S()},R=(f,h,b)=>{h.component=f;const k=f.vnode.props;f.vnode=h,f.next=null,ja(f,h.props,k,b),Ga(f,h.children,b),It(),Oi(f),Ot()},he=(f,h,b,k,v,_,P,C,A=!1)=>{const S=f&&f.children,z=f?f.shapeFlag:0,I=h.children,{patchFlag:V,shapeFlag:K}=h;if(V>0){if(V&128){re(S,I,b,k,v,_,P,C,A);return}else if(V&256){Le(S,I,b,k,v,_,P,C,A);return}}K&8?(z&16&&Qe(S,v,_),I!==S&&u(b,I)):z&16?K&16?re(S,I,b,k,v,_,P,C,A):Qe(S,v,_,!0):(z&8&&u(b,""),K&16&&ee(I,b,k,v,_,P,C,A))},Le=(f,h,b,k,v,_,P,C,A)=>{f=f||mt,h=h||mt;const S=f.length,z=h.length,I=Math.min(S,z);let V;for(V=0;Vz?Qe(f,v,_,!0,!1,I):ee(h,b,k,v,_,P,C,A,I)},re=(f,h,b,k,v,_,P,C,A)=>{let S=0;const z=h.length;let I=f.length-1,V=z-1;for(;S<=I&&S<=V;){const K=f[S],ne=h[S]=A?Yt(h[S]):At(h[S]);if(on(K,ne))x(K,ne,b,null,v,_,P,C,A);else break;S++}for(;S<=I&&S<=V;){const K=f[I],ne=h[V]=A?Yt(h[V]):At(h[V]);if(on(K,ne))x(K,ne,b,null,v,_,P,C,A);else break;I--,V--}if(S>I){if(S<=V){const K=V+1,ne=KV)for(;S<=I;)ue(f[S],v,_,!0),S++;else{const K=S,ne=S,de=new Map;for(S=ne;S<=V;S++){const Ne=h[S]=A?Yt(h[S]):At(h[S]);Ne.key!=null&&de.set(Ne.key,S)}let ie,ke=0;const De=V-ne+1;let ot=!1,at=0;const Bt=new Array(De);for(S=0;S=De){ue(Ne,v,_,!0);continue}let Je;if(Ne.key!=null)Je=de.get(Ne.key);else for(ie=ne;ie<=V;ie++)if(Bt[ie-ne]===0&&on(Ne,h[ie])){Je=ie;break}Je===void 0?ue(Ne,v,_,!0):(Bt[Je-ne]=S+1,Je>=at?at=Je:ot=!0,x(Ne,h[Je],b,null,v,_,P,C,A),ke++)}const Jn=ot?Xa(Bt):mt;for(ie=Jn.length-1,S=De-1;S>=0;S--){const Ne=ne+S,Je=h[Ne],ut=h[Ne+1],Ht=Ne+1{const{el:_,type:P,transition:C,children:A,shapeFlag:S}=f;if(S&6){F(f.component.subTree,h,b,k);return}if(S&128){f.suspense.move(h,b,k);return}if(S&64){P.move(f,h,b,Ie);return}if(P===ze){s(_,h,b);for(let I=0;IC.enter(_),v);else{const{leave:I,delayLeave:V,afterLeave:K}=C,ne=()=>{f.ctx.isUnmounted?r(_):s(_,h,b)},de=()=>{I(_,()=>{ne(),K&&K()})};V?V(_,ne,de):de()}else s(_,h,b)},ue=(f,h,b,k=!1,v=!1)=>{const{type:_,props:P,ref:C,children:A,dynamicChildren:S,shapeFlag:z,patchFlag:I,dirs:V,cacheIndex:K}=f;if(I===-2&&(v=!1),C!=null&&(It(),Bn(C,null,b,f,!0),Ot()),K!=null&&(h.renderCache[K]=void 0),z&256){h.ctx.deactivate(f);return}const ne=z&1&&V,de=!Hn(f);let ie;if(de&&(ie=P&&P.onVnodeBeforeUnmount)&&Rt(ie,h,f),z&6)pe(f.component,b,k);else{if(z&128){f.suspense.unmount(b,k);return}ne&&sn(f,null,h,"beforeUnmount"),z&64?f.type.remove(f,h,b,Ie,k):S&&!S.hasOnce&&(_!==ze||I>0&&I&64)?Qe(S,h,b,!1,!0):(_===ze&&I&384||!v&&z&16)&&Qe(A,h,b),k&&ge(f)}(de&&(ie=P&&P.onVnodeUnmounted)||ne)&&it(()=>{ie&&Rt(ie,h,f),ne&&sn(f,null,h,"unmounted")},b)},ge=f=>{const{type:h,el:b,anchor:k,transition:v}=f;if(h===ze){Te(b,k);return}if(h===mr){$(f);return}const _=()=>{r(b),v&&!v.persisted&&v.afterLeave&&v.afterLeave()};if(f.shapeFlag&1&&v&&!v.persisted){const{leave:P,delayLeave:C}=v,A=()=>P(b,_);C?C(f.el,_,A):A()}else _()},Te=(f,h)=>{let b;for(;f!==h;)b=g(f),r(f),f=b;r(h)},pe=(f,h,b)=>{const{bum:k,scope:v,job:_,subTree:P,um:C,m:A,a:S,parent:z,slots:{__:I}}=f;nl(A),nl(S),k&&rs(k),z&&Q(I)&&I.forEach(V=>{z.renderCache[V]=void 0}),v.stop(),_&&(_.flags|=8,ue(P,f,h,b)),C&&it(C,h),it(()=>{f.isUnmounted=!0},h),h&&h.pendingBranch&&!h.isUnmounted&&f.asyncDep&&!f.asyncResolved&&f.suspenseId===h.pendingId&&(h.deps--,h.deps===0&&h.resolve())},Qe=(f,h,b,k=!1,v=!1,_=0)=>{for(let P=_;P{if(f.shapeFlag&6)return ye(f.component.subTree);if(f.shapeFlag&128)return f.suspense.next();const h=g(f.anchor||f.el),b=h&&h[Ia];return b?g(b):h};let j=!1;const st=(f,h,b)=>{f==null?h._vnode&&ue(h._vnode,null,null,!0):x(h._vnode||null,f,h,null,null,null,b),h._vnode=f,j||(j=!0,Oi(),Mi(),j=!1)},Ie={p:x,um:ue,m:F,r:ge,mt:Se,mc:ee,pc:he,pbc:se,n:ye,o:e};return{render:st,hydrate:void 0,createApp:Ha(st)}}function gr({type:e,props:t},n){return n==="svg"&&e==="foreignObject"||n==="mathml"&&e==="annotation-xml"&&t&&t.encoding&&t.encoding.includes("html")?void 0:n}function rn({effect:e,job:t},n){n?(e.flags|=32,t.flags|=4):(e.flags&=-33,t.flags&=-5)}function Za(e,t){return(!e||e&&!e.pendingBranch)&&t&&!t.persisted}function el(e,t,n=!1){const s=e.children,r=t.children;if(Q(s)&&Q(r))for(let i=0;i>1,e[n[a]]0&&(t[s]=n[i-1]),n[i]=s)}}for(i=n.length,l=n[i-1];i-- >0;)n[i]=l,l=t[l];return n}function tl(e){const t=e.subTree.component;if(t)return t.asyncDep&&!t.asyncResolved?t:tl(t)}function nl(e){if(e)for(let t=0;tza(Qa);function ln(e,t,n){return eu(e,t,n)}function eu(e,t,n=le){const{immediate:s,deep:r,flush:i,once:l}=n,a=bt({},n),o=t&&s||!t&&i!=="post";let c;if(qn){if(i==="sync"){const y=Ja();c=y.__watcherHandles||(y.__watcherHandles=[])}else if(!o){const y=()=>{};return y.stop=Jt,y.resume=Jt,y.pause=Jt,y}}const u=Zt;a.call=(y,E,x)=>Tt(y,u,E,x);let d=!1;i==="post"?a.scheduler=y=>{it(y,u&&u.suspense)}:i!=="sync"&&(d=!0,a.scheduler=(y,E)=>{E?y():lr(y)}),a.augmentJob=y=>{t&&(y.flags|=4),d&&(y.flags|=2,u&&(y.id=u.uid,y.i=u))};const g=_a(e,t,a);return qn&&(c?c.push(g):o&&g()),g}const tu=(e,t)=>t==="modelValue"||t==="model-value"?e.modelModifiers:e[`${t}Modifiers`]||e[`${jt(t)}Modifiers`]||e[`${en(t)}Modifiers`];function nu(e,t,...n){if(e.isUnmounted)return;const s=e.vnode.props||le;let r=n;const i=t.startsWith("update:"),l=i&&tu(s,t.slice(7));l&&(l.trim&&(r=n.map(u=>Ce(u)?u.trim():u)),l.number&&(r=n.map(Vs)));let a,o=s[a=Us(t)]||s[a=Us(jt(t))];!o&&i&&(o=s[a=Us(en(t))]),o&&Tt(o,e,6,r);const c=s[a+"Once"];if(c){if(!e.emitted)e.emitted={};else if(e.emitted[a])return;e.emitted[a]=!0,Tt(c,e,6,r)}}function su(e,t,n=!1){const s=t.emitsCache,r=s.get(e);if(r!==void 0)return r;const i=e.emits;let l={};return i?(Q(i)?i.forEach(a=>l[a]=null):bt(l,i),Re(e)&&s.set(e,l),l):(Re(e)&&s.set(e,null),null)}function vs(e,t){return!e||!ts(t)?!1:(t=t.slice(2).replace(/Once$/,""),me(e,t[0].toLowerCase()+t.slice(1))||me(e,en(t))||me(e,t))}function Ed(){}function sl(e){const{type:t,vnode:n,proxy:s,withProxy:r,propsOptions:[i],slots:l,attrs:a,emit:o,render:c,renderCache:u,props:d,data:g,setupState:y,ctx:E,inheritAttrs:x}=e,M=bs(e);let m,H;try{if(n.shapeFlag&4){const $=r||s,U=$;m=At(c.call(U,$,u,d,y,g,E)),H=a}else{const $=t;m=At($.length>1?$(d,{attrs:a,slots:l,emit:o}):$(d,null)),H=t.props?a:ru(a)}}catch($){jn.length=0,gs($,e,1),m=Me(Ye)}let Y=m;if(H&&x!==!1){const $=Object.keys(H),{shapeFlag:U}=Y;$.length&&U&7&&(i&&$.some(Hs)&&(H=iu(H,i)),Y=Kt(Y,H,!1,!0))}return n.dirs&&(Y=Kt(Y,null,!1,!0),Y.dirs=Y.dirs?Y.dirs.concat(n.dirs):n.dirs),n.transition&&Fn(Y,n.transition),m=Y,bs(M),m}const ru=e=>{let t;for(const n in e)(n==="class"||n==="style"||ts(n))&&((t||(t={}))[n]=e[n]);return t},iu=(e,t)=>{const n={};for(const s in e)(!Hs(s)||!(s.slice(9)in t))&&(n[s]=e[s]);return n};function lu(e,t,n){const{props:s,children:r,component:i}=e,{props:l,children:a,patchFlag:o}=t,c=i.emitsOptions;if(t.dirs||t.transition)return!0;if(n&&o>=0){if(o&1024)return!0;if(o&16)return s?rl(s,l,c):!!l;if(o&8){const u=t.dynamicProps;for(let d=0;de.__isSuspense;function au(e,t){t&&t.pendingBranch?Q(e)?t.effects.push(...e):t.effects.push(e):Ca(e)}const ze=Symbol.for("v-fgt"),_s=Symbol.for("v-txt"),Ye=Symbol.for("v-cmt"),mr=Symbol.for("v-stc"),jn=[];let lt=null;function B(e=!1){jn.push(lt=e?null:[])}function uu(){jn.pop(),lt=jn[jn.length-1]||null}let Vn=1;function ll(e,t=!1){Vn+=e,e<0&<&&t&&(lt.hasOnce=!0)}function ol(e){return e.dynamicChildren=Vn>0?lt||mt:null,uu(),Vn>0&<&<.push(e),e}function G(e,t,n,s,r,i){return ol(w(e,t,n,s,r,i,!0))}function Et(e,t,n,s,r){return ol(Me(e,t,n,s,r,!0))}function Ts(e){return e?e.__v_isVNode===!0:!1}function on(e,t){return e.type===t.type&&e.key===t.key}const al=({key:e})=>e!=null?e:null,ks=({ref:e,ref_key:t,ref_for:n})=>(typeof e=="number"&&(e=""+e),e!=null?Ce(e)||qe(e)||be(e)?{i:ft,r:e,k:t,f:!!n}:e:null);function w(e,t=null,n=null,s=0,r=null,i=e===ze?0:1,l=!1,a=!1){const o={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&al(t),ref:t&&ks(t),scopeId:$i,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:i,patchFlag:s,dynamicProps:r,dynamicChildren:null,appContext:null,ctx:ft};return a?(br(o,n),i&128&&e.normalize(o)):n&&(o.shapeFlag|=Ce(n)?8:16),Vn>0&&!l&<&&(o.patchFlag>0||i&6)&&o.patchFlag!==32&<.push(o),o}const Me=cu;function cu(e,t=null,n=null,s=0,r=null,i=!1){if((!e||e===Na)&&(e=Ye),Ts(e)){const a=Kt(e,t,!0);return n&&br(a,n),Vn>0&&!i&<&&(a.shapeFlag&6?lt[lt.indexOf(e)]=a:lt.push(a)),a.patchFlag=-2,a}if(Tu(e)&&(e=e.__vccOpts),t){t=fu(t);let{class:a,style:o}=t;a&&!Ce(a)&&(t.class=we(a)),Re(o)&&(rr(o)&&!Q(o)&&(o=bt({},o)),t.style=qs(o))}const l=Ce(e)?1:il(e)?128:Ni(e)?64:Re(e)?4:be(e)?2:0;return w(e,t,n,s,r,l,i,!0)}function fu(e){return e?rr(e)||Ki(e)?bt({},e):e:null}function Kt(e,t,n=!1,s=!1){const{props:r,ref:i,patchFlag:l,children:a,transition:o}=e,c=t?pu(r||{},t):r,u={__v_isVNode:!0,__v_skip:!0,type:e.type,props:c,key:c&&al(c),ref:t&&t.ref?n&&i?Q(i)?i.concat(ks(t)):[i,ks(t)]:ks(t):i,scopeId:e.scopeId,slotScopeIds:e.slotScopeIds,children:a,target:e.target,targetStart:e.targetStart,targetAnchor:e.targetAnchor,staticCount:e.staticCount,shapeFlag:e.shapeFlag,patchFlag:t&&e.type!==ze?l===-1?16:l|16:l,dynamicProps:e.dynamicProps,dynamicChildren:e.dynamicChildren,appContext:e.appContext,dirs:e.dirs,transition:o,component:e.component,suspense:e.suspense,ssContent:e.ssContent&&Kt(e.ssContent),ssFallback:e.ssFallback&&Kt(e.ssFallback),placeholder:e.placeholder,el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce};return o&&s&&Fn(u,o.clone(u)),u}function Ss(e=" ",t=0){return Me(_s,null,e,t)}function We(e="",t=!1){return t?(B(),Et(Ye,null,e)):Me(Ye,null,e)}function At(e){return e==null||typeof e=="boolean"?Me(Ye):Q(e)?Me(ze,null,e.slice()):Ts(e)?Yt(e):Me(_s,null,String(e))}function Yt(e){return e.el===null&&e.patchFlag!==-1||e.memo?e:Kt(e)}function br(e,t){let n=0;const{shapeFlag:s}=e;if(t==null)t=null;else if(Q(t))n=16;else if(typeof t=="object")if(s&65){const r=t.default;r&&(r._c&&(r._d=!1),br(e,r()),r._c&&(r._d=!0));return}else{n=32;const r=t._;!r&&!Ki(t)?t._ctx=ft:r===3&&ft&&(ft.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}else be(t)?(t={default:t,_ctx:ft},n=32):(t=String(t),s&64?(n=16,t=[Ss(t)]):n=8);e.children=t,e.shapeFlag|=n}function pu(...e){const t={};for(let n=0;nZt||ft;let Es,xr;{const e=is(),t=(n,s)=>{let r;return(r=e[n])||(r=e[n]=[]),r.push(s),i=>{r.length>1?r.forEach(l=>l(i)):r[0](i)}};Es=t("__VUE_INSTANCE_SETTERS__",n=>Zt=n),xr=t("__VUE_SSR_SETTERS__",n=>qn=n)}const yr=e=>{const t=Zt;return Es(e),e.scope.on(),()=>{e.scope.off(),Es(t)}},cl=()=>{Zt&&Zt.scope.off(),Es(null)};function fl(e){return e.vnode.shapeFlag&4}let qn=!1;function mu(e,t=!1,n=!1){t&&xr(t);const{props:s,children:r}=e.vnode,i=fl(e);Ua(e,s,i,t),Wa(e,r,n||t);const l=i?bu(e,t):void 0;return t&&xr(!1),l}function bu(e,t){const n=e.type;e.accessCache=Object.create(null),e.proxy=new Proxy(e.ctx,Fa);const{setup:s}=n;if(s){It();const r=e.setupContext=s.length>1?yu(e):null,i=yr(e),l=bn(s,e,0,[e.props,r]),a=ti(l);if(Ot(),i(),(a||e.sp)&&!Hn(e)&&$a(e),a){if(l.then(cl,cl),t)return l.then(o=>{pl(e,o)}).catch(o=>{gs(o,e,0)});e.asyncDep=l}else pl(e,l)}else dl(e)}function pl(e,t,n){be(t)?e.type.__ssrInlineRender?e.ssrRender=t:e.render=t:Re(t)&&(e.setupState=Ri(t)),dl(e)}function dl(e,t,n){const s=e.type;e.render||(e.render=s.render||Jt)}const xu={get(e,t){return Ve(e,"get",""),e[t]}};function yu(e){const t=n=>{e.exposed=n||{}};return{attrs:new Proxy(e.attrs,xu),slots:e.slots,emit:e.emit,expose:t}}function As(e){return e.exposed?e.exposeProxy||(e.exposeProxy=new Proxy(Ri(ha(e.exposed)),{get(t,n){if(n in t)return t[n];if(n in Un)return Un[n](e)},has(t,n){return n in t||n in Un}})):e.proxy}const wu=/(?:^|[-_])(\w)/g,vu=e=>e.replace(wu,t=>t.toUpperCase()).replace(/[-_]/g,"");function _u(e,t=!0){return be(e)?e.displayName||e.name:e.name||t&&e.__name}function hl(e,t,n=!1){let s=_u(t);if(!s&&t.__file){const r=t.__file.match(/([^/\\]+)\.\w+$/);r&&(s=r[1])}if(!s&&e&&e.parent){const r=i=>{for(const l in i)if(i[l]===t)return l};s=r(e.components||e.parent.type.components)||r(e.appContext.components)}return s?vu(s):n?"App":"Anonymous"}function Tu(e){return be(e)&&"__vccOpts"in e}const Ee=(e,t)=>wa(e,t,qn);function ku(e,t,n){const s=arguments.length;return s===2?Re(t)&&!Q(t)?Ts(t)?Me(e,null,[t]):Me(e,t):Me(e,null,t):(s>3?n=Array.prototype.slice.call(arguments,2):s===3&&Ts(n)&&(n=[n]),Me(e,t,n))}const Su="3.5.18";let wr;const gl=typeof window!="undefined"&&window.trustedTypes;if(gl)try{wr=gl.createPolicy("vue",{createHTML:e=>e})}catch{}const ml=wr?e=>wr.createHTML(e):e=>e,Eu="http://www.w3.org/2000/svg",Au="http://www.w3.org/1998/Math/MathML",Dt=typeof document!="undefined"?document:null,bl=Dt&&Dt.createElement("template"),Ru={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,s)=>{const r=t==="svg"?Dt.createElementNS(Eu,e):t==="mathml"?Dt.createElementNS(Au,e):n?Dt.createElement(e,{is:n}):Dt.createElement(e);return e==="select"&&s&&s.multiple!=null&&r.setAttribute("multiple",s.multiple),r},createText:e=>Dt.createTextNode(e),createComment:e=>Dt.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>Dt.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,s,r,i){const l=n?n.previousSibling:t.lastChild;if(r&&(r===i||r.nextSibling))for(;t.insertBefore(r.cloneNode(!0),n),!(r===i||!(r=r.nextSibling)););else{bl.innerHTML=ml(s==="svg"?`${e}`:s==="mathml"?`${e}`:e);const a=bl.content;if(s==="svg"||s==="mathml"){const o=a.firstChild;for(;o.firstChild;)a.appendChild(o.firstChild);a.removeChild(o)}t.insertBefore(a,n)}return[l?l.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},Xt="transition",Wn="animation",Gn=Symbol("_vtc"),xl={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},Cu=bt({},Fi,xl),Pu=(e=>(e.displayName="Transition",e.props=Cu,e))((e,{slots:t})=>ku(La,Iu(e),t)),an=(e,t=[])=>{Q(e)?e.forEach(n=>n(...t)):e&&e(...t)},yl=e=>e?Q(e)?e.some(t=>t.length>1):e.length>1:!1;function Iu(e){const t={};for(const D in e)D in xl||(t[D]=e[D]);if(e.css===!1)return t;const{name:n="v",type:s,duration:r,enterFromClass:i=`${n}-enter-from`,enterActiveClass:l=`${n}-enter-active`,enterToClass:a=`${n}-enter-to`,appearFromClass:o=i,appearActiveClass:c=l,appearToClass:u=a,leaveFromClass:d=`${n}-leave-from`,leaveActiveClass:g=`${n}-leave-active`,leaveToClass:y=`${n}-leave-to`}=e,E=Ou(r),x=E&&E[0],M=E&&E[1],{onBeforeEnter:m,onEnter:H,onEnterCancelled:Y,onLeave:$,onLeaveCancelled:U,onBeforeAppear:L=m,onAppear:O=H,onAppearCancelled:ee=Y}=t,q=(D,Z,Se,je)=>{D._enterCancelled=je,un(D,Z?u:a),un(D,Z?c:l),Se&&Se()},se=(D,Z)=>{D._isLeaving=!1,un(D,d),un(D,y),un(D,g),Z&&Z()},fe=D=>(Z,Se)=>{const je=D?O:H,te=()=>q(Z,D,Se);an(je,[Z,te]),wl(()=>{un(Z,D?o:i),Nt(Z,D?u:a),yl(je)||vl(Z,s,x,te)})};return bt(t,{onBeforeEnter(D){an(m,[D]),Nt(D,i),Nt(D,l)},onBeforeAppear(D){an(L,[D]),Nt(D,o),Nt(D,c)},onEnter:fe(!1),onAppear:fe(!0),onLeave(D,Z){D._isLeaving=!0;const Se=()=>se(D,Z);Nt(D,d),D._enterCancelled?(Nt(D,g),kl()):(kl(),Nt(D,g)),wl(()=>{D._isLeaving&&(un(D,d),Nt(D,y),yl($)||vl(D,s,M,Se))}),an($,[D,Se])},onEnterCancelled(D){q(D,!1,void 0,!0),an(Y,[D])},onAppearCancelled(D){q(D,!0,void 0,!0),an(ee,[D])},onLeaveCancelled(D){se(D),an(U,[D])}})}function Ou(e){if(e==null)return null;if(Re(e))return[vr(e.enter),vr(e.leave)];{const t=vr(e);return[t,t]}}function vr(e){return zo(e)}function Nt(e,t){t.split(/\s+/).forEach(n=>n&&e.classList.add(n)),(e[Gn]||(e[Gn]=new Set)).add(t)}function un(e,t){t.split(/\s+/).forEach(s=>s&&e.classList.remove(s));const n=e[Gn];n&&(n.delete(t),n.size||(e[Gn]=void 0))}function wl(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}let Mu=0;function vl(e,t,n,s){const r=e._endId=++Mu,i=()=>{r===e._endId&&s()};if(n!=null)return setTimeout(i,n);const{type:l,timeout:a,propCount:o}=Lu(e,t);if(!l)return s();const c=l+"end";let u=0;const d=()=>{e.removeEventListener(c,g),i()},g=y=>{y.target===e&&++u>=o&&d()};setTimeout(()=>{u(n[E]||"").split(", "),r=s(`${Xt}Delay`),i=s(`${Xt}Duration`),l=_l(r,i),a=s(`${Wn}Delay`),o=s(`${Wn}Duration`),c=_l(a,o);let u=null,d=0,g=0;t===Xt?l>0&&(u=Xt,d=l,g=i.length):t===Wn?c>0&&(u=Wn,d=c,g=o.length):(d=Math.max(l,c),u=d>0?l>c?Xt:Wn:null,g=u?u===Xt?i.length:o.length:0);const y=u===Xt&&/\b(transform|all)(,|$)/.test(s(`${Xt}Property`).toString());return{type:u,timeout:d,propCount:g,hasTransform:y}}function _l(e,t){for(;e.lengthTl(n)+Tl(e[s])))}function Tl(e){return e==="auto"?0:Number(e.slice(0,-1).replace(",","."))*1e3}function kl(){return document.body.offsetHeight}function $u(e,t,n){const s=e[Gn];s&&(t=(t?[t,...s]:[...s]).join(" ")),t==null?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}const Sl=Symbol("_vod"),Du=Symbol("_vsh"),Nu=Symbol(""),Fu=/(^|;)\s*display\s*:/;function Bu(e,t,n){const s=e.style,r=Ce(n);let i=!1;if(n&&!r){if(t)if(Ce(t))for(const l of t.split(";")){const a=l.slice(0,l.indexOf(":")).trim();n[a]==null&&Rs(s,a,"")}else for(const l in t)n[l]==null&&Rs(s,l,"");for(const l in n)l==="display"&&(i=!0),Rs(s,l,n[l])}else if(r){if(t!==n){const l=s[Nu];l&&(n+=";"+l),s.cssText=n,i=Fu.test(n)}}else t&&e.removeAttribute("style");Sl in e&&(e[Sl]=i?s.display:"",e[Du]&&(s.display="none"))}const El=/\s*!important$/;function Rs(e,t,n){if(Q(n))n.forEach(s=>Rs(e,t,s));else if(n==null&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const s=Hu(e,t);El.test(n)?e.setProperty(en(s),n.replace(El,""),"important"):e[s]=n}}const Al=["Webkit","Moz","ms"],_r={};function Hu(e,t){const n=_r[t];if(n)return n;let s=jt(t);if(s!=="filter"&&s in e)return _r[t]=s;s=ri(s);for(let r=0;rTr||(Vu.then(()=>Tr=0),Tr=Date.now());function Wu(e,t){const n=s=>{if(!s._vts)s._vts=Date.now();else if(s._vts<=n.attached)return;Tt(Gu(s,n.value),t,5,[s])};return n.value=e,n.attached=qu(),n}function Gu(e,t){if(Q(t)){const n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(s=>r=>!r._stopped&&s&&s(r))}else return t}const Ml=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,Ku=(e,t,n,s,r,i)=>{const l=r==="svg";t==="class"?$u(e,s,l):t==="style"?Bu(e,n,s):ts(t)?Hs(t)||Uu(e,t,n,s,i):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):Yu(e,t,s,l))?(Pl(e,t,s),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&Cl(e,t,s,l,i,t!=="value")):e._isVueCE&&(/[A-Z]/.test(t)||!Ce(s))?Pl(e,jt(t),s,i,t):(t==="true-value"?e._trueValue=s:t==="false-value"&&(e._falseValue=s),Cl(e,t,s,l))};function Yu(e,t,n,s){if(s)return!!(t==="innerHTML"||t==="textContent"||t in e&&Ml(t)&&be(n));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="autocorrect"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){const r=e.tagName;if(r==="IMG"||r==="VIDEO"||r==="CANVAS"||r==="SOURCE")return!1}return Ml(t)&&Ce(n)?!1:t in e}const Ll=e=>{const t=e.props["onUpdate:modelValue"]||!1;return Q(t)?n=>rs(t,n):t};function Zu(e){e.target.composing=!0}function $l(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const kr=Symbol("_assign"),Xu={created(e,{modifiers:{lazy:t,trim:n,number:s}},r){e[kr]=Ll(r);const i=s||r.props&&r.props.type==="number";vn(e,t?"change":"input",l=>{if(l.target.composing)return;let a=e.value;n&&(a=a.trim()),i&&(a=Vs(a)),e[kr](a)}),n&&vn(e,"change",()=>{e.value=e.value.trim()}),t||(vn(e,"compositionstart",Zu),vn(e,"compositionend",$l),vn(e,"change",$l))},mounted(e,{value:t}){e.value=t==null?"":t},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:s,trim:r,number:i}},l){if(e[kr]=Ll(l),e.composing)return;const a=(i||e.type==="number")&&!/^0\d/.test(e.value)?Vs(e.value):e.value,o=t==null?"":t;a!==o&&(document.activeElement===e&&e.type!=="range"&&(s&&t===n||r&&e.value.trim()===o)||(e.value=o))}},Qu=["ctrl","shift","alt","meta"],Ju={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&e.button!==0,middle:e=>"button"in e&&e.button!==1,right:e=>"button"in e&&e.button!==2,exact:(e,t)=>Qu.some(n=>e[`${n}Key`]&&!t.includes(n))},dt=(e,t)=>{const n=e._withMods||(e._withMods={}),s=t.join(".");return n[s]||(n[s]=(r,...i)=>{for(let l=0;l{const t=tc().createApp(...e),{mount:n}=t;return t.mount=s=>{const r=rc(s);if(!r)return;const i=t._component;!be(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent="");const l=n(r,!1,sc(r));return r instanceof Element&&(r.removeAttribute("v-cloak"),r.setAttribute("data-v-app","")),l},t};function sc(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function rc(e){return Ce(e)?document.querySelector(e):e}const ic=["aria-pressed"],lc={key:0,viewBox:"0 0 24 24",width:"20",height:"20","aria-hidden":"true"},oc={key:1,viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":"true",fill:"none"},ac={__name:"ChatbotToggler",props:{isOpen:{type:Boolean,required:!0}},emits:["toggle"],setup(e){return(t,n)=>(B(),G("button",{class:"fixed bottom-5 right-5 z-9999 grid h-12 w-12 appearance-none place-items-center rounded-full border border-white/20 bg-gradient-to-br from-brand-500 to-brand-600 text-white shadow-[0_20px_36px_-20px_rgba(109,79,194,0.85)] transition-all duration-250 hover:-translate-y-0.5 hover:from-brand-600 hover:to-violet-700 hover:shadow-[0_22px_40px_-22px_rgba(109,79,194,1)] focus:outline-none max-[600px]:bottom-3 max-[600px]:right-3 max-[600px]:h-13 max-[600px]:w-13",style:{"border-radius":"9999px"},"aria-pressed":e.isOpen?"true":"false",onClick:n[0]||(n[0]=s=>t.$emit("toggle"))},[e.isOpen?(B(),G("svg",oc,n[2]||(n[2]=[w("path",{d:"M6 6l12 12M18 6L6 18",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},null,-1)]))):(B(),G("svg",lc,n[1]||(n[1]=[w("path",{d:"M4 4h16a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H8l-4 4v-4H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z",fill:"currentColor",stroke:"currentColor","stroke-width":"2","stroke-linecap":"miter","stroke-linejoin":"miter"},null,-1)])))],8,ic))}},uc={class:"chat-header relative flex min-h-14 items-center justify-between px-4 pb-2.5 pt-3 text-white sm:px-5"},cc={class:"flex min-w-0 flex-1 items-center gap-2 sm:gap-2.5"},fc={xmlns:"http://www.w3.org/2000/svg",width:"35",height:"35",viewBox:"0 0 1024 1024",class:"h-8 w-8 shrink-0 rounded-full bg-white p-1.5 shadow-md motion-safe:animate-soft-float",style:{fill:"#6d4fc2"}},pc={class:"ml-2 flex items-center gap-1.5"},dc=["title"],hc=["title","aria-label"],gc={key:0,viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor","stroke-width":"2","aria-hidden":"true"},mc={key:1,viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor","stroke-width":"2","aria-hidden":"true"},bc=["title","aria-label"],xc={key:0,xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","aria-hidden":"true"},yc={key:1,xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","aria-hidden":"true"},wc={key:2,xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","aria-hidden":"true"},vc={__name:"ChatHeader",props:{windowMode:{type:String,required:!0},autoReadEnabled:{type:Boolean,required:!0},activeTtsProvider:{type:String,required:!0}},emits:["close","cycleResize","toggleAutoRead"],setup(e){const t=e,n={default:"Compact",half:"Half Screen",full:"Full Screen"},s=Ee(()=>n[t.windowMode]||"Compact"),r=Ee(()=>t.windowMode==="default"?"Half Screen":t.windowMode==="half"?"Full Screen":"Compact"),i=Ee(()=>t.activeTtsProvider==="polly"?"TTS: Polly":t.activeTtsProvider==="browser"?"TTS: Browser":"TTS: Off"),l=Ee(()=>t.activeTtsProvider==="polly"?"bg-emerald-500/45":t.activeTtsProvider==="browser"?"bg-amber-500/45":"bg-slate-500/35");return(a,o)=>(B(),G("div",uc,[w("div",cc,[(B(),G("svg",fc,o[3]||(o[3]=[w("path",{d:"M738.3 287.6H285.7c-59 0-106.8 47.8-106.8 106.8v303.1c0 59 47.8 106.8 106.8 106.8h81.5v111.1c0 .7.8 1.1 1.4.7l166.9-110.6 41.8-.8h117.4l43.6-.4c59 0 106.8-47.8 106.8-106.8V394.5c0-59-47.8-106.9-106.8-106.9zM351.7 448.2c0-29.5 23.9-53.5 53.5-53.5s53.5 23.9 53.5 53.5-23.9 53.5-53.5 53.5-53.5-23.9-53.5-53.5zm157.9 267.1c-67.8 0-123.8-47.5-132.3-109h264.6c-8.6 61.5-64.5 109-132.3 109zm110-213.7c-29.5 0-53.5-23.9-53.5-53.5s23.9-53.5 53.5-53.5 53.5 23.9 53.5 53.5-23.9 53.5-53.5 53.5zM867.2 644.5V453.1h26.5c19.4 0 35.1 15.7 35.1 35.1v121.1c0 19.4-15.7 35.1-35.1 35.1h-26.5zM95.2 609.4V488.2c0-19.4 15.7-35.1 35.1-35.1h26.5v191.3h-26.5c-19.4 0-35.1-15.7-35.1-35.1zM561.5 149.6c0 23.4-15.6 43.3-36.9 49.7v44.9h-30v-44.9c-21.4-6.5-36.9-26.3-36.9-49.7 0-28.6 23.3-51.9 51.9-51.9s51.9 23.3 51.9 51.9z"},null,-1)]))),o[4]||(o[4]=w("h2",{class:"truncate text-xs font-semibold tracking-[0.01em] sm:text-base text-white/95"},"ChangAI from ERPGulf",-1))]),w("div",pc,[w("span",{class:we(["hidden rounded-full border border-white/25 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-white/95 shadow-sm backdrop-blur-sm sm:inline",l.value]),title:`TTS provider: ${i.value}`},et(i.value),11,dc),w("button",{class:we(["h-8 min-w-8 appearance-none items-center justify-center rounded-md border border-white/20 px-2 text-xs font-semibold text-white/90 transition-all duration-200 focus:outline-none sm:flex",e.autoReadEnabled?"bg-white/24 shadow-sm":"hover:bg-white/15"]),style:{"border-radius":"0.375rem"},title:e.autoReadEnabled?"Auto speech on":"Auto speech off","aria-label":e.autoReadEnabled?"Turn off auto speech":"Turn on auto speech",onClick:o[0]||(o[0]=c=>a.$emit("toggleAutoRead"))},[e.autoReadEnabled?(B(),G("svg",gc,o[5]||(o[5]=[w("path",{d:"M11 5L6 9H3v6h3l5 4V5z"},null,-1),w("path",{d:"M15 9a4 4 0 0 1 0 6"},null,-1),w("path",{d:"M18 7a7 7 0 0 1 0 10"},null,-1)]))):(B(),G("svg",mc,o[6]||(o[6]=[w("path",{d:"M11 5L6 9H3v6h3l5 4V5z"},null,-1),w("path",{d:"M22 9l-6 6"},null,-1),w("path",{d:"M16 9l6 6"},null,-1)])))],10,hc),w("button",{class:we(["flex h-8 min-w-8 appearance-none items-center justify-center rounded-md border border-white/20 px-2 text-xs font-semibold text-white/90 transition-all duration-200 focus:outline-none","bg-white/20 shadow-sm hover:bg-white/25"]),style:{"border-radius":"0.375rem"},title:`Resize mode: ${s.value} (click to ${r.value})`,"aria-label":`Resize mode ${s.value}. Click to switch to ${r.value}`,onClick:o[1]||(o[1]=c=>a.$emit("cycleResize"))},[e.windowMode==="default"?(B(),G("svg",xc,o[7]||(o[7]=[w("rect",{x:"7",y:"8",width:"10",height:"8",rx:"2"},null,-1)]))):e.windowMode==="half"?(B(),G("svg",yc,o[8]||(o[8]=[w("rect",{x:"4",y:"5",width:"16",height:"14",rx:"2"},null,-1),w("path",{d:"M12 5v14"},null,-1)]))):(B(),G("svg",wc,o[9]||(o[9]=[w("rect",{x:"4",y:"5",width:"16",height:"14",rx:"2"},null,-1),w("path",{d:"M8 8H6v2M16 8h2v2M8 16H6v-2M16 16h2v-2"},null,-1)])))],8,bc),w("button",{class:"grid h-8 w-8 shrink-0 appearance-none place-items-center rounded-full border border-white/20 text-white transition-all duration-200 hover:scale-105 hover:bg-white/20 focus:outline-none focus-visible:ring-2 focus-visible:ring-white/70",style:{"border-radius":"9999px"},"aria-label":"Close chatbot",onClick:o[2]||(o[2]=c=>a.$emit("close"))},o[10]||(o[10]=[w("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24",width:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[w("path",{d:"M6 9l6 6 6-6"})],-1)]))])]))}},_c={class:"flex gap-1.5 border-b border-slate-200/80 px-2.5 pb-2.5 pt-1"},Tc=["onClick"],kc={class:"inline-flex items-center gap-1.5"},Sc={__name:"TabBar",props:{modelValue:{type:String,required:!0},debugEnabled:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(e){const t=e,n=Ee(()=>{const s=[{id:"chat",label:"Chats"},{id:"debug",label:"Debug"},{id:"support",label:"Support"},{id:"settings",label:"Settings"}];return t.debugEnabled?s:s.filter(r=>r.id!=="debug")});return(s,r)=>(B(),G("div",_c,[(B(!0),G(ze,null,ws(n.value,i=>(B(),G("button",{key:i.id,class:we(["group min-w-0 flex-1 h-9 appearance-none rounded-lg border border-transparent bg-transparent px-2 text-xs font-semibold transition-all duration-200 focus:outline-none",e.modelValue===i.id?"border-white/30 bg-linear-to-r from-violet-300/36 via-indigo-300/30 to-sky-300/28 text-white shadow-[0_4px_10px_rgba(20,24,40,0.22)]":"text-white/80 hover:border-white/25 hover:bg-white/12 hover:text-white"]),onClick:l=>s.$emit("update:modelValue",i.id)},[w("span",kc,[w("span",{class:we(["h-1.5 w-1.5 rounded-full transition-colors duration-200",e.modelValue===i.id?"bg-white":"bg-white/40 group-hover:bg-white/70"])},null,2),Ss(" "+et(i.label),1)])],10,Tc))),128))]))}},Ec=(e,t)=>{const n=e.__vccOpts||e;for(const[s,r]of t)n[s]=r;return n},Ac={},Rc={xmlns:"http://www.w3.org/2000/svg",width:"50",height:"50",viewBox:"0 0 1024 1024",class:"h-7.5 w-7.5 shrink-0 self-end rounded-full bg-gradient-to-br from-brand-500 to-brand-600 p-1.5 fill-white shadow-[0_10px_18px_-12px_rgba(109,79,194,0.85)]"};function Cc(e,t){return B(),G("svg",Rc,t[0]||(t[0]=[w("path",{d:"M738.3 287.6H285.7c-59 0-106.8 47.8-106.8 106.8v303.1c0 59 47.8 106.8 106.8 106.8h81.5v111.1c0 .7.8 1.1 1.4.7l166.9-110.6 41.8-.8h117.4l43.6-.4c59 0 106.8-47.8 106.8-106.8V394.5c0-59-47.8-106.9-106.8-106.9zM351.7 448.2c0-29.5 23.9-53.5 53.5-53.5s53.5 23.9 53.5 53.5-23.9 53.5-53.5 53.5-53.5-23.9-53.5-53.5zm157.9 267.1c-67.8 0-123.8-47.5-132.3-109h264.6c-8.6 61.5-64.5 109-132.3 109zm110-213.7c-29.5 0-53.5-23.9-53.5-53.5s23.9-53.5 53.5-53.5 53.5 23.9 53.5 53.5-23.9 53.5-53.5 53.5zM867.2 644.5V453.1h26.5c19.4 0 35.1 15.7 35.1 35.1v121.1c0 19.4-15.7 35.1-35.1 35.1h-26.5zM95.2 609.4V488.2c0-19.4 15.7-35.1 35.1-35.1h26.5v191.3h-26.5c-19.4 0-35.1-15.7-35.1-35.1zM561.5 149.6c0 23.4-15.6 43.3-36.9 49.7v44.9h-30v-44.9c-21.4-6.5-36.9-26.3-36.9-49.7 0-28.6 23.3-51.9 51.9-51.9s51.9 23.3 51.9 51.9z"},null,-1)]))}const Nl=Ec(Ac,[["render",Cc]]),Cs={PIPELINE:"changai.changai.api.v2.text2sql_pipeline_v2.run_text2sql_pipeline",SUPPORT:"changai.changai.api.v2.helpdesk_api.support_bot",SETTINGS:"changai.changai.api.v2.schema_utils.get_frontend_settings",TTS:"changai.changai.api.v2.tts.synthesize_tts"};function Fl(e,t={},n="actual"){return n==="test"?Promise.resolve({Bot:`[TEST MODE] ${JSON.stringify(t)}`}):!window.frappe||!window.frappe.call?Promise.reject(new Error("Frappe API is unavailable in actual mode.")):new Promise((s,r)=>{window.frappe.call({method:e,args:t,callback(i){s(i.message)},error(i){r(i)}})})}function Pc(e,t,n="actual",s=null,r){if(n==="test")return{promise:Promise.resolve({Bot:`[TEST MODE] ${JSON.stringify({user_question:e,chat_id:t,request_id:s,sendNonErptoAI:r})}`}),cancel:()=>!1};if(!window.frappe||!window.frappe.call)return{promise:Promise.reject(new Error("Frappe API is unavailable in actual mode.")),cancel:()=>!1};let i=null,l=!1;return{promise:new Promise((c,u)=>{i=window.frappe.call({method:Cs.PIPELINE,args:{user_question:e,chat_id:t,request_id:s,sendNonErptoAI:r},callback(d){l=!0,c(d.message)},error(d){l=!0,u(d)}})}),cancel:()=>l||!i||typeof i.abort!="function"?!1:(i.abort(),l=!0,!0)}}function Ic(e,t="actual"){if(t==="test")return{promise:Promise.resolve(`[TEST MODE] ${JSON.stringify({message:e})}`),cancel:()=>!1};if(!window.frappe||!window.frappe.call)return{promise:Promise.reject(new Error("Frappe API is unavailable in actual mode.")),cancel:()=>!1};let n=null,s=!1;return{promise:new Promise((l,a)=>{n=window.frappe.call({method:Cs.SUPPORT,args:{message:e},callback(o){s=!0,l(o.message)},error(o){s=!0,a(o)}})}),cancel:()=>s||!n||typeof n.abort!="function"?!1:(n.abort(),s=!0,!0)}}function Oc(e="actual"){return Fl(Cs.SETTINGS,{},e)}function Mc(e,t="Zayd",n="actual"){return Fl(Cs.TTS,{text:e,voice_id:t},n)}function Sr(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var cn=Sr();function Bl(e){cn=e}var fn={exec:()=>null};function oe(e,t=""){let n=typeof e=="string"?e:e.source,s={replace:(r,i)=>{let l=typeof i=="string"?i:i.source;return l=l.replace(Ge.caret,"$1"),n=n.replace(r,l),s},getRegex:()=>new RegExp(n,t)};return s}var Lc=((e="")=>{try{return!!new RegExp("(?<=1)(?/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}>`)},$c=/^(?:[ \t]*(?:\n|$))+/,Dc=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Nc=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Kn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Fc=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Er=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Hl=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,zl=oe(Hl).replace(/bull/g,Er).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Bc=oe(Hl).replace(/bull/g,Er).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ar=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Hc=/^[^\n]+/,Rr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,zc=oe(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Rr).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Uc=oe(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Er).getRegex(),Ps="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Cr=/|$))/,jc=oe("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Cr).replace("tag",Ps).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ul=oe(Ar).replace("hr",Kn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ps).getRegex(),Vc=oe(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ul).getRegex(),Pr={blockquote:Vc,code:Dc,def:zc,fences:Nc,heading:Fc,hr:Kn,html:jc,lheading:zl,list:Uc,newline:$c,paragraph:Ul,table:fn,text:Hc},jl=oe("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Kn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ps).getRegex(),qc={...Pr,lheading:Bc,table:jl,paragraph:oe(Ar).replace("hr",Kn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",jl).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ps).getRegex()},Wc={...Pr,html:oe(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Cr).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:fn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:oe(Ar).replace("hr",Kn).replace("heading",` *#{1,6} *[^ +]`).replace("lheading",zl).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Gc=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Kc=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Vl=/^( {2,}|\\)\n(?!\s*$)/,Yc=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\`+)[^`]+\k(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Lc?"(?`+)[^`]+\k(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Wl=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,ef=oe(Wl,"u").replace(/punct/g,_n).getRegex(),tf=oe(Wl,"u").replace(/punct/g,ql).getRegex(),Gl="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",nf=oe(Gl,"gu").replace(/notPunctSpace/g,Ir).replace(/punctSpace/g,Is).replace(/punct/g,_n).getRegex(),sf=oe(Gl,"gu").replace(/notPunctSpace/g,Qc).replace(/punctSpace/g,Xc).replace(/punct/g,ql).getRegex(),rf=oe("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ir).replace(/punctSpace/g,Is).replace(/punct/g,_n).getRegex(),lf=oe(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,_n).getRegex(),of="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",af=oe(of,"gu").replace(/notPunctSpace/g,Ir).replace(/punctSpace/g,Is).replace(/punct/g,_n).getRegex(),uf=oe(/\\(punct)/,"gu").replace(/punct/g,_n).getRegex(),cf=oe(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ff=oe(Cr).replace("(?:-->|$)","-->").getRegex(),pf=oe("^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^").replace("comment",ff).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Os=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,df=oe(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Os).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Kl=oe(/^!?\[(label)\]\[(ref)\]/).replace("label",Os).replace("ref",Rr).getRegex(),Yl=oe(/^!?\[(ref)\](?:\[\])?/).replace("ref",Rr).getRegex(),hf=oe("reflink|nolink(?!\\()","g").replace("reflink",Kl).replace("nolink",Yl).getRegex(),Zl=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Or={_backpedal:fn,anyPunctuation:uf,autolink:cf,blockSkip:Jc,br:Vl,code:Kc,del:fn,delLDelim:fn,delRDelim:fn,emStrongLDelim:ef,emStrongRDelimAst:nf,emStrongRDelimUnd:rf,escape:Gc,link:df,nolink:Yl,punctuation:Zc,reflink:Kl,reflinkSearch:hf,tag:pf,text:Yc,url:fn},gf={...Or,link:oe(/^!?\[(label)\]\((.*?)\)/).replace("label",Os).getRegex(),reflink:oe(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Os).getRegex()},Mr={...Or,emStrongRDelimAst:sf,emStrongLDelim:tf,delLDelim:lf,delRDelim:af,url:oe(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Zl).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:oe(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\":">",'"':""","'":"'"},Xl=e=>bf[e];function Ct(e,t){if(t){if(Ge.escapeTest.test(e))return e.replace(Ge.escapeReplace,Xl)}else if(Ge.escapeTestNoEncode.test(e))return e.replace(Ge.escapeReplaceNoEncode,Xl);return e}function Ql(e){try{e=encodeURI(e).replace(Ge.percentDecode,"%")}catch{return null}return e}function Jl(e,t){var i;let n=e.replace(Ge.findPipe,(l,a,o)=>{let c=!1,u=a;for(;--u>=0&&o[u]==="\\";)c=!c;return c?"|":" |"}),s=n.split(Ge.splitPipe),r=0;if(s[0].trim()||s.shift(),s.length>0&&!((i=s.at(-1))!=null&&i.trim())&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length=0&&Ge.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(` +`)}function xf(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let s=0;s0?-2:-1}function yf(e,t=0){let n=t,s="";for(let r of e)if(r===" "){let i=4-n%4;s+=" ".repeat(i),n+=i}else s+=r,n++;return s}function to(e,t,n,s,r){let i=t.href,l=t.title||null,a=e[1].replace(r.other.outputLinkReplace,"$1");s.state.inLink=!0;let o={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:l,text:a,tokens:s.inlineTokens(a)};return s.state.inLink=!1,o}function wf(e,t,n){let s=e.match(n.other.indentCodeCompensation);if(s===null)return t;let r=s[1];return t.split(` +`).map(i=>{let l=i.match(n.other.beginningSpace);if(l===null)return i;let[a]=l;return a.length>=r.length?i.slice(r.length):i}).join(` +`)}var Ls=class{constructor(e){ve(this,"options");ve(this,"rules");ve(this,"lexer");this.options=e||cn}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=this.options.pedantic?t[0]:eo(t[0]),s=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:s}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=wf(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let s=Qt(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:Qt(t[0],` +`),depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Qt(t[0],` +`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Qt(t[0],` `).split(` -`), s = "", r = "", i = []; for (; n.length > 0;) { - let o = !1, a = [], l; for (l = 0; l < n.length; l++)if (this.rules.other.blockquoteStart.test(n[l])) a.push(n[l]), o = !0; else if (!o) a.push(n[l]); else break; n = n.slice(l); let f = a.join(` -`), u = f.replace(this.rules.other.blockquoteSetextReplace, ` - $1`).replace(this.rules.other.blockquoteSetextReplace2, ""); s = s ? `${s} -${f}` : f, r = r ? `${r} -${u}` : u; let d = this.lexer.state.top; if (this.lexer.state.top = !0, this.lexer.blockTokens(u, i, !0), this.lexer.state.top = d, n.length === 0) break; let g = i.at(-1); if ((g == null ? void 0 : g.type) === "code") break; if ((g == null ? void 0 : g.type) === "blockquote") { - let y = g, E = y.raw + ` -`+ n.join(` -`), x = this.blockquote(E); i[i.length - 1] = x, s = s.substring(0, s.length - y.raw.length) + x.raw, r = r.substring(0, r.length - y.text.length) + x.text; break - } else if ((g == null ? void 0 : g.type) === "list") { - let y = g, E = y.raw + ` -`+ n.join(` -`), x = this.list(E); i[i.length - 1] = x, s = s.substring(0, s.length - g.raw.length) + x.raw, r = r.substring(0, r.length - y.raw.length) + x.raw, n = E.substring(i.at(-1).raw.length).split(` -`); continue - } - } return { type: "blockquote", raw: s, tokens: i, text: r } - } - } list(e) { - let t = this.rules.block.list.exec(e); if (t) { - let n = t[1].trim(), s = n.length > 1, r = { type: "list", raw: "", ordered: s, start: s ? +n.slice(0, -1) : "", loose: !1, items: [] }; n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]"); let i = this.rules.other.listItemRegex(n), o = !1; for (; e;) { - let l = !1, f = "", u = ""; if (!(t = i.exec(e)) || this.rules.block.hr.test(e)) break; f = t[0], e = e.substring(f.length); let d = yf(t[2].split(` -`, 1)[0], t[1].length), g = e.split(` -`, 1)[0], y = !d.trim(), E = 0; if (this.options.pedantic ? (E = 2, u = d.trimStart()) : y ? E = t[1].length + 1 : (E = d.search(this.rules.other.nonSpaceChar), E = E > 4 ? 1 : E, u = d.slice(E), E += t[1].length), y && this.rules.other.blankLine.test(g) && (f += g + ` -`, e = e.substring(g.length + 1), l = !0), !l) { - let x = this.rules.other.nextBulletRegex(E), M = this.rules.other.hrRegex(E), m = this.rules.other.fencesBeginRegex(E), H = this.rules.other.headingBeginRegex(E), Y = this.rules.other.htmlBeginRegex(E), $ = this.rules.other.blockquoteBeginRegex(E); for (; e;) { - let z = e.split(` -`, 1)[0], O; if (g = z, this.options.pedantic ? (g = g.replace(this.rules.other.listReplaceNesting, " "), O = g) : O = g.replace(this.rules.other.tabCharGlobal, " "), m.test(g) || H.test(g) || Y.test(g) || $.test(g) || x.test(g) || M.test(g)) break; if (O.search(this.rules.other.nonSpaceChar) >= E || !g.trim()) u += ` -`+ O.slice(E); else { - if (y || d.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || m.test(d) || H.test(d) || M.test(d)) break; u += ` -`+ g - } y = !g.trim(), f += z + ` -`, e = e.substring(z.length + 1), d = O.slice(E) - } - } r.loose || (o ? r.loose = !0 : this.rules.other.doubleBlankLine.test(f) && (o = !0)), r.items.push({ type: "list_item", raw: f, task: !!this.options.gfm && this.rules.other.listIsTask.test(u), loose: !1, text: u, tokens: [] }), r.raw += f - } let a = r.items.at(-1); if (a) a.raw = a.raw.trimEnd(), a.text = a.text.trimEnd(); else return; r.raw = r.raw.trimEnd(); for (let l of r.items) { this.lexer.state.top = !1, l.tokens = this.lexer.blockTokens(l.text, []); let f = l.tokens[0]; if (l.task && ((f == null ? void 0 : f.type) === "text" || (f == null ? void 0 : f.type) === "paragraph")) { l.text = l.text.replace(this.rules.other.listReplaceTask, ""), f.raw = f.raw.replace(this.rules.other.listReplaceTask, ""), f.text = f.text.replace(this.rules.other.listReplaceTask, ""); for (let d = this.lexer.inlineQueue.length - 1; d >= 0; d--)if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[d].src)) { this.lexer.inlineQueue[d].src = this.lexer.inlineQueue[d].src.replace(this.rules.other.listReplaceTask, ""); break } let u = this.rules.other.listTaskCheckbox.exec(l.raw); if (u) { let d = { type: "checkbox", raw: u[0] + " ", checked: u[0] !== "[ ]" }; l.checked = d.checked, r.loose ? l.tokens[0] && ["paragraph", "text"].includes(l.tokens[0].type) && "tokens" in l.tokens[0] && l.tokens[0].tokens ? (l.tokens[0].raw = d.raw + l.tokens[0].raw, l.tokens[0].text = d.raw + l.tokens[0].text, l.tokens[0].tokens.unshift(d)) : l.tokens.unshift({ type: "paragraph", raw: d.raw, text: d.raw, tokens: [d] }) : l.tokens.unshift(d) } } else l.task && (l.task = !1); if (!r.loose) { let u = l.tokens.filter(g => g.type === "space"), d = u.length > 0 && u.some(g => this.rules.other.anyLine.test(g.raw)); r.loose = d } } if (r.loose) for (let l of r.items) { l.loose = !0; for (let f of l.tokens) f.type === "text" && (f.type = "paragraph") } return r - } - } html(e) { let t = this.rules.block.html.exec(e); if (t) { let n = tl(t[0]); return { type: "html", block: !0, raw: n, pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: n } } } def(e) { - let t = this.rules.block.def.exec(e); if (t) { - let n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3]; return { - type: "def", tag: n, raw: Qt(t[0], ` -`), href: s, title: r - } - } - } table(e) { - var o; let t = this.rules.block.table.exec(e); if (!t || !this.rules.other.tableDelimiter.test(t[2])) return; let n = el(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = (o = t[3]) != null && o.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(` -`) : [], i = { - type: "table", raw: Qt(t[0], ` -`), header: [], align: [], rows: [] - }; if (n.length === s.length) { for (let a of s) this.rules.other.tableAlignRight.test(a) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(a) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(a) ? i.align.push("left") : i.align.push(null); for (let a = 0; a < n.length; a++)i.header.push({ text: n[a], tokens: this.lexer.inline(n[a]), header: !0, align: i.align[a] }); for (let a of r) i.rows.push(el(a, i.header.length).map((l, f) => ({ text: l, tokens: this.lexer.inline(l), header: !1, align: i.align[f] }))); return i } - } lheading(e) { - let t = this.rules.block.lheading.exec(e); if (t) { - let n = t[1].trim(); return { - type: "heading", raw: Qt(t[0], ` -`), depth: t[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) - } - } - } paragraph(e) { - let t = this.rules.block.paragraph.exec(e); if (t) { - let n = t[1].charAt(t[1].length - 1) === ` -`? t[1].slice(0, -1) : t[1]; return { type: "paragraph", raw: t[0], text: n, tokens: this.lexer.inline(n) } - } - } text(e) { let t = this.rules.block.text.exec(e); if (t) return { type: "text", raw: t[0], text: t[0], tokens: this.lexer.inline(t[0]) } } escape(e) { let t = this.rules.inline.escape.exec(e); if (t) return { type: "escape", raw: t[0], text: t[1] } } tag(e) { let t = this.rules.inline.tag.exec(e); if (t) return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = !1), { type: "html", raw: t[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: !1, text: t[0] } } link(e) { let t = this.rules.inline.link.exec(e); if (t) { let n = t[2].trim(); if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) { if (!this.rules.other.endAngleBracket.test(n)) return; let i = Qt(n.slice(0, -1), "\\"); if ((n.length - i.length) % 2 === 0) return } else { let i = xf(t[2], "()"); if (i === -2) return; if (i > -1) { let o = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i; t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, o).trim(), t[3] = "" } } let s = t[2], r = ""; if (this.options.pedantic) { let i = this.rules.other.pedanticHrefTitle.exec(s); i && (s = i[1], r = i[3]) } else r = t[3] ? t[3].slice(1, -1) : ""; return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? s = s.slice(1) : s = s.slice(1, -1)), nl(t, { href: s && s.replace(this.rules.inline.anyPunctuation, "$1"), title: r && r.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules) } } reflink(e, t) { let n; if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) { let s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = t[s.toLowerCase()]; if (!r) { let i = n[0].charAt(0); return { type: "text", raw: i, text: i } } return nl(n, r, n[0], this.lexer, this.rules) } } emStrong(e, t, n = "") { let s = this.rules.inline.emStrongLDelim.exec(e); if (!(!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && n.match(this.rules.other.unicodeAlphaNumeric)) && (!(s[1] || s[3]) || !n || this.rules.inline.punctuation.exec(n))) { let r = [...s[0]].length - 1, i, o, a = r, l = 0, f = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd; for (f.lastIndex = 0, t = t.slice(-1 * e.length + r); (s = f.exec(t)) !== null;) { if (i = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !i) continue; if (o = [...i].length, s[3] || s[4]) { a += o; continue } else if ((s[5] || s[6]) && r % 3 && !((r + o) % 3)) { l += o; continue } if (a -= o, a > 0) continue; o = Math.min(o, o + a + l); let u = [...s[0]][0].length, d = e.slice(0, r + s.index + u + o); if (Math.min(r, o) % 2) { let y = d.slice(1, -1); return { type: "em", raw: d, text: y, tokens: this.lexer.inlineTokens(y) } } let g = d.slice(2, -2); return { type: "strong", raw: d, text: g, tokens: this.lexer.inlineTokens(g) } } } } codespan(e) { let t = this.rules.inline.code.exec(e); if (t) { let n = t[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(n), r = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n); return s && r && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n } } } br(e) { let t = this.rules.inline.br.exec(e); if (t) return { type: "br", raw: t[0] } } del(e, t, n = "") { let s = this.rules.inline.delLDelim.exec(e); if (s && (!s[1] || !n || this.rules.inline.punctuation.exec(n))) { let r = [...s[0]].length - 1, i, o, a = r, l = this.rules.inline.delRDelim; for (l.lastIndex = 0, t = t.slice(-1 * e.length + r); (s = l.exec(t)) !== null;) { if (i = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !i || (o = [...i].length, o !== r)) continue; if (s[3] || s[4]) { a += o; continue } if (a -= o, a > 0) continue; o = Math.min(o, o + a); let f = [...s[0]][0].length, u = e.slice(0, r + s.index + f + o), d = u.slice(r, -r); return { type: "del", raw: u, text: d, tokens: this.lexer.inlineTokens(d) } } } } autolink(e) { let t = this.rules.inline.autolink.exec(e); if (t) { let n, s; return t[2] === "@" ? (n = t[1], s = "mailto:" + n) : (n = t[1], s = n), { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] } } } url(e) { var n, s; let t; if (t = this.rules.inline.url.exec(e)) { let r, i; if (t[2] === "@") r = t[0], i = "mailto:" + r; else { let o; do o = t[0], t[0] = (s = (n = this.rules.inline._backpedal.exec(t[0])) == null ? void 0 : n[0]) != null ? s : ""; while (o !== t[0]); r = t[0], t[1] === "www." ? i = "http://" + t[0] : i = t[0] } return { type: "link", raw: t[0], text: r, href: i, tokens: [{ type: "text", raw: r, text: r }] } } } inlineText(e) { let t = this.rules.inline.text.exec(e); if (t) { let n = this.lexer.state.inRawBlock; return { type: "text", raw: t[0], text: t[0], escaped: n } } } - }, yt = class Xr { - constructor(t) { _e(this, "tokens"); _e(this, "options"); _e(this, "state"); _e(this, "inlineQueue"); _e(this, "tokenizer"); this.tokens = [], this.tokens.links = Object.create(null), this.options = t || cn, this.options.tokenizer = this.options.tokenizer || new Ls, this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: !1, inRawBlock: !1, top: !0 }; let n = { other: We, block: Os.normal, inline: Yn.normal }; this.options.pedantic ? (n.block = Os.pedantic, n.inline = Yn.pedantic) : this.options.gfm && (n.block = Os.gfm, this.options.breaks ? n.inline = Yn.breaks : n.inline = Yn.gfm), this.tokenizer.rules = n } static get rules() { return { block: Os, inline: Yn } } static lex(t, n) { return new Xr(n).lex(t) } static lexInline(t, n) { return new Xr(n).inlineTokens(t) } lex(t) { - t = t.replace(We.carriageReturn, ` -`), this.blockTokens(t, this.tokens); for (let n = 0; n < this.inlineQueue.length; n++) { let s = this.inlineQueue[n]; this.inlineTokens(s.src, s.tokens) } return this.inlineQueue = [], this.tokens - } blockTokens(t, n = [], s = !1) { - var i, o, a; this.tokenizer.lexer = this, this.options.pedantic && (t = t.replace(We.tabCharGlobal, " ").replace(We.spaceLine, "")); let r = 1 / 0; for (; t;) { - if (t.length < r) r = t.length; else { this.infiniteLoopError(t.charCodeAt(0)); break } let l; if ((o = (i = this.options.extensions) == null ? void 0 : i.block) != null && o.some(u => (l = u.call({ lexer: this }, t, n)) ? (t = t.substring(l.raw.length), n.push(l), !0) : !1)) continue; if (l = this.tokenizer.space(t)) { - t = t.substring(l.raw.length); let u = n.at(-1); l.raw.length === 1 && u !== void 0 ? u.raw += ` -`: n.push(l); continue - } if (l = this.tokenizer.code(t)) { - t = t.substring(l.raw.length); let u = n.at(-1); (u == null ? void 0 : u.type) === "paragraph" || (u == null ? void 0 : u.type) === "text" ? (u.raw += (u.raw.endsWith(` -`) ? "" : ` -`) + l.raw, u.text += ` -`+ l.text, this.inlineQueue.at(-1).src = u.text) : n.push(l); continue - } if (l = this.tokenizer.fences(t)) { t = t.substring(l.raw.length), n.push(l); continue } if (l = this.tokenizer.heading(t)) { t = t.substring(l.raw.length), n.push(l); continue } if (l = this.tokenizer.hr(t)) { t = t.substring(l.raw.length), n.push(l); continue } if (l = this.tokenizer.blockquote(t)) { t = t.substring(l.raw.length), n.push(l); continue } if (l = this.tokenizer.list(t)) { t = t.substring(l.raw.length), n.push(l); continue } if (l = this.tokenizer.html(t)) { t = t.substring(l.raw.length), n.push(l); continue } if (l = this.tokenizer.def(t)) { - t = t.substring(l.raw.length); let u = n.at(-1); (u == null ? void 0 : u.type) === "paragraph" || (u == null ? void 0 : u.type) === "text" ? (u.raw += (u.raw.endsWith(` -`) ? "" : ` -`) + l.raw, u.text += ` -`+ l.raw, this.inlineQueue.at(-1).src = u.text) : this.tokens.links[l.tag] || (this.tokens.links[l.tag] = { href: l.href, title: l.title }, n.push(l)); continue - } if (l = this.tokenizer.table(t)) { t = t.substring(l.raw.length), n.push(l); continue } if (l = this.tokenizer.lheading(t)) { t = t.substring(l.raw.length), n.push(l); continue } let f = t; if ((a = this.options.extensions) != null && a.startBlock) { let u = 1 / 0, d = t.slice(1), g; this.options.extensions.startBlock.forEach(y => { g = y.call({ lexer: this }, d), typeof g == "number" && g >= 0 && (u = Math.min(u, g)) }), u < 1 / 0 && u >= 0 && (f = t.substring(0, u + 1)) } if (this.state.top && (l = this.tokenizer.paragraph(f))) { - let u = n.at(-1); s && (u == null ? void 0 : u.type) === "paragraph" ? (u.raw += (u.raw.endsWith(` -`) ? "" : ` -`) + l.raw, u.text += ` -`+ l.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = u.text) : n.push(l), s = f.length !== t.length, t = t.substring(l.raw.length); continue - } if (l = this.tokenizer.text(t)) { - t = t.substring(l.raw.length); let u = n.at(-1); (u == null ? void 0 : u.type) === "text" ? (u.raw += (u.raw.endsWith(` -`) ? "" : ` -`) + l.raw, u.text += ` -`+ l.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = u.text) : n.push(l); continue - } if (t) { this.infiniteLoopError(t.charCodeAt(0)); break } - } return this.state.top = !0, n - } inline(t, n = []) { return this.inlineQueue.push({ src: t, tokens: n }), n } inlineTokens(t, n = []) { var f, u, d, g, y, E; this.tokenizer.lexer = this; let s = t, r = null; if (this.tokens.links) { let x = Object.keys(this.tokens.links); if (x.length > 0) for (; (r = this.tokenizer.rules.inline.reflinkSearch.exec(s)) !== null;)x.includes(r[0].slice(r[0].lastIndexOf("[") + 1, -1)) && (s = s.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex)) } for (; (r = this.tokenizer.rules.inline.anyPunctuation.exec(s)) !== null;)s = s.slice(0, r.index) + "++" + s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex); let i; for (; (r = this.tokenizer.rules.inline.blockSkip.exec(s)) !== null;)i = r[2] ? r[2].length : 0, s = s.slice(0, r.index + i) + "[" + "a".repeat(r[0].length - i - 2) + "]" + s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex); s = (d = (u = (f = this.options.hooks) == null ? void 0 : f.emStrongMask) == null ? void 0 : u.call({ lexer: this }, s)) != null ? d : s; let o = !1, a = "", l = 1 / 0; for (; t;) { if (t.length < l) l = t.length; else { this.infiniteLoopError(t.charCodeAt(0)); break } o || (a = ""), o = !1; let x; if ((y = (g = this.options.extensions) == null ? void 0 : g.inline) != null && y.some(m => (x = m.call({ lexer: this }, t, n)) ? (t = t.substring(x.raw.length), n.push(x), !0) : !1)) continue; if (x = this.tokenizer.escape(t)) { t = t.substring(x.raw.length), n.push(x); continue } if (x = this.tokenizer.tag(t)) { t = t.substring(x.raw.length), n.push(x); continue } if (x = this.tokenizer.link(t)) { t = t.substring(x.raw.length), n.push(x); continue } if (x = this.tokenizer.reflink(t, this.tokens.links)) { t = t.substring(x.raw.length); let m = n.at(-1); x.type === "text" && (m == null ? void 0 : m.type) === "text" ? (m.raw += x.raw, m.text += x.text) : n.push(x); continue } if (x = this.tokenizer.emStrong(t, s, a)) { t = t.substring(x.raw.length), n.push(x); continue } if (x = this.tokenizer.codespan(t)) { t = t.substring(x.raw.length), n.push(x); continue } if (x = this.tokenizer.br(t)) { t = t.substring(x.raw.length), n.push(x); continue } if (x = this.tokenizer.del(t, s, a)) { t = t.substring(x.raw.length), n.push(x); continue } if (x = this.tokenizer.autolink(t)) { t = t.substring(x.raw.length), n.push(x); continue } if (!this.state.inLink && (x = this.tokenizer.url(t))) { t = t.substring(x.raw.length), n.push(x); continue } let M = t; if ((E = this.options.extensions) != null && E.startInline) { let m = 1 / 0, H = t.slice(1), Y; this.options.extensions.startInline.forEach($ => { Y = $.call({ lexer: this }, H), typeof Y == "number" && Y >= 0 && (m = Math.min(m, Y)) }), m < 1 / 0 && m >= 0 && (M = t.substring(0, m + 1)) } if (x = this.tokenizer.inlineText(M)) { t = t.substring(x.raw.length), x.raw.slice(-1) !== "_" && (a = x.raw.slice(-1)), o = !0; let m = n.at(-1); (m == null ? void 0 : m.type) === "text" ? (m.raw += x.raw, m.text += x.text) : n.push(x); continue } if (t) { this.infiniteLoopError(t.charCodeAt(0)); break } } return n } infiniteLoopError(t) { let n = "Infinite loop on byte: " + t; if (!this.options.silent) throw new Error(n) } - }, $s = class { - constructor(e) { _e(this, "options"); _e(this, "parser"); this.options = e || cn } space(e) { return "" } code({ text: e, lang: t, escaped: n }) { - var i; let s = (i = (t || "").match(We.notSpaceStart)) == null ? void 0 : i[0], r = e.replace(We.endingNewline, "") + ` -`; return s ? '
' + (n ? r : Ct(r, !0)) + `
-`: "
" + (n ? r : Ct(r, !0)) + `
-`} blockquote({ tokens: e }) { - return `
+`),s="",r="",i=[];for(;n.length>0;){let l=!1,a=[],o;for(o=0;o1,r={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");let i=this.rules.other.listItemRegex(n),l=!1;for(;e;){let o=!1,c="",u="";if(!(t=i.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let d=yf(t[2].split(` +`,1)[0],t[1].length),g=e.split(` +`,1)[0],y=!d.trim(),E=0;if(this.options.pedantic?(E=2,u=d.trimStart()):y?E=t[1].length+1:(E=d.search(this.rules.other.nonSpaceChar),E=E>4?1:E,u=d.slice(E),E+=t[1].length),y&&this.rules.other.blankLine.test(g)&&(c+=g+` +`,e=e.substring(g.length+1),o=!0),!o){let x=this.rules.other.nextBulletRegex(E),M=this.rules.other.hrRegex(E),m=this.rules.other.fencesBeginRegex(E),H=this.rules.other.headingBeginRegex(E),Y=this.rules.other.htmlBeginRegex(E),$=this.rules.other.blockquoteBeginRegex(E);for(;e;){let U=e.split(` +`,1)[0],L;if(g=U,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),L=g):L=g.replace(this.rules.other.tabCharGlobal," "),m.test(g)||H.test(g)||Y.test(g)||$.test(g)||x.test(g)||M.test(g))break;if(L.search(this.rules.other.nonSpaceChar)>=E||!g.trim())u+=` +`+L.slice(E);else{if(y||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||m.test(d)||H.test(d)||M.test(d))break;u+=` +`+g}y=!g.trim(),c+=U+` +`,e=e.substring(U.length+1),d=L.slice(E)}}r.loose||(l?r.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(l=!0)),r.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),r.raw+=c}let a=r.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let o of r.items){this.lexer.state.top=!1,o.tokens=this.lexer.blockTokens(o.text,[]);let c=o.tokens[0];if(o.task&&((c==null?void 0:c.type)==="text"||(c==null?void 0:c.type)==="paragraph")){o.text=o.text.replace(this.rules.other.listReplaceTask,""),c.raw=c.raw.replace(this.rules.other.listReplaceTask,""),c.text=c.text.replace(this.rules.other.listReplaceTask,"");for(let d=this.lexer.inlineQueue.length-1;d>=0;d--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[d].src)){this.lexer.inlineQueue[d].src=this.lexer.inlineQueue[d].src.replace(this.rules.other.listReplaceTask,"");break}let u=this.rules.other.listTaskCheckbox.exec(o.raw);if(u){let d={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};o.checked=d.checked,r.loose?o.tokens[0]&&["paragraph","text"].includes(o.tokens[0].type)&&"tokens"in o.tokens[0]&&o.tokens[0].tokens?(o.tokens[0].raw=d.raw+o.tokens[0].raw,o.tokens[0].text=d.raw+o.tokens[0].text,o.tokens[0].tokens.unshift(d)):o.tokens.unshift({type:"paragraph",raw:d.raw,text:d.raw,tokens:[d]}):o.tokens.unshift(d)}}else o.task&&(o.task=!1);if(!r.loose){let u=o.tokens.filter(g=>g.type==="space"),d=u.length>0&&u.some(g=>this.rules.other.anyLine.test(g.raw));r.loose=d}}if(r.loose)for(let o of r.items){o.loose=!0;for(let c of o.tokens)c.type==="text"&&(c.type="paragraph")}return r}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=eo(t[0]);return{type:"html",block:!0,raw:n,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:n}}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:Qt(t[0],` +`),href:s,title:r}}}table(e){var l;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Jl(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=(l=t[3])!=null&&l.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(` +`):[],i={type:"table",raw:Qt(t[0],` +`),header:[],align:[],rows:[]};if(n.length===s.length){for(let a of s)this.rules.other.tableAlignRight.test(a)?i.align.push("right"):this.rules.other.tableAlignCenter.test(a)?i.align.push("center"):this.rules.other.tableAlignLeft.test(a)?i.align.push("left"):i.align.push(null);for(let a=0;a({text:o,tokens:this.lexer.inline(o),header:!1,align:i.align[c]})));return i}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:Qt(t[0],` +`),depth:t[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===` +`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=Qt(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=xf(t[2],"()");if(i===-2)return;if(i>-1){let l=(t[0].indexOf("!")===0?5:4)+t[1].length+i;t[2]=t[2].substring(0,i),t[0]=t[0].substring(0,l).trim(),t[3]=""}}let s=t[2],r="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(s);i&&(s=i[1],r=i[3])}else r=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),to(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=t[s.toLowerCase()];if(!r){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return to(n,r,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!(!s||!s[1]&&!s[2]&&!s[3]&&!s[4]||s[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[3])||!n||this.rules.inline.punctuation.exec(n))){let r=[...s[0]].length-1,i,l,a=r,o=0,c=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+r);(s=c.exec(t))!==null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i)continue;if(l=[...i].length,s[3]||s[4]){a+=l;continue}else if((s[5]||s[6])&&r%3&&!((r+l)%3)){o+=l;continue}if(a-=l,a>0)continue;l=Math.min(l,l+a+o);let u=[...s[0]][0].length,d=e.slice(0,r+s.index+u+l);if(Math.min(r,l)%2){let y=d.slice(1,-1);return{type:"em",raw:d,text:y,tokens:this.lexer.inlineTokens(y)}}let g=d.slice(2,-2);return{type:"strong",raw:d,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),r=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&r&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let s=this.rules.inline.delLDelim.exec(e);if(s&&(!s[1]||!n||this.rules.inline.punctuation.exec(n))){let r=[...s[0]].length-1,i,l,a=r,o=this.rules.inline.delRDelim;for(o.lastIndex=0,t=t.slice(-1*e.length+r);(s=o.exec(t))!==null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i||(l=[...i].length,l!==r))continue;if(s[3]||s[4]){a+=l;continue}if(a-=l,a>0)continue;l=Math.min(l,l+a);let c=[...s[0]][0].length,u=e.slice(0,r+s.index+c+l),d=u.slice(r,-r);return{type:"del",raw:u,text:d,tokens:this.lexer.inlineTokens(d)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,s;return t[2]==="@"?(n=t[1],s="mailto:"+n):(n=t[1],s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n,s;let t;if(t=this.rules.inline.url.exec(e)){let r,i;if(t[2]==="@")r=t[0],i="mailto:"+r;else{let l;do l=t[0],t[0]=(s=(n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])!=null?s:"";while(l!==t[0]);r=t[0],t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},yt=class Xr{constructor(t){ve(this,"tokens");ve(this,"options");ve(this,"state");ve(this,"inlineQueue");ve(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||cn,this.options.tokenizer=this.options.tokenizer||new Ls,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:Ge,block:Ms.normal,inline:Yn.normal};this.options.pedantic?(n.block=Ms.pedantic,n.inline=Yn.pedantic):this.options.gfm&&(n.block=Ms.gfm,this.options.breaks?n.inline=Yn.breaks:n.inline=Yn.gfm),this.tokenizer.rules=n}static get rules(){return{block:Ms,inline:Yn}}static lex(t,n){return new Xr(n).lex(t)}static lexInline(t,n){return new Xr(n).inlineTokens(t)}lex(t){t=t.replace(Ge.carriageReturn,` +`),this.blockTokens(t,this.tokens);for(let n=0;n(o=u.call({lexer:this},t,n))?(t=t.substring(o.raw.length),n.push(o),!0):!1))continue;if(o=this.tokenizer.space(t)){t=t.substring(o.raw.length);let u=n.at(-1);o.raw.length===1&&u!==void 0?u.raw+=` +`:n.push(o);continue}if(o=this.tokenizer.code(t)){t=t.substring(o.raw.length);let u=n.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(` +`)?"":` +`)+o.raw,u.text+=` +`+o.text,this.inlineQueue.at(-1).src=u.text):n.push(o);continue}if(o=this.tokenizer.fences(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.heading(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.hr(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.blockquote(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.list(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.html(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.def(t)){t=t.substring(o.raw.length);let u=n.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(` +`)?"":` +`)+o.raw,u.text+=` +`+o.raw,this.inlineQueue.at(-1).src=u.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title},n.push(o));continue}if(o=this.tokenizer.table(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.lheading(t)){t=t.substring(o.raw.length),n.push(o);continue}let c=t;if((a=this.options.extensions)!=null&&a.startBlock){let u=1/0,d=t.slice(1),g;this.options.extensions.startBlock.forEach(y=>{g=y.call({lexer:this},d),typeof g=="number"&&g>=0&&(u=Math.min(u,g))}),u<1/0&&u>=0&&(c=t.substring(0,u+1))}if(this.state.top&&(o=this.tokenizer.paragraph(c))){let u=n.at(-1);s&&(u==null?void 0:u.type)==="paragraph"?(u.raw+=(u.raw.endsWith(` +`)?"":` +`)+o.raw,u.text+=` +`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):n.push(o),s=c.length!==t.length,t=t.substring(o.raw.length);continue}if(o=this.tokenizer.text(t)){t=t.substring(o.raw.length);let u=n.at(-1);(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(` +`)?"":` +`)+o.raw,u.text+=` +`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):n.push(o);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var c,u,d,g,y,E;this.tokenizer.lexer=this;let s=t,r=null;if(this.tokens.links){let x=Object.keys(this.tokens.links);if(x.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(s))!==null;)x.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(s))!==null;)s=s.slice(0,r.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(s))!==null;)i=r[2]?r[2].length:0,s=s.slice(0,r.index+i)+"["+"a".repeat(r[0].length-i-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=(d=(u=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:u.call({lexer:this},s))!=null?d:s;let l=!1,a="",o=1/0;for(;t;){if(t.length(x=m.call({lexer:this},t,n))?(t=t.substring(x.raw.length),n.push(x),!0):!1))continue;if(x=this.tokenizer.escape(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.tag(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.link(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(x.raw.length);let m=n.at(-1);x.type==="text"&&(m==null?void 0:m.type)==="text"?(m.raw+=x.raw,m.text+=x.text):n.push(x);continue}if(x=this.tokenizer.emStrong(t,s,a)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.codespan(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.br(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.del(t,s,a)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.autolink(t)){t=t.substring(x.raw.length),n.push(x);continue}if(!this.state.inLink&&(x=this.tokenizer.url(t))){t=t.substring(x.raw.length),n.push(x);continue}let M=t;if((E=this.options.extensions)!=null&&E.startInline){let m=1/0,H=t.slice(1),Y;this.options.extensions.startInline.forEach($=>{Y=$.call({lexer:this},H),typeof Y=="number"&&Y>=0&&(m=Math.min(m,Y))}),m<1/0&&m>=0&&(M=t.substring(0,m+1))}if(x=this.tokenizer.inlineText(M)){t=t.substring(x.raw.length),x.raw.slice(-1)!=="_"&&(a=x.raw.slice(-1)),l=!0;let m=n.at(-1);(m==null?void 0:m.type)==="text"?(m.raw+=x.raw,m.text+=x.text):n.push(x);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return n}infiniteLoopError(t){let n="Infinite loop on byte: "+t;if(!this.options.silent)throw new Error(n)}},$s=class{constructor(e){ve(this,"options");ve(this,"parser");this.options=e||cn}space(e){return""}code({text:e,lang:t,escaped:n}){var i;let s=(i=(t||"").match(Ge.notSpaceStart))==null?void 0:i[0],r=e.replace(Ge.endingNewline,"")+` +`;return s?'
'+(n?r:Ct(r,!0))+`
+`:"
"+(n?r:Ct(r,!0))+`
+`}blockquote({tokens:e}){return`
${this.parser.parse(e)}
-`} html({ text: e }) { return e } def(e) { return "" } heading({ tokens: e, depth: t }) { - return `${this.parser.parseInline(e)} -`} hr(e) { - return `
-`} list(e) { - let t = e.ordered, n = e.start, s = ""; for (let o = 0; o < e.items.length; o++) { let a = e.items[o]; s += this.listitem(a) } let r = t ? "ol" : "ul", i = t && n !== 1 ? ' start="' + n + '"' : ""; return "<" + r + i + `> -`+ s + " -`} listitem(e) { - return `
  • ${this.parser.parse(e.tokens)}
  • -`} checkbox({ checked: e }) { return " ' } paragraph({ tokens: e }) { - return `

    ${this.parser.parseInline(e)}

    -`} table(e) { - let t = "", n = ""; for (let r = 0; r < e.header.length; r++)n += this.tablecell(e.header[r]); t += this.tablerow({ text: n }); let s = ""; for (let r = 0; r < e.rows.length; r++) { let i = e.rows[r]; n = ""; for (let o = 0; o < i.length; o++)n += this.tablecell(i[o]); s += this.tablerow({ text: n }) } return s && (s = `${s}`), ` +`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`${this.parser.parseInline(e)} +`}hr(e){return`
    +`}list(e){let t=e.ordered,n=e.start,s="";for(let l=0;l +`+s+" +`}listitem(e){return`
  • ${this.parser.parse(e.tokens)}
  • +`}checkbox({checked:e}){return" '}paragraph({tokens:e}){return`

    ${this.parser.parseInline(e)}

    +`}table(e){let t="",n="";for(let r=0;r${s}`),`
    -`+ t + ` -`+ s + `
    -`} tablerow({ text: e }) { - return ` +`+t+` +`+s+` +`}tablerow({text:e}){return` ${e} -`} tablecell(e) { - let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td"; return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + ` -`} strong({ tokens: e }) { return `${this.parser.parseInline(e)}` } em({ tokens: e }) { return `${this.parser.parseInline(e)}` } codespan({ text: e }) { return `${Ct(e, !0)}` } br(e) { return "
    " } del({ tokens: e }) { return `${this.parser.parseInline(e)}` } link({ href: e, title: t, tokens: n }) { let s = this.parser.parseInline(n), r = Jo(e); if (r === null) return s; e = r; let i = '
    ", i } image({ href: e, title: t, text: n, tokens: s }) { s && (n = this.parser.parseInline(s, this.parser.textRenderer)); let r = Jo(e); if (r === null) return Ct(n); e = r; let i = `${Ct(n)} { let l = o[a].flat(1 / 0); n = n.concat(this.walkTokens(l, t)) }) : o.tokens && (n = n.concat(this.walkTokens(o.tokens, t))) } }return n } use(...e) { let t = this.defaults.extensions || { renderers: {}, childTokens: {} }; return e.forEach(n => { let s = { ...n }; if (s.async = this.defaults.async || s.async || !1, n.extensions && (n.extensions.forEach(r => { if (!r.name) throw new Error("extension name required"); if ("renderer" in r) { let i = t.renderers[r.name]; i ? t.renderers[r.name] = function (...o) { let a = r.renderer.apply(this, o); return a === !1 && (a = i.apply(this, o)), a } : t.renderers[r.name] = r.renderer } if ("tokenizer" in r) { if (!r.level || r.level !== "block" && r.level !== "inline") throw new Error("extension level must be 'block' or 'inline'"); let i = t[r.level]; i ? i.unshift(r.tokenizer) : t[r.level] = [r.tokenizer], r.start && (r.level === "block" ? t.startBlock ? t.startBlock.push(r.start) : t.startBlock = [r.start] : r.level === "inline" && (t.startInline ? t.startInline.push(r.start) : t.startInline = [r.start])) } "childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens) }), s.extensions = t), n.renderer) { let r = this.defaults.renderer || new $s(this.defaults); for (let i in n.renderer) { if (!(i in r)) throw new Error(`renderer '${i}' does not exist`); if (["options", "parser"].includes(i)) continue; let o = i, a = n.renderer[o], l = r[o]; r[o] = (...f) => { let u = a.apply(r, f); return u === !1 && (u = l.apply(r, f)), u || "" } } s.renderer = r } if (n.tokenizer) { let r = this.defaults.tokenizer || new Ls(this.defaults); for (let i in n.tokenizer) { if (!(i in r)) throw new Error(`tokenizer '${i}' does not exist`); if (["options", "rules", "lexer"].includes(i)) continue; let o = i, a = n.tokenizer[o], l = r[o]; r[o] = (...f) => { let u = a.apply(r, f); return u === !1 && (u = l.apply(r, f)), u } } s.tokenizer = r } if (n.hooks) { let r = this.defaults.hooks || new Zn; for (let i in n.hooks) { if (!(i in r)) throw new Error(`hook '${i}' does not exist`); if (["options", "block"].includes(i)) continue; let o = i, a = n.hooks[o], l = r[o]; Zn.passThroughHooks.has(i) ? r[o] = f => { if (this.defaults.async && Zn.passThroughHooksRespectAsync.has(i)) return (async () => { let d = await a.call(r, f); return l.call(r, d) })(); let u = a.call(r, f); return l.call(r, u) } : r[o] = (...f) => { if (this.defaults.async) return (async () => { let d = await a.apply(r, f); return d === !1 && (d = await l.apply(r, f)), d })(); let u = a.apply(r, f); return u === !1 && (u = l.apply(r, f)), u } } s.hooks = r } if (n.walkTokens) { let r = this.defaults.walkTokens, i = n.walkTokens; s.walkTokens = function (o) { let a = []; return a.push(i.call(this, o)), r && (a = a.concat(r.call(this, o))), a } } this.defaults = { ...this.defaults, ...s } }), this } setOptions(e) { return this.defaults = { ...this.defaults, ...e }, this } lexer(e, t) { return yt.lex(e, t != null ? t : this.defaults) } parser(e, t) { return wt.parse(e, t != null ? t : this.defaults) } parseMarkdown(e) { return (t, n) => { let s = { ...n }, r = { ...this.defaults, ...s }, i = this.onError(!!r.silent, !!r.async); if (this.defaults.async === !0 && s.async === !1) return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.")); if (typeof t > "u" || t === null) return i(new Error("marked(): input parameter is undefined or null")); if (typeof t != "string") return i(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(t) + ", string expected")); if (r.hooks && (r.hooks.options = r, r.hooks.block = e), r.async) return (async () => { let o = r.hooks ? await r.hooks.preprocess(t) : t, a = await (r.hooks ? await r.hooks.provideLexer(e) : e ? yt.lex : yt.lexInline)(o, r), l = r.hooks ? await r.hooks.processAllTokens(a) : a; r.walkTokens && await Promise.all(this.walkTokens(l, r.walkTokens)); let f = await (r.hooks ? await r.hooks.provideParser(e) : e ? wt.parse : wt.parseInline)(l, r); return r.hooks ? await r.hooks.postprocess(f) : f })().catch(i); try { r.hooks && (t = r.hooks.preprocess(t)); let o = (r.hooks ? r.hooks.provideLexer(e) : e ? yt.lex : yt.lexInline)(t, r); r.hooks && (o = r.hooks.processAllTokens(o)), r.walkTokens && this.walkTokens(o, r.walkTokens); let a = (r.hooks ? r.hooks.provideParser(e) : e ? wt.parse : wt.parseInline)(o, r); return r.hooks && (a = r.hooks.postprocess(a)), a } catch (o) { return i(o) } } } onError(e, t) { - return n => { - if (n.message += ` -Please report this to https://github.com/markedjs/marked.`, e) { let s = "

    An error occurred:

    " + Ct(n.message + "", !0) + "
    "; return t ? Promise.resolve(s) : s } if (t) return Promise.reject(n); throw n - } - } - }, pn = new vf; function xe(e, t) { return pn.parse(e, t) } xe.options = xe.setOptions = function (e) { return pn.setOptions(e), xe.defaults = pn.defaults, Ho(xe.defaults), xe }, xe.getDefaults = Sr, xe.defaults = cn, xe.use = function (...e) { return pn.use(...e), xe.defaults = pn.defaults, Ho(xe.defaults), xe }, xe.walkTokens = function (e, t) { return pn.walkTokens(e, t) }, xe.parseInline = pn.parseInline, xe.Parser = wt, xe.parser = wt.parse, xe.Renderer = $s, xe.TextRenderer = Lr, xe.Lexer = yt, xe.lexer = yt.lex, xe.Tokenizer = Ls, xe.Hooks = Zn, xe.parse = xe, xe.options, xe.setOptions, xe.use, xe.walkTokens, xe.parseInline, wt.parse, yt.lex; function sl(e, t) { (t == null || t > e.length) && (t = e.length); for (var n = 0, s = Array(t); n < t; n++)s[n] = e[n]; return s } function _f(e) { if (Array.isArray(e)) return e } function Tf(e, t) { var n = e == null ? null : typeof Symbol != "undefined" && e[Symbol.iterator] || e["@@iterator"]; if (n != null) { var s, r, i, o, a = [], l = !0, f = !1; try { if (i = (n = n.call(e)).next, t !== 0) for (; !(l = (s = i.call(n)).done) && (a.push(s.value), a.length !== t); l = !0); } catch (u) { f = !0, r = u } finally { try { if (!l && n.return != null && (o = n.return(), Object(o) !== o)) return } finally { if (f) throw r } } return a } } function kf() { - throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`) - } function Sf(e, t) { return _f(e) || Tf(e, t) || Ef(e, t) || kf() } function Ef(e, t) { if (e) { if (typeof e == "string") return sl(e, t); var n = {}.toString.call(e).slice(8, -1); return n === "Object" && e.constructor && (n = e.constructor.name), n === "Map" || n === "Set" ? Array.from(e) : n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? sl(e, t) : void 0 } } const rl = Object.entries, il = Object.setPrototypeOf, Af = Object.isFrozen, Rf = Object.getPrototypeOf, Cf = Object.getOwnPropertyDescriptor; let Ze = Object.freeze, dt = Object.seal, Tn = Object.create, ol = typeof Reflect != "undefined" && Reflect, $r = ol.apply, Dr = ol.construct; Ze || (Ze = function (t) { return t }), dt || (dt = function (t) { return t }), $r || ($r = function (t, n) { for (var s = arguments.length, r = new Array(s > 2 ? s - 2 : 0), i = 2; i < s; i++)r[i - 2] = arguments[i]; return t.apply(n, r) }), Dr || (Dr = function (t) { for (var n = arguments.length, s = new Array(n > 1 ? n - 1 : 0), r = 1; r < n; r++)s[r - 1] = arguments[r]; return new t(...s) }); const kn = Ie(Array.prototype.forEach), Pf = Ie(Array.prototype.lastIndexOf), ll = Ie(Array.prototype.pop), Sn = Ie(Array.prototype.push), If = Ie(Array.prototype.splice), Xe = Array.isArray, Xn = Ie(String.prototype.toLowerCase), Nr = Ie(String.prototype.toString), al = Ie(String.prototype.match), En = Ie(String.prototype.replace), ul = Ie(String.prototype.indexOf), Mf = Ie(String.prototype.trim), Of = Ie(Number.prototype.toString), Lf = Ie(Boolean.prototype.toString), cl = typeof BigInt == "undefined" ? null : Ie(BigInt.prototype.toString), fl = typeof Symbol == "undefined" ? null : Ie(Symbol.prototype.toString), Ae = Ie(Object.prototype.hasOwnProperty), Qn = Ie(Object.prototype.toString), ze = Ie(RegExp.prototype.test), Ds = $f(TypeError); function Ie(e) { return function (t) { t instanceof RegExp && (t.lastIndex = 0); for (var n = arguments.length, s = new Array(n > 1 ? n - 1 : 0), r = 1; r < n; r++)s[r - 1] = arguments[r]; return $r(e, t, s) } } function $f(e) { return function () { for (var t = arguments.length, n = new Array(t), s = 0; s < t; s++)n[s] = arguments[s]; return Dr(e, n) } } function X(e, t) { let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : Xn; if (il && il(e, null), !Xe(t)) return e; let s = t.length; for (; s--;) { let r = t[s]; if (typeof r == "string") { const i = n(r); i !== r && (Af(t) || (t[s] = i), r = i) } e[r] = !0 } return e } function Df(e) { for (let t = 0; t < e.length; t++)Ae(e, t) || (e[t] = null); return e } function tt(e) { const t = Tn(null); for (const s of rl(e)) { var n = Sf(s, 2); const r = n[0], i = n[1]; Ae(e, r) && (Xe(i) ? t[r] = Df(i) : i && typeof i == "object" && i.constructor === Object ? t[r] = tt(i) : t[r] = i) } return t } function Nf(e) { switch (typeof e) { case "string": return e; case "number": return Of(e); case "boolean": return Lf(e); case "bigint": return cl ? cl(e) : "0"; case "symbol": return fl ? fl(e) : "Symbol()"; case "undefined": return Qn(e); case "function": case "object": { if (e === null) return Qn(e); const t = e, n = An(t, "toString"); if (typeof n == "function") { const s = n(t); return typeof s == "string" ? s : Qn(s) } return Qn(e) } default: return Qn(e) } } function An(e, t) { for (; e !== null;) { const s = Cf(e, t); if (s) { if (s.get) return Ie(s.get); if (typeof s.value == "function") return Ie(s.value) } e = Rf(e) } function n() { return null } return n } function Ff(e) { try { return ze(e, ""), !0 } catch { return !1 } } const pl = Ze(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), Fr = Ze(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), Br = Ze(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), Bf = Ze(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), Hr = Ze(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]), Hf = Ze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), dl = Ze(["#text"]), hl = Ze(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns"]), zr = Ze(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]), gl = Ze(["accent", "accentunder", "align", "bevelled", "close", "columnalign", "columnlines", "columnspacing", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lquote", "lspace", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]), Ns = Ze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), zf = dt(/{{[\w\W]*|^[\w\W]*}}/g), Uf = dt(/<%[\w\W]*|^[\w\W]*%>/g), jf = dt(/\${[\w\W]*/g), Vf = dt(/^data-[\-\w.\u00B7-\uFFFF]+$/), qf = dt(/^aria-[\-\w]+$/), ml = dt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i), Wf = dt(/^(?:\w+script|data):/i), Gf = dt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g), Kf = dt(/^html$/i), Yf = dt(/^[a-z][.\w]*(-[.\w]+)+$/i), Rn = { element: 1, text: 3, progressingInstruction: 7, comment: 8, document: 9 }, Zf = function () { return typeof window == "undefined" ? null : window }, Xf = function (t, n) { if (typeof t != "object" || typeof t.createPolicy != "function") return null; let s = null; const r = "data-tt-policy-suffix"; n && n.hasAttribute(r) && (s = n.getAttribute(r)); const i = "dompurify" + (s ? "#" + s : ""); try { return t.createPolicy(i, { createHTML(o) { return o }, createScriptURL(o) { return o } }) } catch { return null } }, bl = function () { return { afterSanitizeAttributes: [], afterSanitizeElements: [], afterSanitizeShadowDOM: [], beforeSanitizeAttributes: [], beforeSanitizeElements: [], beforeSanitizeShadowDOM: [], uponSanitizeAttribute: [], uponSanitizeElement: [], uponSanitizeShadowNode: [] } }; function xl() { - let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Zf(); const t = q => xl(q); if (t.version = "3.4.3", t.removed = [], !e || !e.document || e.document.nodeType !== Rn.document || !e.Element) return t.isSupported = !1, t; let n = e.document; const s = n, r = s.currentScript, i = e.DocumentFragment, o = e.HTMLTemplateElement, a = e.Node, l = e.Element, f = e.NodeFilter, u = e.NamedNodeMap, d = u === void 0 ? e.NamedNodeMap || e.MozNamedAttrMap : u, g = e.HTMLFormElement, y = e.DOMParser, E = e.trustedTypes, x = l.prototype, M = An(x, "cloneNode"), m = An(x, "remove"), H = An(x, "nextSibling"), Y = An(x, "childNodes"), $ = An(x, "parentNode"); if (typeof o == "function") { const q = n.createElement("template"); q.content && q.content.ownerDocument && (n = q.content.ownerDocument) } let z, O = ""; const P = n, ee = P.implementation, V = P.createNodeIterator, se = P.createDocumentFragment, fe = P.getElementsByTagName, D = s.importNode; let Z = bl(); t.isSupported = typeof rl == "function" && typeof $ == "function" && ee && ee.createHTMLDocument !== void 0; const Se = zf, Ue = Uf, te = jf, C = Vf, pe = qf, Ge = Wf, re = Gf, B = Yf; let de = ml, ae = null; const ve = X({}, [...pl, ...Fr, ...Br, ...Hr, ...dl]); let ge = null; const nt = X({}, [...hl, ...zr, ...gl, ...Ns]); let ye = Object.seal(Tn(null, { tagNameCheck: { writable: !0, configurable: !1, enumerable: !0, value: null }, attributeNameCheck: { writable: !0, configurable: !1, enumerable: !0, value: null }, allowCustomizedBuiltInElements: { writable: !0, configurable: !1, enumerable: !0, value: !1 } })), ht = null, G = null; const Ce = Object.seal(Tn(null, { tagCheck: { writable: !0, configurable: !1, enumerable: !0, value: null }, attributeCheck: { writable: !0, configurable: !1, enumerable: !0, value: null } })); let Ft = !0, c = !0, h = !1, b = !0, k = !1, v = !0, _ = !1, I = !1, R = !1, A = !1, S = !1, U = !1, L = !0, j = !1; const K = "user-content-"; let ne = !0, he = !1, ie = {}, ke = null; const $e = X({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]); let ot = null; const lt = X({}, ["audio", "video", "img", "source", "image", "track"]); let Bt = null; const Jn = X({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), De = "http://www.w3.org/1998/Math/MathML", Qe = "http://www.w3.org/2000/svg", at = "http://www.w3.org/1999/xhtml"; let Ht = at, Ur = !1, jr = null; const hd = X({}, [De, Qe, at], Nr); let Vr = X({}, ["mi", "mo", "mn", "ms", "mtext"]), qr = X({}, ["annotation-xml"]); const gd = X({}, ["title", "style", "font", "a", "script"]); let es = null; const md = ["application/xhtml+xml", "text/html"], bd = "text/html"; let Le = null, Cn = null; const xd = n.createElement("form"), Sl = function (p) { return p instanceof RegExp || p instanceof Function }, Wr = function () { let p = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; if (Cn && Cn === p) return; (!p || typeof p != "object") && (p = {}), p = tt(p), es = md.indexOf(p.PARSER_MEDIA_TYPE) === -1 ? bd : p.PARSER_MEDIA_TYPE, Le = es === "application/xhtml+xml" ? Nr : Xn, ae = Ae(p, "ALLOWED_TAGS") && Xe(p.ALLOWED_TAGS) ? X({}, p.ALLOWED_TAGS, Le) : ve, ge = Ae(p, "ALLOWED_ATTR") && Xe(p.ALLOWED_ATTR) ? X({}, p.ALLOWED_ATTR, Le) : nt, jr = Ae(p, "ALLOWED_NAMESPACES") && Xe(p.ALLOWED_NAMESPACES) ? X({}, p.ALLOWED_NAMESPACES, Nr) : hd, Bt = Ae(p, "ADD_URI_SAFE_ATTR") && Xe(p.ADD_URI_SAFE_ATTR) ? X(tt(Jn), p.ADD_URI_SAFE_ATTR, Le) : Jn, ot = Ae(p, "ADD_DATA_URI_TAGS") && Xe(p.ADD_DATA_URI_TAGS) ? X(tt(lt), p.ADD_DATA_URI_TAGS, Le) : lt, ke = Ae(p, "FORBID_CONTENTS") && Xe(p.FORBID_CONTENTS) ? X({}, p.FORBID_CONTENTS, Le) : $e, ht = Ae(p, "FORBID_TAGS") && Xe(p.FORBID_TAGS) ? X({}, p.FORBID_TAGS, Le) : tt({}), G = Ae(p, "FORBID_ATTR") && Xe(p.FORBID_ATTR) ? X({}, p.FORBID_ATTR, Le) : tt({}), ie = Ae(p, "USE_PROFILES") ? p.USE_PROFILES && typeof p.USE_PROFILES == "object" ? tt(p.USE_PROFILES) : p.USE_PROFILES : !1, Ft = p.ALLOW_ARIA_ATTR !== !1, c = p.ALLOW_DATA_ATTR !== !1, h = p.ALLOW_UNKNOWN_PROTOCOLS || !1, b = p.ALLOW_SELF_CLOSE_IN_ATTR !== !1, k = p.SAFE_FOR_TEMPLATES || !1, v = p.SAFE_FOR_XML !== !1, _ = p.WHOLE_DOCUMENT || !1, A = p.RETURN_DOM || !1, S = p.RETURN_DOM_FRAGMENT || !1, U = p.RETURN_TRUSTED_TYPE || !1, R = p.FORCE_BODY || !1, L = p.SANITIZE_DOM !== !1, j = p.SANITIZE_NAMED_PROPS || !1, ne = p.KEEP_CONTENT !== !1, he = p.IN_PLACE || !1, de = Ff(p.ALLOWED_URI_REGEXP) ? p.ALLOWED_URI_REGEXP : ml, Ht = typeof p.NAMESPACE == "string" ? p.NAMESPACE : at, Vr = Ae(p, "MATHML_TEXT_INTEGRATION_POINTS") && p.MATHML_TEXT_INTEGRATION_POINTS && typeof p.MATHML_TEXT_INTEGRATION_POINTS == "object" ? tt(p.MATHML_TEXT_INTEGRATION_POINTS) : X({}, ["mi", "mo", "mn", "ms", "mtext"]), qr = Ae(p, "HTML_INTEGRATION_POINTS") && p.HTML_INTEGRATION_POINTS && typeof p.HTML_INTEGRATION_POINTS == "object" ? tt(p.HTML_INTEGRATION_POINTS) : X({}, ["annotation-xml"]); const T = Ae(p, "CUSTOM_ELEMENT_HANDLING") && p.CUSTOM_ELEMENT_HANDLING && typeof p.CUSTOM_ELEMENT_HANDLING == "object" ? tt(p.CUSTOM_ELEMENT_HANDLING) : Tn(null); if (ye = Tn(null), Ae(T, "tagNameCheck") && Sl(T.tagNameCheck) && (ye.tagNameCheck = T.tagNameCheck), Ae(T, "attributeNameCheck") && Sl(T.attributeNameCheck) && (ye.attributeNameCheck = T.attributeNameCheck), Ae(T, "allowCustomizedBuiltInElements") && typeof T.allowCustomizedBuiltInElements == "boolean" && (ye.allowCustomizedBuiltInElements = T.allowCustomizedBuiltInElements), k && (c = !1), S && (A = !0), ie && (ae = X({}, dl), ge = Tn(null), ie.html === !0 && (X(ae, pl), X(ge, hl)), ie.svg === !0 && (X(ae, Fr), X(ge, zr), X(ge, Ns)), ie.svgFilters === !0 && (X(ae, Br), X(ge, zr), X(ge, Ns)), ie.mathMl === !0 && (X(ae, Hr), X(ge, gl), X(ge, Ns))), Ce.tagCheck = null, Ce.attributeCheck = null, Ae(p, "ADD_TAGS") && (typeof p.ADD_TAGS == "function" ? Ce.tagCheck = p.ADD_TAGS : Xe(p.ADD_TAGS) && (ae === ve && (ae = tt(ae)), X(ae, p.ADD_TAGS, Le))), Ae(p, "ADD_ATTR") && (typeof p.ADD_ATTR == "function" ? Ce.attributeCheck = p.ADD_ATTR : Xe(p.ADD_ATTR) && (ge === nt && (ge = tt(ge)), X(ge, p.ADD_ATTR, Le))), Ae(p, "ADD_URI_SAFE_ATTR") && Xe(p.ADD_URI_SAFE_ATTR) && X(Bt, p.ADD_URI_SAFE_ATTR, Le), Ae(p, "FORBID_CONTENTS") && Xe(p.FORBID_CONTENTS) && (ke === $e && (ke = tt(ke)), X(ke, p.FORBID_CONTENTS, Le)), Ae(p, "ADD_FORBID_CONTENTS") && Xe(p.ADD_FORBID_CONTENTS) && (ke === $e && (ke = tt(ke)), X(ke, p.ADD_FORBID_CONTENTS, Le)), ne && (ae["#text"] = !0), _ && X(ae, ["html", "head", "body"]), ae.table && (X(ae, ["tbody"]), delete ht.tbody), p.TRUSTED_TYPES_POLICY) { if (typeof p.TRUSTED_TYPES_POLICY.createHTML != "function") throw Ds('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.'); if (typeof p.TRUSTED_TYPES_POLICY.createScriptURL != "function") throw Ds('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.'); z = p.TRUSTED_TYPES_POLICY, O = z.createHTML("") } else z === void 0 && (z = Xf(E, r)), z !== null && typeof O == "string" && (O = z.createHTML("")); Ze && Ze(p), Cn = p }, El = X({}, [...Fr, ...Br, ...Bf]), Al = X({}, [...Hr, ...Hf]), yd = function (p) { let T = $(p); (!T || !T.tagName) && (T = { namespaceURI: Ht, tagName: "template" }); const N = Xn(p.tagName), ce = Xn(T.tagName); return jr[p.namespaceURI] ? p.namespaceURI === Qe ? T.namespaceURI === at ? N === "svg" : T.namespaceURI === De ? N === "svg" && (ce === "annotation-xml" || Vr[ce]) : !!El[N] : p.namespaceURI === De ? T.namespaceURI === at ? N === "math" : T.namespaceURI === Qe ? N === "math" && qr[ce] : !!Al[N] : p.namespaceURI === at ? T.namespaceURI === Qe && !qr[ce] || T.namespaceURI === De && !Vr[ce] ? !1 : !Al[N] && (gd[N] || !El[N]) : !!(es === "application/xhtml+xml" && jr[p.namespaceURI]) : !1 }, vt = function (p) { Sn(t.removed, { element: p }); try { $(p).removeChild(p) } catch { m(p) } }, dn = function (p, T) { try { Sn(t.removed, { attribute: T.getAttributeNode(p), from: T }) } catch { Sn(t.removed, { attribute: null, from: T }) } if (T.removeAttribute(p), p === "is") if (A || S) try { vt(T) } catch { } else try { T.setAttribute(p, "") } catch { } }, Rl = function (p) { let T = null, N = null; if (R) p = "" + p; else { const Me = al(p, /^[\r\n\t ]+/); N = Me && Me[0] } es === "application/xhtml+xml" && Ht === at && (p = '' + p + ""); const ce = z ? z.createHTML(p) : p; if (Ht === at) try { T = new y().parseFromString(ce, es) } catch { } if (!T || !T.documentElement) { T = ee.createDocument(Ht, "template", null); try { T.documentElement.innerHTML = Ur ? O : ce } catch { } } const Ne = T.body || T.documentElement; return p && N && Ne.insertBefore(n.createTextNode(N), Ne.childNodes[0] || null), Ht === at ? fe.call(T, _ ? "html" : "body")[0] : _ ? T.documentElement : Ne }, Cl = function (p) { return V.call(p.ownerDocument || p, p, f.SHOW_ELEMENT | f.SHOW_COMMENT | f.SHOW_TEXT | f.SHOW_PROCESSING_INSTRUCTION | f.SHOW_CDATA_SECTION, null) }, Gr = function (p) { return p instanceof g && (typeof p.nodeName != "string" || typeof p.textContent != "string" || typeof p.removeChild != "function" || !(p.attributes instanceof d) || typeof p.removeAttribute != "function" || typeof p.setAttribute != "function" || typeof p.namespaceURI != "string" || typeof p.insertBefore != "function" || typeof p.hasChildNodes != "function") }, Kr = function (p) { return typeof a == "function" && p instanceof a }; function zt(q, p, T) { kn(q, N => { N.call(t, p, T, Cn) }) } const Pl = function (p) { let T = null; if (zt(Z.beforeSanitizeElements, p, null), Gr(p)) return vt(p), !0; const N = Le(p.nodeName); if (zt(Z.uponSanitizeElement, p, { tagName: N, allowedTags: ae }), v && p.hasChildNodes() && !Kr(p.firstElementChild) && ze(/<[/\w!]/g, p.innerHTML) && ze(/<[/\w!]/g, p.textContent) || v && p.namespaceURI === at && N === "style" && Kr(p.firstElementChild) || p.nodeType === Rn.progressingInstruction || v && p.nodeType === Rn.comment && ze(/<[/\w]/g, p.data)) return vt(p), !0; if (ht[N] || !(Ce.tagCheck instanceof Function && Ce.tagCheck(N)) && !ae[N]) { if (!ht[N] && Ml(N) && (ye.tagNameCheck instanceof RegExp && ze(ye.tagNameCheck, N) || ye.tagNameCheck instanceof Function && ye.tagNameCheck(N))) return !1; if (ne && !ke[N]) { const ce = $(p) || p.parentNode, Ne = Y(p) || p.childNodes; if (Ne && ce) { const Me = Ne.length; for (let st = Me - 1; st >= 0; --st) { const gt = M(Ne[st], !0); ce.insertBefore(gt, H(p)) } } } return vt(p), !0 } return p instanceof l && !yd(p) || (N === "noscript" || N === "noembed" || N === "noframes") && ze(/<\/no(script|embed|frames)/i, p.innerHTML) ? (vt(p), !0) : (k && p.nodeType === Rn.text && (T = p.textContent, kn([Se, Ue, te], ce => { T = En(T, ce, " ") }), p.textContent !== T && (Sn(t.removed, { element: p.cloneNode() }), p.textContent = T)), zt(Z.afterSanitizeElements, p, null), !1) }, Il = function (p, T, N) { if (G[T] || L && (T === "id" || T === "name") && (N in n || N in xd)) return !1; const ce = ge[T] || Ce.attributeCheck instanceof Function && Ce.attributeCheck(T, p); if (!(c && !G[T] && ze(C, T))) { if (!(Ft && ze(pe, T))) { if (!ce || G[T]) { if (!(Ml(p) && (ye.tagNameCheck instanceof RegExp && ze(ye.tagNameCheck, p) || ye.tagNameCheck instanceof Function && ye.tagNameCheck(p)) && (ye.attributeNameCheck instanceof RegExp && ze(ye.attributeNameCheck, T) || ye.attributeNameCheck instanceof Function && ye.attributeNameCheck(T, p)) || T === "is" && ye.allowCustomizedBuiltInElements && (ye.tagNameCheck instanceof RegExp && ze(ye.tagNameCheck, N) || ye.tagNameCheck instanceof Function && ye.tagNameCheck(N)))) return !1 } else if (!Bt[T]) { if (!ze(de, En(N, re, ""))) { if (!((T === "src" || T === "xlink:href" || T === "href") && p !== "script" && ul(N, "data:") === 0 && ot[p])) { if (!(h && !ze(Ge, En(N, re, "")))) { if (N) return !1 } } } } } } return !0 }, wd = X({}, ["annotation-xml", "color-profile", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "missing-glyph"]), Ml = function (p) { return !wd[Xn(p)] && ze(B, p) }, Ol = function (p) { zt(Z.beforeSanitizeAttributes, p, null); const T = p.attributes; if (!T || Gr(p)) return; const N = { attrName: "", attrValue: "", keepAttr: !0, allowedAttributes: ge, forceKeepAttr: void 0 }; let ce = T.length; for (; ce--;) { const Ne = T[ce], Me = Ne.name, st = Ne.namespaceURI, gt = Ne.value, _t = Le(Me), Zr = gt; let Fe = Me === "value" ? Zr : Mf(Zr); if (N.attrName = _t, N.attrValue = Fe, N.keepAttr = !0, N.forceKeepAttr = void 0, zt(Z.uponSanitizeAttribute, p, N), Fe = N.attrValue, j && (_t === "id" || _t === "name") && ul(Fe, K) !== 0 && (dn(Me, p), Fe = K + Fe), v && ze(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, Fe)) { dn(Me, p); continue } if (_t === "attributename" && al(Fe, "href")) { dn(Me, p); continue } if (N.forceKeepAttr) continue; if (!N.keepAttr) { dn(Me, p); continue } if (!b && ze(/\/>/i, Fe)) { dn(Me, p); continue } k && kn([Se, Ue, te], $l => { Fe = En(Fe, $l, " ") }); const Ll = Le(p.nodeName); if (!Il(Ll, _t, Fe)) { dn(Me, p); continue } if (z && typeof E == "object" && typeof E.getAttributeType == "function" && !st) switch (E.getAttributeType(Ll, _t)) { case "TrustedHTML": { Fe = z.createHTML(Fe); break } case "TrustedScriptURL": { Fe = z.createScriptURL(Fe); break } }if (Fe !== Zr) try { st ? p.setAttributeNS(st, Me, Fe) : p.setAttribute(Me, Fe), Gr(p) ? vt(p) : ll(t.removed) } catch { dn(Me, p) } } zt(Z.afterSanitizeAttributes, p, null) }, Yr = function (p) { let T = null; const N = Cl(p); for (zt(Z.beforeSanitizeShadowDOM, p, null); T = N.nextNode();)zt(Z.uponSanitizeShadowNode, T, null), Pl(T), Ol(T), T.content instanceof i && Yr(T.content); zt(Z.afterSanitizeShadowDOM, p, null) }, Bs = function (p) { if (p.nodeType === Rn.element && p.shadowRoot instanceof i) { const ce = p.shadowRoot; Bs(ce), Yr(ce) } const T = p.childNodes; if (!T) return; const N = []; kn(T, ce => { Sn(N, ce) }); for (const ce of N) Bs(ce) }; return t.sanitize = function (q) { - let p = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, T = null, N = null, ce = null, Ne = null; if (Ur = !q, Ur && (q = ""), typeof q != "string" && !Kr(q) && (q = Nf(q), typeof q != "string")) throw Ds("dirty is not a string, aborting"); if (!t.isSupported) return q; if (I || Wr(p), t.removed = [], typeof q == "string" && (he = !1), he) { const gt = q.nodeName; if (typeof gt == "string") { const _t = Le(gt); if (!ae[_t] || ht[_t]) throw Ds("root node is forbidden and cannot be sanitized in-place") } Bs(q) } else if (q instanceof a) T = Rl(""), N = T.ownerDocument.importNode(q, !0), N.nodeType === Rn.element && N.nodeName === "BODY" || N.nodeName === "HTML" ? T = N : T.appendChild(N), Bs(N); else { if (!A && !k && !_ && q.indexOf("<") === -1) return z && U ? z.createHTML(q) : q; if (T = Rl(q), !T) return A ? null : U ? O : "" } T && R && vt(T.firstChild); const Me = Cl(he ? q : T); for (; ce = Me.nextNode();)Pl(ce), Ol(ce), ce.content instanceof i && Yr(ce.content); if (he) return q; if (A) { if (k) { T.normalize(); let gt = T.innerHTML; kn([Se, Ue, te], _t => { gt = En(gt, _t, " ") }), T.innerHTML = gt } if (S) for (Ne = se.call(T.ownerDocument); T.firstChild;)Ne.appendChild(T.firstChild); else Ne = T; return (ge.shadowroot || ge.shadowrootmode) && (Ne = D.call(s, Ne, !0)), Ne } let st = _ ? T.outerHTML : T.innerHTML; return _ && ae["!doctype"] && T.ownerDocument && T.ownerDocument.doctype && T.ownerDocument.doctype.name && ze(Kf, T.ownerDocument.doctype.name) && (st = " -`+ st), k && kn([Se, Ue, te], gt => { st = En(st, gt, " ") }), z && U ? z.createHTML(st) : st - }, t.setConfig = function () { let q = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; Wr(q), I = !0 }, t.clearConfig = function () { Cn = null, I = !1 }, t.isValidAttribute = function (q, p, T) { Cn || Wr({}); const N = Le(q), ce = Le(p); return Il(N, ce, T) }, t.addHook = function (q, p) { typeof p == "function" && Sn(Z[q], p) }, t.removeHook = function (q, p) { if (p !== void 0) { const T = Pf(Z[q], p); return T === -1 ? void 0 : If(Z[q], T, 1)[0] } return ll(Z[q]) }, t.removeHooks = function (q) { Z[q] = [] }, t.removeAllHooks = function () { Z = bl() }, t - } var Qf = xl(); const Jf = { key: 1, class: "flex min-w-0 max-w-[calc(100%-2.5rem)] flex-1 flex-col max-[600px]:max-w-[calc(100%-2.25rem)]" }, ep = { key: 0, class: "flex w-fit flex-col items-start gap-1" }, tp = ["aria-label"], np = { class: "inline-flex items-center gap-1.5" }, sp = { class: "text-[8px] font-semibold tracking-[0.12em] uppercase text-[#3a67c9]" }, rp = { key: 1, class: "flex w-fit max-w-full flex-col items-start gap-2" }, ip = { class: "chat-card relative w-fit max-w-full whitespace-pre-line rounded-[10px_10px_10px_3px] px-4 py-3 text-xs leading-relaxed wrap-anywhere text-slate-900" }, op = ["innerHTML"], lp = { key: 0, class: "pointer-events-none absolute inset-x-0 bottom-0 h-14 rounded-b-[10px] bg-linear-to-t from-white via-white/92 to-white/0", "aria-hidden": "true" }, ap = { key: 0, class: "flex flex-wrap items-center gap-2" }, up = ["title", "aria-label"], cp = { key: 1, class: "flex flex-wrap items-center" }, fp = ["title", "aria-label"], pp = { viewBox: "0 0 24 24", width: "14", height: "14", fill: "none", stroke: "currentColor", "stroke-width": "2", "aria-hidden": "true" }, dp = ["innerHTML"], yl = { __name: "ChatMessage", props: { message: { type: Object, required: !0 }, autoReadEnabled: { type: Boolean, default: !1 }, ttsConfig: { type: Object, default: () => ({ enableVoiceChat: !1, pollyAvailable: !1, usePolly: !0, voiceId: "Zayd" }) } }, setup(e) { const t = e, n = J(!1), s = J(null), r = J(!1), i = J(!1), o = Ee(() => typeof window != "undefined" && "speechSynthesis" in window && "SpeechSynthesisUtterance" in window); function a(O) { typeof window != "undefined" && window.dispatchEvent(new CustomEvent("changai-tts-provider", { detail: { provider: O } })) } function l(O) { if (typeof O != "string") return ""; const P = O.replace(/[\u{1F000}-\u{1FFFF}]/gu, "").replace(/[\u{2600}-\u{26FF}]/gu, "").replace(/[\u{2700}-\u{27BF}]/gu, "").replace(/\*\*(.*?)\*\*/g, "$1").replace(/\*(.*?)\*/g, "$1").replace(/`([^`]+)`/g, "$1").replace(/#{1,6}\s+/g, "").replace(/[-*+]\s+/g, "").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").replace(/\s+/g, " "); return P.includes("<") ? (new DOMParser().parseFromString(O, "text/html").body.textContent || "").replace(/\s+/g, " ").trim() : P.trim() } function f() { o.value && window.speechSynthesis.cancel(), s.value && (s.value.pause(), s.value.src = "", s.value = null), n.value = !1 } function u() { var O, P, ee; if (i.value = !i.value, i.value) f(); else { const V = M.value; if (!t.autoReadEnabled || !((O = t.ttsConfig) != null && O.enableVoiceChat) || !V || E()) return; if ((P = t.ttsConfig) != null && P.pollyAvailable && ((ee = t.ttsConfig) != null && ee.usePolly)) { g(V).catch(se => { d(V) }); return } d(V) } } function d(O) { if (!o.value || !O) return; window.dispatchEvent(new CustomEvent("changai-tts-stop")), window.speechSynthesis.cancel(); const P = new SpeechSynthesisUtterance(O); P.rate = 1, P.pitch = 1, P.onend = () => { n.value = !1 }, P.onerror = () => { n.value = !1 }, n.value = !0, a("browser"), window.speechSynthesis.speak(P) } async function g(O) { var fe; const P = await Oc(O, ((fe = t.ttsConfig) == null ? void 0 : fe.voiceId) || "Zayd"); if (!(P != null && P.ok) || !(P != null && P.audio_base64)) throw new Error((P == null ? void 0 : P.error) || "Polly synthesis failed"); window.dispatchEvent(new CustomEvent("changai-tts-stop")), f(); const ee = (P == null ? void 0 : P.mime_type) || "audio/mpeg", V = new Audio(`data:${ee};base64,${P.audio_base64}`); s.value = V, n.value = !0; let se = !1; V.onplay = () => { se = !0, a("polly") }, V.onended = () => { s.value === V && (s.value = null), n.value = !1 }, V.onerror = () => { s.value === V && (s.value = null), n.value = !1 }, await V.play(), se || a("polly") } function y() { f() } function E() { var O; return !!((O = t.message) != null && O.isStatus) } function x(O) { const P = O.target.closest("a"); !P || !P.href || (O.preventDefault(), O.stopPropagation(), window.open(P.href, "_blank", "noopener,noreferrer")) } const M = Ee(() => { var O; return l(((O = t.message) == null ? void 0 : O.text) || "") }), m = Ee(() => { var O; return ((O = t.message) == null ? void 0 : O.role) !== "user" && E() }), H = Ee(() => { var O; return (O = t.message) != null && O.isStatus ? t.message.statusType === "support" ? "Sending to support" : M.value || "Thinking" : "" }), Y = Ee(() => { var ee; if (((ee = t.message) == null ? void 0 : ee.role) === "user" || m.value) return !1; const O = M.value, P = O.split(/\n+/).filter(Boolean).length; return O.length > 520 || P > 8 }), $ = Ee(() => { var O, P; return ((O = t.message) == null ? void 0 : O.role) !== "user" && !m.value && ((P = t.ttsConfig) == null ? void 0 : P.enableVoiceChat) }), z = Ee(() => { var P; const O = ((P = t.message) == null ? void 0 : P.text) || ""; return Qf.sanitize(xe.parse(O)) }); return on(() => t.message.text, async (O, P) => { var se, fe, D; if (!t.autoReadEnabled || t.message.role === "user" || i.value) return; if (!((se = t.ttsConfig) != null && se.enableVoiceChat)) { a("off"); return } const ee = l(O); if (!ee || E()) return; const V = l(P || ""); if (ee !== V) { if ((fe = t.ttsConfig) != null && fe.pollyAvailable && ((D = t.ttsConfig) != null && D.usePolly)) try { await g(ee); return } catch { } d(ee) } }), on(() => t.message.text, () => { r.value = !1, i.value = !1 }), zn(() => { typeof window != "undefined" && window.addEventListener("changai-tts-stop", y) }), ys(() => { typeof window != "undefined" && window.removeEventListener("changai-tts-stop", y), n.value && f() }), (O, P) => (F(), W("div", { class: we(["motion-safe:animate-fade-rise flex w-full gap-1.5", e.message.role === "user" ? "flex-col items-end" : "items-start"]) }, [e.message.role !== "user" ? (F(), Et(Fo, { key: 0 })) : qe("", !0), e.message.role !== "user" ? (F(), W("div", Jf, [m.value ? (F(), W("div", ep, [w("div", { class: "chat-card inline-flex w-fit rounded-[10px_10px_10px_3px] px-3 py-2", role: "status", "aria-live": "polite", "aria-label": H.value }, [w("div", np, [P[1] || (P[1] = w("span", { class: "relative inline-flex h-4 w-4 shrink-0 items-center justify-center" }, [w("span", { class: "absolute inset-0 rounded-full border border-transparent border-t-[#4b89ff] border-r-[#4b89ff]/70 animate-gemini-arc" }), w("svg", { viewBox: "0 0 24 24", class: "relative h-3 w-3 text-[#4b89ff] animate-gemini-spark", "aria-hidden": "true" }, [w("path", { fill: "currentColor", d: "M12 2.8c.52 3.22 1.6 5.66 3.22 7.28 1.62 1.62 4.06 2.7 7.28 3.22-3.22.52-5.66 1.6-7.28 3.22-1.62 1.62-2.7 4.06-3.22 7.28-.52-3.22-1.6-5.66-3.22-7.28-1.62-1.62-4.06-2.7-7.28-3.22 3.22-.52 5.66-1.6 7.28-3.22 1.62-1.62 2.7-4.06 3.22-7.28Z" })])], -1)), w("span", sp, Je(H.value), 1)])], 8, tp)])) : (F(), W("div", rp, [w("div", ip, [w("div", { class: we(["overflow-x-auto", Y.value && !r.value ? "max-h-48 overflow-y-hidden" : ""]), innerHTML: z.value, onClick: x }, null, 10, op), Y.value && !r.value ? (F(), W("div", lp)) : qe("", !0)]), Y.value ? (F(), W("div", ap, [w("button", { type: "button", class: "inline-flex items-center rounded-full border border-slate-200 bg-white px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.08em] text-slate-600 transition-colors duration-200 hover:border-brand-200 hover:text-brand-600", title: r.value ? "Collapse response" : "Expand response", "aria-label": r.value ? "Collapse response" : "Expand response", onClick: P[0] || (P[0] = ee => r.value = !r.value) }, Je(r.value ? "Collapse" : "Expand"), 9, up)])) : qe("", !0), $.value ? (F(), W("div", cp, [w("button", { type: "button", class: we(["inline-flex h-8 w-8 items-center justify-center rounded-full border transition-colors duration-200", i.value ? "border-red-200 bg-red-50 text-red-600 hover:border-red-300 hover:bg-red-100" : "border-green-200 bg-green-50 text-green-600 hover:border-green-300 hover:bg-green-100"]), title: i.value ? "Unmute voice playback" : "Mute voice playback", "aria-label": i.value ? "Unmute voice playback" : "Mute voice playback", onClick: u }, [(F(), W("svg", pp, [P[6] || (P[6] = w("path", { d: "M11 5L6 9H3v6h3l5 4V5Z" }, null, -1)), i.value ? (F(), W(He, { key: 0 }, [P[2] || (P[2] = w("path", { d: "M15 9l4 6" }, null, -1)), P[3] || (P[3] = w("path", { d: "M19 9l-4 6" }, null, -1))], 64)) : (F(), W(He, { key: 1 }, [P[4] || (P[4] = w("path", { d: "M15 10a3 3 0 0 1 0 4" }, null, -1)), P[5] || (P[5] = w("path", { d: "M17.5 7.5a6 6 0 0 1 0 9" }, null, -1))], 64))]))], 10, fp)])) : qe("", !0)]))])) : (F(), W("div", { key: 2, class: "w-fit max-w-[85%] whitespace-pre-line rounded-[13px_13px_3px_13px] bg-linear-to-br from-brand-500 to-brand-600 px-4 py-3 text-[11px] leading-relaxed wrap-anywhere text-white shadow-[0_14px_30px_-18px_rgba(109,79,194,0.85)] max-[600px]:max-w-[88%]", innerHTML: z.value }, null, 8, dp))], 2)) } }, hp = { class: "flex flex-col gap-4 sm:gap-5" }, gp = { class: "motion-safe:animate-fade-rise flex w-full items-start gap-1.5" }, mp = { __name: "ChatTab", props: { messages: { type: Array, required: !0 }, autoReadEnabled: { type: Boolean, default: !1 }, ttsConfig: { type: Object, required: !0 } }, setup(e) { return (t, n) => (F(), W("div", hp, [w("div", gp, [Oe(Fo), n[0] || (n[0] = w("p", { class: "w-fit max-w-[calc(100%-2.5rem)] whitespace-pre-line rounded-[10px_10px_10px_3px] bg-brand-50 px-4 py-3 text-xs leading-relaxed wrap-anywhere text-slate-900 max-[600px]:max-w-[calc(100%-2.25rem)]" }, [Ss(" Hello there 👋 I am ChangAI from "), w("a", { target: "_blank", href: "https://erpgulf.com", rel: "noopener noreferrer", style: { color: "#1e90ff" } }, "ERPGulf.com"), Ss(", your ERP assistant."), w("br"), w("a", { target: "_blank", href: "https://app.erpgulf.com/en/articles/chang-ai-quick-start-guide", rel: "noopener noreferrer", style: { color: "#1e90ff" } }, "ChangAI Quick Start Guide - Click here.")], -1))]), (F(!0), W(He, null, ws(e.messages, (s, r) => (F(), Et(yl, { key: r, message: s, autoReadEnabled: e.autoReadEnabled, ttsConfig: e.ttsConfig }, null, 8, ["message", "autoReadEnabled", "ttsConfig"]))), 128))])) } }; function wl(e) { try { return JSON.stringify(e, null, 2) } catch { return String(e) } } function vl(e) { var t, n; return (e == null ? void 0 : e.message) || ((t = e == null ? void 0 : e.responseJSON) == null ? void 0 : t.exception) || ((n = e == null ? void 0 : e.responseJSON) == null ? void 0 : n.message) || (e == null ? void 0 : e.responseText) || String(e) } function bp(e) { return typeof e == "string" ? e : e && typeof e == "object" ? e.error ? `⚠️ ${e.error}` : e.answer || e.text || "" : "" } const xp = { key: 0, class: "rounded-lg bg-brand-50 px-4 py-3 text-xs text-black" }, yp = { class: "whitespace-pre-wrap wrap-anywhere text-[11px] leading-relaxed text-black" }, wp = { key: 1, class: "mb-3 min-w-0 overflow-x-auto rounded-lg bg-brand-50 p-2 text-[11px]" }, vp = { class: "whitespace-pre-wrap wrap-anywhere text-[11px] leading-relaxed text-black" }, _p = { __name: "DebugTab", props: { logs: { type: Array, required: !0 }, currentDebug: { type: Object, default: null } }, setup(e) { const t = new Set(["gemini_json_content", "private_key", "private_key_id", "client_secret", "client_id", "aws_access_key", "aws_secret_key", "api_key", "token", "access_token", "refresh_token", "password", "secret", "authorization", "embed_version_id", "llm_version_id", "entity_retriever", "retriever", "deploy_url", "support_api_url", "get_ticket_details_url"]); function n(r, i = 0) { if (i > 10 || r === null || r === void 0 || typeof r == "string" || typeof r == "number" || typeof r == "boolean") return r; if (Array.isArray(r)) return r.map(o => n(o, i + 1)); if (typeof r == "object") { const o = {}; for (const [a, l] of Object.entries(r)) t.has(a.toLowerCase()) || (o[a] = n(l, i + 1)); return o } return r } function s(r) { return wl(n(r)) } return (r, i) => (F(), W("div", null, [e.logs.length === 0 ? (F(), W("p", xp, "No debug data yet.")) : qe("", !0), (F(!0), W(He, null, ws(e.logs, (o, a) => (F(), W("div", { key: a, class: "mb-3 min-w-0 overflow-x-auto rounded-lg bg-gray-100 p-2 text-[11px]" }, [w("pre", yp, Je(s(o)), 1)]))), 128)), e.currentDebug ? (F(), W("div", wp, [w("pre", vp, Je(s(e.currentDebug)), 1)])) : qe("", !0)])) } }, Tp = { class: "flex flex-col gap-4 sm:gap-5" }, kp = { key: 0, class: "chat-card motion-safe:animate-fade-rise rounded-lg px-4 py-3 text-xs text-slate-900" }, Sp = { __name: "SupportTab", props: { messages: { type: Array, required: !0 }, autoReadEnabled: { type: Boolean, default: !1 }, ttsConfig: { type: Object, required: !0 } }, setup(e) { return (t, n) => (F(), W("div", Tp, [e.messages.length === 0 ? (F(), W("p", kp, "Send a message to Support.")) : qe("", !0), (F(!0), W(He, null, ws(e.messages, (s, r) => (F(), Et(yl, { key: r, message: s, autoReadEnabled: e.autoReadEnabled, ttsConfig: e.ttsConfig }, null, 8, ["message", "autoReadEnabled", "ttsConfig"]))), 128))])) } }, Ep = { class: "flex flex-col gap-4" }, Ap = { class: "chat-card motion-safe:animate-fade-rise rounded-xl p-4" }, Rp = { class: "flex items-start justify-between gap-4" }, Cp = ["aria-pressed", "title"], Pp = { class: "chat-card motion-safe:animate-fade-rise rounded-xl p-4" }, Ip = { class: "flex items-start justify-between gap-4" }, Mp = { class: "mt-2 text-[11px] text-slate-500" }, Op = { key: 0, class: "mt-1 text-[11px] text-slate-500" }, Lp = { key: 1, class: "mt-1 text-[11px] text-slate-500" }, $p = ["aria-pressed", "disabled"], Dp = { key: 0, class: "mt-3 rounded-md bg-amber-50 px-2.5 py-2 text-xs text-amber-700" }, Np = { key: 1, class: "mt-3 rounded-md bg-amber-50 px-2.5 py-2 text-xs text-amber-700" }, Fp = { class: "chat-card motion-safe:animate-fade-rise rounded-xl p-4" }, Bp = { class: "flex items-start justify-between gap-4" }, Hp = ["aria-pressed", "title"], zp = { class: "chat-card motion-safe:animate-fade-rise rounded-xl p-4" }, Up = { class: "flex items-start justify-between gap-4" }, jp = ["aria-pressed", "title"], Vp = { __name: "SettingsTab", props: { autoReadEnabled: { type: Boolean, required: !0 }, ttsConfig: { type: Object, required: !0 }, settings: { type: Object, default: null }, debugEnabled: { type: Boolean, default: !1 }, sendNonERPtoaiEnabled: { type: Boolean, default: !1 } }, emits: ["toggleAutoRead", "togglePollyPreference", "toggleDebug", "toggleSendNonERP"], setup(e) { const t = e, n = Ee(() => { var s, r; return (s = t.ttsConfig) != null && s.enableVoiceChat ? (r = t.ttsConfig) != null && r.pollyAvailable ? "Available" : "Unavailable" : "Voice disabled on server" }); return (s, r) => { var i, o, a, l, f, u, d, g, y, E, x, M, m, H, Y; return F(), W("div", Ep, [r[10] || (r[10] = w("div", { class: "chat-card motion-safe:animate-fade-rise rounded-xl p-4 text-slate-900" }, [w("h3", { class: "text-sm font-semibold tracking-[0.01em]" }, "Speech Settings"), w("p", { class: "mt-1 text-xs leading-relaxed text-slate-600" }, "These controls apply only inside this chatbot box for the current browser session.")], -1)), w("div", Ap, [w("div", Rp, [r[4] || (r[4] = w("div", null, [w("p", { class: "text-sm font-semibold text-slate-900" }, "Auto Read Replies"), w("p", { class: "mt-1 text-xs text-slate-600" }, "Automatically read bot replies aloud.")], -1)), w("button", { class: we(["group relative h-7 w-12 shrink-0 rounded-full border border-slate-200 transition-all duration-200", e.autoReadEnabled ? "bg-emerald-500/95" : "bg-slate-300"]), "aria-pressed": e.autoReadEnabled ? "true" : "false", title: e.autoReadEnabled ? "Disable auto read" : "Enable auto read", onClick: r[0] || (r[0] = $ => s.$emit("toggleAutoRead")) }, [w("span", { class: we(["absolute top-0.5 h-5.5 w-5.5 rounded-full bg-white shadow-sm transition-all duration-200", e.autoReadEnabled ? "left-[1.45rem]" : "left-0.5"]) }, null, 2)], 10, Cp)]), w("p", { class: we(["mt-3 text-[11px] font-medium", e.autoReadEnabled ? "text-emerald-700" : "text-slate-500"]) }, Je(e.autoReadEnabled ? "Auto read is active." : "Auto read is currently off."), 3)]), w("div", Pp, [w("div", Ip, [w("div", null, [r[5] || (r[5] = w("p", { class: "text-sm font-semibold text-slate-900" }, "Use Amazon Polly", -1)), r[6] || (r[6] = w("p", { class: "mt-1 text-xs text-slate-600" }, "Use Polly when available; otherwise browser speech is used automatically.", -1)), w("p", Mp, "Availability: " + Je(n.value), 1), (i = e.settings) != null && i.aws_region ? (F(), W("p", Op, "Region: " + Je(e.settings.aws_region), 1)) : qe("", !0), (o = e.ttsConfig) != null && o.voiceId ? (F(), W("p", Lp, "Voice: " + Je(e.ttsConfig.voiceId), 1)) : qe("", !0)]), w("button", { class: we(["relative h-7 w-12 shrink-0 rounded-full border border-slate-200 transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-55", (a = e.ttsConfig) != null && a.usePolly && ((l = e.ttsConfig) != null && l.enableVoiceChat) && ((f = e.ttsConfig) != null && f.pollyAvailable) ? "bg-emerald-500/95" : "bg-slate-300"]), "aria-pressed": (u = e.ttsConfig) != null && u.usePolly && ((d = e.ttsConfig) != null && d.enableVoiceChat) && ((g = e.ttsConfig) != null && g.pollyAvailable) ? "true" : "false", disabled: !((y = e.ttsConfig) != null && y.pollyAvailable) || !((E = e.ttsConfig) != null && E.enableVoiceChat), onClick: r[1] || (r[1] = $ => s.$emit("togglePollyPreference")) }, [w("span", { class: we(["absolute top-0.5 h-5.5 w-5.5 rounded-full bg-white shadow-sm transition-all duration-200", (x = e.ttsConfig) != null && x.usePolly && ((M = e.ttsConfig) != null && M.enableVoiceChat) && ((m = e.ttsConfig) != null && m.pollyAvailable) ? "left-[1.45rem]" : "left-0.5"]) }, null, 2)], 10, $p)]), (H = e.ttsConfig) != null && H.enableVoiceChat ? (Y = e.ttsConfig) != null && Y.pollyAvailable ? qe("", !0) : (F(), W("p", Np, "Polly is not available for this site. Browser speech will be used.")) : (F(), W("p", Dp, "Voice chat is disabled in ChangAI Settings."))]), w("div", Fp, [w("div", Bp, [w("div", null, [r[7] || (r[7] = w("p", { class: "text-sm font-semibold text-slate-900" }, "Enable Debug Tab", -1)), r[8] || (r[8] = w("p", { class: "mt-1 text-xs text-slate-600" }, " Show or hide the Debug tab inside this chatbot. ", -1)), w("p", { class: we(["mt-2 text-[11px] font-medium", e.debugEnabled ? "text-emerald-700" : "text-slate-500"]) }, Je(e.debugEnabled ? "Debug tab is active." : "Debug tab is currently off."), 3)]), w("button", { type: "button", class: we(["relative h-7 w-12 shrink-0 rounded-full border border-slate-200 transition-all duration-200", e.debugEnabled ? "bg-emerald-500/95" : "bg-slate-300"]), "aria-pressed": e.debugEnabled ? "true" : "false", title: e.debugEnabled ? "Disable debug tab" : "Enable debug tab", onClick: r[2] || (r[2] = $ => s.$emit("toggleDebug")) }, [w("span", { class: we(["absolute top-0.5 h-5.5 w-5.5 rounded-full bg-white shadow-sm transition-all duration-200", e.debugEnabled ? "left-[1.45rem]" : "left-0.5"]) }, null, 2)], 10, Hp)])]), w("div", zp, [w("div", Up, [r[9] || (r[9] = w("div", null, [w("p", { class: "text-sm font-semibold text-slate-900" }, "Send non-ERP questions directly to AI"), w("p", { class: "mt-1 text-xs text-slate-600" }, "Questions unrelated to your ERP will skip the system and go straight to AI")], -1)), w("button", { class: we(["group relative h-7 w-12 shrink-0 rounded-full border border-slate-200 transition-all duration-200", e.sendNonERPtoaiEnabled ? "bg-emerald-500/95" : "bg-slate-300"]), "aria-pressed": e.sendNonERPtoaiEnabled ? "true" : "false", title: e.sendNonERPtoaiEnabled ? "Non-ERP questions are being sent directly to AI" : "Enable direct AI reply for non-ERP questions", onClick: r[3] || (r[3] = $ => s.$emit("toggleSendNonERP")) }, [w("span", { class: we(["absolute top-0.5 h-5.5 w-5.5 rounded-full bg-white shadow-sm transition-all duration-200", e.sendNonERPtoaiEnabled ? "left-[1.45rem]" : "left-0.5"]) }, null, 2)], 10, jp)]), w("p", { class: we(["mt-3 text-[11px] font-medium", e.sendNonERPtoaiEnabled ? "text-emerald-700" : "text-slate-500"]) }, Je(e.sendNonERPtoaiEnabled ? "Non-ERP questions are now routed directly to AI" : "Direct AI routing is currently off"), 3)])]) } } }, qp = { key: 0, class: "pointer-events-none absolute -top-14 left-0 right-0 z-20 flex justify-center px-2", role: "status", "aria-live": "polite" }, Wp = { __name: "StatusToast", props: { visible: { type: Boolean, required: !0 }, message: { type: String, default: "" }, type: { type: String, default: "info" }, dismissible: { type: Boolean, default: !0 } }, emits: ["close"], setup(e) { const t = e, n = Ee(() => t.type === "error" ? "bg-red-50 text-red-700 ring-red-200" : (t.type === "listening", "bg-blue-50 text-blue-700 ring-blue-200")), s = Ee(() => t.type === "error" ? "bg-red-500" : t.type === "listening" ? "bg-blue-500 animate-pulse" : "bg-blue-500"); return (r, i) => (F(), Et(Pu, { "enter-active-class": "transition duration-200 ease-out", "enter-from-class": "translate-y-1 opacity-0", "enter-to-class": "translate-y-0 opacity-100", "leave-active-class": "transition duration-150 ease-in", "leave-from-class": "translate-y-0 opacity-100", "leave-to-class": "translate-y-1 opacity-0" }, { default: Di(() => [e.visible ? (F(), W("div", qp, [w("div", { class: we(["pointer-events-auto flex max-w-[92%] items-start gap-2 rounded-lg px-3 py-2 text-xs shadow-lg ring-1", n.value]) }, [w("span", { class: we(["mt-0.5 h-2 w-2 shrink-0 rounded-full", s.value]) }, null, 2), w("span", null, Je(e.message), 1), e.dismissible ? (F(), W("button", { key: 0, type: "button", class: "ml-1 appearance-none border-0 text-current/80 transition hover:text-current focus:outline-none", "aria-label": "Dismiss notification", onClick: i[0] || (i[0] = o => r.$emit("close")) }, " × ")) : qe("", !0)], 2)])) : qe("", !0)]), _: 1 })) } }, Gp = { class: "relative w-full" }, Kp = ["placeholder", "disabled"], Yp = ["title", "aria-label", "disabled"], Zp = { key: 0, viewBox: "0 0 24 24", width: "16", height: "16", fill: "currentColor", "aria-hidden": "true" }, Xp = { key: 1, viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", "stroke-width": "2", "aria-hidden": "true" }, Qp = { key: 2, viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", "stroke-width": "2", "aria-hidden": "true", class: "animate-spin" }, Jp = ["title", "aria-label", "disabled"], ed = { key: 0, viewBox: "0 0 24 24", width: "18", height: "18", fill: "none", "aria-hidden": "true", class: "text-rose-600 motion-safe:animate-stop-button-pulse" }, td = { key: 1, viewBox: "0 0 24 24", width: "16", height: "16", fill: "currentColor", "aria-hidden": "true" }, nd = { __name: "ChatForm", props: { placeholder: { type: String, default: "Message..." }, disabled: { type: Boolean, default: !1 }, isAwaitingResponse: { type: Boolean, default: !1 } }, emits: ["submit", "cancel"], setup(e, { expose: t, emit: n }) { const s = e, r = n, i = J(""), o = J(null), a = J(!1), l = J(!1), f = J(!1), u = J(!1), d = J(!1), g = J(!1), y = J(!1), E = J(""), x = J("info"), M = J("Voice input is unavailable in this browser/context."); let m = null, H = null, Y = null; const $ = J(""), z = J(!1), O = Ee(() => f.value ? "Requesting microphone permission..." : u.value ? "Starting voice input..." : d.value ? "Stopping voice input..." : l.value ? a.value ? "Stop voice input" : "Start voice input" : "Voice input is unavailable in this browser/context"), P = Ee(() => s.isAwaitingResponse ? "Stop response" : "Send"), ee = Ee(() => s.isAwaitingResponse ? !1 : s.disabled || !i.value.trim()), V = Ee(() => s.isAwaitingResponse ? "bg-white border border-rose-100 shadow-[0_8px_20px_-12px_rgba(159,18,57,0.35)] hover:bg-rose-50" : "bg-linear-to-br from-brand-500 to-brand-600 text-white shadow-[0_10px_24px_-16px_rgba(109,79,194,0.85)] hover:from-brand-600 hover:to-violet-700"); function se() { return typeof window == "undefined" ? null : window.SpeechRecognition || window.webkitSpeechRecognition || null } function fe() { var ae; const re = se(), B = typeof window != "undefined" ? window.isSecureContext : !1, de = typeof navigator != "undefined" && !!((ae = navigator.mediaDevices) != null && ae.getUserMedia); l.value = !!(re && B && de), B ? (!de || !re) && (M.value = "Voice input is not supported in this browser.") : M.value = "Voice input requires HTTPS (or localhost).", re && l.value && (m = new re, m.continuous = !0, m.interimResults = !0, m.lang = typeof navigator != "undefined" && navigator.language || "en-US", m.onstart = () => { a.value = !0, u.value = !1, d.value = !1, D(), C("Listening... Tap mic to stop", "listening", { persistent: !0, key: "listening" }) }, m.onend = () => { a.value = !1, u.value = !1, d.value = !1, D(), $.value === "listening" && pe(), z.value && (z.value = !1, Ge()) }, m.onerror = ve => { if (a.value = !1, u.value = !1, d.value = !1, D(), z.value = !1, (ve == null ? void 0 : ve.error) === "not-allowed" || (ve == null ? void 0 : ve.error) === "service-not-allowed") { C("Microphone permission denied. Please allow microphone access in browser settings.", "error"); return } if ((ve == null ? void 0 : ve.error) === "audio-capture") { C("No microphone detected. Please connect a microphone and try again.", "error"); return } if ((ve == null ? void 0 : ve.error) === "no-speech") { C("No speech detected. Try speaking a bit louder.", "info"); return } C("Voice input failed. Please try again.", "error") }, m.onresult = ve => { let ge = ""; for (let nt = ve.resultIndex; nt < ve.results.length; nt += 1)ge += ve.results[nt][0].transcript; i.value = ge.trimStart() }) } function D() { Y && (clearTimeout(Y), Y = null) } function Z(re = {}) { const { submitAfterStop: B = !1 } = re; if (m) { z.value = B, u.value = !1, d.value = !0, D(); try { m.stop() } catch { d.value = !1, B && (z.value = !1, Ge()); return } Y = setTimeout(() => { if (m && !(!a.value && !d.value)) try { m.abort() } catch { d.value = !1, z.value = !1 } }, 1200) } } function Se() { if (!l.value || !m) { C(M.value, "error"); return } if (a.value || u.value || d.value) { Z({ submitAfterStop: a.value }); return } te() } async function Ue() { var re; if (g.value) return !0; if (!((re = navigator.mediaDevices) != null && re.getUserMedia)) return C("Microphone API is unavailable in this browser.", "error"), !1; f.value = !0, C("Requesting microphone permission...", "info", { persistent: !0, key: "requesting" }); try { return (await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach(de => de.stop()), g.value = !0, !0 } catch (B) { return (B == null ? void 0 : B.name) === "NotAllowedError" || (B == null ? void 0 : B.name) === "SecurityError" ? C("Microphone permission denied. Please allow it and try again.", "error") : (B == null ? void 0 : B.name) === "NotFoundError" ? C("No microphone found on this device.", "error") : C("Unable to access microphone. Please check browser permissions.", "error"), !1 } finally { f.value = !1, $.value === "requesting" && pe() } } async function te() { var B; if (!(!m || a.value || u.value || d.value || !await Ue() || !m)) { z.value = !1, (B = o.value) == null || B.focus(), u.value = !0; try { m.start() } catch (de) { u.value = !1, d.value = !1, (de == null ? void 0 : de.name) !== "InvalidStateError" && C("Unable to start voice input. Please try again.", "error") } } } function C(re, B = "info", de = {}) { const { duration: ae = 4200, persistent: ve = !1, key: ge = "" } = de; E.value = re, x.value = B, $.value = ge, y.value = !0, H && clearTimeout(H), ve || (H = setTimeout(() => { y.value = !1, $.value = "" }, ae)) } function pe() { y.value = !1, $.value = "", H && (clearTimeout(H), H = null) } function Ge() { if (s.isAwaitingResponse) { r("cancel"); return } const re = i.value.trim(); re && ((a.value || u.value || d.value) && m && Z({ submitAfterStop: !1 }), r("submit", re), i.value = "") } return t({ focus: () => { var re; return (re = o.value) == null ? void 0 : re.focus() } }), zn(() => { fe() }), ys(() => { if (m && (a.value || u.value || d.value)) { z.value = !1, D(); try { m.abort() } catch { } } D(), pe() }), (re, B) => (F(), W("div", Gp, [w("form", { class: "group flex min-h-11 items-center gap-2 rounded-full border border-slate-200/90 bg-white/95 px-3 shadow-[0_12px_26px_-20px_rgba(15,23,42,0.7)] transition-all duration-250 focus-within:-translate-y-0.5 focus-within:border-brand-200 focus-within:shadow-[0_18px_30px_-20px_rgba(13,110,253,0.5)] focus-within:ring-2 focus-within:ring-brand-500/25", style: { "border-radius": "9999px" }, autocomplete: "off", onSubmit: pt(Ge, ["prevent"]), onClick: B[5] || (B[5] = pt(() => { }, ["stop"])), onMousedown: B[6] || (B[6] = pt(() => { }, ["stop"])), onKeydown: B[7] || (B[7] = pt(() => { }, ["stop"])), onKeyup: B[8] || (B[8] = pt(() => { }, ["stop"])) }, [Pa(w("input", { ref_key: "inputRef", ref: o, type: "text", "onUpdate:modelValue": B[0] || (B[0] = de => i.value = de), class: "h-11 w-full border-none bg-transparent text-sm font-medium text-slate-800 placeholder:text-slate-400 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50", placeholder: e.disabled ? "Waiting for response..." : e.placeholder, disabled: e.disabled, required: "", onKeydown: B[1] || (B[1] = pt(() => { }, ["stop"])), onKeyup: B[2] || (B[2] = pt(() => { }, ["stop"])), onKeypress: B[3] || (B[3] = pt(() => { }, ["stop"])), onInput: B[4] || (B[4] = pt(() => { }, ["stop"])) }, null, 40, Kp), [[Xu, i.value]]), w("button", { type: "button", class: we(["grid h-8 w-8 shrink-0 appearance-none place-items-center rounded-full border border-transparent text-slate-600 transition-all duration-200 hover:-translate-y-0.5 hover:border-slate-200 hover:bg-slate-100 hover:text-slate-900 focus:outline-none disabled:cursor-not-allowed disabled:opacity-40", a.value ? "border-red-200 bg-red-100 text-red-600 shadow-[0_10px_20px_-18px_rgba(220,38,38,0.9)] hover:bg-red-100 hover:text-red-600" : ""]), style: { "border-radius": "9999px" }, title: O.value, "aria-label": O.value, disabled: e.disabled || !l.value || f.value || u.value || d.value, onClick: Se }, [a.value && !f.value ? (F(), W("svg", Zp, B[9] || (B[9] = [w("rect", { x: "6", y: "6", width: "12", height: "12", rx: "2" }, null, -1)]))) : f.value ? (F(), W("svg", Qp, B[11] || (B[11] = [w("circle", { cx: "12", cy: "12", r: "9", opacity: "0.3" }, null, -1), w("path", { d: "M21 12a9 9 0 0 1-9 9" }, null, -1)]))) : (F(), W("svg", Xp, B[10] || (B[10] = [w("path", { d: "M12 3a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3z" }, null, -1), w("path", { d: "M19 10v2a7 7 0 0 1-14 0v-2" }, null, -1), w("path", { d: "M12 19v3" }, null, -1)])))], 10, Yp), w("button", { type: "submit", title: P.value, "aria-label": P.value, class: we(["grid h-8 w-8 shrink-0 appearance-none place-items-center rounded-full border-0 transition-all duration-200 hover:-translate-y-0.5 focus:outline-none disabled:cursor-not-allowed disabled:opacity-40", V.value]), style: { "border-radius": "9999px" }, disabled: ee.value }, [e.isAwaitingResponse ? (F(), W("svg", ed, B[12] || (B[12] = [w("circle", { cx: "12", cy: "12", r: "8", stroke: "currentColor", "stroke-width": "2.1", class: "opacity-95" }, null, -1), w("rect", { x: "9", y: "9", width: "6", height: "6", rx: "1.35", fill: "currentColor" }, null, -1)]))) : (F(), W("svg", td, B[13] || (B[13] = [w("path", { d: "M4 12l1.41 1.41L11 7.83V20h2V7.83l5.59 5.58L20 12l-8-8-8 8z" }, null, -1)])))], 10, Jp)], 32), Oe(Wp, { visible: y.value, message: E.value, type: x.value, dismissible: x.value !== "listening", onClose: pe }, null, 8, ["visible", "message", "type", "dismissible"])])) } }, sd = { class: "relative overflow-hidden bg-linear-to-br from-brand-600 via-brand-500 to-violet-400" }, rd = { class: "min-w-0" }, id = { key: 1, class: "border-t border-slate-200/80 bg-white/90 px-3 py-3 pb-[calc(12px+env(safe-area-inset-bottom))] backdrop-blur-sm sm:px-4 sm:py-4" }, od = 56, ld = { __name: "ChatbotPopup", props: { isOpen: { type: Boolean, required: !0 }, activeTab: { type: String, required: !0 }, debugEnabled: { type: Boolean, default: !1 }, sendNonERPtoaiEnabled: { type: Boolean, default: !1 }, chatHistory: { type: Array, required: !0 }, debugLogs: { type: Array, required: !0 }, currentDebug: { type: Object, default: null }, supportHistory: { type: Array, required: !0 }, autoReadEnabled: { type: Boolean, required: !0 }, ttsConfig: { type: Object, required: !0 }, activeTtsProvider: { type: String, required: !0 }, settings: { type: Object, default: null }, isAwaitingChatResponse: { type: Boolean, default: !1 }, isAwaitingSupportResponse: { type: Boolean, default: !1 } }, emits: ["close", "submit", "cancelResponse", "update:activeTab", "toggleAutoRead", "togglePollyPreference", "toggleDebug", "toggleSendNonERP"], setup(e, { expose: t, emit: n }) { const s = e, r = n, i = J(null), o = J(null), a = J(s.activeTab), l = J("default"), f = J(!1), u = Ee(() => a.value === "support" ? s.isAwaitingSupportResponse : a.value === "chat" ? s.isAwaitingChatResponse : !1); function d() { const M = i.value; if (!s.isOpen || !M) { f.value = !1; return } const m = M.scrollHeight - M.clientHeight; if (m <= 4) { f.value = !1; return } const H = m - M.scrollTop; f.value = H > od } function g() { const M = i.value; M && (M.scrollTo({ top: M.scrollHeight, behavior: "smooth" }), setTimeout(() => { d() }, 220)) } function y() { St(() => { d() }) } function E() { if (l.value === "default") { l.value = "half"; return } if (l.value === "half") { l.value = "full"; return } l.value = "default" } const x = Ee(() => { const M = "chat-shell fixed z-[9999] flex min-h-0 flex-col overflow-hidden border border-slate-200/80 shadow-[0_32px_80px_-44px_rgba(2,6,23,0.7),0_18px_40px_-24px_rgba(15,23,42,0.45)] transition-all duration-300 ease-out origin-bottom-right", m = s.isOpen ? "pointer-events-auto opacity-100 translate-x-0 translate-y-0 scale-100 motion-safe:animate-surface-in" : "pointer-events-none opacity-0 translate-x-1/5 translate-y-8 scale-95"; return l.value === "full" ? [M, m, "inset-0 h-screen w-screen max-h-screen max-w-screen rounded-none origin-center"] : l.value === "half" ? [M, m, "bottom-[74px] right-5 h-[min(86vh,860px)] w-[min(50vw,860px)] rounded-2xl", "max-[900px]:bottom-[78px] max-[900px]:right-3 max-[900px]:h-[min(86vh,760px)] max-[900px]:w-[min(70vw,760px)] max-[900px]:rounded-[14px]", "max-[600px]:inset-0 max-[600px]:h-screen max-[600px]:w-screen max-[600px]:max-h-screen max-[600px]:max-w-screen max-[600px]:rounded-none max-[600px]:pb-[env(safe-area-inset-bottom)]"] : [M, m, "bottom-[74px] right-5 h-[min(560px,72vh)] w-[min(360px,calc(100vw-40px))] rounded-2xl", "max-[900px]:bottom-[78px] max-[900px]:right-3 max-[900px]:h-[min(70vh,540px)] max-[900px]:w-[min(360px,calc(100vw-24px))] max-[900px]:rounded-[14px]", "max-[600px]:inset-0 max-[600px]:h-screen max-[600px]:w-screen max-[600px]:max-h-screen max-[600px]:max-w-screen max-[600px]:rounded-none max-[600px]:pb-[env(safe-area-inset-bottom)]"] }); return on(() => s.activeTab, M => { a.value = M, y() }), on(() => s.isOpen, M => { M && a.value !== "settings" && St(() => { var m; return (m = o.value) == null ? void 0 : m.focus() }), y() }), on(a, M => { r("update:activeTab", M), y() }), on(() => [s.chatHistory.length, s.supportHistory.length, s.debugLogs.length, s.currentDebug], () => { y() }), on(() => s.debugEnabled, M => { !M && a.value === "debug" && (a.value = "chat"), y() }), zn(() => { y() }), t({ scrollToBottom() { St(() => { g() }) } }), (M, m) => (F(), W("div", { class: we(x.value), onKeydown: m[9] || (m[9] = pt(() => { }, ["stop"])), onKeyup: m[10] || (m[10] = pt(() => { }, ["stop"])), onKeypress: m[11] || (m[11] = pt(() => { }, ["stop"])) }, [m[14] || (m[14] = w("div", { class: "pointer-events-none absolute -right-14 -top-14 h-36 w-36 rounded-full bg-brand-500/15 blur-2xl" }, null, -1)), m[15] || (m[15] = w("div", { class: "pointer-events-none absolute -bottom-14 -left-12 h-32 w-32 rounded-full bg-violet-400/15 blur-2xl" }, null, -1)), w("div", sd, [m[12] || (m[12] = w("div", { class: "pointer-events-none absolute inset-0 opacity-45", style: { background: "linear-gradient(120deg, rgba(255,255,255,0.16) 0%, rgba(255,255,255,0.02) 52%, rgba(255,255,255,0.12) 100%)" } }, null, -1)), Oe(vc, { windowMode: l.value, autoReadEnabled: e.autoReadEnabled, activeTtsProvider: e.activeTtsProvider, onClose: m[0] || (m[0] = H => M.$emit("close")), onCycleResize: E, onToggleAutoRead: m[1] || (m[1] = H => M.$emit("toggleAutoRead")) }, null, 8, ["windowMode", "autoReadEnabled", "activeTtsProvider"]), Oe(Sc, { modelValue: a.value, "onUpdate:modelValue": m[2] || (m[2] = H => a.value = H), debugEnabled: e.debugEnabled }, null, 8, ["modelValue", "debugEnabled"])]), w("div", { class: "chat-scrollbar min-h-0 flex-1 overflow-x-hidden overflow-y-scroll bg-slate-50/60 px-4 py-4 max-[900px]:px-3.5 max-[900px]:py-3.5 max-[600px]:px-3 max-[600px]:py-3", ref_key: "chatBodyRef", ref: i, onScrollPassive: d }, [w("div", rd, [a.value === "chat" ? (F(), Et(mp, { key: 0, messages: e.chatHistory, autoReadEnabled: e.autoReadEnabled, ttsConfig: e.ttsConfig }, null, 8, ["messages", "autoReadEnabled", "ttsConfig"])) : a.value === "debug" && e.debugEnabled ? (F(), Et(_p, { key: 1, logs: e.debugLogs, currentDebug: e.currentDebug }, null, 8, ["logs", "currentDebug"])) : a.value === "support" ? (F(), Et(Sp, { key: 2, messages: e.supportHistory, autoReadEnabled: e.autoReadEnabled, ttsConfig: e.ttsConfig }, null, 8, ["messages", "autoReadEnabled", "ttsConfig"])) : a.value === "settings" ? (F(), Et(Vp, { key: 3, autoReadEnabled: e.autoReadEnabled, ttsConfig: e.ttsConfig, settings: e.settings, debugEnabled: e.debugEnabled, sendNonERPtoaiEnabled: e.sendNonERPtoaiEnabled, onToggleAutoRead: m[3] || (m[3] = H => M.$emit("toggleAutoRead")), onTogglePollyPreference: m[4] || (m[4] = H => M.$emit("togglePollyPreference")), onToggleDebug: m[5] || (m[5] = H => M.$emit("toggleDebug")), onToggleSendNonERP: m[6] || (m[6] = H => M.$emit("toggleSendNonERP")) }, null, 8, ["autoReadEnabled", "ttsConfig", "settings", "debugEnabled", "sendNonERPtoaiEnabled"])) : qe("", !0)])], 544), f.value ? (F(), W("button", { key: 0, type: "button", class: we(["absolute right-4 z-20 grid h-9 w-9 place-items-center rounded-full border border-brand-200/70 bg-white/95 text-brand-600 shadow-[0_14px_26px_-16px_rgba(15,23,42,0.65)] transition-all duration-200 hover:-translate-y-0.5 hover:border-brand-300 hover:text-brand-700 focus:outline-none", a.value !== "settings" ? "bottom-[calc(90px+env(safe-area-inset-bottom))] sm:bottom-[96px]" : "bottom-4 sm:bottom-5"]), title: "Scroll to bottom", "aria-label": "Scroll to bottom", onClick: g }, m[13] || (m[13] = [w("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", "stroke-width": "2", "aria-hidden": "true" }, [w("path", { d: "M7 10l5 5 5-5" })], -1)]), 2)) : qe("", !0), a.value !== "settings" ? (F(), W("div", id, [Oe(nd, { ref_key: "chatFormRef", ref: o, placeholder: a.value === "support" ? "Message Support..." : "Message...", disabled: u.value, isAwaitingResponse: u.value, onSubmit: m[7] || (m[7] = H => M.$emit("submit", H)), onCancel: m[8] || (m[8] = H => M.$emit("cancelResponse")) }, null, 8, ["placeholder", "disabled", "isAwaitingResponse"])])) : qe("", !0)], 34)) } }, _l = "changai_chat_id", Tl = "changai_polly_enabled"; function ad() { let e = sessionStorage.getItem(_l); return e || (e = `session_${Date.now()}_${crypto.randomUUID()}`, sessionStorage.setItem(_l, e)), e } function ud() { const e = localStorage.getItem(Tl); return e === null ? !0 : e === "true" } function cd(e) { localStorage.setItem(Tl, String(!!e)) } const fd = { __name: "App", setup(e) { const t = J(!1), n = J("chat"), s = J([]), r = J([]), i = J(!1), o = J([]), a = J(null), l = J("actual"), f = J(!0), u = J(null), d = J(!1), g = J(null), y = J(!1), E = J({ enableVoiceChat: !1, pollyAvailable: !1, usePolly: !0, voiceId: "Zayd", enable_changai: !1 }), x = J("off"), M = J(null), m = J(null), H = Ee(() => M.value !== null), Y = Ee(() => m.value !== null); function $() { if (!E.value.enableVoiceChat) { x.value = "off"; return } x.value = E.value.usePolly ? "polly" : "browser" } function z(te) { var pe; const C = (pe = te == null ? void 0 : te.detail) == null ? void 0 : pe.provider; (C === "polly" || C === "browser" || C === "off") && (x.value = C) } async function O() { var pe, Ge, re, B, de; if (!(d.value || u.value)) { d.value = !0; try { u.value = await Mc(l.value), E.value = { enableVoiceChat: !!((pe = u.value) != null && pe.enable_voice_chat), pollyAvailable: !!((Ge = u.value) != null && Ge.polly_enabled), usePolly: !!((re = u.value) != null && re.polly_enabled) && ud(), voiceId: ((B = u.value) == null ? void 0 : B.polly_voice_id) || "Zayd", enable_changai: !!((de = u.value) != null && de.enable_changai) }, $(), r.value.push({ type: "settings", settings: u.value }) } catch (ae) { const ve = vl(ae); r.value.push({ type: "settings", error: ve }) } finally { d.value = !1 } } } function P() { t.value = !t.value } function ee() { var te; (te = a.value) == null || te.scrollToBottom() } function V() { f.value = !f.value } function se() { const te = !E.value.usePolly; E.value = { ...E.value, usePolly: te && E.value.pollyAvailable }, cd(E.value.usePolly), $() } function fe() { y.value = !y.value } async function D(te) { n.value === "support" ? await Ue(te) : await Z(te) } async function Z(te) { var ye, ht; g.value = null, l.value === "actual" && await O(), s.value.push({ role: "user", text: te }), await St(), ee(); const C = cs({ role: "model", text: "Thinking...", cancelable: !0, isStatus: !0, statusType: "thinking" }); s.value.push(C), await St(), ee(); let pe = !1; const Ge = ad(), re = `${Ge}_${Date.now()}`, B = y.value, de = Pc(te, Ge, l.value, re, y.value), ae = `debug_${re}`; let ve = Date.now(); const ge = [], nt = G => { var h; const Ce = Date.now(), Ft = ((Ce - ve) / 1e3).toFixed(2); ve = Ce; const c = `${G.message} (${Ft}s)`; if (G.message && (ge.push(c), g.value = c), !G.done && G.message && (C.text = G.message, C.statusType = "pipeline"), G.done) { C.cancelable = !1, G.error ? (C.text = `⚠️ ${G.message || "Something failed"}`, C.isStatus = !1, C.statusType = null) : (h = G.data) != null && h.answer && (C.text = G.data.answer, C.isStatus = !1, C.statusType = null), frappe.realtime.off(ae), g.value = null; return } }; frappe.realtime.on(ae, nt), M.value = () => { pe || (pe = !0, de.cancel(), frappe.realtime.off(ae), C.isStatus = !1, C.statusType = null, C.text = "Cancelled by user.", r.value.push({ type: "cancelled", user: te, steps: [...ge] }), g.value = null, C.cancelable = !1, M.value = null) }; try { const G = await de.promise; if (G != null && G.open_report) { if (C.isStatus = !1, C.statusType = null, C.text = `Opening "${G.report_name}" report." `, r.value.push({ type: "success", steps: [...ge], final_response: G, entity_raw: G.entity_raw }), g.value = null, !G.report_name) { C.text = "Report name extraction failed.Can you ask the same question again?"; return } frappe.set_route("query-report", G.report_name, G.filters || {}); return } else if (G != null && G.create_entity) { C.isStatus = !1, C.statusType = null, C.cancelable = !1, C.text = `Opening "${G.doc}" doctype for creating Entity "${G.entity_name}" record.`, r.value.push({ type: "success", user: te, steps: [...ge], final_response: G }), g.value = null; const Ft = G.doc, c = G.entity_name || "", b = { Customer: { customer_name: c }, Supplier: { supplier_name: c }, Employee: { employee_name: c }, Item: { item_code: c, item_name: c }, Project: { project_name: c }, Lead: { lead_name: c }, Opportunity: { opportunity_name: c } }[Ft] || {}; frappe.route_options = b, frappe.set_route("Form", Ft, "new"); const k = setInterval(() => { cur_frm && cur_frm.doctype === Ft && cur_frm.is_new() && (clearInterval(k), Object.entries(b).forEach(([v, _]) => { _ && cur_frm.fields_dict[v] && (cur_frm.set_value(v, _), cur_frm.refresh_field(v)) })) }, 200); return } if (pe) return; C.cancelable = !1; const Ce = ((ye = bp(G == null ? void 0 : G.Bot)) == null ? void 0 : ye.trim()) || "No response."; C.isStatus = !1, C.statusType = null, C.text = Ce, r.value.push({ type: "success", user: te, steps: [...ge], final_response: G }), g.value = null } catch (G) { if (pe) return; frappe.realtime.off(ae), C.cancelable = !1, C.isStatus = !1, C.statusType = null; const Ce = vl(G); g.value = null, r.value.push({ type: "failed", user: te, steps: [...ge], error: Ce }), (G == null ? void 0 : G.code) === "ERR_NETWORK_CHANGED" || (ht = G == null ? void 0 : G.message) != null && ht.includes("ERR_NETWORK_CHANGED") ? (C.isStatus = !1, C.statusType = null, C.text = "⚠️ Network error. Please check your connection and try again.") : (C.isStatus = !1, C.statusType = null, C.text = "⚠️ Something went wrong. Please try again.") } finally { frappe.realtime.off(ae), pe || (M.value = null) } await St(), ee() } function Se() { var te, C; if (n.value === "support") { (te = m.value) == null || te.call(m); return } (C = M.value) == null || C.call(M) } async function Ue(te) { o.value.push({ role: "user", text: te }), await St(), ee(); const C = cs({ role: "model", text: "Sending to support...", isStatus: !0, statusType: "support" }); o.value.push(C), await St(), ee(); let pe = !1; const Ge = Ic(te, l.value); m.value = () => { pe || (pe = !0, Ge.cancel(), C.isStatus = !1, C.statusType = null, C.text = "Cancelled by user.", m.value = null) }; try { const re = await Ge.promise; if (pe) return; C.isStatus = !1, C.statusType = null, C.text = re ? wl(re) : "Support request sent successfully." } catch { if (pe) return; C.isStatus = !1, C.statusType = null, C.text = "⚠️ Failed to reach support. Please try again." } finally { pe || (m.value = null) } await St(), ee() } return zn(() => { typeof window != "undefined" && window.addEventListener("changai-tts-provider", z), l.value === "actual" && O() }), ys(() => { typeof window != "undefined" && window.removeEventListener("changai-tts-provider", z) }), (te, C) => (F(), W(He, null, [E.value.enable_changai ? (F(), Et(ac, { key: 0, isOpen: t.value, onToggle: P }, null, 8, ["isOpen"])) : qe("", !0), Oe(ld, { ref_key: "popupRef", ref: a, isOpen: t.value, activeTab: n.value, "onUpdate:activeTab": C[0] || (C[0] = pe => n.value = pe), chatHistory: s.value, debugLogs: r.value, currentDebug: g.value, supportHistory: o.value, autoReadEnabled: f.value, ttsConfig: E.value, activeTtsProvider: x.value, settings: u.value, isAwaitingChatResponse: H.value, isAwaitingSupportResponse: Y.value, debugEnabled: i.value, sendNonERPtoaiEnabled: y.value, onToggleDebug: C[1] || (C[1] = pe => i.value = !i.value), onClose: C[2] || (C[2] = pe => t.value = !1), onSubmit: D, onCancelResponse: Se, onToggleAutoRead: V, onTogglePollyPreference: se, onToggleSendNonERP: fe }, null, 8, ["isOpen", "activeTab", "chatHistory", "debugLogs", "currentDebug", "supportHistory", "autoReadEnabled", "ttsConfig", "activeTtsProvider", "settings", "isAwaitingChatResponse", "isAwaitingSupportResponse", "debugEnabled", "sendNonERPtoaiEnabled"])], 64)) } }; function pd() { const e = document.querySelector('link[href*="/assets/changai/dist/changai-chatbot.css"]'); if (e != null && e.href) return e.href; const t = Array.from(document.scripts).find(n => { var s; return (s = n.src) == null ? void 0 : s.includes("/assets/changai/dist/changai-chatbot.js") }); return t != null && t.src ? t.src.replace(/changai-chatbot\.js(\?.*)?$/, "changai-chatbot.css$1") : null } function dd(e) { const t = pd(); if (!t) { const n = Array.from(document.querySelectorAll("style[data-vite-dev-id]")); return n.length && n.forEach(s => { const r = document.createElement("style"); r.dataset.changaiShadowDevStyle = "1", r.textContent = s.textContent || "", e.appendChild(r) }), Promise.resolve() } return e.querySelector('link[data-changai-shadow-style="1"]') ? Promise.resolve() : new Promise(n => { const s = document.createElement("link"); s.rel = "stylesheet", s.href = t, s.dataset.changaiShadowStyle = "1", s.onload = () => n(), s.onerror = () => n(), e.appendChild(s), setTimeout(n, 1200) }) } async function kl() { if (document.getElementById("changai-chatbot-host")) return; const e = document.createElement("div"); e.id = "changai-chatbot-host", document.body.appendChild(e); const t = e.attachShadow({ mode: "open" }); await dd(t); const n = document.createElement("div"); n.id = "changai-chatbot-root", t.appendChild(n), nc(fd).mount(n); function s(r) { r.stopPropagation() } n.addEventListener("keydown", s), n.addEventListener("keyup", s), n.addEventListener("keypress", s) } document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", kl) : kl() -})(); +`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+` +`}strong({tokens:e}){return`${this.parser.parseInline(e)}`}em({tokens:e}){return`${this.parser.parseInline(e)}`}codespan({text:e}){return`${Ct(e,!0)}`}br(e){return"
    "}del({tokens:e}){return`${this.parser.parseInline(e)}`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),r=Ql(e);if(r===null)return s;e=r;let i='
    ",i}image({href:e,title:t,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let r=Ql(e);if(r===null)return Ct(n);e=r;let i=`${Ct(n)}{let o=l[a].flat(1/0);n=n.concat(this.walkTokens(o,t))}):l.tokens&&(n=n.concat(this.walkTokens(l.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let i=t.renderers[r.name];i?t.renderers[r.name]=function(...l){let a=r.renderer.apply(this,l);return a===!1&&(a=i.apply(this,l)),a}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=t[r.level];i?i.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),s.extensions=t),n.renderer){let r=this.defaults.renderer||new $s(this.defaults);for(let i in n.renderer){if(!(i in r))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let l=i,a=n.renderer[l],o=r[l];r[l]=(...c)=>{let u=a.apply(r,c);return u===!1&&(u=o.apply(r,c)),u||""}}s.renderer=r}if(n.tokenizer){let r=this.defaults.tokenizer||new Ls(this.defaults);for(let i in n.tokenizer){if(!(i in r))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let l=i,a=n.tokenizer[l],o=r[l];r[l]=(...c)=>{let u=a.apply(r,c);return u===!1&&(u=o.apply(r,c)),u}}s.tokenizer=r}if(n.hooks){let r=this.defaults.hooks||new Zn;for(let i in n.hooks){if(!(i in r))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let l=i,a=n.hooks[l],o=r[l];Zn.passThroughHooks.has(i)?r[l]=c=>{if(this.defaults.async&&Zn.passThroughHooksRespectAsync.has(i))return(async()=>{let d=await a.call(r,c);return o.call(r,d)})();let u=a.call(r,c);return o.call(r,u)}:r[l]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await a.apply(r,c);return d===!1&&(d=await o.apply(r,c)),d})();let u=a.apply(r,c);return u===!1&&(u=o.apply(r,c)),u}}s.hooks=r}if(n.walkTokens){let r=this.defaults.walkTokens,i=n.walkTokens;s.walkTokens=function(l){let a=[];return a.push(i.call(this,l)),r&&(a=a.concat(r.call(this,l))),a}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return yt.lex(e,t!=null?t:this.defaults)}parser(e,t){return wt.parse(e,t!=null?t:this.defaults)}parseMarkdown(e){return(t,n)=>{let s={...n},r={...this.defaults,...s},i=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&s.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=e),r.async)return(async()=>{let l=r.hooks?await r.hooks.preprocess(t):t,a=await(r.hooks?await r.hooks.provideLexer(e):e?yt.lex:yt.lexInline)(l,r),o=r.hooks?await r.hooks.processAllTokens(a):a;r.walkTokens&&await Promise.all(this.walkTokens(o,r.walkTokens));let c=await(r.hooks?await r.hooks.provideParser(e):e?wt.parse:wt.parseInline)(o,r);return r.hooks?await r.hooks.postprocess(c):c})().catch(i);try{r.hooks&&(t=r.hooks.preprocess(t));let l=(r.hooks?r.hooks.provideLexer(e):e?yt.lex:yt.lexInline)(t,r);r.hooks&&(l=r.hooks.processAllTokens(l)),r.walkTokens&&this.walkTokens(l,r.walkTokens);let a=(r.hooks?r.hooks.provideParser(e):e?wt.parse:wt.parseInline)(l,r);return r.hooks&&(a=r.hooks.postprocess(a)),a}catch(l){return i(l)}}}onError(e,t){return n=>{if(n.message+=` +Please report this to https://github.com/markedjs/marked.`,e){let s="

    An error occurred:

    "+Ct(n.message+"",!0)+"
    ";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}},pn=new vf;function xe(e,t){return pn.parse(e,t)}xe.options=xe.setOptions=function(e){return pn.setOptions(e),xe.defaults=pn.defaults,Bl(xe.defaults),xe},xe.getDefaults=Sr,xe.defaults=cn,xe.use=function(...e){return pn.use(...e),xe.defaults=pn.defaults,Bl(xe.defaults),xe},xe.walkTokens=function(e,t){return pn.walkTokens(e,t)},xe.parseInline=pn.parseInline,xe.Parser=wt,xe.parser=wt.parse,xe.Renderer=$s,xe.TextRenderer=Lr,xe.Lexer=yt,xe.lexer=yt.lex,xe.Tokenizer=Ls,xe.Hooks=Zn,xe.parse=xe,xe.options,xe.setOptions,xe.use,xe.walkTokens,xe.parseInline,wt.parse,yt.lex;function no(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,s=Array(t);n2?s-2:0),i=2;i1?n-1:0),r=1;r1?n-1:0),r=1;r2&&arguments[2]!==void 0?arguments[2]:Xn;if(ro&&ro(e,null),!Xe(t))return e;let s=t.length;for(;s--;){let r=t[s];if(typeof r=="string"){const i=n(r);i!==r&&(Af(t)||(t[s]=i),r=i)}e[r]=!0}return e}function Df(e){for(let t=0;t/g),jf=ht(/\${[\w\W]*/g),Vf=ht(/^data-[\-\w.\u00B7-\uFFFF]+$/),qf=ht(/^aria-[\-\w]+$/),mo=ht(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Wf=ht(/^(?:\w+script|data):/i),Gf=ht(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Kf=ht(/^html$/i),Yf=ht(/^[a-z][.\w]*(-[.\w]+)+$/i),Rn={element:1,text:3,progressingInstruction:7,comment:8,document:9},Zf=function(){return typeof window=="undefined"?null:window},Xf=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let s=null;const r="data-tt-policy-suffix";n&&n.hasAttribute(r)&&(s=n.getAttribute(r));const i="dompurify"+(s?"#"+s:"");try{return t.createPolicy(i,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return null}},bo=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function xo(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Zf();const t=W=>xo(W);if(t.version="3.4.3",t.removed=[],!e||!e.document||e.document.nodeType!==Rn.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const s=n,r=s.currentScript,i=e.DocumentFragment,l=e.HTMLTemplateElement,a=e.Node,o=e.Element,c=e.NodeFilter,u=e.NamedNodeMap,d=u===void 0?e.NamedNodeMap||e.MozNamedAttrMap:u,g=e.HTMLFormElement,y=e.DOMParser,E=e.trustedTypes,x=o.prototype,M=An(x,"cloneNode"),m=An(x,"remove"),H=An(x,"nextSibling"),Y=An(x,"childNodes"),$=An(x,"parentNode");if(typeof l=="function"){const W=n.createElement("template");W.content&&W.content.ownerDocument&&(n=W.content.ownerDocument)}let U,L="";const O=n,ee=O.implementation,q=O.createNodeIterator,se=O.createDocumentFragment,fe=O.getElementsByTagName,D=s.importNode;let Z=bo();t.isSupported=typeof so=="function"&&typeof $=="function"&&ee&&ee.createHTMLDocument!==void 0;const Se=zf,je=Uf,te=jf,R=Vf,he=qf,Le=Wf,re=Gf,F=Yf;let ue=mo,ge=null;const Te=X({},[...fo,...Fr,...Br,...Hr,...po]);let pe=null;const Qe=X({},[...ho,...zr,...go,...Ns]);let ye=Object.seal(Tn(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),j=null,st=null;const Ie=Object.seal(Tn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ft=!0,f=!0,h=!1,b=!0,k=!1,v=!0,_=!1,P=!1,C=!1,A=!1,S=!1,z=!1,I=!0,V=!1;const K="user-content-";let ne=!0,de=!1,ie={},ke=null;const De=X({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ot=null;const at=X({},["audio","video","img","source","image","track"]);let Bt=null;const Jn=X({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ne="http://www.w3.org/1998/Math/MathML",Je="http://www.w3.org/2000/svg",ut="http://www.w3.org/1999/xhtml";let Ht=ut,Ur=!1,jr=null;const hd=X({},[Ne,Je,ut],Nr);let Vr=X({},["mi","mo","mn","ms","mtext"]),qr=X({},["annotation-xml"]);const gd=X({},["title","style","font","a","script"]);let es=null;const md=["application/xhtml+xml","text/html"],bd="text/html";let $e=null,Cn=null;const xd=n.createElement("form"),So=function(p){return p instanceof RegExp||p instanceof Function},Wr=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Cn&&Cn===p)return;(!p||typeof p!="object")&&(p={}),p=nt(p),es=md.indexOf(p.PARSER_MEDIA_TYPE)===-1?bd:p.PARSER_MEDIA_TYPE,$e=es==="application/xhtml+xml"?Nr:Xn,ge=Ae(p,"ALLOWED_TAGS")&&Xe(p.ALLOWED_TAGS)?X({},p.ALLOWED_TAGS,$e):Te,pe=Ae(p,"ALLOWED_ATTR")&&Xe(p.ALLOWED_ATTR)?X({},p.ALLOWED_ATTR,$e):Qe,jr=Ae(p,"ALLOWED_NAMESPACES")&&Xe(p.ALLOWED_NAMESPACES)?X({},p.ALLOWED_NAMESPACES,Nr):hd,Bt=Ae(p,"ADD_URI_SAFE_ATTR")&&Xe(p.ADD_URI_SAFE_ATTR)?X(nt(Jn),p.ADD_URI_SAFE_ATTR,$e):Jn,ot=Ae(p,"ADD_DATA_URI_TAGS")&&Xe(p.ADD_DATA_URI_TAGS)?X(nt(at),p.ADD_DATA_URI_TAGS,$e):at,ke=Ae(p,"FORBID_CONTENTS")&&Xe(p.FORBID_CONTENTS)?X({},p.FORBID_CONTENTS,$e):De,j=Ae(p,"FORBID_TAGS")&&Xe(p.FORBID_TAGS)?X({},p.FORBID_TAGS,$e):nt({}),st=Ae(p,"FORBID_ATTR")&&Xe(p.FORBID_ATTR)?X({},p.FORBID_ATTR,$e):nt({}),ie=Ae(p,"USE_PROFILES")?p.USE_PROFILES&&typeof p.USE_PROFILES=="object"?nt(p.USE_PROFILES):p.USE_PROFILES:!1,Ft=p.ALLOW_ARIA_ATTR!==!1,f=p.ALLOW_DATA_ATTR!==!1,h=p.ALLOW_UNKNOWN_PROTOCOLS||!1,b=p.ALLOW_SELF_CLOSE_IN_ATTR!==!1,k=p.SAFE_FOR_TEMPLATES||!1,v=p.SAFE_FOR_XML!==!1,_=p.WHOLE_DOCUMENT||!1,A=p.RETURN_DOM||!1,S=p.RETURN_DOM_FRAGMENT||!1,z=p.RETURN_TRUSTED_TYPE||!1,C=p.FORCE_BODY||!1,I=p.SANITIZE_DOM!==!1,V=p.SANITIZE_NAMED_PROPS||!1,ne=p.KEEP_CONTENT!==!1,de=p.IN_PLACE||!1,ue=Ff(p.ALLOWED_URI_REGEXP)?p.ALLOWED_URI_REGEXP:mo,Ht=typeof p.NAMESPACE=="string"?p.NAMESPACE:ut,Vr=Ae(p,"MATHML_TEXT_INTEGRATION_POINTS")&&p.MATHML_TEXT_INTEGRATION_POINTS&&typeof p.MATHML_TEXT_INTEGRATION_POINTS=="object"?nt(p.MATHML_TEXT_INTEGRATION_POINTS):X({},["mi","mo","mn","ms","mtext"]),qr=Ae(p,"HTML_INTEGRATION_POINTS")&&p.HTML_INTEGRATION_POINTS&&typeof p.HTML_INTEGRATION_POINTS=="object"?nt(p.HTML_INTEGRATION_POINTS):X({},["annotation-xml"]);const T=Ae(p,"CUSTOM_ELEMENT_HANDLING")&&p.CUSTOM_ELEMENT_HANDLING&&typeof p.CUSTOM_ELEMENT_HANDLING=="object"?nt(p.CUSTOM_ELEMENT_HANDLING):Tn(null);if(ye=Tn(null),Ae(T,"tagNameCheck")&&So(T.tagNameCheck)&&(ye.tagNameCheck=T.tagNameCheck),Ae(T,"attributeNameCheck")&&So(T.attributeNameCheck)&&(ye.attributeNameCheck=T.attributeNameCheck),Ae(T,"allowCustomizedBuiltInElements")&&typeof T.allowCustomizedBuiltInElements=="boolean"&&(ye.allowCustomizedBuiltInElements=T.allowCustomizedBuiltInElements),k&&(f=!1),S&&(A=!0),ie&&(ge=X({},po),pe=Tn(null),ie.html===!0&&(X(ge,fo),X(pe,ho)),ie.svg===!0&&(X(ge,Fr),X(pe,zr),X(pe,Ns)),ie.svgFilters===!0&&(X(ge,Br),X(pe,zr),X(pe,Ns)),ie.mathMl===!0&&(X(ge,Hr),X(pe,go),X(pe,Ns))),Ie.tagCheck=null,Ie.attributeCheck=null,Ae(p,"ADD_TAGS")&&(typeof p.ADD_TAGS=="function"?Ie.tagCheck=p.ADD_TAGS:Xe(p.ADD_TAGS)&&(ge===Te&&(ge=nt(ge)),X(ge,p.ADD_TAGS,$e))),Ae(p,"ADD_ATTR")&&(typeof p.ADD_ATTR=="function"?Ie.attributeCheck=p.ADD_ATTR:Xe(p.ADD_ATTR)&&(pe===Qe&&(pe=nt(pe)),X(pe,p.ADD_ATTR,$e))),Ae(p,"ADD_URI_SAFE_ATTR")&&Xe(p.ADD_URI_SAFE_ATTR)&&X(Bt,p.ADD_URI_SAFE_ATTR,$e),Ae(p,"FORBID_CONTENTS")&&Xe(p.FORBID_CONTENTS)&&(ke===De&&(ke=nt(ke)),X(ke,p.FORBID_CONTENTS,$e)),Ae(p,"ADD_FORBID_CONTENTS")&&Xe(p.ADD_FORBID_CONTENTS)&&(ke===De&&(ke=nt(ke)),X(ke,p.ADD_FORBID_CONTENTS,$e)),ne&&(ge["#text"]=!0),_&&X(ge,["html","head","body"]),ge.table&&(X(ge,["tbody"]),delete j.tbody),p.TRUSTED_TYPES_POLICY){if(typeof p.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ds('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof p.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ds('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');U=p.TRUSTED_TYPES_POLICY,L=U.createHTML("")}else U===void 0&&(U=Xf(E,r)),U!==null&&typeof L=="string"&&(L=U.createHTML(""));Ze&&Ze(p),Cn=p},Eo=X({},[...Fr,...Br,...Bf]),Ao=X({},[...Hr,...Hf]),yd=function(p){let T=$(p);(!T||!T.tagName)&&(T={namespaceURI:Ht,tagName:"template"});const N=Xn(p.tagName),ce=Xn(T.tagName);return jr[p.namespaceURI]?p.namespaceURI===Je?T.namespaceURI===ut?N==="svg":T.namespaceURI===Ne?N==="svg"&&(ce==="annotation-xml"||Vr[ce]):!!Eo[N]:p.namespaceURI===Ne?T.namespaceURI===ut?N==="math":T.namespaceURI===Je?N==="math"&&qr[ce]:!!Ao[N]:p.namespaceURI===ut?T.namespaceURI===Je&&!qr[ce]||T.namespaceURI===Ne&&!Vr[ce]?!1:!Ao[N]&&(gd[N]||!Eo[N]):!!(es==="application/xhtml+xml"&&jr[p.namespaceURI]):!1},vt=function(p){Sn(t.removed,{element:p});try{$(p).removeChild(p)}catch{m(p)}},dn=function(p,T){try{Sn(t.removed,{attribute:T.getAttributeNode(p),from:T})}catch{Sn(t.removed,{attribute:null,from:T})}if(T.removeAttribute(p),p==="is")if(A||S)try{vt(T)}catch{}else try{T.setAttribute(p,"")}catch{}},Ro=function(p){let T=null,N=null;if(C)p=""+p;else{const Oe=oo(p,/^[\r\n\t ]+/);N=Oe&&Oe[0]}es==="application/xhtml+xml"&&Ht===ut&&(p=''+p+"");const ce=U?U.createHTML(p):p;if(Ht===ut)try{T=new y().parseFromString(ce,es)}catch{}if(!T||!T.documentElement){T=ee.createDocument(Ht,"template",null);try{T.documentElement.innerHTML=Ur?L:ce}catch{}}const Fe=T.body||T.documentElement;return p&&N&&Fe.insertBefore(n.createTextNode(N),Fe.childNodes[0]||null),Ht===ut?fe.call(T,_?"html":"body")[0]:_?T.documentElement:Fe},Co=function(p){return q.call(p.ownerDocument||p,p,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Gr=function(p){return p instanceof g&&(typeof p.nodeName!="string"||typeof p.textContent!="string"||typeof p.removeChild!="function"||!(p.attributes instanceof d)||typeof p.removeAttribute!="function"||typeof p.setAttribute!="function"||typeof p.namespaceURI!="string"||typeof p.insertBefore!="function"||typeof p.hasChildNodes!="function")},Kr=function(p){return typeof a=="function"&&p instanceof a};function zt(W,p,T){kn(W,N=>{N.call(t,p,T,Cn)})}const Po=function(p){let T=null;if(zt(Z.beforeSanitizeElements,p,null),Gr(p))return vt(p),!0;const N=$e(p.nodeName);if(zt(Z.uponSanitizeElement,p,{tagName:N,allowedTags:ge}),v&&p.hasChildNodes()&&!Kr(p.firstElementChild)&&Ue(/<[/\w!]/g,p.innerHTML)&&Ue(/<[/\w!]/g,p.textContent)||v&&p.namespaceURI===ut&&N==="style"&&Kr(p.firstElementChild)||p.nodeType===Rn.progressingInstruction||v&&p.nodeType===Rn.comment&&Ue(/<[/\w]/g,p.data))return vt(p),!0;if(j[N]||!(Ie.tagCheck instanceof Function&&Ie.tagCheck(N))&&!ge[N]){if(!j[N]&&Oo(N)&&(ye.tagNameCheck instanceof RegExp&&Ue(ye.tagNameCheck,N)||ye.tagNameCheck instanceof Function&&ye.tagNameCheck(N)))return!1;if(ne&&!ke[N]){const ce=$(p)||p.parentNode,Fe=Y(p)||p.childNodes;if(Fe&&ce){const Oe=Fe.length;for(let rt=Oe-1;rt>=0;--rt){const gt=M(Fe[rt],!0);ce.insertBefore(gt,H(p))}}}return vt(p),!0}return p instanceof o&&!yd(p)||(N==="noscript"||N==="noembed"||N==="noframes")&&Ue(/<\/no(script|embed|frames)/i,p.innerHTML)?(vt(p),!0):(k&&p.nodeType===Rn.text&&(T=p.textContent,kn([Se,je,te],ce=>{T=En(T,ce," ")}),p.textContent!==T&&(Sn(t.removed,{element:p.cloneNode()}),p.textContent=T)),zt(Z.afterSanitizeElements,p,null),!1)},Io=function(p,T,N){if(st[T]||I&&(T==="id"||T==="name")&&(N in n||N in xd))return!1;const ce=pe[T]||Ie.attributeCheck instanceof Function&&Ie.attributeCheck(T,p);if(!(f&&!st[T]&&Ue(R,T))){if(!(Ft&&Ue(he,T))){if(!ce||st[T]){if(!(Oo(p)&&(ye.tagNameCheck instanceof RegExp&&Ue(ye.tagNameCheck,p)||ye.tagNameCheck instanceof Function&&ye.tagNameCheck(p))&&(ye.attributeNameCheck instanceof RegExp&&Ue(ye.attributeNameCheck,T)||ye.attributeNameCheck instanceof Function&&ye.attributeNameCheck(T,p))||T==="is"&&ye.allowCustomizedBuiltInElements&&(ye.tagNameCheck instanceof RegExp&&Ue(ye.tagNameCheck,N)||ye.tagNameCheck instanceof Function&&ye.tagNameCheck(N))))return!1}else if(!Bt[T]){if(!Ue(ue,En(N,re,""))){if(!((T==="src"||T==="xlink:href"||T==="href")&&p!=="script"&&ao(N,"data:")===0&&ot[p])){if(!(h&&!Ue(Le,En(N,re,"")))){if(N)return!1}}}}}}return!0},wd=X({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Oo=function(p){return!wd[Xn(p)]&&Ue(F,p)},Mo=function(p){zt(Z.beforeSanitizeAttributes,p,null);const T=p.attributes;if(!T||Gr(p))return;const N={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:pe,forceKeepAttr:void 0};let ce=T.length;for(;ce--;){const Fe=T[ce],Oe=Fe.name,rt=Fe.namespaceURI,gt=Fe.value,_t=$e(Oe),Zr=gt;let Be=Oe==="value"?Zr:Of(Zr);if(N.attrName=_t,N.attrValue=Be,N.keepAttr=!0,N.forceKeepAttr=void 0,zt(Z.uponSanitizeAttribute,p,N),Be=N.attrValue,V&&(_t==="id"||_t==="name")&&ao(Be,K)!==0&&(dn(Oe,p),Be=K+Be),v&&Ue(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Be)){dn(Oe,p);continue}if(_t==="attributename"&&oo(Be,"href")){dn(Oe,p);continue}if(N.forceKeepAttr)continue;if(!N.keepAttr){dn(Oe,p);continue}if(!b&&Ue(/\/>/i,Be)){dn(Oe,p);continue}k&&kn([Se,je,te],$o=>{Be=En(Be,$o," ")});const Lo=$e(p.nodeName);if(!Io(Lo,_t,Be)){dn(Oe,p);continue}if(U&&typeof E=="object"&&typeof E.getAttributeType=="function"&&!rt)switch(E.getAttributeType(Lo,_t)){case"TrustedHTML":{Be=U.createHTML(Be);break}case"TrustedScriptURL":{Be=U.createScriptURL(Be);break}}if(Be!==Zr)try{rt?p.setAttributeNS(rt,Oe,Be):p.setAttribute(Oe,Be),Gr(p)?vt(p):lo(t.removed)}catch{dn(Oe,p)}}zt(Z.afterSanitizeAttributes,p,null)},Yr=function(p){let T=null;const N=Co(p);for(zt(Z.beforeSanitizeShadowDOM,p,null);T=N.nextNode();)zt(Z.uponSanitizeShadowNode,T,null),Po(T),Mo(T),T.content instanceof i&&Yr(T.content);zt(Z.afterSanitizeShadowDOM,p,null)},Bs=function(p){if(p.nodeType===Rn.element&&p.shadowRoot instanceof i){const ce=p.shadowRoot;Bs(ce),Yr(ce)}const T=p.childNodes;if(!T)return;const N=[];kn(T,ce=>{Sn(N,ce)});for(const ce of N)Bs(ce)};return t.sanitize=function(W){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,N=null,ce=null,Fe=null;if(Ur=!W,Ur&&(W=""),typeof W!="string"&&!Kr(W)&&(W=Nf(W),typeof W!="string"))throw Ds("dirty is not a string, aborting");if(!t.isSupported)return W;if(P||Wr(p),t.removed=[],typeof W=="string"&&(de=!1),de){const gt=W.nodeName;if(typeof gt=="string"){const _t=$e(gt);if(!ge[_t]||j[_t])throw Ds("root node is forbidden and cannot be sanitized in-place")}Bs(W)}else if(W instanceof a)T=Ro(""),N=T.ownerDocument.importNode(W,!0),N.nodeType===Rn.element&&N.nodeName==="BODY"||N.nodeName==="HTML"?T=N:T.appendChild(N),Bs(N);else{if(!A&&!k&&!_&&W.indexOf("<")===-1)return U&&z?U.createHTML(W):W;if(T=Ro(W),!T)return A?null:z?L:""}T&&C&&vt(T.firstChild);const Oe=Co(de?W:T);for(;ce=Oe.nextNode();)Po(ce),Mo(ce),ce.content instanceof i&&Yr(ce.content);if(de)return W;if(A){if(k){T.normalize();let gt=T.innerHTML;kn([Se,je,te],_t=>{gt=En(gt,_t," ")}),T.innerHTML=gt}if(S)for(Fe=se.call(T.ownerDocument);T.firstChild;)Fe.appendChild(T.firstChild);else Fe=T;return(pe.shadowroot||pe.shadowrootmode)&&(Fe=D.call(s,Fe,!0)),Fe}let rt=_?T.outerHTML:T.innerHTML;return _&&ge["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&Ue(Kf,T.ownerDocument.doctype.name)&&(rt=" +`+rt),k&&kn([Se,je,te],gt=>{rt=En(rt,gt," ")}),U&&z?U.createHTML(rt):rt},t.setConfig=function(){let W=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Wr(W),P=!0},t.clearConfig=function(){Cn=null,P=!1},t.isValidAttribute=function(W,p,T){Cn||Wr({});const N=$e(W),ce=$e(p);return Io(N,ce,T)},t.addHook=function(W,p){typeof p=="function"&&Sn(Z[W],p)},t.removeHook=function(W,p){if(p!==void 0){const T=Pf(Z[W],p);return T===-1?void 0:If(Z[W],T,1)[0]}return lo(Z[W])},t.removeHooks=function(W){Z[W]=[]},t.removeAllHooks=function(){Z=bo()},t}var Qf=xo();const Jf={key:1,class:"flex min-w-0 max-w-[calc(100%-2.5rem)] flex-1 flex-col max-[600px]:max-w-[calc(100%-2.25rem)]"},ep={key:0,class:"flex w-fit flex-col items-start gap-1"},tp=["aria-label"],np={class:"inline-flex items-center gap-1.5"},sp={class:"text-[8px] font-semibold tracking-[0.12em] uppercase text-[#3a67c9]"},rp={key:1,class:"flex w-fit max-w-full flex-col items-start gap-2"},ip={class:"chat-card relative w-fit max-w-full whitespace-pre-line rounded-[10px_10px_10px_3px] px-4 py-3 text-xs leading-relaxed wrap-anywhere text-slate-900"},lp=["innerHTML"],op={key:0,class:"pointer-events-none absolute inset-x-0 bottom-0 h-14 rounded-b-[10px] bg-linear-to-t from-white via-white/92 to-white/0","aria-hidden":"true"},ap={key:0,class:"flex flex-wrap items-center gap-2"},up=["title","aria-label"],cp={key:1,class:"flex flex-wrap items-center"},fp=["title","aria-label"],pp={viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor","stroke-width":"2","aria-hidden":"true"},dp=["innerHTML"],yo={__name:"ChatMessage",props:{message:{type:Object,required:!0},autoReadEnabled:{type:Boolean,default:!1},ttsConfig:{type:Object,default:()=>({enableVoiceChat:!1,pollyAvailable:!1,usePolly:!0,voiceId:"Zayd"})}},setup(e){const t=e,n=J(!1),s=J(null),r=J(!1),i=J(!1),l=Ee(()=>typeof window!="undefined"&&"speechSynthesis"in window&&"SpeechSynthesisUtterance"in window);function a(L){typeof window!="undefined"&&window.dispatchEvent(new CustomEvent("changai-tts-provider",{detail:{provider:L}}))}function o(L){if(typeof L!="string")return"";const O=L.replace(/[\u{1F000}-\u{1FFFF}]/gu,"").replace(/[\u{2600}-\u{26FF}]/gu,"").replace(/[\u{2700}-\u{27BF}]/gu,"").replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/#{1,6}\s+/g,"").replace(/[-*+]\s+/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\s+/g," ");return O.includes("<")?(new DOMParser().parseFromString(L,"text/html").body.textContent||"").replace(/\s+/g," ").trim():O.trim()}function c(){l.value&&window.speechSynthesis.cancel(),s.value&&(s.value.pause(),s.value.src="",s.value=null),n.value=!1}function u(){var L,O,ee;if(i.value=!i.value,i.value)c();else{const q=M.value;if(!t.autoReadEnabled||!((L=t.ttsConfig)!=null&&L.enableVoiceChat)||!q||E())return;if((O=t.ttsConfig)!=null&&O.pollyAvailable&&((ee=t.ttsConfig)!=null&&ee.usePolly)){g(q).catch(se=>{d(q)});return}d(q)}}function d(L){if(!l.value||!L)return;window.dispatchEvent(new CustomEvent("changai-tts-stop")),window.speechSynthesis.cancel();const O=new SpeechSynthesisUtterance(L);O.rate=1,O.pitch=1,O.onend=()=>{n.value=!1},O.onerror=()=>{n.value=!1},n.value=!0,a("browser"),window.speechSynthesis.speak(O)}async function g(L){var fe;const O=await Mc(L,((fe=t.ttsConfig)==null?void 0:fe.voiceId)||"Zayd");if(!(O!=null&&O.ok)||!(O!=null&&O.audio_base64))throw new Error((O==null?void 0:O.error)||"Polly synthesis failed");window.dispatchEvent(new CustomEvent("changai-tts-stop")),c();const ee=(O==null?void 0:O.mime_type)||"audio/mpeg",q=new Audio(`data:${ee};base64,${O.audio_base64}`);s.value=q,n.value=!0;let se=!1;q.onplay=()=>{se=!0,a("polly")},q.onended=()=>{s.value===q&&(s.value=null),n.value=!1},q.onerror=()=>{s.value===q&&(s.value=null),n.value=!1},await q.play(),se||a("polly")}function y(){c()}function E(){var L;return!!((L=t.message)!=null&&L.isStatus)}function x(L){const O=L.target.closest("a");!O||!O.href||(L.preventDefault(),L.stopPropagation(),window.open(O.href,"_blank","noopener,noreferrer"))}const M=Ee(()=>{var L;return o(((L=t.message)==null?void 0:L.text)||"")}),m=Ee(()=>{var L;return((L=t.message)==null?void 0:L.role)!=="user"&&E()}),H=Ee(()=>{var L;return(L=t.message)!=null&&L.isStatus?t.message.statusType==="support"?"Sending to support":M.value||"Thinking":""}),Y=Ee(()=>{var ee;if(((ee=t.message)==null?void 0:ee.role)==="user"||m.value)return!1;const L=M.value,O=L.split(/\n+/).filter(Boolean).length;return L.length>520||O>8}),$=Ee(()=>{var L,O;return((L=t.message)==null?void 0:L.role)!=="user"&&!m.value&&((O=t.ttsConfig)==null?void 0:O.enableVoiceChat)}),U=Ee(()=>{var O;const L=((O=t.message)==null?void 0:O.text)||"";return Qf.sanitize(xe.parse(L))});return ln(()=>t.message.text,async(L,O)=>{var se,fe,D;if(!t.autoReadEnabled||t.message.role==="user"||i.value)return;if(!((se=t.ttsConfig)!=null&&se.enableVoiceChat)){a("off");return}const ee=o(L);if(!ee||E())return;const q=o(O||"");if(ee!==q){if((fe=t.ttsConfig)!=null&&fe.pollyAvailable&&((D=t.ttsConfig)!=null&&D.usePolly))try{await g(ee);return}catch{}d(ee)}}),ln(()=>t.message.text,()=>{r.value=!1,i.value=!1}),zn(()=>{typeof window!="undefined"&&window.addEventListener("changai-tts-stop",y)}),ys(()=>{typeof window!="undefined"&&window.removeEventListener("changai-tts-stop",y),n.value&&c()}),(L,O)=>(B(),G("div",{class:we(["motion-safe:animate-fade-rise flex w-full gap-1.5",e.message.role==="user"?"flex-col items-end":"items-start"])},[e.message.role!=="user"?(B(),Et(Nl,{key:0})):We("",!0),e.message.role!=="user"?(B(),G("div",Jf,[m.value?(B(),G("div",ep,[w("div",{class:"chat-card inline-flex w-fit rounded-[10px_10px_10px_3px] px-3 py-2",role:"status","aria-live":"polite","aria-label":H.value},[w("div",np,[O[1]||(O[1]=w("span",{class:"relative inline-flex h-4 w-4 shrink-0 items-center justify-center"},[w("span",{class:"absolute inset-0 rounded-full border border-transparent border-t-[#4b89ff] border-r-[#4b89ff]/70 animate-gemini-arc"}),w("svg",{viewBox:"0 0 24 24",class:"relative h-3 w-3 text-[#4b89ff] animate-gemini-spark","aria-hidden":"true"},[w("path",{fill:"currentColor",d:"M12 2.8c.52 3.22 1.6 5.66 3.22 7.28 1.62 1.62 4.06 2.7 7.28 3.22-3.22.52-5.66 1.6-7.28 3.22-1.62 1.62-2.7 4.06-3.22 7.28-.52-3.22-1.6-5.66-3.22-7.28-1.62-1.62-4.06-2.7-7.28-3.22 3.22-.52 5.66-1.6 7.28-3.22 1.62-1.62 2.7-4.06 3.22-7.28Z"})])],-1)),w("span",sp,et(H.value),1)])],8,tp)])):(B(),G("div",rp,[w("div",ip,[w("div",{class:we(["overflow-x-auto",Y.value&&!r.value?"max-h-48 overflow-y-hidden":""]),innerHTML:U.value,onClick:x},null,10,lp),Y.value&&!r.value?(B(),G("div",op)):We("",!0)]),Y.value?(B(),G("div",ap,[w("button",{type:"button",class:"inline-flex items-center rounded-full border border-slate-200 bg-white px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.08em] text-slate-600 transition-colors duration-200 hover:border-brand-200 hover:text-brand-600",title:r.value?"Collapse response":"Expand response","aria-label":r.value?"Collapse response":"Expand response",onClick:O[0]||(O[0]=ee=>r.value=!r.value)},et(r.value?"Collapse":"Expand"),9,up)])):We("",!0),$.value?(B(),G("div",cp,[w("button",{type:"button",class:we(["inline-flex h-8 w-8 items-center justify-center rounded-full border transition-colors duration-200",i.value?"border-red-200 bg-red-50 text-red-600 hover:border-red-300 hover:bg-red-100":"border-green-200 bg-green-50 text-green-600 hover:border-green-300 hover:bg-green-100"]),title:i.value?"Unmute voice playback":"Mute voice playback","aria-label":i.value?"Unmute voice playback":"Mute voice playback",onClick:u},[(B(),G("svg",pp,[O[6]||(O[6]=w("path",{d:"M11 5L6 9H3v6h3l5 4V5Z"},null,-1)),i.value?(B(),G(ze,{key:0},[O[2]||(O[2]=w("path",{d:"M15 9l4 6"},null,-1)),O[3]||(O[3]=w("path",{d:"M19 9l-4 6"},null,-1))],64)):(B(),G(ze,{key:1},[O[4]||(O[4]=w("path",{d:"M15 10a3 3 0 0 1 0 4"},null,-1)),O[5]||(O[5]=w("path",{d:"M17.5 7.5a6 6 0 0 1 0 9"},null,-1))],64))]))],10,fp)])):We("",!0)]))])):(B(),G("div",{key:2,class:"w-fit max-w-[85%] whitespace-pre-line rounded-[13px_13px_3px_13px] bg-linear-to-br from-brand-500 to-brand-600 px-4 py-3 text-[11px] leading-relaxed wrap-anywhere text-white shadow-[0_14px_30px_-18px_rgba(109,79,194,0.85)] max-[600px]:max-w-[88%]",innerHTML:U.value},null,8,dp))],2))}},hp={class:"flex flex-col gap-4 sm:gap-5"},gp={class:"motion-safe:animate-fade-rise flex w-full items-start gap-1.5"},mp={__name:"ChatTab",props:{messages:{type:Array,required:!0},autoReadEnabled:{type:Boolean,default:!1},ttsConfig:{type:Object,required:!0}},setup(e){return(t,n)=>(B(),G("div",hp,[w("div",gp,[Me(Nl),n[0]||(n[0]=w("p",{class:"w-fit max-w-[calc(100%-2.5rem)] whitespace-pre-line rounded-[10px_10px_10px_3px] bg-brand-50 px-4 py-3 text-xs leading-relaxed wrap-anywhere text-slate-900 max-[600px]:max-w-[calc(100%-2.25rem)]"},[Ss(" Hello there 👋 I am ChangAI from "),w("a",{target:"_blank",href:"https://erpgulf.com",rel:"noopener noreferrer",style:{color:"#1e90ff"}},"ERPGulf.com"),Ss(", your ERP assistant."),w("br"),w("a",{target:"_blank",href:"https://app.erpgulf.com/en/articles/chang-ai-quick-start-guide",rel:"noopener noreferrer",style:{color:"#1e90ff"}},"ChangAI Quick Start Guide - Click here.")],-1))]),(B(!0),G(ze,null,ws(e.messages,(s,r)=>(B(),Et(yo,{key:r,message:s,autoReadEnabled:e.autoReadEnabled,ttsConfig:e.ttsConfig},null,8,["message","autoReadEnabled","ttsConfig"]))),128))]))}};function wo(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function vo(e){var t,n;return(e==null?void 0:e.message)||((t=e==null?void 0:e.responseJSON)==null?void 0:t.exception)||((n=e==null?void 0:e.responseJSON)==null?void 0:n.message)||(e==null?void 0:e.responseText)||String(e)}function bp(e){return typeof e=="string"?e:e&&typeof e=="object"?e.error?`⚠️ ${e.error}`:e.answer||e.text||"":""}const xp={key:0,class:"rounded-lg bg-brand-50 px-4 py-3 text-xs text-black"},yp={class:"whitespace-pre-wrap wrap-anywhere text-[11px] leading-relaxed text-black"},wp={key:1,class:"mb-3 min-w-0 overflow-x-auto rounded-lg bg-brand-50 p-2 text-[11px]"},vp={class:"whitespace-pre-wrap wrap-anywhere text-[11px] leading-relaxed text-black"},_p={__name:"DebugTab",props:{logs:{type:Array,required:!0},currentDebug:{type:Object,default:null}},setup(e){const t=new Set(["gemini_json_content","private_key","private_key_id","client_secret","client_id","aws_access_key","aws_secret_key","api_key","token","access_token","refresh_token","password","secret","authorization","embed_version_id","llm_version_id","entity_retriever","retriever","deploy_url","support_api_url","get_ticket_details_url"]);function n(r,i=0){if(i>10||r===null||r===void 0||typeof r=="string"||typeof r=="number"||typeof r=="boolean")return r;if(Array.isArray(r))return r.map(l=>n(l,i+1));if(typeof r=="object"){const l={};for(const[a,o]of Object.entries(r))t.has(a.toLowerCase())||(l[a]=n(o,i+1));return l}return r}function s(r){return wo(n(r))}return(r,i)=>(B(),G("div",null,[e.logs.length===0?(B(),G("p",xp,"No debug data yet.")):We("",!0),(B(!0),G(ze,null,ws(e.logs,(l,a)=>(B(),G("div",{key:a,class:"mb-3 min-w-0 overflow-x-auto rounded-lg bg-gray-100 p-2 text-[11px]"},[w("pre",yp,et(s(l)),1)]))),128)),e.currentDebug?(B(),G("div",wp,[w("pre",vp,et(s(e.currentDebug)),1)])):We("",!0)]))}},Tp={class:"flex flex-col gap-4 sm:gap-5"},kp={key:0,class:"chat-card motion-safe:animate-fade-rise rounded-lg px-4 py-3 text-xs text-slate-900"},Sp={__name:"SupportTab",props:{messages:{type:Array,required:!0},autoReadEnabled:{type:Boolean,default:!1},ttsConfig:{type:Object,required:!0}},setup(e){return(t,n)=>(B(),G("div",Tp,[e.messages.length===0?(B(),G("p",kp,"Send a message to Support.")):We("",!0),(B(!0),G(ze,null,ws(e.messages,(s,r)=>(B(),Et(yo,{key:r,message:s,autoReadEnabled:e.autoReadEnabled,ttsConfig:e.ttsConfig},null,8,["message","autoReadEnabled","ttsConfig"]))),128))]))}},Ep={class:"flex flex-col gap-4"},Ap={class:"chat-card motion-safe:animate-fade-rise rounded-xl p-4"},Rp={class:"flex items-start justify-between gap-4"},Cp=["aria-pressed","title"],Pp={class:"chat-card motion-safe:animate-fade-rise rounded-xl p-4"},Ip={class:"flex items-start justify-between gap-4"},Op={class:"mt-2 text-[11px] text-slate-500"},Mp={key:0,class:"mt-1 text-[11px] text-slate-500"},Lp={key:1,class:"mt-1 text-[11px] text-slate-500"},$p=["aria-pressed","disabled"],Dp={key:0,class:"mt-3 rounded-md bg-amber-50 px-2.5 py-2 text-xs text-amber-700"},Np={key:1,class:"mt-3 rounded-md bg-amber-50 px-2.5 py-2 text-xs text-amber-700"},Fp={class:"chat-card motion-safe:animate-fade-rise rounded-xl p-4"},Bp={class:"flex items-start justify-between gap-4"},Hp=["aria-pressed","title"],zp={class:"chat-card motion-safe:animate-fade-rise rounded-xl p-4"},Up={class:"flex items-start justify-between gap-4"},jp=["aria-pressed","title"],Vp={__name:"SettingsTab",props:{autoReadEnabled:{type:Boolean,required:!0},ttsConfig:{type:Object,required:!0},settings:{type:Object,default:null},debugEnabled:{type:Boolean,default:!1},sendNonERPtoaiEnabled:{type:Boolean,default:!1}},emits:["toggleAutoRead","togglePollyPreference","toggleDebug","toggleSendNonERP"],setup(e){const t=e,n=Ee(()=>{var s,r;return(s=t.ttsConfig)!=null&&s.enableVoiceChat?(r=t.ttsConfig)!=null&&r.pollyAvailable?"Available":"Unavailable":"Voice disabled on server"});return(s,r)=>{var i,l,a,o,c,u,d,g,y,E,x,M,m,H,Y;return B(),G("div",Ep,[r[10]||(r[10]=w("div",{class:"chat-card motion-safe:animate-fade-rise rounded-xl p-4 text-slate-900"},[w("h3",{class:"text-sm font-semibold tracking-[0.01em]"},"Speech Settings"),w("p",{class:"mt-1 text-xs leading-relaxed text-slate-600"},"These controls apply only inside this chatbot box for the current browser session.")],-1)),w("div",Ap,[w("div",Rp,[r[4]||(r[4]=w("div",null,[w("p",{class:"text-sm font-semibold text-slate-900"},"Auto Read Replies"),w("p",{class:"mt-1 text-xs text-slate-600"},"Automatically read bot replies aloud.")],-1)),w("button",{class:we(["group relative h-7 w-12 shrink-0 rounded-full border border-slate-200 transition-all duration-200",e.autoReadEnabled?"bg-emerald-500/95":"bg-slate-300"]),"aria-pressed":e.autoReadEnabled?"true":"false",title:e.autoReadEnabled?"Disable auto read":"Enable auto read",onClick:r[0]||(r[0]=$=>s.$emit("toggleAutoRead"))},[w("span",{class:we(["absolute top-0.5 h-5.5 w-5.5 rounded-full bg-white shadow-sm transition-all duration-200",e.autoReadEnabled?"left-[1.45rem]":"left-0.5"])},null,2)],10,Cp)]),w("p",{class:we(["mt-3 text-[11px] font-medium",e.autoReadEnabled?"text-emerald-700":"text-slate-500"])},et(e.autoReadEnabled?"Auto read is active.":"Auto read is currently off."),3)]),w("div",Pp,[w("div",Ip,[w("div",null,[r[5]||(r[5]=w("p",{class:"text-sm font-semibold text-slate-900"},"Use Amazon Polly",-1)),r[6]||(r[6]=w("p",{class:"mt-1 text-xs text-slate-600"},"Use Polly when available; otherwise browser speech is used automatically.",-1)),w("p",Op,"Availability: "+et(n.value),1),(i=e.settings)!=null&&i.aws_region?(B(),G("p",Mp,"Region: "+et(e.settings.aws_region),1)):We("",!0),(l=e.ttsConfig)!=null&&l.voiceId?(B(),G("p",Lp,"Voice: "+et(e.ttsConfig.voiceId),1)):We("",!0)]),w("button",{class:we(["relative h-7 w-12 shrink-0 rounded-full border border-slate-200 transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-55",(a=e.ttsConfig)!=null&&a.usePolly&&((o=e.ttsConfig)!=null&&o.enableVoiceChat)&&((c=e.ttsConfig)!=null&&c.pollyAvailable)?"bg-emerald-500/95":"bg-slate-300"]),"aria-pressed":(u=e.ttsConfig)!=null&&u.usePolly&&((d=e.ttsConfig)!=null&&d.enableVoiceChat)&&((g=e.ttsConfig)!=null&&g.pollyAvailable)?"true":"false",disabled:!((y=e.ttsConfig)!=null&&y.pollyAvailable)||!((E=e.ttsConfig)!=null&&E.enableVoiceChat),onClick:r[1]||(r[1]=$=>s.$emit("togglePollyPreference"))},[w("span",{class:we(["absolute top-0.5 h-5.5 w-5.5 rounded-full bg-white shadow-sm transition-all duration-200",(x=e.ttsConfig)!=null&&x.usePolly&&((M=e.ttsConfig)!=null&&M.enableVoiceChat)&&((m=e.ttsConfig)!=null&&m.pollyAvailable)?"left-[1.45rem]":"left-0.5"])},null,2)],10,$p)]),(H=e.ttsConfig)!=null&&H.enableVoiceChat?(Y=e.ttsConfig)!=null&&Y.pollyAvailable?We("",!0):(B(),G("p",Np,"Polly is not available for this site. Browser speech will be used.")):(B(),G("p",Dp,"Voice chat is disabled in ChangAI Settings."))]),w("div",Fp,[w("div",Bp,[w("div",null,[r[7]||(r[7]=w("p",{class:"text-sm font-semibold text-slate-900"},"Enable Debug Tab",-1)),r[8]||(r[8]=w("p",{class:"mt-1 text-xs text-slate-600"}," Show or hide the Debug tab inside this chatbot. ",-1)),w("p",{class:we(["mt-2 text-[11px] font-medium",e.debugEnabled?"text-emerald-700":"text-slate-500"])},et(e.debugEnabled?"Debug tab is active.":"Debug tab is currently off."),3)]),w("button",{type:"button",class:we(["relative h-7 w-12 shrink-0 rounded-full border border-slate-200 transition-all duration-200",e.debugEnabled?"bg-emerald-500/95":"bg-slate-300"]),"aria-pressed":e.debugEnabled?"true":"false",title:e.debugEnabled?"Disable debug tab":"Enable debug tab",onClick:r[2]||(r[2]=$=>s.$emit("toggleDebug"))},[w("span",{class:we(["absolute top-0.5 h-5.5 w-5.5 rounded-full bg-white shadow-sm transition-all duration-200",e.debugEnabled?"left-[1.45rem]":"left-0.5"])},null,2)],10,Hp)])]),w("div",zp,[w("div",Up,[r[9]||(r[9]=w("div",null,[w("p",{class:"text-sm font-semibold text-slate-900"},"Send non-ERP questions directly to AI"),w("p",{class:"mt-1 text-xs text-slate-600"},"Questions unrelated to your ERP will skip the system and go straight to AI")],-1)),w("button",{class:we(["group relative h-7 w-12 shrink-0 rounded-full border border-slate-200 transition-all duration-200",e.sendNonERPtoaiEnabled?"bg-emerald-500/95":"bg-slate-300"]),"aria-pressed":e.sendNonERPtoaiEnabled?"true":"false",title:e.sendNonERPtoaiEnabled?"Non-ERP questions are being sent directly to AI":"Enable direct AI reply for non-ERP questions",onClick:r[3]||(r[3]=$=>s.$emit("toggleSendNonERP"))},[w("span",{class:we(["absolute top-0.5 h-5.5 w-5.5 rounded-full bg-white shadow-sm transition-all duration-200",e.sendNonERPtoaiEnabled?"left-[1.45rem]":"left-0.5"])},null,2)],10,jp)]),w("p",{class:we(["mt-3 text-[11px] font-medium",e.sendNonERPtoaiEnabled?"text-emerald-700":"text-slate-500"])},et(e.sendNonERPtoaiEnabled?"Non-ERP questions are now routed directly to AI":"Direct AI routing is currently off"),3)])])}}},qp={key:0,class:"pointer-events-none absolute -top-14 left-0 right-0 z-20 flex justify-center px-2",role:"status","aria-live":"polite"},Wp={__name:"StatusToast",props:{visible:{type:Boolean,required:!0},message:{type:String,default:""},type:{type:String,default:"info"},dismissible:{type:Boolean,default:!0}},emits:["close"],setup(e){const t=e,n=Ee(()=>t.type==="error"?"bg-red-50 text-red-700 ring-red-200":(t.type==="listening","bg-blue-50 text-blue-700 ring-blue-200")),s=Ee(()=>t.type==="error"?"bg-red-500":t.type==="listening"?"bg-blue-500 animate-pulse":"bg-blue-500");return(r,i)=>(B(),Et(Pu,{"enter-active-class":"transition duration-200 ease-out","enter-from-class":"translate-y-1 opacity-0","enter-to-class":"translate-y-0 opacity-100","leave-active-class":"transition duration-150 ease-in","leave-from-class":"translate-y-0 opacity-100","leave-to-class":"translate-y-1 opacity-0"},{default:Di(()=>[e.visible?(B(),G("div",qp,[w("div",{class:we(["pointer-events-auto flex max-w-[92%] items-start gap-2 rounded-lg px-3 py-2 text-xs shadow-lg ring-1",n.value])},[w("span",{class:we(["mt-0.5 h-2 w-2 shrink-0 rounded-full",s.value])},null,2),w("span",null,et(e.message),1),e.dismissible?(B(),G("button",{key:0,type:"button",class:"ml-1 appearance-none border-0 text-current/80 transition hover:text-current focus:outline-none","aria-label":"Dismiss notification",onClick:i[0]||(i[0]=l=>r.$emit("close"))}," × ")):We("",!0)],2)])):We("",!0)]),_:1}))}},Gp={class:"relative w-full"},Kp=["placeholder","disabled"],Yp=["title","aria-label","disabled"],Zp={key:0,viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor","aria-hidden":"true"},Xp={key:1,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor","stroke-width":"2","aria-hidden":"true"},Qp={key:2,viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor","stroke-width":"2","aria-hidden":"true",class:"animate-spin"},Jp=["title","aria-label","disabled"],ed={key:0,viewBox:"0 0 24 24",width:"18",height:"18",fill:"none","aria-hidden":"true",class:"text-rose-600 motion-safe:animate-stop-button-pulse"},td={key:1,viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor","aria-hidden":"true"},nd={__name:"ChatForm",props:{placeholder:{type:String,default:"Message..."},disabled:{type:Boolean,default:!1},isAwaitingResponse:{type:Boolean,default:!1}},emits:["submit","cancel"],setup(e,{expose:t,emit:n}){const s=e,r=n,i=J(""),l=J(null),a=J(!1),o=J(!1),c=J(!1),u=J(!1),d=J(!1),g=J(!1),y=J(!1),E=J(""),x=J("info"),M=J("Voice input is unavailable in this browser/context.");let m=null,H=null,Y=null;const $=J(""),U=J(!1),L=Ee(()=>c.value?"Requesting microphone permission...":u.value?"Starting voice input...":d.value?"Stopping voice input...":o.value?a.value?"Stop voice input":"Start voice input":"Voice input is unavailable in this browser/context"),O=Ee(()=>s.isAwaitingResponse?"Stop response":"Send"),ee=Ee(()=>s.isAwaitingResponse?!1:s.disabled||!i.value.trim()),q=Ee(()=>s.isAwaitingResponse?"bg-white border border-rose-100 shadow-[0_8px_20px_-12px_rgba(159,18,57,0.35)] hover:bg-rose-50":"bg-linear-to-br from-brand-500 to-brand-600 text-white shadow-[0_10px_24px_-16px_rgba(109,79,194,0.85)] hover:from-brand-600 hover:to-violet-700");function se(){return typeof window=="undefined"?null:window.SpeechRecognition||window.webkitSpeechRecognition||null}function fe(){var ge;const re=se(),F=typeof window!="undefined"?window.isSecureContext:!1,ue=typeof navigator!="undefined"&&!!((ge=navigator.mediaDevices)!=null&&ge.getUserMedia);o.value=!!(re&&F&&ue),F?(!ue||!re)&&(M.value="Voice input is not supported in this browser."):M.value="Voice input requires HTTPS (or localhost).",re&&o.value&&(m=new re,m.continuous=!0,m.interimResults=!0,m.lang=typeof navigator!="undefined"&&navigator.language||"en-US",m.onstart=()=>{a.value=!0,u.value=!1,d.value=!1,D(),R("Listening... Tap mic to stop","listening",{persistent:!0,key:"listening"})},m.onend=()=>{a.value=!1,u.value=!1,d.value=!1,D(),$.value==="listening"&&he(),U.value&&(U.value=!1,Le())},m.onerror=Te=>{if(a.value=!1,u.value=!1,d.value=!1,D(),U.value=!1,(Te==null?void 0:Te.error)==="not-allowed"||(Te==null?void 0:Te.error)==="service-not-allowed"){R("Microphone permission denied. Please allow microphone access in browser settings.","error");return}if((Te==null?void 0:Te.error)==="audio-capture"){R("No microphone detected. Please connect a microphone and try again.","error");return}if((Te==null?void 0:Te.error)==="no-speech"){R("No speech detected. Try speaking a bit louder.","info");return}R("Voice input failed. Please try again.","error")},m.onresult=Te=>{let pe="";for(let Qe=Te.resultIndex;Qe{if(m&&!(!a.value&&!d.value))try{m.abort()}catch{d.value=!1,U.value=!1}},1200)}}function Se(){if(!o.value||!m){R(M.value,"error");return}if(a.value||u.value||d.value){Z({submitAfterStop:a.value});return}te()}async function je(){var re;if(g.value)return!0;if(!((re=navigator.mediaDevices)!=null&&re.getUserMedia))return R("Microphone API is unavailable in this browser.","error"),!1;c.value=!0,R("Requesting microphone permission...","info",{persistent:!0,key:"requesting"});try{return(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(ue=>ue.stop()),g.value=!0,!0}catch(F){return(F==null?void 0:F.name)==="NotAllowedError"||(F==null?void 0:F.name)==="SecurityError"?R("Microphone permission denied. Please allow it and try again.","error"):(F==null?void 0:F.name)==="NotFoundError"?R("No microphone found on this device.","error"):R("Unable to access microphone. Please check browser permissions.","error"),!1}finally{c.value=!1,$.value==="requesting"&&he()}}async function te(){var F;if(!(!m||a.value||u.value||d.value||!await je()||!m)){U.value=!1,(F=l.value)==null||F.focus(),u.value=!0;try{m.start()}catch(ue){u.value=!1,d.value=!1,(ue==null?void 0:ue.name)!=="InvalidStateError"&&R("Unable to start voice input. Please try again.","error")}}}function R(re,F="info",ue={}){const{duration:ge=4200,persistent:Te=!1,key:pe=""}=ue;E.value=re,x.value=F,$.value=pe,y.value=!0,H&&clearTimeout(H),Te||(H=setTimeout(()=>{y.value=!1,$.value=""},ge))}function he(){y.value=!1,$.value="",H&&(clearTimeout(H),H=null)}function Le(){if(s.isAwaitingResponse){r("cancel");return}const re=i.value.trim();re&&((a.value||u.value||d.value)&&m&&Z({submitAfterStop:!1}),r("submit",re),i.value="")}return t({focus:()=>{var re;return(re=l.value)==null?void 0:re.focus()}}),zn(()=>{fe()}),ys(()=>{if(m&&(a.value||u.value||d.value)){U.value=!1,D();try{m.abort()}catch{}}D(),he()}),(re,F)=>(B(),G("div",Gp,[w("form",{class:"group flex min-h-11 items-center gap-2 rounded-full border border-slate-200/90 bg-white/95 px-3 shadow-[0_12px_26px_-20px_rgba(15,23,42,0.7)] transition-all duration-250 focus-within:-translate-y-0.5 focus-within:border-brand-200 focus-within:shadow-[0_18px_30px_-20px_rgba(13,110,253,0.5)] focus-within:ring-2 focus-within:ring-brand-500/25",style:{"border-radius":"9999px"},autocomplete:"off",onSubmit:dt(Le,["prevent"]),onClick:F[5]||(F[5]=dt(()=>{},["stop"])),onMousedown:F[6]||(F[6]=dt(()=>{},["stop"])),onKeydown:F[7]||(F[7]=dt(()=>{},["stop"])),onKeyup:F[8]||(F[8]=dt(()=>{},["stop"]))},[Pa(w("input",{ref_key:"inputRef",ref:l,type:"text","onUpdate:modelValue":F[0]||(F[0]=ue=>i.value=ue),class:"h-11 w-full border-none bg-transparent text-sm font-medium text-slate-800 placeholder:text-slate-400 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",placeholder:e.disabled?"Waiting for response...":e.placeholder,disabled:e.disabled,required:"",onKeydown:F[1]||(F[1]=dt(()=>{},["stop"])),onKeyup:F[2]||(F[2]=dt(()=>{},["stop"])),onKeypress:F[3]||(F[3]=dt(()=>{},["stop"])),onInput:F[4]||(F[4]=dt(()=>{},["stop"]))},null,40,Kp),[[Xu,i.value]]),w("button",{type:"button",class:we(["grid h-8 w-8 shrink-0 appearance-none place-items-center rounded-full border border-transparent text-slate-600 transition-all duration-200 hover:-translate-y-0.5 hover:border-slate-200 hover:bg-slate-100 hover:text-slate-900 focus:outline-none disabled:cursor-not-allowed disabled:opacity-40",a.value?"border-red-200 bg-red-100 text-red-600 shadow-[0_10px_20px_-18px_rgba(220,38,38,0.9)] hover:bg-red-100 hover:text-red-600":""]),style:{"border-radius":"9999px"},title:L.value,"aria-label":L.value,disabled:e.disabled||!o.value||c.value||u.value||d.value,onClick:Se},[a.value&&!c.value?(B(),G("svg",Zp,F[9]||(F[9]=[w("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"},null,-1)]))):c.value?(B(),G("svg",Qp,F[11]||(F[11]=[w("circle",{cx:"12",cy:"12",r:"9",opacity:"0.3"},null,-1),w("path",{d:"M21 12a9 9 0 0 1-9 9"},null,-1)]))):(B(),G("svg",Xp,F[10]||(F[10]=[w("path",{d:"M12 3a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3z"},null,-1),w("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"},null,-1),w("path",{d:"M12 19v3"},null,-1)])))],10,Yp),w("button",{type:"submit",title:O.value,"aria-label":O.value,class:we(["grid h-8 w-8 shrink-0 appearance-none place-items-center rounded-full border-0 transition-all duration-200 hover:-translate-y-0.5 focus:outline-none disabled:cursor-not-allowed disabled:opacity-40",q.value]),style:{"border-radius":"9999px"},disabled:ee.value},[e.isAwaitingResponse?(B(),G("svg",ed,F[12]||(F[12]=[w("circle",{cx:"12",cy:"12",r:"8",stroke:"currentColor","stroke-width":"2.1",class:"opacity-95"},null,-1),w("rect",{x:"9",y:"9",width:"6",height:"6",rx:"1.35",fill:"currentColor"},null,-1)]))):(B(),G("svg",td,F[13]||(F[13]=[w("path",{d:"M4 12l1.41 1.41L11 7.83V20h2V7.83l5.59 5.58L20 12l-8-8-8 8z"},null,-1)])))],10,Jp)],32),Me(Wp,{visible:y.value,message:E.value,type:x.value,dismissible:x.value!=="listening",onClose:he},null,8,["visible","message","type","dismissible"])]))}},sd={class:"relative overflow-hidden bg-linear-to-br from-brand-600 via-brand-500 to-violet-400"},rd={class:"min-w-0"},id={key:1,class:"border-t border-slate-200/80 bg-white/90 px-3 py-3 pb-[calc(12px+env(safe-area-inset-bottom))] backdrop-blur-sm sm:px-4 sm:py-4"},ld=56,od={__name:"ChatbotPopup",props:{isOpen:{type:Boolean,required:!0},activeTab:{type:String,required:!0},debugEnabled:{type:Boolean,default:!1},sendNonERPtoaiEnabled:{type:Boolean,default:!1},chatHistory:{type:Array,required:!0},debugLogs:{type:Array,required:!0},currentDebug:{type:Object,default:null},supportHistory:{type:Array,required:!0},autoReadEnabled:{type:Boolean,required:!0},ttsConfig:{type:Object,required:!0},activeTtsProvider:{type:String,required:!0},settings:{type:Object,default:null},isAwaitingChatResponse:{type:Boolean,default:!1},isAwaitingSupportResponse:{type:Boolean,default:!1}},emits:["close","submit","cancelResponse","update:activeTab","toggleAutoRead","togglePollyPreference","toggleDebug","toggleSendNonERP"],setup(e,{expose:t,emit:n}){const s=e,r=n,i=J(null),l=J(null),a=J(s.activeTab),o=J("default"),c=J(!1),u=Ee(()=>a.value==="support"?s.isAwaitingSupportResponse:a.value==="chat"?s.isAwaitingChatResponse:!1);function d(){const M=i.value;if(!s.isOpen||!M){c.value=!1;return}const m=M.scrollHeight-M.clientHeight;if(m<=4){c.value=!1;return}const H=m-M.scrollTop;c.value=H>ld}function g(){const M=i.value;M&&(M.scrollTo({top:M.scrollHeight,behavior:"smooth"}),setTimeout(()=>{d()},220))}function y(){St(()=>{d()})}function E(){if(o.value==="default"){o.value="half";return}if(o.value==="half"){o.value="full";return}o.value="default"}const x=Ee(()=>{const M="chat-shell fixed z-[9999] flex min-h-0 flex-col overflow-hidden border border-slate-200/80 shadow-[0_32px_80px_-44px_rgba(2,6,23,0.7),0_18px_40px_-24px_rgba(15,23,42,0.45)] transition-all duration-300 ease-out origin-bottom-right",m=s.isOpen?"pointer-events-auto opacity-100 translate-x-0 translate-y-0 scale-100 motion-safe:animate-surface-in":"pointer-events-none opacity-0 translate-x-1/5 translate-y-8 scale-95";return o.value==="full"?[M,m,"inset-0 h-screen w-screen max-h-screen max-w-screen rounded-none origin-center"]:o.value==="half"?[M,m,"bottom-[74px] right-5 h-[min(86vh,860px)] w-[min(50vw,860px)] rounded-2xl","max-[900px]:bottom-[78px] max-[900px]:right-3 max-[900px]:h-[min(86vh,760px)] max-[900px]:w-[min(70vw,760px)] max-[900px]:rounded-[14px]","max-[600px]:inset-0 max-[600px]:h-screen max-[600px]:w-screen max-[600px]:max-h-screen max-[600px]:max-w-screen max-[600px]:rounded-none max-[600px]:pb-[env(safe-area-inset-bottom)]"]:[M,m,"bottom-[74px] right-5 h-[min(560px,72vh)] w-[min(360px,calc(100vw-40px))] rounded-2xl","max-[900px]:bottom-[78px] max-[900px]:right-3 max-[900px]:h-[min(70vh,540px)] max-[900px]:w-[min(360px,calc(100vw-24px))] max-[900px]:rounded-[14px]","max-[600px]:inset-0 max-[600px]:h-screen max-[600px]:w-screen max-[600px]:max-h-screen max-[600px]:max-w-screen max-[600px]:rounded-none max-[600px]:pb-[env(safe-area-inset-bottom)]"]});return ln(()=>s.activeTab,M=>{a.value=M,y()}),ln(()=>s.isOpen,M=>{M&&a.value!=="settings"&&St(()=>{var m;return(m=l.value)==null?void 0:m.focus()}),y()}),ln(a,M=>{r("update:activeTab",M),y()}),ln(()=>[s.chatHistory.length,s.supportHistory.length,s.debugLogs.length,s.currentDebug],()=>{y()}),ln(()=>s.debugEnabled,M=>{!M&&a.value==="debug"&&(a.value="chat"),y()}),zn(()=>{y()}),t({scrollToBottom(){St(()=>{g()})}}),(M,m)=>(B(),G("div",{class:we(x.value),onKeydown:m[9]||(m[9]=dt(()=>{},["stop"])),onKeyup:m[10]||(m[10]=dt(()=>{},["stop"])),onKeypress:m[11]||(m[11]=dt(()=>{},["stop"]))},[m[14]||(m[14]=w("div",{class:"pointer-events-none absolute -right-14 -top-14 h-36 w-36 rounded-full bg-brand-500/15 blur-2xl"},null,-1)),m[15]||(m[15]=w("div",{class:"pointer-events-none absolute -bottom-14 -left-12 h-32 w-32 rounded-full bg-violet-400/15 blur-2xl"},null,-1)),w("div",sd,[m[12]||(m[12]=w("div",{class:"pointer-events-none absolute inset-0 opacity-45",style:{background:"linear-gradient(120deg, rgba(255,255,255,0.16) 0%, rgba(255,255,255,0.02) 52%, rgba(255,255,255,0.12) 100%)"}},null,-1)),Me(vc,{windowMode:o.value,autoReadEnabled:e.autoReadEnabled,activeTtsProvider:e.activeTtsProvider,onClose:m[0]||(m[0]=H=>M.$emit("close")),onCycleResize:E,onToggleAutoRead:m[1]||(m[1]=H=>M.$emit("toggleAutoRead"))},null,8,["windowMode","autoReadEnabled","activeTtsProvider"]),Me(Sc,{modelValue:a.value,"onUpdate:modelValue":m[2]||(m[2]=H=>a.value=H),debugEnabled:e.debugEnabled},null,8,["modelValue","debugEnabled"])]),w("div",{class:"chat-scrollbar min-h-0 flex-1 overflow-x-hidden overflow-y-scroll bg-slate-50/60 px-4 py-4 max-[900px]:px-3.5 max-[900px]:py-3.5 max-[600px]:px-3 max-[600px]:py-3",ref_key:"chatBodyRef",ref:i,onScrollPassive:d},[w("div",rd,[a.value==="chat"?(B(),Et(mp,{key:0,messages:e.chatHistory,autoReadEnabled:e.autoReadEnabled,ttsConfig:e.ttsConfig},null,8,["messages","autoReadEnabled","ttsConfig"])):a.value==="debug"&&e.debugEnabled?(B(),Et(_p,{key:1,logs:e.debugLogs,currentDebug:e.currentDebug},null,8,["logs","currentDebug"])):a.value==="support"?(B(),Et(Sp,{key:2,messages:e.supportHistory,autoReadEnabled:e.autoReadEnabled,ttsConfig:e.ttsConfig},null,8,["messages","autoReadEnabled","ttsConfig"])):a.value==="settings"?(B(),Et(Vp,{key:3,autoReadEnabled:e.autoReadEnabled,ttsConfig:e.ttsConfig,settings:e.settings,debugEnabled:e.debugEnabled,sendNonERPtoaiEnabled:e.sendNonERPtoaiEnabled,onToggleAutoRead:m[3]||(m[3]=H=>M.$emit("toggleAutoRead")),onTogglePollyPreference:m[4]||(m[4]=H=>M.$emit("togglePollyPreference")),onToggleDebug:m[5]||(m[5]=H=>M.$emit("toggleDebug")),onToggleSendNonERP:m[6]||(m[6]=H=>M.$emit("toggleSendNonERP"))},null,8,["autoReadEnabled","ttsConfig","settings","debugEnabled","sendNonERPtoaiEnabled"])):We("",!0)])],544),c.value?(B(),G("button",{key:0,type:"button",class:we(["absolute right-4 z-20 grid h-9 w-9 place-items-center rounded-full border border-brand-200/70 bg-white/95 text-brand-600 shadow-[0_14px_26px_-16px_rgba(15,23,42,0.65)] transition-all duration-200 hover:-translate-y-0.5 hover:border-brand-300 hover:text-brand-700 focus:outline-none",a.value!=="settings"?"bottom-[calc(90px+env(safe-area-inset-bottom))] sm:bottom-[96px]":"bottom-4 sm:bottom-5"]),title:"Scroll to bottom","aria-label":"Scroll to bottom",onClick:g},m[13]||(m[13]=[w("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor","stroke-width":"2","aria-hidden":"true"},[w("path",{d:"M7 10l5 5 5-5"})],-1)]),2)):We("",!0),a.value!=="settings"?(B(),G("div",id,[Me(nd,{ref_key:"chatFormRef",ref:l,placeholder:a.value==="support"?"Message Support...":"Message...",disabled:u.value,isAwaitingResponse:u.value,onSubmit:m[7]||(m[7]=H=>M.$emit("submit",H)),onCancel:m[8]||(m[8]=H=>M.$emit("cancelResponse"))},null,8,["placeholder","disabled","isAwaitingResponse"])])):We("",!0)],34))}},_o="changai_chat_id",To="changai_polly_enabled";function ad(){let e=sessionStorage.getItem(_o);return e||(e=`session_${Date.now()}_${crypto.randomUUID()}`,sessionStorage.setItem(_o,e)),e}function ud(){const e=localStorage.getItem(To);return e===null?!0:e==="true"}function cd(e){localStorage.setItem(To,String(!!e))}const fd={__name:"App",setup(e){const t=J(!1),n=J("chat"),s=J([]),r=J([]),i=J(!1),l=J([]),a=J(null),o=J("actual"),c=J(!0),u=J(null),d=J(!1),g=J(null),y=J((()=>{try{return localStorage.getItem("sendNonERPtoaiEnabled")==="true"}catch{return!1}})()),E=J({enableVoiceChat:!1,pollyAvailable:!1,usePolly:!0,voiceId:"Zayd",enable_changai:!1}),x=J("off"),M=J(null),m=J(null),H=Ee(()=>M.value!==null),Y=Ee(()=>m.value!==null);function $(){if(!E.value.enableVoiceChat){x.value="off";return}x.value=E.value.usePolly?"polly":"browser"}function U(te){var he;const R=(he=te==null?void 0:te.detail)==null?void 0:he.provider;(R==="polly"||R==="browser"||R==="off")&&(x.value=R)}async function L(){var R,he,Le,re,F;if(!(d.value||u.value)){d.value=!0;try{u.value=await Oc(o.value),E.value={enableVoiceChat:!!((R=u.value)!=null&&R.enable_voice_chat),pollyAvailable:!!((he=u.value)!=null&&he.polly_enabled),usePolly:!!((Le=u.value)!=null&&Le.polly_enabled)&&ud(),voiceId:((re=u.value)==null?void 0:re.polly_voice_id)||"Zayd",enable_changai:!!((F=u.value)!=null&&F.enable_changai)},$(),r.value.push({type:"settings",settings:u.value})}catch(ue){const ge=vo(ue);r.value.push({type:"settings",error:ge})}finally{d.value=!1}}}function O(){t.value=!t.value}function ee(){var te;(te=a.value)==null||te.scrollToBottom()}function q(){c.value=!c.value}function se(){const te=!E.value.usePolly;E.value={...E.value,usePolly:te&&E.value.pollyAvailable},cd(E.value.usePolly),$()}function fe(){y.value=!y.value,localStorage.setItem("sendNonERPtoaiEnabled",y.value)}async function D(te){n.value==="support"?await je(te):await Z(te)}async function Z(te){var Qe,ye;g.value=null,o.value==="actual"&&await L(),s.value.push({role:"user",text:te}),await St(),ee();const R=cs({role:"model",text:"Thinking...",cancelable:!0,isStatus:!0,statusType:"thinking"});s.value.push(R),await St(),ee();const he=j=>{var Ft;const st=Date.now(),Ie=((st-Te)/1e3).toFixed(2);if(Te=st,j.message){const f=`${j.message} (${Ie}s)`;pe.push(f),g.value=f,R.text=j.message,R.statusType="pipeline"}if(!j.done&&j.message&&(R.text=j.message,R.statusType="pipeline"),j.done){R.cancelable=!1,j.error?(R.text=`⚠️ ${j.message||"Something failed"}`,R.isStatus=!1,R.statusType=null):(Ft=j.data)!=null&&Ft.answer&&(R.text=j.data.answer,R.isStatus=!1,R.statusType=null),frappe.realtime.off(ue,he),g.value=null;return}};let Le=!1;const re=ad(),F=`${re}_${Date.now()}`,ue=`debug_${F}`;frappe.realtime.on(ue,he);const ge=Pc(te,re,o.value,F,y.value);let Te=Date.now();const pe=[];M.value=()=>{Le||(Le=!0,ge.cancel(),frappe.realtime.off(ue,he),R.isStatus=!1,R.statusType=null,R.text="Cancelled by user.",r.value.push({type:"cancelled",user:te,steps:[...pe]}),g.value=null,R.cancelable=!1,M.value=null)};try{const j=await ge.promise;if(j!=null&&j.open_report){if(R.isStatus=!1,R.statusType=null,R.text=`Opening "${j.report_name}" report." `,r.value.push({type:"success",steps:[...pe],final_response:j,entity_raw:j.entity_raw}),g.value=null,!j.report_name){R.text="Report name extraction failed.Can you ask the same question again?";return}frappe.set_route("query-report",j.report_name,j.filters||{});return}else if(j!=null&&j.create_entity){R.isStatus=!1,R.statusType=null,R.cancelable=!1,R.text=`Opening "${j.doc}" doctype for creating a new record.`,r.value.push({type:"success",user:te,steps:[...pe],final_response:j}),g.value=null;const Ie=j.doc,Ft=j.fields_to_fill||{},f=j.child_tables||{},h=j.entity_name||"",b={Customer:{customer_name:h},Supplier:{supplier_name:h},Employee:{employee_name:h},Item:{item_code:h,item_name:h},Project:{project_name:h},Lead:{lead_name:h},Opportunity:{opportunity_name:h}},k=Object.keys(Ft).length>0?Ft:b[Ie]||{};frappe.route_options=k,frappe.set_route("Form",Ie,"new");let v=0;const _=setInterval(()=>{if(v++>50){clearInterval(_);return}cur_frm&&cur_frm.doctype===Ie&&cur_frm.is_new()&&(clearInterval(_),Object.entries(k).forEach(([P,C])=>{C&&cur_frm.fields_dict[P]&&(cur_frm.set_value(P,C),cur_frm.refresh_field(P))}),Object.entries(f).forEach(([P,C])=>{!Array.isArray(C)||!C.length||cur_frm.fields_dict[P]&&(C.forEach(A=>{const S=frappe.model.add_child(cur_frm.doc,P);Object.entries(A).forEach(([z,I])=>{I!=null&&I!==""&&frappe.model.set_value(S.doctype,S.name,z,I)})}),cur_frm.refresh_field(P))}))},200);return}if(j!=null&&j.stop_followup){R.isStatus=!1,R.statusType=null,R.cancelable=!1,R.text=j.message||"You’re welcome!",r.value.push({type:"stop_followup",user:te,steps:[...pe],final_response:j}),g.value=null;return}if(Le)return;R.cancelable=!1;const st=((Qe=bp(j==null?void 0:j.Bot))==null?void 0:Qe.trim())||"No response.";R.isStatus=!1,R.statusType=null,R.text=st,r.value.push({type:"success",user:te,steps:[...pe],final_response:j}),g.value=null}catch(j){if(Le)return;R.cancelable=!1,R.isStatus=!1,R.statusType=null;const st=vo(j);g.value=null,r.value.push({type:"failed",user:te,steps:[...pe],error:st}),(j==null?void 0:j.code)==="ERR_NETWORK_CHANGED"||(ye=j==null?void 0:j.message)!=null&&ye.includes("ERR_NETWORK_CHANGED")?(R.isStatus=!1,R.statusType=null,R.text="⚠️ Network error. Please check your connection and try again."):(R.isStatus=!1,R.statusType=null,R.text="⚠️ Something went wrong. Please try again.")}finally{frappe.realtime.off(ue,he),Le||(M.value=null)}await St(),ee()}function Se(){var te,R;if(n.value==="support"){(te=m.value)==null||te.call(m);return}(R=M.value)==null||R.call(M)}async function je(te){l.value.push({role:"user",text:te}),await St(),ee();const R=cs({role:"model",text:"Sending to support...",isStatus:!0,statusType:"support"});l.value.push(R),await St(),ee();let he=!1;const Le=Ic(te,o.value);m.value=()=>{he||(he=!0,Le.cancel(),R.isStatus=!1,R.statusType=null,R.text="Cancelled by user.",m.value=null)};try{const re=await Le.promise;if(he)return;R.isStatus=!1,R.statusType=null,R.text=re?wo(re):"Support request sent successfully."}catch{if(he)return;R.isStatus=!1,R.statusType=null,R.text="⚠️ Failed to reach support. Please try again."}finally{he||(m.value=null)}await St(),ee()}return zn(()=>{typeof window!="undefined"&&window.addEventListener("changai-tts-provider",U),o.value==="actual"&&L()}),ys(()=>{typeof window!="undefined"&&window.removeEventListener("changai-tts-provider",U)}),(te,R)=>(B(),G(ze,null,[E.value.enable_changai?(B(),Et(ac,{key:0,isOpen:t.value,onToggle:O},null,8,["isOpen"])):We("",!0),Me(od,{ref_key:"popupRef",ref:a,isOpen:t.value,activeTab:n.value,"onUpdate:activeTab":R[0]||(R[0]=he=>n.value=he),chatHistory:s.value,debugLogs:r.value,currentDebug:g.value,supportHistory:l.value,autoReadEnabled:c.value,ttsConfig:E.value,activeTtsProvider:x.value,settings:u.value,isAwaitingChatResponse:H.value,isAwaitingSupportResponse:Y.value,debugEnabled:i.value,sendNonERPtoaiEnabled:y.value,onToggleDebug:R[1]||(R[1]=he=>i.value=!i.value),onClose:R[2]||(R[2]=he=>t.value=!1),onSubmit:D,onCancelResponse:Se,onToggleAutoRead:q,onTogglePollyPreference:se,onToggleSendNonERP:fe},null,8,["isOpen","activeTab","chatHistory","debugLogs","currentDebug","supportHistory","autoReadEnabled","ttsConfig","activeTtsProvider","settings","isAwaitingChatResponse","isAwaitingSupportResponse","debugEnabled","sendNonERPtoaiEnabled"])],64))}};function pd(){const e=document.querySelector('link[href*="/assets/changai/dist/changai-chatbot.css"]');if(e!=null&&e.href)return e.href;const t=Array.from(document.scripts).find(n=>{var s;return(s=n.src)==null?void 0:s.includes("/assets/changai/dist/changai-chatbot.js")});return t!=null&&t.src?t.src.replace(/changai-chatbot\.js(\?.*)?$/,"changai-chatbot.css$1"):null}function dd(e){const t=pd();if(!t){const n=Array.from(document.querySelectorAll("style[data-vite-dev-id]"));return n.length&&n.forEach(s=>{const r=document.createElement("style");r.dataset.changaiShadowDevStyle="1",r.textContent=s.textContent||"",e.appendChild(r)}),Promise.resolve()}return e.querySelector('link[data-changai-shadow-style="1"]')?Promise.resolve():new Promise(n=>{const s=document.createElement("link");s.rel="stylesheet",s.href=t,s.dataset.changaiShadowStyle="1",s.onload=()=>n(),s.onerror=()=>n(),e.appendChild(s),setTimeout(n,1200)})}async function ko(){if(document.getElementById("changai-chatbot-host"))return;const e=document.createElement("div");e.id="changai-chatbot-host",document.body.appendChild(e);const t=e.attachShadow({mode:"open"});await dd(t);const n=document.createElement("div");n.id="changai-chatbot-root",t.appendChild(n),nc(fd).mount(n);function s(r){r.stopPropagation()}n.addEventListener("keydown",s),n.addEventListener("keyup",s),n.addEventListener("keypress",s)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",ko):ko()})(); diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 23fd542..1fd7385 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1441,9 +1441,9 @@ } }, "node_modules/dompurify": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.3.tgz", - "integrity": "sha512-VVwJidIJcp1hpg2OMXML3ZVRPYSZiq4aX7qBh83BSIpOaRDqI+qxhXjjIWnpzkOXhmp0L81lnoME1mnCc9H48A==", + "version": "3.4.11", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.11.tgz", + "integrity": "sha512-zhlUV12GsaRzMsf9q5M254YhA4+VuF0fG+QFqu6aYpoGlKtz+w8//jBcGVYBgQkR5GHjUomejY84AV+/uPbWdw==", "license": "(MPL-2.0 OR Apache-2.0)", "optionalDependencies": { "@types/trusted-types": "^2.0.7" @@ -2091,9 +2091,9 @@ } }, "node_modules/vite": { - "version": "7.3.3", - "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.3.tgz", - "integrity": "sha512-/4XH147Ui7OGTjg3HbdWe5arnZQSbfuRzdr9Ec7TQi5I7R+ir0Rlc9GIvD4v0XZurELqA035KVXJXpR61xhiTA==", + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.5.tgz", + "integrity": "sha512-KuOaNhcnGFN2zIPGA7wRmzF+lJA1sea7rHq17aiJ++9lzY1WWG6Jpwqwe1KNbRVPIqHmr8GLYx7jbrQcN/7/ww==", "dev": true, "license": "MIT", "peer": true, diff --git a/frontend/src/App.vue b/frontend/src/App.vue index bc4be27..d84ddd4 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -17,7 +17,13 @@ const autoReadEnabled = ref(true) const settings = ref(null) const isLoadingSettings = ref(false) const currentDebug = ref(null) -const sendNonERPtoaiEnabled = ref(false) +const sendNonERPtoaiEnabled = ref((() => { + try { + return localStorage.getItem('sendNonERPtoaiEnabled') === 'true' + } catch { + return false + } +})()) const ttsConfig = ref({ enableVoiceChat: false, pollyAvailable: false, @@ -48,14 +54,11 @@ function handleTtsProviderEvent(event) { async function loadSettings() { console.log('loadSettings called, frappe available:', !!window.frappe?.call) - console.log('loadSettings called') if (isLoadingSettings.value || settings.value) return isLoadingSettings.value = true try { settings.value = await getSettingsDetails(responseMode.value) - console.log('Full settings:', settings.value) // 👈 add this - console.log('enable_changai raw value:', settings.value?.enable_changai) // 👈 add this ttsConfig.value = { enableVoiceChat: Boolean(settings.value?.enable_voice_chat), pollyAvailable: Boolean(settings.value?.polly_enabled), @@ -126,19 +129,6 @@ async function handleChatSubmit(message) { chatHistory.value.push(thinkingMsg) await nextTick() scrollToBottom() - - let cancelled = false - const chatId = getOrCreateChatId() - const requestId = `${chatId}_${Date.now()}` - const sendNonERPtoaiEnabled = ref( - localStorage.getItem('sendNonERPtoaiEnabled') === 'true' - ) - console.log('sendNonErptoAI value being sent:', sendNonErptoAI, typeof sendNonErptoAI) - const eventName = `debug_${requestId}` - frappe.realtime.on(eventName, onPipelineUpdate) - const request = runPipelineCancelable(message,chatId, responseMode.value,requestId,sendNonERPtoaiEnabled.value) - let lastStepTime = Date.now() - const steps = [] const onPipelineUpdate = (msg) => { const now = Date.now() const seconds = ((now - lastStepTime) / 1000).toFixed(2) @@ -175,6 +165,14 @@ if (msg.done) { } } + let cancelled = false + const chatId = getOrCreateChatId() + const requestId = `${chatId}_${Date.now()}` + const eventName = `debug_${requestId}` + frappe.realtime.on(eventName, onPipelineUpdate) + const request = runPipelineCancelable(message,chatId, responseMode.value,requestId,sendNonERPtoaiEnabled.value) + let lastStepTime = Date.now() + const steps = [] cancelPendingChatRequest.value = () => { if (cancelled) return cancelled = true @@ -217,7 +215,7 @@ else if (response?.create_entity) { thinkingMsg.isStatus = false thinkingMsg.statusType = null thinkingMsg.cancelable = false - thinkingMsg.text = `Opening "${response.doc}" doctype for creating Entity "${response.entity_name}" record.` + thinkingMsg.text = `Opening "${response.doc}" doctype for creating a new record.` debugLogs.value.push({ type: 'success', @@ -229,49 +227,62 @@ else if (response?.create_entity) { currentDebug.value = null const doctype = response.doc - const entityName = response.entity_name || "" + const fieldsToFill = response.fields_to_fill || {} + const childTables = response.child_tables || {} + // Fallback: if new fields_to_fill is empty, use old defaultMap logic + const entityName = response.entity_name || "" const defaultMap = { - Customer: { - customer_name: entityName - }, - Supplier: { - supplier_name: entityName - }, - Employee: { - employee_name: entityName - }, - Item: { - item_code: entityName, - item_name: entityName - }, - Project: { - project_name: entityName - }, - Lead: { - lead_name: entityName - }, - Opportunity: { - opportunity_name: entityName - } + Customer: { customer_name: entityName }, + Supplier: { supplier_name: entityName }, + Employee: { employee_name: entityName }, + Item: { item_code: entityName, item_name: entityName }, + Project: { project_name: entityName }, + Lead: { lead_name: entityName }, + Opportunity: { opportunity_name: entityName } } - const defaults = defaultMap[doctype] || {} + const defaults = Object.keys(fieldsToFill).length > 0 + ? fieldsToFill + : (defaultMap[doctype] || {}) frappe.route_options = defaults - frappe.set_route("Form", doctype, "new") + let attempts = 0 const timer = setInterval(() => { + if (attempts++ > 50) { + clearInterval(timer) + return + } + if (cur_frm && cur_frm.doctype === doctype && cur_frm.is_new()) { clearInterval(timer) + // Fill main form fields Object.entries(defaults).forEach(([field, value]) => { if (value && cur_frm.fields_dict[field]) { cur_frm.set_value(field, value) cur_frm.refresh_field(field) } }) + + // Fill child tables generically + Object.entries(childTables).forEach(([tableField, rows]) => { + if (!Array.isArray(rows) || !rows.length) return + if (!cur_frm.fields_dict[tableField]) return + + rows.forEach(row => { + const childRow = frappe.model.add_child(cur_frm.doc, tableField) + Object.entries(row).forEach(([field, value]) => { + if (value != null && value !== "") { + frappe.model.set_value(childRow.doctype, childRow.name, field, value) + } + }) + }) + + cur_frm.refresh_field(tableField) + }) } }, 200) @@ -281,7 +292,7 @@ if (response?.stop_followup) { thinkingMsg.isStatus = false thinkingMsg.statusType = null thinkingMsg.cancelable = false - thinkingMsg.text = response.message || 'You’re welcome!' + thinkingMsg.text = response.message || "You’re welcome!" debugLogs.value.push({ type: 'stop_followup', @@ -309,7 +320,6 @@ if (response?.stop_followup) { currentDebug.value = null } catch (err) { if (cancelled) return - frappe.realtime.off(eventName, onPipelineUpdate) thinkingMsg.cancelable = false thinkingMsg.isStatus = false thinkingMsg.statusType = null