@progress/kendo-react-webmcp 16.2.0-develop.7 → 16.2.0-develop.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
13
13
|
*-------------------------------------------------------------------------------------------
|
|
14
14
|
*/
|
|
15
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@progress/kendo-react-common"),require("@progress/kendo-react-editor")):"function"==typeof define&&define.amd?define(["exports","react","@progress/kendo-react-common","@progress/kendo-react-editor"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactWebmcp={},e.React,e.KendoReactCommon,e.KendoReactEditor)}(this,function(e,t,n,r){"use strict";function o(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var a=o(t);const i=["eq","neq","gt","gte","lt","lte","contains","doesnotcontain","startswith","endswith","isnull","isnotnull","isempty","isnotempty"];function c(){return{type:"object",properties:{}}}function l(e){return{type:"object",properties:{field:{type:"string",enum:e,description:"Column field name to filter"},operator:{type:"string",enum:i,description:"Filter operator"},value:{description:"Filter value (string, number, or boolean depending on column type)"}},required:["field","operator","value"]}}function s(e){return{type:"object",properties:{field:{type:"string",enum:e,description:"Column field name to sort by"},dir:{type:"string",enum:["asc","desc"],description:"Sort direction"}},required:["field","dir"]}}function d(){return{type:"object",properties:{page:{type:"number",description:"Page number (1-based)"}},required:["page"]}}function p(e){return{type:"object",properties:{pageSize:{type:"number",enum:e,description:"Number of items per page"}},required:["pageSize"]}}function u(){return{type:"object",properties:{fileName:{type:"string",description:"Name of the exported file (optional)"}}}}function m(e){return e.field&&e.operator?{logic:"and",filters:[{field:e.field,operator:e.operator,value:e.value}]}:null}function g(e){return l(e)}function f(){return{type:"object",properties:{value:{type:"string",description:"The text value to set."}},required:["value"]}}function h(){return{type:"object",properties:{value:{type:"number",description:"The numeric value to set."}},required:["value"]}}function y(){return{type:"object",properties:{value:{type:"boolean",description:"The boolean value to set (true or false)."}},required:["value"]}}function x(){return{type:"object",properties:{value:{type:"string",description:'The date value in ISO 8601 format (e.g. "2026-04-23").'}},required:["value"]}}function C(){return{type:"object",properties:{value:{type:"string",description:'The time value in ISO 8601 format (e.g. "14:30:00").'}},required:["value"]}}function S(){return{type:"object",properties:{value:{type:"string",description:'The date and time value in ISO 8601 format (e.g. "2026-04-23T14:30:00").'}},required:["value"]}}function b(){return{type:"object",properties:{startValue:{type:"string",description:'The start date in ISO 8601 format (e.g. "2026-04-01").'},endValue:{type:"string",description:'The end date in ISO 8601 format (e.g. "2026-04-30").'}},required:["startValue","endValue"]}}function v(){return{type:"object",properties:{startValue:{type:"number",description:"The start value of the range."},endValue:{type:"number",description:"The end value of the range."}},required:["startValue","endValue"]}}function T(){return{type:"object",properties:{value:{type:"string",description:'The color value as a hex string (e.g. "#ff6358") or named CSS color.'}},required:["value"]}}function w(){return{type:"object",properties:{value:{type:"string",description:"The value to select from the available options."}},required:["value"]}}function $(){return{type:"object",properties:{value:{type:"string",description:"The value to add to the selection."}},required:["value"]}}function E(){return{type:"object",properties:{value:{type:"string",description:"The value to remove from the selection."}},required:["value"]}}const N={SetValue:"TextBoxSetValue",Clear:"TextBoxClear"};function k(e){return e===N.SetValue?{type:"object",properties:{value:{type:"string",description:"The text value to set."}},required:["value"]}:{type:"object",properties:{}}}const j={componentSuffix:"textbox",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the value of the ${n.dataName} text box.`,commandType:N.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear the value of the ${n.dataName} text box.`,commandType:N.Clear,enabled:!!i.onChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(t,n)=>{switch(t){case N.SetValue:{const t=n.value;return null==t?{content:[{type:"text",text:"Missing required argument: value"}],isError:!0}:(i.onChange&&i.onChange({value:t,target:e}),{content:[{type:"text",text:`Value set to "${t}".`}]})}case N.Clear:return i.onChange&&i.onChange({value:"",target:e}),{content:[{type:"text",text:"Value cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${t}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=k(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},D={Click:"ButtonClick"};function G(e){return{type:"object",properties:{}}}const A={componentSuffix:"button",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=[{name:"click",description:`Click the ${n.dataName} button.`,commandType:D.Click,enabled:!0}],c=t.current.webMcp,l="object"==typeof c&&null!==c&&"function"==typeof c.tools?c.tools:void 0,s=l?l(i):i,d=async(r,o)=>r!==D.Click?{content:[{type:"text",text:`Unknown command: ${r}`}],isError:!0}:t.current.disabled?{content:[{type:"text",text:"Button is disabled."}],isError:!0}:null!=e&&e.click?(e.click(),{content:[{type:"text",text:`Clicked the ${n.dataName} button.`}]}):{content:[{type:"text",text:"Button ref not available."}],isError:!0};for(const e of s){if(!e.enabled)continue;const t=G(e.commandType),n=e.commandType,i=e.execute;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:i?async e=>await i(e):async e=>d(n)}))}catch{}}return o}},V={Expand:"TreeViewExpand",Collapse:"TreeViewCollapse",Select:"TreeViewSelect",Check:"TreeViewCheck"};function M(e){switch(e){case V.Expand:return{type:"object",properties:{nodeText:{type:"string",description:"The text of the tree node to expand"}},required:["nodeText"]};case V.Collapse:return{type:"object",properties:{nodeText:{type:"string",description:"The text of the tree node to collapse"}},required:["nodeText"]};case V.Select:return{type:"object",properties:{nodeText:{type:"string",description:"The text of the tree node to select"}},required:["nodeText"]};case V.Check:return{type:"object",properties:{nodeText:{type:"string",description:"The text of the tree node to check or uncheck"},checkChildren:{type:"boolean",description:"When true, also checks or unchecks all child nodes recursively. Defaults to false."}},required:["nodeText"]};default:return{type:"object",properties:{}}}}function I(e){if("string"==typeof e)return e;if(null===e)return"null";if(void 0===e)return"undefined";if("number"==typeof e||"boolean"==typeof e)return e.toString();try{return JSON.stringify(e)}catch{return"[object]"}}function q(e,t,n,r,o=""){for(let a=0;a<e.length;a++){const i=e[a],c=o?`${o}_${a}`:`${a}`;if(I(i[n])===t)return{node:i,path:c};const l=i[r];if(l&&Array.isArray(l)&&l.length>0){const e=q(l,t,n,r,c);if(e)return e}}}function _(e,t,n){switch(e){case V.Expand:return function(e,t){const n=e.nodeText;if(!n)return{content:[{type:"text",text:"Missing required argument: nodeText"}],isError:!0};const r=t.current,o=r.textField||"text",a=r.childrenField||"items",i=r.data;if(!i)return{content:[{type:"text",text:"TreeView has no data."}]};const c=q(i,n,o,a);return c?(r.onExpandChange&&r.onExpandChange({item:c.node,itemHierarchicalIndex:c.path,nativeEvent:null,target:null,syntheticEvent:null}),{content:[{type:"text",text:`Expanded node "${n}".`}]}):{content:[{type:"text",text:`Node "${n}" not found.`}],isError:!0}}(t,n);case V.Collapse:return function(e,t){const n=e.nodeText;if(!n)return{content:[{type:"text",text:"Missing required argument: nodeText"}],isError:!0};const r=t.current,o=r.textField||"text",a=r.childrenField||"items",i=r.data;if(!i)return{content:[{type:"text",text:"TreeView has no data."}]};const c=q(i,n,o,a);return c?(r.onExpandChange&&r.onExpandChange({item:c.node,itemHierarchicalIndex:c.path,nativeEvent:null,target:null,syntheticEvent:null}),{content:[{type:"text",text:`Collapsed node "${n}".`}]}):{content:[{type:"text",text:`Node "${n}" not found.`}],isError:!0}}(t,n);case V.Select:return function(e,t){const n=e.nodeText;if(!n)return{content:[{type:"text",text:"Missing required argument: nodeText"}],isError:!0};const r=t.current,o=r.textField||"text",a=r.childrenField||"items",i=r.data;if(!i)return{content:[{type:"text",text:"TreeView has no data."}]};const c=q(i,n,o,a);return c?(r.onItemClick&&r.onItemClick({item:c.node,itemHierarchicalIndex:c.path,nativeEvent:null,target:null,syntheticEvent:null}),{content:[{type:"text",text:`Selected node "${n}".`}]}):{content:[{type:"text",text:`Node "${n}" not found.`}],isError:!0}}(t,n);default:return{content:[{type:"text",text:`Unknown command: ${e}`}],isError:!0}}}const R={componentSuffix:"treeview",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"expand_node",description:`Expand a node in the ${n.dataName} treeview`,commandType:V.Expand,enabled:!!i.onExpandChange},{name:"collapse_node",description:`Collapse a node in the ${n.dataName} treeview`,commandType:V.Collapse,enabled:!!i.onExpandChange},{name:"select_node",description:`Select a node in the ${n.dataName} treeview`,commandType:V.Select,enabled:!!i.onItemClick}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c,{tname:a}):c,p=async(e,n)=>_(e,n,t);if(i.onFilterChange)try{o.push(r.registerTool({name:a("search"),description:`Search for nodes matching a text pattern in the ${n.dataName} treeview.`,inputSchema:{type:"object",properties:{query:{type:"string",description:"Text to search for (case-insensitive)"}},required:["query"]},async execute(e){const n=(e.query||"").toLowerCase();if(!n)return{content:[{type:"text",text:"Missing required argument: query"}],isError:!0};const r=t.current,o=r.textField||"text",a=r.childrenField||"items",i=r.data;if(!i)return{content:[{type:"text",text:"TreeView has no data."}]};const c=[],l=(e,t)=>{e.forEach((e,r)=>{const i=t?`${t}_${r}`:`${r}`,s=e[o]||"";"string"==typeof s&&s.toLowerCase().includes(n)&&c.push({text:s,path:i});const d=e[a];d&&Array.isArray(d)&&l(d,i)})};return l(i,""),0===c.length?{content:[{type:"text",text:`No nodes matching "${n}".`}]}:{content:[{type:"text",text:`${c.length} match(es):\n${JSON.stringify(c,null,2)}`}]}}}))}catch{}for(const e of d){if(!e.enabled)continue;const t=M(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},O={SendMessage:"ChatSendMessage"};function P(e){return e===O.SendMessage?{type:"object",properties:{text:{type:"string",description:"The message text to send"}},required:["text"]}:{type:"object",properties:{}}}const F={componentSuffix:"chat",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"send_message",description:`Send a message to the ${n.dataName} conversation`,commandType:O.SendMessage,enabled:!!i.onSendMessage}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(e,n)=>{if(e===O.SendMessage){const e=n.text;if(!e)return{content:[{type:"text",text:"Missing required argument: text"}],isError:!0};const r=t.current;if(!r.onSendMessage)return{content:[{type:"text",text:"Chat has no onSendMessage handler."}],isError:!0};const o={id:Date.now(),author:{id:r.authorId},text:e,timestamp:new Date};return r.onSendMessage({message:o,nativeEvent:null,target:null,syntheticEvent:null}),{content:[{type:"text",text:`Message sent: "${e}"`}]}}return{content:[{type:"text",text:`Unknown command: ${e}`}],isError:!0}};for(const e of d){if(!e.enabled)continue;const t=P(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},U={Fill:"FormFill",Validate:"FormValidate",Submit:"FormSubmit",Reset:"FormReset"};function z(e,t){return e===U.Fill?{type:"object",properties:{values:{type:"object",description:"Key-value pairs of field names to values."+(t&&t.length>0?` Available fields: ${t.join(", ")}.`:"")}},additionalProperties:!0,description:"Provide either a `values` object, or pass field/value pairs directly as top-level properties."}:{type:"object",properties:{}}}const L={componentSuffix:"form",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=(null==e?void 0:e.fields)||[],c=i.length>0?` Available fields: ${i.join(", ")}.`:"",l=[{name:"fill",description:`Fill the ${n.dataName} form fields with the provided values.${c}`,commandType:U.Fill,enabled:!0},{name:"validate",description:`Validate the ${n.dataName} form and return any errors.`,commandType:U.Validate,enabled:!0},{name:"submit",description:`Submit the ${n.dataName} form.`,commandType:U.Submit,enabled:!0},{name:"reset",description:`Reset the ${n.dataName} form to its initial values.`,commandType:U.Reset,enabled:!0}],s=t.current.webMcp,d="object"==typeof s&&null!==s&&"function"==typeof s.tools?s.tools:void 0,p=d?d(l):l,u=async(t,n)=>{switch(t){case U.Fill:return function(e,t){var n;if(!t)return{content:[{type:"text",text:"Form ref not available."}],isError:!0};const r=e.values,o=r&&"object"==typeof r&&!Array.isArray(r)?r:Object.fromEntries(Object.entries(e).filter(([e])=>"values"!==e&&"target"!==e&&"syntheticEvent"!==e));if(!o||"object"!=typeof o||0===Object.keys(o).length)return{content:[{type:"text",text:"Missing required argument: values (object)"}],isError:!0};const a=new Set(t.fields||[]),i=a.size>0,c=[];for(const[e,r]of Object.entries(o))!i||a.has(e)?(t.onChange(e,{value:r}),null==(n=t.onBlur)||n.call(t,e,!0)):c.push(e);const l=Object.keys(o).filter(e=>!c.includes(e));return 0===l.length?{content:[{type:"text",text:"No matching form fields were filled."}],isError:!0}:c.length>0?{content:[{type:"text",text:`Filled ${l.length} field(s): ${l.join(", ")}. Skipped unknown field(s): ${c.join(", ")}.`}]}:{content:[{type:"text",text:`Filled ${l.length} field(s): ${l.join(", ")}.`}]}}(n,e);case U.Validate:return function(e){if(!e)return{content:[{type:"text",text:"Form ref not available."}],isError:!0};(e.fields||[]).forEach(t=>{var n;return null==(n=e.onBlur)?void 0:n.call(e,t)});const t=e.errors||{},n=Object.entries(t).filter(([,e])=>!!e);return 0===n.length?{content:[{type:"text",text:"Form is valid."}]}:{content:[{type:"text",text:"Validation errors:\n"+n.map(([e,t])=>` ${e}: ${t}`).join("\n")}]}}(e);case U.Submit:return function(e){return e?(e.onSubmit({preventDefault:()=>{},stopPropagation:()=>{}}),{content:[{type:"text",text:"Form submitted."}]}):{content:[{type:"text",text:"Form ref not available."}],isError:!0}}(e);case U.Reset:return function(e){return e?(e.onReset(),{content:[{type:"text",text:"Form reset to initial values."}]}):{content:[{type:"text",text:"Form ref not available."}],isError:!0}}(e);default:return{content:[{type:"text",text:`Unknown command: ${t}`}],isError:!0}}};for(const e of p){if(!e.enabled)continue;const t=e.inputSchema||z(e.commandType,i),n=e.commandType,c=e.execute;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:c?async e=>await c(e||{}):async e=>u(n,e||{})}))}catch{}}return o}},B={GetValue:"EditorGetValue",SetValue:"EditorSetValue"};function H(e){return e===B.SetValue?{type:"object",properties:{value:{type:"string",description:"The text value to set."}},required:["value"]}:{type:"object",properties:{}}}const W={componentSuffix:"editor",createTools(e,t,n,o){const a=[],i=e=>`${n.groupName}_${e}`,c=t.current,l=!(null==e||!e.view),s=!!c.onChange,d=[{name:"get_content",description:`Get the current HTML content of the ${n.dataName} editor.`,commandType:B.GetValue,enabled:!1},{name:"set_content",description:`Replace the entire content of the ${n.dataName} editor with the provided HTML.`,commandType:B.SetValue,enabled:l||s},{name:"insert_html",description:`Insert HTML content at the cursor position in the ${n.dataName} editor.`,commandType:B.SetValue,enabled:l||s},{name:"clear_content",description:`Clear all content from the ${n.dataName} editor.`,commandType:B.GetValue,enabled:l||s}],p=t.current.webMcp,u="object"==typeof p&&null!==p&&"function"==typeof p.tools?p.tools:void 0,m=u?u(d):d,g={content:[{type:"text",text:"Editor ref or view not available."}],isError:!0};const f=(t,n,o)=>{switch(n){case"get_content":return null!=e&&e.view?{content:[{type:"text",text:r.EditorUtils.getHtml(e.view.state)||"(empty)"}]}:g;case"set_content":return function(t){if(null==e||!e.view)return g;const n=t.value;return null==n?{content:[{type:"text",text:"Missing required argument: value"}],isError:!0}:(r.EditorUtils.setHtml(e.view,n),{content:[{type:"text",text:"Content replaced."}]})}(o);case"insert_html":return function(t){if(null==e||!e.view)return g;const n=t.value;if(!n)return{content:[{type:"text",text:"Missing required argument: value"}],isError:!0};const o=r.EditorUtils.createDocument(e.view.state.schema,n);return o&&r.EditorUtils.insertNode(e.view,o),{content:[{type:"text",text:"HTML inserted at cursor position."}]}}(o);case"clear_content":return null!=e&&e.view?(r.EditorUtils.setHtml(e.view,""),{content:[{type:"text",text:"Content cleared."}]}):g;default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of m){if(!e.enabled)continue;const t=H(e.commandType),n=(e.commandType,e.name);try{a.push(o.registerTool({name:i(e.name),description:e.description,inputSchema:t,execute:e=>Promise.resolve(f(0,n,e||{}))}))}catch{}}return a}},J={SetCell:"SpreadsheetSetCell",SetCells:"SpreadsheetSetCells",GetCell:"SpreadsheetGetCell",GetData:"SpreadsheetGetData",SetData:"SpreadsheetSetData",GetSheets:"SpreadsheetGetSheets",SwitchSheet:"SpreadsheetSwitchSheet",NavigateSheet:"SpreadsheetNavigateSheet",AddSheet:"SpreadsheetAddSheet",RenameSheet:"SpreadsheetRenameSheet",ExecuteCommand:"SpreadsheetExecuteCommand",Export:"SpreadsheetExport"};function K(e){switch(e){case J.SetCell:return{type:"object",properties:{ref:{type:"string",description:'Cell reference (e.g. "A1", "B2:B10")'},value:{description:"The value to set (string, number, or formula)"}},required:["ref","value"]};case J.SetCells:return{type:"object",properties:{cells:{type:"array",description:"Array of cell updates to apply in batch",items:{type:"object",properties:{ref:{type:"string",description:'Cell reference (e.g. "A1")'},value:{description:"The value to set"}},required:["ref","value"]}}},required:["cells"]};case J.GetCell:return{type:"object",properties:{ref:{type:"string",description:'Cell reference to read (e.g. "A1")'}},required:["ref"]};case J.SetData:return{type:"object",properties:{data:{description:"Workbook JSON object to load (replaces all sheets)"}},required:["data"]};case J.SwitchSheet:case J.NavigateSheet:return{type:"object",properties:{name:{type:"string",description:"The name of the sheet to activate"}},required:["name"]};case J.RenameSheet:return{type:"object",properties:{name:{type:"string",description:"The new name for the active sheet"}},required:["name"]};case J.AddSheet:return{type:"object",properties:{name:{type:"string",description:"Optional name for the new sheet"}}};case J.GetData:case J.GetSheets:case J.Export:return{type:"object",properties:{}};case J.ExecuteCommand:return{type:"object",properties:{command:{type:"string",description:'The command name to execute (e.g. "bold", "italic", "underline", "undo", "redo")'},options:{description:"Optional command-specific options object"}},required:["command"]};default:return{type:"object",properties:{}}}}const Z={bold:!0,italic:!0,underline:!0};const Y={componentSuffix:"spreadsheet",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=[{name:"set_cell",description:`Set a cell value in the ${n.dataName} spreadsheet.`,commandType:J.SetCell,enabled:!0},{name:"set_cells",description:`Set multiple cell values at once in the ${n.dataName} spreadsheet. Preferred over multiple set_cell calls.`,commandType:J.SetCells,enabled:!0},{name:"get_cell",description:`Get the value of a cell in the ${n.dataName} spreadsheet.`,commandType:J.GetCell,enabled:!1},{name:"get_data",description:`Get the full workbook data from the ${n.dataName} spreadsheet as JSON.`,commandType:J.GetData,enabled:!1},{name:"set_data",description:`Load workbook data into the ${n.dataName} spreadsheet from a JSON object.`,commandType:J.SetData,enabled:!0},{name:"get_sheets",description:`Get the names of all sheets in the ${n.dataName} spreadsheet.`,commandType:J.GetSheets,enabled:!1},{name:"switch_sheet",description:`Switch the active sheet in the ${n.dataName} spreadsheet by name.`,commandType:J.SwitchSheet,enabled:!0},{name:"navigate_sheet",description:`Switch the active sheet in the ${n.dataName} spreadsheet.`,commandType:J.NavigateSheet,enabled:!0},{name:"add_sheet",description:`Add a new sheet to the ${n.dataName} spreadsheet.`,commandType:J.AddSheet,enabled:!0},{name:"rename_sheet",description:`Rename the active sheet in the ${n.dataName} spreadsheet.`,commandType:J.RenameSheet,enabled:!0},{name:"export",description:`Export the ${n.dataName} spreadsheet (triggers Excel download).`,commandType:J.Export,enabled:!0},{name:"execute_command",description:`Execute a command (e.g. bold, italic, underline, undo, redo) on the selected cells in the ${n.dataName} spreadsheet.`,commandType:J.ExecuteCommand,enabled:!0}],c=t.current.webMcp,l="object"==typeof c&&null!==c&&"function"==typeof c.tools?c.tools:void 0,s=l?l(i):i,d=async(t,n)=>{switch(t){case J.SetCell:return function(e,t){if(null==t||!t.instance)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const n=e.ref;if(!n)return{content:[{type:"text",text:'Missing required argument: ref (e.g. "A1")'}],isError:!0};const r=t.activeSheet();return r?(r.range(n).value(e.value),{content:[{type:"text",text:`Set ${n} = ${JSON.stringify(e.value)}.`}]}):{content:[{type:"text",text:"No active sheet."}],isError:!0}}(n,e);case J.SetCells:return function(e,t){if(null==t||!t.instance)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const n=e.cells;if(!Array.isArray(n)||0===n.length)return{content:[{type:"text",text:"Missing required argument: cells (array of {ref, value})"}],isError:!0};const r=t.activeSheet();if(!r)return{content:[{type:"text",text:"No active sheet."}],isError:!0};for(const e of n)e.ref&&r.range(e.ref).value(e.value);return{content:[{type:"text",text:`Set ${n.length} cell(s).`}]}}(n,e);case J.GetCell:return function(e,t){if(null==t||!t.instance)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const n=e.ref;if(!n)return{content:[{type:"text",text:'Missing required argument: ref (e.g. "A1")'}],isError:!0};const r=t.activeSheet();if(!r)return{content:[{type:"text",text:"No active sheet."}],isError:!0};const o=r.range(n).value();return{content:[{type:"text",text:JSON.stringify(o)}]}}(n,e);case J.GetData:return function(e){if(!e)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const t=e.toJSON();return{content:[{type:"text",text:JSON.stringify(t)}]}}(e);case J.SetData:return function(e,t){if(!t)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const n=e.data;return n&&"object"==typeof n?(t.fromJSON(n),{content:[{type:"text",text:"Workbook data loaded."}]}):{content:[{type:"text",text:"Missing required argument: data (object)"}],isError:!0}}(n,e);case J.GetSheets:return function(e){if(!e)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const t=e.sheets().map(e=>e.name());return{content:[{type:"text",text:JSON.stringify(t)}]}}(e);case J.SwitchSheet:case J.NavigateSheet:return function(e,t){if(!t)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const n=e.name;if(!n)return{content:[{type:"text",text:"Missing required argument: name"}],isError:!0};const r=t.sheets().find(e=>e.name()===n);return r?(t.activeSheet(r),{content:[{type:"text",text:`Switched to sheet "${n}".`}]}):{content:[{type:"text",text:`Sheet "${n}" not found.`}],isError:!0}}(n,e);case J.AddSheet:return function(e,t){if(null==t||!t.instance)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const n=t.instance;if(n.insertSheet){const t=e.name;n.insertSheet(t?{name:t}:void 0)}const r=e.name;return{content:[{type:"text",text:r?'Sheet "'+r+'" added.':"Sheet added."}]}}(n,e);case J.RenameSheet:return function(e,t){if(null==t||!t.instance)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const n=e.name;if(!n)return{content:[{type:"text",text:"Missing required argument: name"}],isError:!0};const r=t.activeSheet();if(!r)return{content:[{type:"text",text:"No active sheet."}],isError:!0};const o=t.instance;return o.renameSheet?(o.renameSheet(r,n),{content:[{type:"text",text:`Sheet renamed to "${n}".`}]}):{content:[{type:"text",text:"Rename sheet is not supported by this instance."}],isError:!0}}(n,e);case J.ExecuteCommand:return function(e,t){var n,r;if(!t)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const o=e.command;if(!o)return{content:[{type:"text",text:"Missing required argument: command"}],isError:!0};if(Z[o]){const e=t.activeSheet();if(!e)return{content:[{type:"text",text:"No active sheet."}],isError:!0};const a=e.activeCell(),i=!!a&&(null==(r=(n=e.range(a))[o])?void 0:r.call(n));t.executeCommand({command:"PropertyChangeCommand",options:{property:o,value:!i}})}else{const n=e.options||void 0;t.executeCommand(n?{command:o,...n}:{command:o})}return{content:[{type:"text",text:`Command "${o}" executed.`}]}}(n,e);case J.Export:return function(e){return null!=e&&e.instance?(e.saveAsExcel({}),{content:[{type:"text",text:"Export triggered."}]}):{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0}}(e);default:return{content:[{type:"text",text:`Unknown command: ${t}`}],isError:!0}}};for(const e of s){if(!e.enabled)continue;const t=K(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>d(n,e||{})}))}catch{}}return o}},X=["Day","MultiDay","Week","Month","Timeline","Agenda"];function Q(){return{type:"object",properties:{title:{type:"string",description:"Title of the new event"},start:{type:"string",description:'Start date and time in ISO 8601 format (e.g. "2026-04-08T09:00:00")'},end:{type:"string",description:'End date and time in ISO 8601 format (e.g. "2026-04-08T10:00:00")'},isAllDay:{type:"boolean",description:"Whether the event spans the entire day"},description:{type:"string",description:"Optional description of the event"}},required:["title","start","end"]}}function ee(){return{type:"object",properties:{title:{type:"string",description:"Title of the event to delete"},start:{type:"string",description:"Start date/time of the event to identify it (ISO 8601)"}},required:["title"]}}function te(){return{type:"object",properties:{date:{type:"string",description:'Date to navigate to in ISO 8601 format (e.g. "2026-04-15")'}},required:["date"]}}function ne(){return{type:"object",properties:{view:{type:"string",enum:X,description:"The scheduler view to switch to"}},required:["view"]}}const re={Create:"SchedulerCreate",Delete:"SchedulerDelete",Navigate:"SchedulerNavigate",Update:"SchedulerUpdate",View:"SchedulerView"};function oe(e){switch(e){case re.Create:return{type:"object",properties:{title:{type:"string",description:"Title of the new event"},start:{type:"string",description:'Start date and time in ISO 8601 format (e.g. "2026-04-08T09:00:00")'},end:{type:"string",description:'End date and time in ISO 8601 format (e.g. "2026-04-08T10:00:00")'},isAllDay:{type:"boolean",description:"Whether the event spans the entire day"},description:{type:"string",description:"Optional description of the event"}},required:["title","start","end"]};case re.Delete:return{type:"object",properties:{title:{type:"string",description:"Title of the event to delete"},start:{type:"string",description:"Start date/time of the event to identify it (ISO 8601)"}},required:["title"]};case re.Update:return{type:"object",properties:{title:{type:"string",description:"Title of the event to update (used to find the event)"},start:{type:"string",description:"Current start date/time to identify the event (ISO 8601)"},newTitle:{type:"string",description:"New title for the event"},newStart:{type:"string",description:"New start date-time in ISO 8601 format"},newEnd:{type:"string",description:"New end date-time in ISO 8601 format"},isAllDay:{type:"boolean",description:"Whether the event spans the entire day"},description:{type:"string",description:"New description for the event"}},required:["title"]};case re.Navigate:return{type:"object",properties:{date:{type:"string",description:'Date to navigate to in ISO 8601 format (e.g. "2026-04-15")'}},required:["date"]};case re.View:return ne();default:return{type:"object",properties:{}}}}function ae(e){const t=e.modelFields;return{id:(null==t?void 0:t.id)||"id",title:(null==t?void 0:t.title)||"title",start:(null==t?void 0:t.start)||"start",end:(null==t?void 0:t.end)||"end",isAllDay:(null==t?void 0:t.isAllDay)||"isAllDay",description:(null==t?void 0:t.description)||"description"}}function ie(e,t,n){switch(e){case re.Navigate:return function(e,t){const n=e.date;if(!n)return{content:[{type:"text",text:"Missing required argument: date"}],isError:!0};const r=new Date(n);if(Number.isNaN(r.getTime()))return{content:[{type:"text",text:`Invalid date: ${n}`}],isError:!0};const o=t.current;return o.onDateChange&&o.onDateChange({value:r}),{content:[{type:"text",text:`Navigated to ${r.toISOString().split("T")[0]}.`}]}}(t,n);case re.View:return function(e,t){const n=e.view;if(!n)return{content:[{type:"text",text:"Missing required argument: view"}],isError:!0};const r=t.current;return r.onViewChange&&r.onViewChange({value:n}),{content:[{type:"text",text:`Switched to ${n} view.`}]}}(t,n);case re.Create:return function(e,t){const n=t.current;if(!n.onDataChange)return{content:[{type:"text",text:"Scheduler is not editable (no onDataChange handler)."}],isError:!0};const r=ae(n),o=e.title||"New Event",a=e.start,i=e.end;if(!a||!i)return{content:[{type:"text",text:"Missing required arguments: start and end (ISO strings)"}],isError:!0};const c=new Date(a),l=new Date(i);if(Number.isNaN(c.getTime())||Number.isNaN(l.getTime()))return{content:[{type:"text",text:"Invalid start or end date."}],isError:!0};const s={[r.id]:Date.now(),[r.title]:o,[r.start]:c,[r.end]:l,[r.isAllDay]:!0===e.isAllDay};return e.description&&(s[r.description]=e.description),n.onDataChange({created:[s],updated:[],deleted:[]}),{content:[{type:"text",text:`Created event "${o}" from ${a} to ${i}.`}]}}(t,n);case re.Update:return function(e,t){const n=t.current;if(!n.onDataChange)return{content:[{type:"text",text:"Scheduler is not editable (no onDataChange handler)."}],isError:!0};const r=ae(n),o=e.title;if(!o)return{content:[{type:"text",text:"Missing required argument: title"}],isError:!0};const a=n.data||[],i=e.start,c=a.find(e=>{if(I(e[r.title])!==o)return!1;if(i){const t=e[r.start];return(t instanceof Date?t.toISOString():I(t)).startsWith(i)}return!0});if(!c)return{content:[{type:"text",text:`Event "${o}" not found.`}],isError:!0};const l={...c};if(e.newTitle&&(l[r.title]=e.newTitle),e.newStart){const t=new Date(e.newStart);Number.isNaN(t.getTime())||(l[r.start]=t)}if(e.newEnd){const t=new Date(e.newEnd);Number.isNaN(t.getTime())||(l[r.end]=t)}return void 0!==e.isAllDay&&(l[r.isAllDay]=!0===e.isAllDay),void 0!==e.description&&(l[r.description]=e.description),n.onDataChange({created:[],updated:[l],deleted:[]}),{content:[{type:"text",text:`Updated event "${I(l[r.title])}".`}]}}(t,n);case re.Delete:return function(e,t){const n=t.current;if(!n.onDataChange)return{content:[{type:"text",text:"Scheduler is not editable (no onDataChange handler)."}],isError:!0};const r=ae(n),o=e.title;if(!o)return{content:[{type:"text",text:"Missing required argument: title"}],isError:!0};const a=n.data||[],i=e.start,c=a.find(e=>{if(I(e[r.title])!==o)return!1;if(i){const t=e[r.start];return(t instanceof Date?t.toISOString():I(t)).startsWith(i)}return!0});return c?(n.onDataChange({created:[],updated:[],deleted:[c]}),{content:[{type:"text",text:`Deleted event "${I(c[r.title])}".`}]}):{content:[{type:"text",text:`Event "${o}" not found.`}],isError:!0}}(t,n);default:return{content:[{type:"text",text:`Unknown command: ${e}`}],isError:!0}}}const ce={componentSuffix:"scheduler",createTools(e,t,n,r){const o=[],i=e=>`${n.groupName}_${e}`,c=t.current,l=function(e){const t=[];return a.Children.forEach(e,e=>{if(a.isValidElement(e)){const n=e.props.name;n&&t.push(n)}}),t}(c.children),s=l.length>0?` Available views: ${l.join(", ")}.`:"",d=[{name:"navigate",description:`Navigate the ${n.dataName} scheduler to a specific date.`,commandType:re.Navigate,enabled:!!c.onDateChange},{name:"set_view",description:`Switch the ${n.dataName} scheduler view.${s}`,commandType:re.View,enabled:!!c.onViewChange},{name:"create_event",description:`Create a new event in the ${n.dataName} scheduler.`,commandType:re.Create,enabled:!!c.onDataChange},{name:"update_event",description:`Update an existing event in the ${n.dataName} scheduler.`,commandType:re.Update,enabled:!!c.onDataChange},{name:"delete_event",description:`Delete an event from the ${n.dataName} scheduler.`,commandType:re.Delete,enabled:!!c.onDataChange}],p=t.current.webMcp,u="object"==typeof p&&null!==p&&"function"==typeof p.tools?p.tools:void 0,m={tname:i,data:c.data},g=u?u(d,m):d;for(const e of g){if(!e.enabled)continue;const n=oe(e.commandType),a=e.commandType;try{o.push(r.registerTool({name:i(e.name),description:e.description,inputSchema:n,execute:async e=>ie(a,e||{},t)}))}catch{}}return o}};function le(e){return{type:"object",properties:{id:{type:"string",description:"Column identifier",...e.length>0?{enum:e}:{}}},required:["id"]}}function se(e){return{type:"object",properties:{id:{type:"string",description:"Column identifier to move",...e.length>0?{enum:e}:{}},position:{type:"number",description:"Target position index (0-based)"}},required:["id","position"]}}function de(e){return{type:"object",properties:{id:{type:"string",description:"Column identifier to resize",...e.length>0?{enum:e}:{}},size:{type:"string",description:'New column width (e.g. "200px")'}},required:["id","size"]}}function pe(e){return{type:"object",properties:{field:{type:"string",enum:e,description:"Column field name to match"},operator:{type:"string",enum:i,description:"Filter operator"},value:{description:"Filter value (string, number, or boolean depending on column type)"},cells:{type:"array",items:{type:"string",enum:e},description:"Optional list of column fields to target. When provided, only the specified cells in matching rows are affected instead of entire rows."}},required:["field","operator","value"]}}function ue(){return{type:"object",properties:{view:{type:"string",description:"The Gantt view to switch to",enum:["Day","Week","Month","Year"]}},required:["view"]}}function me(){return{type:"object",properties:{title:{type:"string",description:"The title of the new task"},start:{type:"string",format:"date-time",description:"The start date of the task (ISO 8601 format)"},end:{type:"string",format:"date-time",description:"The end date of the task (ISO 8601 format)"}},required:["title"]}}function ge(e){return{type:"object",properties:{field:{type:"string",description:"The field used to identify the task to delete (use with operator and value)",enum:e.length>0?e:void 0},operator:{type:"string",description:"Filter operator to match the task",enum:["eq","neq","contains","startswith","gt","gte","lt","lte"]},value:{description:"The value to match in the field"},id:{description:"The task ID (alternative to field/operator/value)"}}}}const fe={Filter:"GanttFilter",ClearFilter:"GanttClearFilter",Sort:"GanttSort",ClearSort:"GanttClearSort",ColumnReorder:"GanttColumnReorder",ColumnResize:"GanttColumnResize",ColumnShow:"GanttColumnShow",ColumnHide:"GanttColumnHide",Expand:"GanttExpand",Collapse:"GanttCollapse",ExpandAll:"GanttExpandAll",CollapseAll:"GanttCollapseAll",ChangeView:"GanttChangeView",CreateTask:"GanttCreateTask",DeleteTask:"GanttDeleteTask"};function he(e,t){const n=t.map(e=>e.field).filter(Boolean),r=t.map(e=>e.id).filter(Boolean);switch(e){case fe.Filter:return l(n);case fe.ClearFilter:return{type:"object",properties:{}};case fe.Sort:return s(n);case fe.ClearSort:return{type:"object",properties:{}};case fe.ColumnReorder:return se(r);case fe.ColumnResize:return de(r);case fe.ColumnShow:case fe.ColumnHide:return le(r);case fe.Expand:case fe.Collapse:return g(n);case fe.ExpandAll:case fe.CollapseAll:return{type:"object",properties:{}};case fe.ChangeView:return{type:"object",properties:{view:{type:"string",description:"The Gantt view to switch to",enum:["Day","Week","Month","Year"]}},required:["view"]};case fe.CreateTask:return{type:"object",properties:{title:{type:"string",description:"The title of the new task"},start:{type:"string",format:"date-time",description:"The start date of the task (ISO 8601 format)"},end:{type:"string",format:"date-time",description:"The end date of the task (ISO 8601 format)"}},required:["title"]};case fe.DeleteTask:return ge(n);case"GanttUpdateTask":return function(e){return{type:"object",properties:{field:{type:"string",description:"The field used to identify the task to update (use with operator and value)",enum:e.length>0?e:void 0},operator:{type:"string",description:"Filter operator to match the task",enum:["eq","contains","startswith"]},value:{description:"The value to match in the field"},id:{description:"The task ID (alternative to field/operator/value)"},title:{type:"string",description:"New title for the task"},start:{type:"string",format:"date-time",description:"New start date (ISO 8601)"},end:{type:"string",format:"date-time",description:"New end date (ISO 8601)"},percentComplete:{type:"number",description:"New percent complete (0-1)"}}}}(n);case"GanttSelect":return function(e){return{type:"object",properties:{field:{type:"string",description:"The field used to identify the task to select (use with operator and value)",enum:e.length>0?e:void 0},operator:{type:"string",description:"Filter operator to match the task",enum:["eq","neq","contains","startswith","gt","gte","lt","lte"]},value:{description:"The value to match in the field"},id:{description:"The task ID (alternative to field/operator/value)"}}}}(n);default:return{type:"object",properties:{}}}}const ye="GanttUpdateTask",xe="GanttSelect";function Ce(e){return{id:(null==e?void 0:e.id)||"id",title:(null==e?void 0:e.title)||"title",start:(null==e?void 0:e.start)||"start",end:(null==e?void 0:e.end)||"end",percentComplete:(null==e?void 0:e.percentComplete)||"percentComplete",isExpanded:(null==e?void 0:e.isExpanded)||"isExpanded",children:(null==e?void 0:e.children)||"children"}}function Se(e,t){const n=[],r=e=>{for(const o of e){n.push(o);const e=o[t.children];Array.isArray(e)&&e.length>0&&r(e)}};return r(e),n}function be(e,t,n){const r="string"==typeof e?e.toLowerCase():e,o="string"==typeof n?n.toLowerCase():n;switch(t){case"eq":default:return r===o;case"neq":return r!==o;case"contains":return"string"==typeof r&&"string"==typeof o&&r.includes(o);case"startswith":return"string"==typeof r&&"string"==typeof o&&r.startsWith(o);case"endswith":return"string"==typeof r&&"string"==typeof o&&r.endsWith(o)}}function ve(e,t,n,r){const o=n.current,a=Ce(o.taskModelFields),i=Se(o.taskData||[],a);let c;return t.field&&t.operator?c=i.find(e=>be(e[t.field],t.operator,t.value)):void 0!==t.id&&(c=i.find(e=>String(e[a.id])===String(t.id))),c?(o.onExpandChange&&o.onExpandChange({dataItem:c,value:e,level:[],target:r}),{content:[{type:"text",text:`${e?"Expanded":"Collapsed"} task "${I(c[a.title])}".`}]}):{content:[{type:"text",text:"No matching task found."}],isError:!0}}function Te(e,t,n){const r=t.current,o=Ce(r.taskModelFields),a=Se(r.taskData||[],o).filter(e=>{const t=e[o.children];return Array.isArray(t)&&t.length>0});if(r.onExpandChange)for(const t of a)r.onExpandChange({dataItem:t,value:e,level:[],target:n});return{content:[{type:"text",text:`${e?"Expanded":"Collapsed"} ${a.length} parent task(s).`}]}}function we(e,t){return e.id===t||e.field===t}function $e(e,t,n){return e.map(e=>we(e,t)?n(e):e)}function Ee(e,t,n,r,o,a){var i;return a?(null==(i=n.onColumnsStateChange)||i.call(n,{columnsState:$e(o,e,e=>({...e,hidden:t})),target:r}),{content:[{type:"text",text:`Column ${e} is now ${t?"hidden":"visible"}.`}]}):{content:[{type:"text",text:"Column state changes not supported."}],isError:!0}}function Ne(e,t,n,r,o){const a=t.id;if(!a)return{content:[{type:"text",text:"Missing required argument: id"}],isError:!0};const i=n.current,c=!!i.onColumnsStateChange&&!!r,l=c&&(i.columnsState||(null==r?void 0:r.columns))||[];switch(e){case fe.ColumnReorder:return function(e,t,n,r,o,a,i){var c;const l=Number(t.position);if(Number.isNaN(l))return{content:[{type:"text",text:"Missing required argument: position"}],isError:!0};if(i){const t=o.findIndex(t=>we(t,e)),i=a[t];if(i){const e=[...a];e.splice(t,1),e.splice(l,0,i),null==(c=n.onColumnsStateChange)||c.call(n,{columnsState:e.map((e,t)=>({...e,orderIndex:t})),target:r})}}else{if(!n.onColumnReorder)return{content:[{type:"text",text:"Column reorder not supported."}],isError:!0};{const t=o.findIndex(t=>we(t,e));n.onColumnReorder({oldIndex:t,newIndex:l,target:r})}}return{content:[{type:"text",text:`Column ${e} moved to position ${l}.`}]}}(a,t,i,r,o,l,c);case fe.ColumnResize:return function(e,t,n,r,o,a,i){var c;const l=Number.parseInt(t.size,10);if(Number.isNaN(l))return{content:[{type:"text",text:"Missing required argument: size"}],isError:!0};if(i)null==(c=n.onColumnsStateChange)||c.call(n,{columnsState:$e(a,e,e=>({...e,width:l})),target:r});else{if(!n.onColumnResize)return{content:[{type:"text",text:"Column resize not supported."}],isError:!0};{const t=o.findIndex(t=>we(t,e)),a=(n.columns||[])[t],i=a&&a.width||0;n.onColumnResize({index:t,newWidth:l,oldWidth:i,end:!0,target:r})}}return{content:[{type:"text",text:`Column ${e} resized to ${l}px.`}]}}(a,t,i,r,o,l,c);case fe.ColumnShow:return Ee(a,!1,i,r,l,c);case fe.ColumnHide:return Ee(a,!0,i,r,l,c);default:return null}}const ke={componentSuffix:"gantt",createTools(e,t,n,r){const o=[],i=e=>`${n.groupName}_${e}`,c=t.current,l=function(e){const t=[];if(Array.isArray(e.columns))for(const n of e.columns)n.field&&t.push({field:n.field,id:n.id||n.field});return 0===t.length&&e.children&&a.Children.forEach(e.children,e=>{if(a.isValidElement(e)&&e.props.field){const n=e.props;t.push({field:n.field,id:n.id||n.field})}}),t}(c),s=!!c.sortable,d=!!c.onFilterChange,p=!!c.onExpandChange,u=!!c.onViewChange,m=!!c.onTaskChange||!!c.onDataStateChange,g=!!c.reorderable||!!c.onColumnReorder,f=!!c.resizable||!!c.onColumnResize,h=!!c.onColumnsStateChange,y=[{name:"sort",description:`Sort the ${n.dataName} gantt by a column`,commandType:fe.Sort,enabled:s},{name:"clear_sort",description:`Remove all sorting from the ${n.dataName} gantt`,commandType:fe.ClearSort,enabled:s},{name:"filter",description:`Filter the ${n.dataName} gantt on a column`,commandType:fe.Filter,enabled:d},{name:"clear_filters",description:`Remove all filters from the ${n.dataName} gantt`,commandType:fe.ClearFilter,enabled:d},{name:"expand",description:`Expand a task in the ${n.dataName} gantt`,commandType:fe.Expand,enabled:p},{name:"collapse",description:`Collapse a task in the ${n.dataName} gantt`,commandType:fe.Collapse,enabled:p},{name:"expand_all",description:`Expand all parent tasks in the ${n.dataName} gantt`,commandType:fe.ExpandAll,enabled:p},{name:"collapse_all",description:`Collapse all parent tasks in the ${n.dataName} gantt`,commandType:fe.CollapseAll,enabled:p},{name:"set_view",description:`Switch the ${n.dataName} gantt chart view`,commandType:fe.ChangeView,enabled:u},{name:"add_task",description:`Add a new task to the ${n.dataName} gantt`,commandType:fe.CreateTask,enabled:m},{name:"update_task",description:`Update an existing task in the ${n.dataName} gantt`,commandType:ye,enabled:m},{name:"delete_task",description:`Delete a task from the ${n.dataName} gantt`,commandType:fe.DeleteTask,enabled:m},{name:"select",description:`Select a task in the ${n.dataName} gantt`,commandType:xe,enabled:!!c.selectable||!!c.onSelectionChange||m},{name:"reorder_column",description:`Reorder a column in the ${n.dataName} gantt`,commandType:fe.ColumnReorder,enabled:g},{name:"resize_column",description:`Resize a column in the ${n.dataName} gantt`,commandType:fe.ColumnResize,enabled:f},{name:"show_column",description:`Show a hidden column in the ${n.dataName} gantt`,commandType:fe.ColumnShow,enabled:h},{name:"hide_column",description:`Hide a column in the ${n.dataName} gantt`,commandType:fe.ColumnHide,enabled:h}],x=t.current.webMcp,C="object"==typeof x&&null!==x&&"function"==typeof x.tools?x.tools:void 0,S={tname:i,columns:l,data:c.taskData},b=C?C(y,S):y,v=async(n,r)=>{const o=t.current;switch(n){case fe.Sort:return function(e,t,n){if(!e.field)return{content:[{type:"text",text:"Missing required argument: field"}],isError:!0};const r=e.field,o=e.dir||"asc",a=[{field:r,dir:o}];return t.current.onSortChange&&t.current.onSortChange({sort:a,field:r,target:n}),{content:[{type:"text",text:`Sorted by ${r} ${o}.`}]}}(r,t,e);case fe.ClearSort:return o.onSortChange&&o.onSortChange({sort:[],field:"",target:e}),{content:[{type:"text",text:"Sorting cleared."}]};case fe.Filter:return function(e,t,n){if(!e.field||!e.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const r=e.field,o=e.operator,a=e.value;return t.current.onFilterChange&&t.current.onFilterChange({filter:{logic:"and",filters:[{field:r,operator:o,value:a}]},target:n}),{content:[{type:"text",text:`Filter applied: ${r} ${o} "${I(a)}".`}]}}(r,t,e);case fe.ClearFilter:return o.onFilterChange&&o.onFilterChange({filter:{logic:"and",filters:[]},target:e}),{content:[{type:"text",text:"All filters cleared."}]};case fe.Expand:case fe.Collapse:case fe.ExpandAll:case fe.CollapseAll:return function(e,t,n,r){switch(e){case fe.Expand:return ve(!0,t,n,r);case fe.Collapse:return ve(!1,t,n,r);case fe.ExpandAll:return Te(!0,n,r);case fe.CollapseAll:return Te(!1,n,r);default:return{content:[{type:"text",text:`Unknown expand/collapse command: ${e}`}],isError:!0}}}(n,r,t,e);case fe.ChangeView:return function(e,t,n){const r=e.view;return r?(t.current.onViewChange&&t.current.onViewChange({value:r,target:n}),{content:[{type:"text",text:`Switched to ${r} view.`}]}):{content:[{type:"text",text:"Missing required argument: view"}],isError:!0}}(r,t,e);case fe.CreateTask:case fe.DeleteTask:case ye:{const e=function(e,t,n){var r;const o=n.current,a=o.onTaskChange||o.onDataStateChange;if(!a)return null;const i=Ce(o.taskModelFields);switch(e){case fe.CreateTask:{const e=t.title;return e?(a({created:[{[i.id]:Date.now(),[i.title]:e,[i.start]:t.start?new Date(t.start):void 0,[i.end]:t.end?new Date(t.end):void 0,[i.percentComplete]:null!=(r=t.percentComplete)?r:0}],updated:[],deleted:[]}),{content:[{type:"text",text:`Added task "${e}".`}]}):{content:[{type:"text",text:"Missing required argument: title"}],isError:!0}}case fe.DeleteTask:{const e=Se(o.taskData||[],i);let n;return t.field&&t.operator?n=e.find(e=>be(e[t.field],t.operator,t.value)):void 0!==t.id&&(n=e.find(e=>String(e[i.id])===String(t.id))),n?(a({created:[],updated:[],deleted:[n]}),{content:[{type:"text",text:`Deleted task "${I(n[i.title])}".`}]}):{content:[{type:"text",text:"No matching task found."}],isError:!0}}case ye:{const e=Se(o.taskData||[],i);let n;if(t.field&&t.operator?n=e.find(e=>be(e[t.field],t.operator,t.value)):void 0!==t.id&&(n=e.find(e=>String(e[i.id])===String(t.id))),!n)return{content:[{type:"text",text:"No matching task found."}],isError:!0};const r={...n};return void 0!==t.title&&(r[i.title]=t.title),void 0!==t.start&&(r[i.start]=new Date(t.start)),void 0!==t.end&&(r[i.end]=new Date(t.end)),void 0!==t.percentComplete&&(r[i.percentComplete]=t.percentComplete),a({created:[],updated:[r],deleted:[]}),{content:[{type:"text",text:`Updated task "${I(r[i.title])}".`}]}}default:return null}}(n,r,t);return e||{content:[{type:"text",text:"Task operations not supported."}],isError:!0}}case xe:{const n=t.current,o=Ce(n.taskModelFields),a=Se(n.taskData||[],o);let i;if(r.field&&r.operator?i=a.find(e=>be(e[r.field],r.operator,r.value)):void 0!==r.id&&(i=a.find(e=>String(e[o.id])===String(r.id))),!i)return{content:[{type:"text",text:"No matching task found."}],isError:!0};if(n.onSelectionChange)n.onSelectionChange({dataItem:i,dataItems:a,target:e});else{if(!n.onDataStateChange)return{content:[{type:"text",text:"Selection not supported. Add onSelectionChange or selectable prop."}],isError:!0};n.onDataStateChange({selected:[i],target:e})}return{content:[{type:"text",text:`Selected task "${I(i[o.title])}".`}]}}case fe.ColumnReorder:case fe.ColumnResize:case fe.ColumnShow:case fe.ColumnHide:return Ne(n,r,t,e,l)||{content:[{type:"text",text:`Unknown column command: ${n}`}],isError:!0};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of b){if(!e.enabled)continue;const t=e.inputSchema||he(e.commandType,l),n=e.commandType,a=e.execute;try{o.push(r.registerTool({name:i(e.name),description:e.description,inputSchema:t,execute:a?async e=>await a(e||{}):async e=>v(n,e||{})}))}catch{}}return o}};function je(e){return{type:"object",properties:{field:{type:"string",enum:e,description:"Column field name to group by"},dir:{type:"string",enum:["asc","desc"],description:"Sort direction within the group"}},required:["field"]}}function De(e){return{type:"object",properties:{field:{type:"string",enum:e,description:"Column field name to aggregate"},aggregate:{type:"string",enum:["sum","average","count","min","max"],description:"Aggregate function to apply"}},required:["field","aggregate"]}}function Ge(e){return{type:"object",properties:{field:{type:"string",enum:e,description:"The grouped field name"},value:{type:"string",description:"The group value to expand or collapse"}},required:["field","value"]}}const Ae={Filter:"GridFilter",ClearFilter:"GridClearFilter",Sort:"GridSort",ClearSort:"GridClearSort",Group:"GridGroup",ClearGroup:"GridClearGroup",Highlight:"GridHighlight",ClearHighlight:"GridClearHighlight",Select:"GridSelect",ClearSelect:"GridClearSelect",Page:"GridPage",PageSize:"GridPageSize",ColumnReorder:"GridColumnReorder",ColumnResize:"GridColumnResize",ColumnShow:"GridColumnShow",ColumnHide:"GridColumnHide",ColumnLock:"GridColumnLock",ColumnUnlock:"GridColumnUnlock",ExportPDF:"GridExportPDF",ExportCSV:"GridExportCSV",SelectAll:"GridSelectAll",DetailExpand:"GridDetailExpand",DetailCollapse:"GridDetailCollapse",DetailExpandAll:"GridDetailExpandAll",DetailCollapseAll:"GridDetailCollapseAll",GroupExpand:"GridGroupExpand",GroupCollapse:"GridGroupCollapse",GroupExpandAll:"GridGroupExpandAll",GroupCollapseAll:"GridGroupCollapseAll",SetAggregates:"GridSetAggregates",GetData:"GridGetData"};function Ve(e,t,n=[]){const r=t.map(e=>e.field).filter(Boolean),o=t.map(e=>e.id).filter(Boolean);switch(e){case Ae.Filter:return l(r);case Ae.ClearFilter:return{type:"object",properties:{}};case Ae.Sort:return s(r);case Ae.ClearSort:return{type:"object",properties:{}};case Ae.Group:return je(r);case Ae.ClearGroup:return{type:"object",properties:{}};case Ae.Highlight:return pe(r);case Ae.ClearHighlight:return{type:"object",properties:{}};case Ae.Select:return pe(r);case Ae.ClearSelect:return{type:"object",properties:{}};case Ae.Page:return{type:"object",properties:{page:{type:"number",description:"Page number (1-based)"}},required:["page"]};case Ae.PageSize:return p(n);case Ae.ColumnReorder:return se(o);case Ae.ColumnResize:return de(o);case Ae.ColumnShow:case Ae.ColumnHide:case Ae.ColumnLock:case Ae.ColumnUnlock:return le(o);case Ae.ExportPDF:case Ae.ExportCSV:return{type:"object",properties:{fileName:{type:"string",description:"Name of the exported file (optional)"}}};case Ae.SelectAll:return{type:"object",properties:{}};case Ae.DetailExpand:case Ae.DetailCollapse:return pe(r);case Ae.DetailExpandAll:case Ae.DetailCollapseAll:return{type:"object",properties:{}};case Ae.GroupExpand:case Ae.GroupCollapse:return Ge(r);case Ae.GroupExpandAll:case Ae.GroupCollapseAll:return{type:"object",properties:{}};case Ae.SetAggregates:return De(r);default:return{type:"object",properties:{}}}}function Me(e,t,n,r,o){const a=e.current;if(t)t({...n,target:o});else if(a.onDataStateChange){const e={filter:a.filter,sort:a.sort,skip:a.skip,take:a.take,group:a.group};a.onDataStateChange({dataState:{...e,...r},target:o})}}function Ie(e,t,n,r,o){const a=n.current;switch(e){case"GridSort":return function(e,t,n){if(!e.field)return{content:[{type:"text",text:"Missing required argument: field"}],isError:!0};const r=e.field,o=e.dir||"asc",a=[{field:r,dir:o}];return Me(t,t.current.onSortChange,{sort:a},{sort:a},n),{content:[{type:"text",text:`Sorted by ${r} ${o}.`}]}}(t,n,r);case"GridClearSort":return Me(n,a.onSortChange,{sort:[]},{sort:[]},r),{content:[{type:"text",text:"Sorting cleared."}]};case"GridFilter":return function(e,t,n,r){var o,a;if(!e.field||!e.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const i=e.field,c=e.operator,l=e.value,s=t.current,d={logic:"and",filters:[...null!=(a=null!=r?r:null==(o=s.filter)?void 0:o.filters)?a:[],{field:i,operator:c,value:l}]};return Me(t,s.onFilterChange,{filter:d},{filter:d,skip:0},n),{content:[{type:"text",text:`Filter applied: ${i} ${c} "${l}".`}]}}(t,n,r,o);case"GridClearFilter":{const e={logic:"and",filters:[]};return Me(n,a.onFilterChange,{filter:e},{filter:e,skip:0},r),{content:[{type:"text",text:"All filters cleared."}]}}case"GridGroup":return function(e,t,n){var r;if(!e.field)return{content:[{type:"text",text:"Missing required argument: field"}],isError:!0};const o=e.field,a=e.dir||"asc",i=t.current,c=[...null!=(r=i.group)?r:[],{field:o,dir:a}];return Me(t,i.onGroupChange,{group:c},{group:c},n),{content:[{type:"text",text:`Grouped by ${o} ${a}.`}]}}(t,n,r);case"GridClearGroup":return Me(n,a.onGroupChange,{group:[]},{group:[]},r),{content:[{type:"text",text:"Grouping cleared."}]};case"GridPage":return function(e,t,n){var r;const o=Number(e.page);if(!o||o<1)return{content:[{type:"text",text:"Invalid page number."}],isError:!0};const a=null!=(r=t.current.take)?r:10,i=(o-1)*a;return Me(t,t.current.onPageChange,{page:{skip:i,take:a}},{skip:i,take:a},n),{content:[{type:"text",text:`Navigated to page ${o}.`}]}}(t,n,r);case"GridPageSize":return function(e,t,n){const r=Number(e.pageSize);return!r||r<1?{content:[{type:"text",text:"Invalid page size."}],isError:!0}:(Me(t,t.current.onPageChange,{page:{skip:0,take:r}},{skip:0,take:r},n),{content:[{type:"text",text:`Page size set to ${r}.`}]})}(t,n,r);default:return null}}function qe(e){return Array.isArray(e)?e:e&&"object"==typeof e&&Array.isArray(e.data)?e.data:[]}function _e(e,t,n,r,o){switch(e){case"GridHighlight":return function(e,t,n){var r,o;if(!e.field||!e.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const a=e.field,i=e.operator,c=e.value,l=t.current.dataItemKey;if(!l)return{content:[{type:"text",text:"dataItemKey prop is required for highlighting."}],isError:!0};const s=null!=(o=null==(r=null==n?void 0:n.getLeafDataItems)?void 0:r.call(n))?o:qe(t.current.data),d={};for(const e of s){const t=e;if(Pe(t[a],i,c)){const e=Re(t[l]);null!==e&&(d[e]=!0)}}return t.current.onHighlightChange&&t.current.onHighlightChange({highlight:d}),{content:[{type:"text",text:`Highlighted rows where ${a} ${i} "${JSON.stringify(c)}".`}]}}(t,n,r);case"GridClearHighlight":return n.current.onHighlightChange&&n.current.onHighlightChange({highlight:{}}),{content:[{type:"text",text:"Highlights cleared."}]};case"GridSelect":return function(e,t,n){var r,o;if(!e.field||!e.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const a=e.field,i=e.operator,c=e.value,l=t.current.dataItemKey;if(!l)return{content:[{type:"text",text:"dataItemKey prop is required for selection."}],isError:!0};const s=null!=(o=null==(r=null==n?void 0:n.getLeafDataItems)?void 0:r.call(n))?o:qe(t.current.data),d={};for(const e of s){const t=e;if(Pe(t[a],i,c)){const e=Re(t[l]);null!==e&&(d[e]=!0)}}return t.current.onSelectionChange&&t.current.onSelectionChange({select:d,dataItem:null,dataItems:s,startDataItem:null,endDataItem:null,target:n}),{content:[{type:"text",text:`Selected rows where ${a} ${i} "${JSON.stringify(c)}".`}]}}(t,n,r);case"GridClearSelect":return n.current.onSelectionChange&&n.current.onSelectionChange({select:{},target:r}),{content:[{type:"text",text:"Selection cleared."}]};case"GridSelectAll":return function(e,t){var n,r;const o=e.current;if(!o.onHeaderSelectionChange&&!o.onSelectionChange)return{content:[{type:"text",text:"Selection not enabled."}],isError:!0};const a=null!=(r=null==(n=null==t?void 0:t.getLeafDataItems)?void 0:n.call(t))?r:[],i=o.dataItemKey;if(o.onHeaderSelectionChange){const e=i?Oe(a,i):{};o.onHeaderSelectionChange({select:e,field:void 0,dataItems:a,target:t})}else if(o.onSelectionChange){if(!i)return{content:[{type:"text",text:"dataItemKey prop is required for select all."}],isError:!0};o.onSelectionChange({select:Oe(a,i),dataItems:a,target:t})}return{content:[{type:"text",text:"All rows selected."}]}}(n,r);case"GridDetailExpand":case"GridDetailCollapse":case"GridDetailExpandAll":case"GridDetailCollapseAll":return function(e,t,n,r){var o,a;const i=n.current;if(!i.onDetailExpandChange)return{content:[{type:"text",text:"onDetailExpandChange callback not provided."}],isError:!0};const c=i.dataItemKey;if(!c)return{content:[{type:"text",text:"dataItemKey prop is required for detail expand."}],isError:!0};const l=null!=(a=null==(o=null==r?void 0:r.getLeafDataItems)?void 0:o.call(r))?a:[];switch(e){case"GridDetailExpandAll":return i.onDetailExpandChange({detailExpand:Oe(l,c),target:r}),{content:[{type:"text",text:"All detail rows expanded."}]};case"GridDetailCollapseAll":return i.onDetailExpandChange({detailExpand:{},target:r}),{content:[{type:"text",text:"All detail rows collapsed."}]};case"GridDetailExpand":case"GridDetailCollapse":return function(e,t,n,r,o,a){var i;if(!t.field||!t.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const c=t.field,l=t.operator,s=t.value,d="GridDetailExpand"===e,p={...null!=(i=n.detailExpand)?i:{}};for(const e of a){if(Pe(e[c],l,s)){const t=Re(e[o]);null!==t&&(d?p[t]=!0:delete p[t])}}return n.onDetailExpandChange&&n.onDetailExpandChange({detailExpand:p,target:r}),{content:[{type:"text",text:`Detail rows ${d?"expanded":"collapsed"} where ${c} ${l} "${s}".`}]}}(e,t,i,r,c,l);default:return{content:[{type:"text",text:`Unknown expand command: ${e}`}],isError:!0}}}(e,t,n,r);case"GridGroupExpand":case"GridGroupCollapse":case"GridGroupExpandAll":case"GridGroupCollapseAll":return function(e,t,n,r){var o,a,i;const c=n.current;if(!c.groupable)return{content:[{type:"text",text:"Grouping not enabled."}],isError:!0};if(!c.onGroupExpandChange)return{content:[{type:"text",text:"onGroupExpandChange callback not provided."}],isError:!0};switch(e){case"GridGroupExpandAll":return c.onGroupExpandChange({groupExpand:[],target:r}),{content:[{type:"text",text:"All groups expanded."}]};case"GridGroupCollapseAll":{if(!c.group||0===c.group.length)return{content:[{type:"text",text:"No active grouping."}],isError:!0};const e=null!=(a=null==(o=null==r?void 0:r.getLeafDataItems)?void 0:o.call(r))?a:qe(c.data),t=function(e,t){const n=[];for(const r of e){const e=new Set;for(const o of t){const t=o[r.field];e.has(t)||(e.add(t),n.push({field:r.field,value:t,expanded:!1}))}}return n}(c.group,e);return c.onGroupExpandChange({groupExpand:t,target:r}),{content:[{type:"text",text:"All groups collapsed."}]}}case"GridGroupExpand":case"GridGroupCollapse":{const n="GridGroupExpand"===e,o=function(e,t,n){if(!e.field||null==e.value)return null;const r=e.field,o=e.value,a="string"==typeof o||"number"==typeof o?String(o):JSON.stringify(o);return{updated:t.find(e=>e.field===r&&String(e.value)===a)?t.map(e=>e.field===r&&String(e.value)===a?{...e,expanded:n}:e):[...t,{field:r,value:o,expanded:n}],field:r,valueStr:a}}(t,null!=(i=c.groupExpand)?i:[],n);if(!o)return{content:[{type:"text",text:"Missing required arguments: field, value"}],isError:!0};c.onGroupExpandChange({groupExpand:o.updated,target:r});const a=n?"expanded":"collapsed";return{content:[{type:"text",text:`Group "${o.field}=${o.valueStr}" ${a}.`}]}}default:return{content:[{type:"text",text:`Unknown group expand command: ${e}`}],isError:!0}}}(e,t,n,r);case"GridSetAggregates":return function(e,t,n){const r=t.current;if(!r.groupable)return{content:[{type:"text",text:"Grouping not enabled — aggregates require grouped data."}],isError:!0};if(!r.group||0===r.group.length)return{content:[{type:"text",text:"No active grouping — group the data first."}],isError:!0};if(!e.field||!e.aggregate)return{content:[{type:"text",text:"Missing required arguments: field, aggregate"}],isError:!0};const o=e.field,a=e.aggregate,i={field:o,aggregate:a},c=r.group.map(e=>{var t;const n=null!=(t=e.aggregates)?t:[];return n.some(e=>e.field===o&&e.aggregate===a)?e:{...e,aggregates:[...n,i]}});return Me(t,r.onGroupChange,{group:c},{group:c},n),{content:[{type:"text",text:`Aggregate "${a}" added for column "${o}".`}]}}(t,n,r);case"GridExportPDF":return null!=r&&r.exportAsPdf&&r.exportAsPdf(),{content:[{type:"text",text:"PDF export triggered."}]};case"GridExportCSV":return null!=r&&r.saveAsCsv?r.saveAsCsv().then(()=>({content:[{type:"text",text:"CSV export triggered."}]})):{content:[{type:"text",text:"CSV export not available."}],isError:!0};case"GridColumnReorder":case"GridColumnResize":case"GridColumnShow":case"GridColumnHide":case"GridColumnLock":case"GridColumnUnlock":return function(e,t,n,r){const o=t.id;if(!o)return{content:[{type:"text",text:"Missing required argument: id"}],isError:!0};const a=n.current;if(!a.onColumnsStateChange||!r)return{content:[{type:"text",text:"Column state changes not supported."}],isError:!0};const i=a.columnsState||r.columns||[],c=e=>e.id===o||e.field===o;switch(e){case"GridColumnReorder":{const e=Number(t.position);if(Number.isNaN(e))return{content:[{type:"text",text:"Missing required argument: position"}],isError:!0};const n=i.findIndex(c),l=i[n];if(l){const t=[...i];t.splice(n,1),t.splice(e,0,l),a.onColumnsStateChange({columnsState:t.map((e,t)=>({...e,orderIndex:t})),target:r})}return{content:[{type:"text",text:`Column ${o} moved to position ${e}.`}]}}case"GridColumnResize":{const e=Number.parseInt(t.size,10);if(Number.isNaN(e))return{content:[{type:"text",text:"Missing required argument: size"}],isError:!0};const n=i.map(t=>c(t)?{...t,width:e}:t);return a.onColumnsStateChange({columnsState:n,target:r}),{content:[{type:"text",text:`Column ${o} resized to ${e}px.`}]}}case"GridColumnShow":{const e=i.map(e=>c(e)?{...e,hidden:!1}:e);return a.onColumnsStateChange({columnsState:e,target:r}),{content:[{type:"text",text:`Column ${o} is now visible.`}]}}case"GridColumnHide":{const e=i.map(e=>c(e)?{...e,hidden:!0}:e);return a.onColumnsStateChange({columnsState:e,target:r}),{content:[{type:"text",text:`Column ${o} is now hidden.`}]}}case"GridColumnLock":{const e=i.map(e=>c(e)?{...e,locked:!0}:e);return a.onColumnsStateChange({columnsState:e,target:r}),{content:[{type:"text",text:`Column ${o} locked.`}]}}case"GridColumnUnlock":{const e=i.map(e=>c(e)?{...e,locked:!1}:e);return a.onColumnsStateChange({columnsState:e,target:r}),{content:[{type:"text",text:`Column ${o} unlocked.`}]}}default:return null}}(e,t,n,r);case"GridAdd":case"GridUpdate":case"GridDelete":return function(e,t,n,r){const o=n.current;if(!o.onItemChange)return null;switch(e){case"GridAdd":return o.onItemChange({dataItem:t,dataIndex:-1,field:void 0,value:void 0,target:r}),{content:[{type:"text",text:"Record added."}]};case"GridUpdate":return o.onItemChange({dataItem:t,dataIndex:-1,field:void 0,value:void 0,target:r}),{content:[{type:"text",text:"Record updated."}]};case"GridDelete":return o.onItemChange({dataItem:t,dataIndex:-1,field:"_deleted",value:!0,target:r}),{content:[{type:"text",text:"Record deleted."}]};default:return null}}(e,t,n,r);default:return null}}function Re(e){return null==e?null:"string"==typeof e||"number"==typeof e?String(e):null}function Oe(e,t){const n={};for(const r of e){const e=Re(r[t]);null!==e&&(n[e]=!0)}return n}function Pe(e,t,n){switch(t){case"eq":return e===n||String(e)===String(n);case"neq":return e!==n&&String(e)!==String(n);case"contains":return"string"==typeof e&&"string"==typeof n&&e.toLowerCase().includes(n.toLowerCase());case"startswith":return"string"==typeof e&&"string"==typeof n&&e.toLowerCase().startsWith(n.toLowerCase());case"gt":return Number(e)>Number(n);case"gte":return Number(e)>=Number(n);case"lt":return Number(e)<Number(n);case"lte":return Number(e)<=Number(n);default:return!1}}const Fe={componentSuffix:"grid",createTools(e,t,n,r){const o=[],i=e=>`${n.groupName}_${e}`,c=t.current,l=function(e){const t=[];return a.Children.forEach(e,e=>{if(a.isValidElement(e)&&e.props.field){const n=e.props;t.push({field:n.field,id:n.id||n.field})}}),t}(c.children),s=!!c.onHighlightChange,d=!!c.selectable,p=d&&(!!c.onHeaderSelectionChange||!!c.dataItemKey),u=!!c.onDetailExpandChange,m=!!c.groupable&&!!c.onGroupExpandChange,g=!!c.pdf,f=!!c.csv,h=!!c.reorderable,y=!!c.resizable,x=!!c.onColumnsStateChange,C=!!c.onItemChange||!!c.editable,S=[{name:"sort",description:`Sort the ${n.dataName} grid by a column`,commandType:"GridSort",enabled:!(!c.sortable&&!c.columnMenu)},{name:"clear_sort",description:`Remove all sorting from the ${n.dataName} grid`,commandType:"GridClearSort",enabled:!(!c.sortable&&!c.columnMenu)},{name:"filter",description:`Filter the ${n.dataName} grid on a column`,commandType:"GridFilter",enabled:!(!c.filterable&&!c.columnMenu)},{name:"clear_filters",description:`Remove all filters from the ${n.dataName} grid`,commandType:"GridClearFilter",enabled:!(!c.filterable&&!c.columnMenu)},{name:"group",description:`Group the ${n.dataName} grid rows by a column`,commandType:"GridGroup",enabled:!(!c.groupable&&!c.columnMenu)},{name:"clear_group",description:`Remove all grouping from the ${n.dataName} grid`,commandType:"GridClearGroup",enabled:!(!c.groupable&&!c.columnMenu)},{name:"page",description:`Navigate to a specific page in the ${n.dataName} grid`,commandType:"GridPage",enabled:!!c.pageable},{name:"set_page_size",description:`Change the number of items per page in the ${n.dataName} grid`,commandType:"GridPageSize",enabled:!!c.pageable},{name:"highlight",description:`Visually highlight rows in the ${n.dataName} grid`,commandType:"GridHighlight",enabled:s},{name:"clear_highlight",description:`Remove all row highlighting from the ${n.dataName} grid`,commandType:"GridClearHighlight",enabled:s},{name:"select",description:`Select rows in the ${n.dataName} grid`,commandType:"GridSelect",enabled:d},{name:"clear_select",description:`Clear all row selections in the ${n.dataName} grid`,commandType:"GridClearSelect",enabled:d},{name:"select_all",description:`Select all rows in the ${n.dataName} grid`,commandType:"GridSelectAll",enabled:p},{name:"detail_expand",description:`Expand detail rows matching a condition in the ${n.dataName} grid`,commandType:"GridDetailExpand",enabled:u},{name:"detail_collapse",description:`Collapse detail rows matching a condition in the ${n.dataName} grid`,commandType:"GridDetailCollapse",enabled:u},{name:"detail_expand_all",description:`Expand all detail rows in the ${n.dataName} grid`,commandType:"GridDetailExpandAll",enabled:u},{name:"detail_collapse_all",description:`Collapse all detail rows in the ${n.dataName} grid`,commandType:"GridDetailCollapseAll",enabled:u},{name:"group_expand",description:`Expand a specific group in the ${n.dataName} grid`,commandType:"GridGroupExpand",enabled:m},{name:"group_collapse",description:`Collapse a specific group in the ${n.dataName} grid`,commandType:"GridGroupCollapse",enabled:m},{name:"group_expand_all",description:`Expand all groups in the ${n.dataName} grid`,commandType:"GridGroupExpandAll",enabled:m},{name:"group_collapse_all",description:`Collapse all groups in the ${n.dataName} grid`,commandType:"GridGroupCollapseAll",enabled:m},{name:"set_aggregates",description:`Add an aggregate function (sum, average, count, min, max) to a column in the ${n.dataName} grid. Requires active grouping.`,commandType:"GridSetAggregates",enabled:!!c.groupable},{name:"export_pdf",description:`Export the ${n.dataName} grid to PDF`,commandType:"GridExportPDF",enabled:g},{name:"export_csv",description:`Export the ${n.dataName} grid to CSV`,commandType:"GridExportCSV",enabled:f},{name:"reorder_column",description:`Reorder a column in the ${n.dataName} grid`,commandType:"GridColumnReorder",enabled:h},{name:"resize_column",description:`Resize a column in the ${n.dataName} grid`,commandType:"GridColumnResize",enabled:y},{name:"show_column",description:`Show a hidden column in the ${n.dataName} grid`,commandType:"GridColumnShow",enabled:x},{name:"hide_column",description:`Hide a column in the ${n.dataName} grid`,commandType:"GridColumnHide",enabled:x},{name:"lock_column",description:`Lock a column in the ${n.dataName} grid`,commandType:"GridColumnLock",enabled:x},{name:"unlock_column",description:`Unlock a column in the ${n.dataName} grid`,commandType:"GridColumnUnlock",enabled:x},{name:"add",description:`Add a new record to the ${n.dataName} grid`,commandType:"GridAdd",enabled:C},{name:"update",description:`Update a record in the ${n.dataName} grid`,commandType:"GridUpdate",enabled:C},{name:"delete",description:`Delete a record from the ${n.dataName} grid`,commandType:"GridDelete",enabled:C},{name:"get_data",description:`Read the data currently visible in the ${n.dataName} grid as JSON`,commandType:"GridGetData",enabled:!1}],b=t.current.webMcp,v="object"==typeof b&&null!==b&&"function"==typeof b.tools?b.tools:void 0,T={tname:i,columns:l,data:c.data},w=v?v(S,T):S;let $=null;const E=async(n,r)=>{var o,a,i,c,l,s,d;const p=null!=(a=null==$?void 0:$.filters)?a:null==(o=t.current.filter)?void 0:o.filters,u=Ie(n,r,t,e,p);if(u)return"GridFilter"===n&&r.field&&r.operator?$={logic:"and",filters:[...null!=(l=null!=(c=null==$?void 0:$.filters)?c:null==(i=t.current.filter)?void 0:i.filters)?l:[],{field:r.field,operator:r.operator,value:r.value}]}:"GridClearFilter"===n&&($={logic:"and",filters:[]}),u;const m=_e(n,r,t,e);if(m)return m;if("GridGetData"===n){$&&await new Promise(e=>setTimeout(e,100));const n=1e3,r=null!=(d=null==(s=null==e?void 0:e.getLeafDataItems)?void 0:s.call(e))?d:qe(t.current.data),o=Array.isArray(r)&&r.length>n?r.slice(0,n):r;return{content:[{type:"text",text:JSON.stringify(o!==r?{rows:o,truncated:!0,total:r.length}:r)}]}}return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of w){if(!e.enabled)continue;const t=Ve(e.commandType,l),n=e.commandType;try{o.push(r.registerTool({name:i(e.name),description:e.description,inputSchema:t,execute:async e=>E(n,e||{})}))}catch{}}return o}},Ue={Filter:"TreeListFilter",ClearFilter:"TreeListClearFilter",Sort:"TreeListSort",ClearSort:"TreeListClearSort",Select:"TreeListSelect",ClearSelect:"TreeListClearSelect",Page:"TreeListPage",PageSize:"TreeListPageSize",ColumnReorder:"TreeListColumnReorder",ColumnResize:"TreeListColumnResize",ColumnShow:"TreeListColumnShow",ColumnHide:"TreeListColumnHide",ColumnLock:"TreeListColumnLock",ColumnUnlock:"TreeListColumnUnlock",Expand:"TreeListExpand",Collapse:"TreeListCollapse",ExpandAll:"TreeListExpandAll",CollapseAll:"TreeListCollapseAll"};function ze(e,t,n=[]){const r=t.map(e=>e.field).filter(Boolean),o=t.map(e=>e.id).filter(Boolean);switch(e){case Ue.Filter:return l(r);case Ue.ClearFilter:return{type:"object",properties:{}};case Ue.Sort:return s(r);case Ue.ClearSort:return{type:"object",properties:{}};case Ue.Select:return pe(r);case Ue.ClearSelect:return{type:"object",properties:{}};case Ue.Page:return{type:"object",properties:{page:{type:"number",description:"Page number (1-based)"}},required:["page"]};case Ue.PageSize:return p(n);case Ue.ColumnReorder:return se(o);case Ue.ColumnResize:return de(o);case Ue.ColumnShow:case Ue.ColumnHide:case Ue.ColumnLock:case Ue.ColumnUnlock:return le(o);case Ue.Expand:case Ue.Collapse:return g(r);default:return{type:"object",properties:{}}}}function Le(e,t,n,r,o){const a=e.current;if(t)t({...n,target:o});else if(a.onDataStateChange){const e={filter:a.filter,sort:a.sort,skip:a.skip,take:a.take};a.onDataStateChange({dataState:{...e,...r},target:o})}}function Be(e){return"object"==typeof e&&null!==e}function He(e,t){const n=[],r=e=>{for(const o of e){if(!Be(o))continue;n.push(o);const e=o[t];Array.isArray(e)&&e.length>0&&r(e)}};return r(e),n}function We(e,t,n,r){const o=n.current;switch(e){case Ue.Sort:return function(e,t,n){if(!e.field)return{content:[{type:"text",text:"Missing required argument: field"}],isError:!0};const r=e.field,o=e.dir||"asc",a=[{field:r,dir:o}];return Le(t,t.current.onSortChange,{sort:a},{sort:a},n),{content:[{type:"text",text:`Sorted by ${r} ${o}.`}]}}(t,n,r);case Ue.ClearSort:return Le(n,o.onSortChange,{sort:[]},{sort:[]},r),{content:[{type:"text",text:"Sorting cleared."}]};case Ue.Filter:return function(e,t,n){var r,o;if(!e.field||!e.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const a=e.field,i=e.operator,c=e.value,l=t.current,s=[...Array.isArray(l.filter)?l.filter:null!=(o=null==(r=l.filter)?void 0:r.filters)?o:[],{field:a,operator:i,value:c}];return Le(t,l.onFilterChange,{filter:s},{filter:s,skip:0},n),{content:[{type:"text",text:`Filter applied: ${a} ${i} "${c}".`}]}}(t,n,r);case Ue.ClearFilter:{const e=[];return Le(n,o.onFilterChange,{filter:e},{filter:e,skip:0},r),{content:[{type:"text",text:"All filters cleared."}]}}case Ue.Page:return function(e,t,n){var r;const o=Number(e.page);if(!o||o<1)return{content:[{type:"text",text:"Invalid page number."}],isError:!0};const a=null!=(r=t.current.take)?r:10,i=(o-1)*a;return Le(t,t.current.onPageChange,{page:{skip:i,take:a}},{skip:i,take:a},n),{content:[{type:"text",text:`Navigated to page ${o}.`}]}}(t,n,r);case Ue.PageSize:return function(e,t,n){const r=Number(e.pageSize);return!r||r<1?{content:[{type:"text",text:"Invalid page size."}],isError:!0}:(Le(t,t.current.onPageChange,{page:{skip:0,take:r}},{skip:0,take:r},n),{content:[{type:"text",text:`Page size set to ${r}.`}]})}(t,n,r);default:return null}}function Je(e,t){return e.id===t||e.field===t}function Ke(e,t,n){return e.map(e=>Je(e,t)?n(e):e)}function Ze(e,t,n,r,o,a){var i;return a?(null==(i=n.onColumnsStateChange)||i.call(n,{columnsState:Ke(o,e,e=>({...e,hidden:t})),target:r}),{content:[{type:"text",text:`Column ${e} is now ${t?"hidden":"visible"}.`}]}):{content:[{type:"text",text:"Column state changes not supported."}],isError:!0}}function Ye(e,t,n,r,o,a){var i;return a?(null==(i=n.onColumnsStateChange)||i.call(n,{columnsState:Ke(o,e,e=>({...e,locked:t})),target:r}),{content:[{type:"text",text:`Column ${e} ${t?"locked":"unlocked"}.`}]}):{content:[{type:"text",text:"Column state changes not supported."}],isError:!0}}function Xe(e,t,n,r,o){const a=t.id;if(!a)return{content:[{type:"text",text:"Missing required argument: id"}],isError:!0};const i=n.current,c=!!i.onColumnsStateChange&&!!r,l=c&&(i.columnsState||(null==r?void 0:r.columns))||[];switch(e){case Ue.ColumnReorder:return function(e,t,n,r,o,a,i){var c;const l=Number(t.position);if(Number.isNaN(l))return{content:[{type:"text",text:"Missing required argument: position"}],isError:!0};if(i){const t=o.findIndex(t=>Je(t,e)),i=a[t];if(i){const e=[...a];e.splice(t,1),e.splice(l,0,i),null==(c=n.onColumnsStateChange)||c.call(n,{columnsState:e.map((e,t)=>({...e,orderIndex:t})),target:r})}}else{if(!n.onColumnReorder)return{content:[{type:"text",text:"Column reorder not supported."}],isError:!0};{const t=o.findIndex(t=>Je(t,e));n.onColumnReorder({oldIndex:t,newIndex:l,target:r})}}return{content:[{type:"text",text:`Column ${e} moved to position ${l}.`}]}}(a,t,i,r,o,l,c);case Ue.ColumnResize:return function(e,t,n,r,o,a,i){var c;const l=Number.parseInt(t.size,10);if(Number.isNaN(l))return{content:[{type:"text",text:"Missing required argument: size"}],isError:!0};if(i)null==(c=n.onColumnsStateChange)||c.call(n,{columnsState:Ke(a,e,e=>({...e,width:l})),target:r});else{if(!n.onColumnResize)return{content:[{type:"text",text:"Column resize not supported."}],isError:!0};{const t=o.findIndex(t=>Je(t,e)),a=(n.columns||[])[t],i=a&&a.width||0;n.onColumnResize({index:t,newWidth:l,oldWidth:i,end:!0,target:r})}}return{content:[{type:"text",text:`Column ${e} resized to ${l}px.`}]}}(a,t,i,r,o,l,c);case Ue.ColumnShow:return Ze(a,!1,i,r,l,c);case Ue.ColumnHide:return Ze(a,!0,i,r,l,c);case Ue.ColumnLock:return Ye(a,!0,i,r,l,c);case Ue.ColumnUnlock:return Ye(a,!1,i,r,l,c);default:return null}}function Qe(e,t,n,r){const o=n.current,a=o.subItemsField||"items",i=He(o.data||[],a);let c;if(t.field){const e=t.field,n=t.value;c=i.find(t=>String(t[e])===String(n))}else void 0!==t.id&&(c=i.find(e=>String(e.id)===String(t.id)));return c?(o.onExpandChange&&o.onExpandChange({dataItem:c,value:e,level:[],target:r}),{content:[{type:"text",text:e?"Row expanded.":"Row collapsed."}]}):{content:[{type:"text",text:"Item not found."}],isError:!0}}function et(e,t,n){const r=t.current,o=r.subItemsField||"items",a=He(r.data||[],o).filter(e=>{const t=e[o];return Array.isArray(t)&&t.length>0});if(r.onExpandChange)for(const t of a)r.onExpandChange({dataItem:t,value:e,level:[],target:n});return{content:[{type:"text",text:`${e?"Expanded":"Collapsed"} ${a.length} parent row(s).`}]}}function tt(e,t,n,r,o){switch(e){case Ue.Select:return function(e,t,n){if(!e.field||!e.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const r=e.field,o=e.operator;return t.current.onSelectionChange&&t.current.onSelectionChange({criteria:[{logic:"and",filters:[{field:r,operator:o,value:e.value}],cells:{}}],target:n}),{content:[{type:"text",text:`Selected rows where ${r} ${o} "${JSON.stringify(e.value)}".`}]}}(t,n,r);case Ue.ClearSelect:return n.current.onSelectionChange&&n.current.onSelectionChange({criteria:[],target:r}),{content:[{type:"text",text:"Selection cleared."}]};case Ue.ColumnReorder:case Ue.ColumnResize:case Ue.ColumnShow:case Ue.ColumnHide:case Ue.ColumnLock:case Ue.ColumnUnlock:return Xe(e,t,n,r,o);case Ue.Expand:case Ue.Collapse:case Ue.ExpandAll:case Ue.CollapseAll:return function(e,t,n,r){switch(e){case Ue.Expand:return Qe(!0,t,n,r);case Ue.Collapse:return Qe(!1,t,n,r);case Ue.ExpandAll:return et(!0,n,r);case Ue.CollapseAll:return et(!1,n,r);default:return null}}(e,t,n,r);default:return null}}const nt={componentSuffix:"treelist",createTools(e,t,n,r){const o=[],i=e=>`${n.groupName}_${e}`,c=t.current,l=function(e){const t=[];if(Array.isArray(e.columns))for(const n of e.columns)n.field&&t.push({field:n.field,id:n.id||n.field});return 0===t.length&&e.children&&a.Children.forEach(e.children,e=>{if(a.isValidElement(e)&&e.props.field){const n=e.props;t.push({field:n.field,id:n.id||n.field})}}),t}(c),s=!!c.onSelectionChange,d=!!c.reorderable,p=!!c.resizable,u=!!c.onColumnsStateChange,m=!!c.onExpandChange,g=c.pageable,f="object"==typeof g&&null!==g&&Array.isArray(g.pageSizes)?g.pageSizes:[],h=[{name:"sort",description:`Sort the ${n.dataName} tree list by a column`,commandType:Ue.Sort,enabled:!!c.sortable},{name:"clear_sort",description:`Remove all sorting from the ${n.dataName} tree list`,commandType:Ue.ClearSort,enabled:!!c.sortable},{name:"filter",description:`Filter the ${n.dataName} tree list on a column`,commandType:Ue.Filter,enabled:!!c.filterable},{name:"clear_filters",description:`Remove all filters from the ${n.dataName} tree list`,commandType:Ue.ClearFilter,enabled:!!c.filterable},{name:"page",description:`Navigate to a specific page in the ${n.dataName} tree list`,commandType:Ue.Page,enabled:!!c.pageable},{name:"set_page_size",description:`Change the number of items per page in the ${n.dataName} tree list`,commandType:Ue.PageSize,enabled:!!c.pageable},{name:"select",description:`Select rows in the ${n.dataName} tree list`,commandType:Ue.Select,enabled:s},{name:"clear_select",description:`Clear all row selections in the ${n.dataName} tree list`,commandType:Ue.ClearSelect,enabled:s},{name:"reorder_column",description:`Reorder a column in the ${n.dataName} tree list`,commandType:Ue.ColumnReorder,enabled:d},{name:"resize_column",description:`Resize a column in the ${n.dataName} tree list`,commandType:Ue.ColumnResize,enabled:p},{name:"show_column",description:`Show a hidden column in the ${n.dataName} tree list`,commandType:Ue.ColumnShow,enabled:u},{name:"hide_column",description:`Hide a column in the ${n.dataName} tree list`,commandType:Ue.ColumnHide,enabled:u},{name:"lock_column",description:`Lock a column in the ${n.dataName} tree list`,commandType:Ue.ColumnLock,enabled:u},{name:"unlock_column",description:`Unlock a column in the ${n.dataName} tree list`,commandType:Ue.ColumnUnlock,enabled:u},{name:"expand",description:`Expand a row in the ${n.dataName} tree list to show its children`,commandType:Ue.Expand,enabled:m},{name:"collapse",description:`Collapse a row in the ${n.dataName} tree list to hide its children`,commandType:Ue.Collapse,enabled:m},{name:"expand_all",description:`Expand all rows in the ${n.dataName} tree list`,commandType:Ue.ExpandAll,enabled:m},{name:"collapse_all",description:`Collapse all rows in the ${n.dataName} tree list`,commandType:Ue.CollapseAll,enabled:m}],y=t.current.webMcp,x="object"==typeof y&&null!==y&&"function"==typeof y.tools?y.tools:void 0,C={tname:i,columns:l,data:c.data},S=x?x(h,C):h,b=async(n,r)=>{const o=We(n,r,t,e);if(o)return o;return tt(n,r,t,e,l)||{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of S){if(!e.enabled)continue;const t=ze(e.commandType,l,f),n=e.commandType;try{o.push(r.registerTool({name:i(e.name),description:e.description,inputSchema:t,execute:async e=>b(n,e||{})}))}catch{}}return o}},rt={SelectTab:"TabStripSelectTab"};function ot(e){return e===rt.SelectTab?{type:"object",properties:{index:{type:"number",description:"The 0-based index of the visible tab to switch to"},title:{type:"string",description:"The title of the tab to switch to (case-insensitive)"}}}:{type:"object",properties:{}}}const at={componentSuffix:"tabstrip",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"select_tab",description:`Select a tab in the ${n.dataName} tab strip. Tab indices start at 0.`,commandType:rt.SelectTab,enabled:!!i.onSelect}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(e,n)=>{if(e===rt.SelectTab){const e=t.current,r=n.index;return e.onSelect&&e.onSelect({selected:r}),{content:[{type:"text",text:`Tab ${r} selected.`}]}}return{content:[{type:"text",text:`Unknown command: ${e}`}],isError:!0}};for(const e of d){if(!e.enabled)continue;const t=ot(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},it={Expand:"PanelBarExpand",Collapse:"PanelBarCollapse"};function ct(e){switch(e){case it.Expand:case it.Collapse:return{type:"object",properties:{id:{type:"string",description:"Unique panel id"}},required:["id"]};default:return{type:"object",properties:{}}}}const lt={componentSuffix:"panelbar",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"expand",description:`Expand a panel in the ${n.dataName} panel bar by its unique id.`,commandType:it.Expand,enabled:!!i.onSelect},{name:"collapse",description:`Collapse a panel in the ${n.dataName} panel bar by its unique id.`,commandType:it.Collapse,enabled:!!i.onSelect}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(e,n)=>{var r,o;const a=t.current,i=n.id;switch(e){case it.Expand:{const e=null!=(r=a.expanded)?r:[];if(!e.includes(i)){const t=[...e,i];a.onSelect&&a.onSelect({expanded:t})}return{content:[{type:"text",text:`Panel "${i}" expanded.`}]}}case it.Collapse:{const e=(null!=(o=a.expanded)?o:[]).filter(e=>e!==i);return a.onSelect&&a.onSelect({expanded:e}),{content:[{type:"text",text:`Panel "${i}" collapsed.`}]}}default:return{content:[{type:"text",text:`Unknown command: ${e}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=ct(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},st={Step:"StepperStep"};function dt(e,t){if(e===st.Step){const e={type:"number",description:"Zero-based step index to navigate to"};return void 0!==t&&(e.minimum=0,e.maximum=t),{type:"object",properties:{value:e},required:["value"]}}return{type:"object",properties:{}}}const pt={componentSuffix:"stepper",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=i.items?i.items.length-1:void 0,l=[{name:"step",description:`Navigate to a step in the ${n.dataName} stepper.`+(void 0!==c?` Valid values: 0-${c}.`:""),commandType:st.Step,enabled:!!i.onChange}],s=t.current.webMcp,d="object"==typeof s&&null!==s&&"function"==typeof s.tools?s.tools:void 0,p=d?d(l):l,u=async(e,n)=>{if(e===st.Step){const e=n.value,r=t.current;return r.onChange&&r.onChange({value:e}),{content:[{type:"text",text:`Navigated to step ${e}.`}]}}return{content:[{type:"text",text:`Unknown command: ${e}`}],isError:!0}};for(const e of p){if(!e.enabled)continue;const t=dt(e.commandType,c),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>u(n,e||{})}))}catch{}}return o}},ut={Open:"DrawerOpen",Close:"DrawerClose",SelectItem:"DrawerSelectItem"};function mt(e){return e===ut.SelectItem?{type:"object",properties:{text:{type:"string",description:"The text label of the drawer item to select"}},required:["text"]}:{type:"object",properties:{}}}function gt(e,t){const n=e[t];if("function"==typeof n)return n;const r=e.webMcp;return"object"==typeof r&&null!==r&&"function"==typeof r[t]?r[t]:void 0}const ft={componentSuffix:"drawer",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=!!gt(t.current,"onOverlayClick")||!!gt(t.current,"onExpandedChange"),c=[{name:"open",description:`Open the ${n.dataName} navigation drawer.`,commandType:ut.Open,enabled:i},{name:"close",description:`Close the ${n.dataName} navigation drawer.`,commandType:ut.Close,enabled:i},{name:"select_item",description:`Select an item in the ${n.dataName} navigation drawer by its text.`,commandType:ut.SelectItem,enabled:!!t.current.onSelect}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(e,n)=>{const r=t.current;switch(e){case ut.Open:{if(r.expanded)return{content:[{type:"text",text:"Drawer is already open."}]};const e=gt(r,"onExpandedChange")||gt(r,"onOverlayClick");return e&&e({expanded:!0}),{content:[{type:"text",text:"Drawer opened."}]}}case ut.Close:{if(!r.expanded)return{content:[{type:"text",text:"Drawer is already closed."}]};const e=gt(r,"onExpandedChange")||gt(r,"onOverlayClick");return e&&e({expanded:!1}),{content:[{type:"text",text:"Drawer closed."}]}}case ut.SelectItem:{const e=n.text;if(!e)return{content:[{type:"text",text:"Missing required argument: text"}],isError:!0};const t=(r.items||[]).find(t=>t.text===e);return t?(r.onSelect&&r.onSelect({itemTarget:{props:t}}),{content:[{type:"text",text:`Selected "${e}".`}]}):{content:[{type:"text",text:`Item "${e}" not found.`}],isError:!0}}default:return{content:[{type:"text",text:`Unknown command: ${e}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=mt(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},ht={Minimize:"WindowMinimize",Maximize:"WindowMaximize",Restore:"WindowRestore"};function yt(e){return{type:"object",properties:{}}}const xt={componentSuffix:"window",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"minimize",description:`Minimize the ${n.dataName} window`,commandType:ht.Minimize,enabled:!!i.onStageChange},{name:"maximize",description:`Maximize the ${n.dataName} window`,commandType:ht.Maximize,enabled:!!i.onStageChange},{name:"restore",description:`Restore the ${n.dataName} window to its default size`,commandType:ht.Restore,enabled:!!i.onStageChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(e,n)=>{const r=t.current;switch(e){case ht.Minimize:return r.onStageChange&&r.onStageChange({state:"MINIMIZED"}),{content:[{type:"text",text:"Window minimized."}]};case ht.Maximize:return r.onStageChange&&r.onStageChange({state:"MAXIMIZED"}),{content:[{type:"text",text:"Window maximized."}]};case ht.Restore:return r.onStageChange&&r.onStageChange({state:"DEFAULT"}),{content:[{type:"text",text:"Window restored."}]};default:return{content:[{type:"text",text:`Unknown command: ${e}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=yt(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n)}))}catch{}}return o}},Ct={SetValue:"DropDownListSetValue",Open:"DropDownListOpen",Close:"DropDownListClose"};function St(e){return e===Ct.SetValue?{type:"object",properties:{value:{type:"string",description:"The value to select from the available options."}},required:["value"]}:{type:"object",properties:{}}}const bt={componentSuffix:"dropdownlist",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"open",description:`Open the ${n.dataName} dropdown list`,commandType:Ct.Open,enabled:!!i.onOpen},{name:"select",description:`Select an item from the ${n.dataName} dropdown list`,commandType:Ct.SetValue,enabled:!!i.onChange},{name:"close",description:`Close the ${n.dataName} dropdown list`,commandType:Ct.Close,enabled:!!i.onClose}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{switch(n){case Ct.Open:{const n=t.current;return n.onOpen&&n.onOpen({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Dropdown opened."}]}}case Ct.SetValue:{const n=t.current,o=n.data||[],a=n.textField,i=r.value,c=o.find(e=>a&&"object"==typeof e&&null!==e?e[a]===i:e===i);return n.onChange&&n.onChange({value:null!=c?c:i,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Selected "${String(i)}".`}]}}case Ct.Close:{const n=t.current;return n.onClose&&n.onClose({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Dropdown closed."}]}}default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=St(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},vt={SetValue:"ComboBoxSetValue",Clear:"ComboBoxClear",Open:"ComboBoxOpen",Close:"ComboBoxClose"};function Tt(e){return e===vt.SetValue?{type:"object",properties:{value:{type:"string",description:"The value to select from the available options."}},required:["value"]}:{type:"object",properties:{}}}const wt="ComboBoxType",$t={componentSuffix:"combobox",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=!!i.onChange,l=[{name:"open",description:`Open the ${n.dataName} combo box popup`,commandType:vt.Open,enabled:!!i.onOpen},{name:"close",description:`Close the ${n.dataName} combo box popup`,commandType:vt.Close,enabled:!!i.onClose},{name:"type",description:`Type text to filter the ${n.dataName} combo box options`,commandType:wt,enabled:c},{name:"select",description:`Select an item from the ${n.dataName} combo box`,commandType:vt.SetValue,enabled:c},{name:"clear",description:`Clear the ${n.dataName} combo box selection`,commandType:vt.Clear,enabled:c}],s=t.current.webMcp,d="object"==typeof s&&null!==s&&"function"==typeof s.tools?s.tools:void 0,p=d?d(l):l,u=async(n,r)=>{const o=t.current;switch(n){case vt.Open:return o.onOpen&&o.onOpen({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Combo box opened."}]};case wt:return o.onChange&&o.onChange({value:r.text,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Typed "${String(r.text)}".`}]};case vt.SetValue:{const t=o.data||[],n=o.textField,a=r.value,i=t.find(e=>!(!n||"object"!=typeof e||null===e||e[n]!==a)||e===a),c=void 0===i?a:i;return o.onChange&&o.onChange({value:c,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Selected "${String(a)}".`}]}}case vt.Clear:return o.onChange&&o.onChange({value:null,syntheticEvent:null,target:e}),{content:[{type:"text",text:"Selection cleared."}]};case vt.Close:return o.onClose&&o.onClose({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Combo box closed."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of p){if(!e.enabled)continue;const t=e.commandType,n=t===wt?{type:"object",properties:{text:{type:"string",description:"Text to type for filtering"}},required:["text"]}:Tt(t);try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:n,execute:async e=>u(t,e||{})}))}catch{}}return o}},Et={SetValue:"MultiColumnComboBoxSetValue",Clear:"MultiColumnComboBoxClear",Open:"MultiColumnComboBoxOpen",Close:"MultiColumnComboBoxClose"};function Nt(e){return e===Et.SetValue?{type:"object",properties:{value:{type:"string",description:"The value to select from the available options."}},required:["value"]}:{type:"object",properties:{}}}const kt={componentSuffix:"multicolumncombobox",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=!!i.onChange,l=[{name:"open",description:`Open the ${n.dataName} multi-column combo box popup`,commandType:Et.Open,enabled:!!i.onOpen},{name:"close",description:`Close the ${n.dataName} multi-column combo box popup`,commandType:Et.Close,enabled:!!i.onClose},{name:"set_value",description:`Select an item from the ${n.dataName} multi-column combo box`,commandType:Et.SetValue,enabled:c},{name:"clear",description:`Clear the ${n.dataName} multi-column combo box selection`,commandType:Et.Clear,enabled:c}],s=t.current.webMcp,d="object"==typeof s&&null!==s&&"function"==typeof s.tools?s.tools:void 0,p=d?d(l):l,u=async(n,r)=>{const o=t.current;switch(n){case Et.Open:return o.onOpen&&o.onOpen({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Multi-column combo box opened."}]};case Et.SetValue:{const t=o.data||[],n=o.textField,a=r.value,i=t.find(e=>!(!n||"object"!=typeof e||null===e||e[n]!==a)||e===a),c=void 0===i?a:i;return o.onChange&&o.onChange({value:c,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Selected "${String(a)}".`}]}}case Et.Clear:return o.onChange&&o.onChange({value:null,syntheticEvent:null,target:e}),{content:[{type:"text",text:"Selection cleared."}]};case Et.Close:return o.onClose&&o.onClose({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Multi-column combo box closed."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of p){if(!e.enabled)continue;const t=e.commandType,n=Nt(t);try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:n,execute:async e=>u(t,e||{})}))}catch{}}return o}},jt={SetValue:"AutoCompleteSetValue",Clear:"AutoCompleteClear"};function Dt(e){return e===jt.SetValue?{type:"object",properties:{value:{type:"string",description:"The text value to set."}},required:["value"]}:{type:"object",properties:{}}}const Gt="AutoCompleteType",At={componentSuffix:"autocomplete",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=!!t.current.onChange,c=[{name:"type",description:`Type text in the ${n.dataName} autocomplete to trigger suggestions`,commandType:Gt,enabled:i},{name:"select",description:`Select a suggestion from the ${n.dataName} autocomplete`,commandType:jt.SetValue,enabled:i},{name:"clear",description:`Clear the ${n.dataName} autocomplete input`,commandType:jt.Clear,enabled:i}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;switch(n){case Gt:return o.onChange&&o.onChange({value:r.text,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Typed "${String(r.text)}".`}]};case jt.SetValue:return o.onChange&&o.onChange({value:r.value,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Selected "${String(r.value)}".`}]};case jt.Clear:return o.onChange&&o.onChange({value:"",syntheticEvent:null,target:e}),{content:[{type:"text",text:"Input cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=e.commandType,n=t===Gt?{type:"object",properties:{text:{type:"string",description:"Text to type"}},required:["text"]}:Dt(t);try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:n,execute:async e=>p(t,e||{})}))}catch{}}return o}},Vt={AddValue:"MultiSelectAddValue",RemoveValue:"MultiSelectRemoveValue",Clear:"MultiSelectClear",Open:"MultiSelectOpen",Close:"MultiSelectClose"};function Mt(e){switch(e){case Vt.AddValue:return{type:"object",properties:{value:{type:"string",description:"The value to add to the selection."}},required:["value"]};case Vt.RemoveValue:return{type:"object",properties:{value:{type:"string",description:"The value to remove from the selection."}},required:["value"]};default:return{type:"object",properties:{}}}}function It(e){return"object"==typeof e&&null!==e}const qt={componentSuffix:"multiselect",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current;if(!i.onChange)return o;const c=[{name:"add",description:`Add an item to the ${n.dataName} multi-select`,commandType:Vt.AddValue,enabled:!0},{name:"remove",description:`Remove an item from the ${n.dataName} multi-select`,commandType:Vt.RemoveValue,enabled:!0},{name:"clear",description:`Clear all selections from the ${n.dataName} multi-select`,commandType:Vt.Clear,enabled:!0},{name:"open",description:`Open the ${n.dataName} multi-select popup`,commandType:Vt.Open,enabled:!!i.onOpen},{name:"close",description:`Close the ${n.dataName} multi-select popup`,commandType:Vt.Close,enabled:!!i.onClose}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;switch(n){case Vt.AddValue:{const t=o.textField,n=o.dataItemKey,a=o.data||[],i=r.value,c=a.find(e=>!(!It(e)||!(t&&e[t]===i||n&&e[n]===i))||e===i),l=void 0===c?i:c,s=o.value||[];return o.onChange&&o.onChange({value:[...s,l],syntheticEvent:null,target:e}),{content:[{type:"text",text:`Added "${String(i)}".`}]}}case Vt.RemoveValue:{const t=o.textField,n=o.dataItemKey,a=r.value,i=(o.value||[]).filter(e=>(!It(e)||!(t&&e[t]===a||n&&e[n]===a))&&e!==a);return o.onChange&&o.onChange({value:i,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Removed "${String(a)}".`}]}}case Vt.Clear:return o.onChange&&o.onChange({value:[],syntheticEvent:null,target:e}),{content:[{type:"text",text:"All selections cleared."}]};case Vt.Open:return o.onOpen&&o.onOpen({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Multi-select popup opened."}]};case Vt.Close:return o.onClose&&o.onClose({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Multi-select popup closed."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=Mt(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},_t={SetValue:"DropDownTreeSetValue",Clear:"DropDownTreeClear",Open:"DropDownTreeOpen",Close:"DropDownTreeClose"};function Rt(e){return e===_t.SetValue?{type:"object",properties:{value:{type:"string",description:"The value to select from the available options."}},required:["value"]}:{type:"object",properties:{}}}const Ot="DropDownTreeExpand",Pt="DropDownTreeCollapse";function Ft(e,t,n,r){for(const o of e)if("object"==typeof o&&null!==o){const e=o;if(String(e[t])===String(n))return o;const a=e[r];if(Array.isArray(a)){const e=Ft(a,t,n,r);if(e)return e}}}const Ut={componentSuffix:"dropdowntree",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=!!i.onChange,l=[{name:"open",description:`Open the ${n.dataName} dropdown tree`,commandType:_t.Open,enabled:!!i.onOpen},{name:"expand",description:`Expand a node in the ${n.dataName} dropdown tree`,commandType:Ot,enabled:!!i.onExpandChange},{name:"collapse",description:`Collapse a node in the ${n.dataName} dropdown tree`,commandType:Pt,enabled:!!i.onExpandChange},{name:"select",description:`Select a node in the ${n.dataName} dropdown tree`,commandType:_t.SetValue,enabled:c},{name:"clear",description:`Clear the ${n.dataName} dropdown tree selection`,commandType:_t.Clear,enabled:c},{name:"close",description:`Close the ${n.dataName} dropdown tree`,commandType:_t.Close,enabled:!0}],s=t.current.webMcp,d="object"==typeof s&&null!==s&&"function"==typeof s.tools?s.tools:void 0,p=d?d(l):l,u=async(n,r)=>{switch(n){case _t.Open:{const n=t.current;return n.onOpen&&n.onOpen({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Dropdown tree opened."}]}}case Ot:{const n=t.current,o=n.dataItemKey||"id",a=n.subItemsField||"items",i=Ft(n.data||[],o,r.id,a);return n.onExpandChange&&i&&n.onExpandChange({item:i,expanded:!0,syntheticEvent:null,target:e}),{content:[{type:"text",text:i?"Node expanded.":`Node with id "${String(r.id)}" not found.`}]}}case Pt:{const n=t.current,o=n.dataItemKey||"id",a=n.subItemsField||"items",i=Ft(n.data||[],o,r.id,a);return n.onExpandChange&&i&&n.onExpandChange({item:i,expanded:!1,syntheticEvent:null,target:e}),{content:[{type:"text",text:i?"Node collapsed.":`Node with id "${String(r.id)}" not found.`}]}}case _t.SetValue:{const n=t.current,o=n.dataItemKey||"id",a=n.textField||"text",i=n.subItemsField||"items",c=n.data||[],l=Ft(c,o,r.value,i)||Ft(c,a,r.value,i);return n.onChange&&n.onChange({value:l||r.value,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Selected "${String(r.value)}".`}]}}case _t.Close:{const n=t.current;return n.onClose&&n.onClose({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Dropdown tree closed."}]}}case _t.Clear:{const n=t.current;return n.onChange&&n.onChange({value:null,syntheticEvent:null,target:e}),{content:[{type:"text",text:"Selection cleared."}]}}default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of p){if(!e.enabled)continue;const t=e.commandType,n=t===Ot||t===Pt?{type:"object",properties:{id:{type:"string",description:"The data item key of the node to expand/collapse"}},required:["id"]}:Rt(t);try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:n,execute:async e=>u(t,e||{})}))}catch{}}return o}},zt={SetValue:"DatePickerSetValue",Clear:"DatePickerClear"};function Lt(e){return e===zt.SetValue?{type:"object",properties:{value:{type:"string",description:'The date value in ISO 8601 format (e.g. "2026-04-23").'}},required:["value"]}:{type:"object",properties:{}}}const Bt={componentSuffix:"datepicker",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the date in the ${n.dataName} date picker. Use ISO 8601 format (YYYY-MM-DD).`,commandType:zt.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear the ${n.dataName} date picker.`,commandType:zt.Clear,enabled:!!i.onChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;switch(n){case zt.SetValue:{const t=new Date(r.value);return o.onChange&&o.onChange({value:t,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Date set to ${t.toISOString().slice(0,10)}.`}]}}case zt.Clear:return o.onChange&&o.onChange({value:null,syntheticEvent:null,target:e}),{content:[{type:"text",text:"Date cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=Lt(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},Ht={SetValue:"DateRangePickerSetValue",Clear:"DateRangePickerClear"};function Wt(e){return e===Ht.SetValue?{type:"object",properties:{startValue:{type:"string",description:'The start date in ISO 8601 format (e.g. "2026-04-01").'},endValue:{type:"string",description:'The end date in ISO 8601 format (e.g. "2026-04-30").'}},required:["startValue","endValue"]}:{type:"object",properties:{}}}const Jt={componentSuffix:"daterangepicker",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the date range in the ${n.dataName} date range picker. Use ISO 8601 format.`,commandType:Ht.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear the ${n.dataName} date range picker.`,commandType:Ht.Clear,enabled:!!i.onChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;switch(n){case Ht.SetValue:{const t=new Date(r.startValue),n=new Date(r.endValue);return o.onChange&&o.onChange({value:{start:t,end:n},syntheticEvent:null,target:e}),{content:[{type:"text",text:`Range set: ${t.toISOString().slice(0,10)} to ${n.toISOString().slice(0,10)}.`}]}}case Ht.Clear:return o.onChange&&o.onChange({value:{start:null,end:null},syntheticEvent:null,target:e}),{content:[{type:"text",text:"Date range cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=Wt(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},Kt={SetValue:"TimePickerSetValue",Clear:"TimePickerClear"};function Zt(e){return e===Kt.SetValue?{type:"object",properties:{value:{type:"string",description:'The time value in ISO 8601 format (e.g. "14:30:00").'}},required:["value"]}:{type:"object",properties:{}}}const Yt={componentSuffix:"timepicker",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the time in the ${n.dataName} time picker. Use HH:mm or ISO format.`,commandType:Kt.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear the ${n.dataName} time picker.`,commandType:Kt.Clear,enabled:!!i.onChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;switch(n){case Kt.SetValue:{const t=r.value,n=new Date(t.includes("T")?t:"1970-01-01T"+t);return o.onChange&&o.onChange({value:n,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Time set to ${t}.`}]}}case Kt.Clear:return o.onChange&&o.onChange({value:null,syntheticEvent:null,target:e}),{content:[{type:"text",text:"Time cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=Zt(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},Xt={SetValue:"DateTimePickerSetValue",Clear:"DateTimePickerClear"};function Qt(e){return e===Xt.SetValue?{type:"object",properties:{value:{type:"string",description:'The date and time value in ISO 8601 format (e.g. "2026-04-23T14:30:00").'}},required:["value"]}:{type:"object",properties:{}}}const en={componentSuffix:"datetimepicker",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the date and time in the ${n.dataName} date-time picker. Use ISO 8601 format.`,commandType:Xt.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear the ${n.dataName} date-time picker.`,commandType:Xt.Clear,enabled:!!i.onChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;switch(n){case Xt.SetValue:{const t=new Date(r.value);return o.onChange&&o.onChange({value:t,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Date-time set to ${t.toISOString()}.`}]}}case Xt.Clear:return o.onChange&&o.onChange({value:null,syntheticEvent:null,target:e}),{content:[{type:"text",text:"Date-time cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=Qt(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},tn={Navigate:"CalendarNavigate",SelectDate:"CalendarSelectDate"};function nn(e){switch(e){case tn.Navigate:return{type:"object",properties:{date:{type:"string",description:'The date to navigate to (ISO 8601 format, e.g. "2026-05-15")'}},required:["date"]};case tn.SelectDate:return{type:"object",properties:{date:{type:"string",description:'The date to select (ISO 8601 format, e.g. "2026-05-15")'}},required:["date"]};default:return{type:"object",properties:{}}}}const rn={componentSuffix:"calendar",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"navigate",description:`Navigate the ${n.dataName} calendar to a specific month/year`,commandType:tn.Navigate,enabled:!!i.onChange},{name:"select_date",description:`Select a date on the ${n.dataName} calendar`,commandType:tn.SelectDate,enabled:!!i.onChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;switch(n){case tn.Navigate:{const t=new Date(r.date);return o.onChange&&o.onChange({value:t,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Navigated to ${t.toISOString().slice(0,10)}.`}]}}case tn.SelectDate:{const t=new Date(r.date);return o.onChange&&o.onChange({value:t,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Selected ${t.toISOString().slice(0,10)}.`}]}}default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=nn(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},on={SetValue:"NumericTextBoxSetValue",Clear:"NumericTextBoxClear",Increment:"NumericTextBoxIncrement",Decrement:"NumericTextBoxDecrement"};function an(e){return e===on.SetValue?{type:"object",properties:{value:{type:"number",description:"The numeric value to set."}},required:["value"]}:{type:"object",properties:{}}}const cn={componentSuffix:"numerictextbox",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the value of the ${n.dataName} numeric input`,commandType:on.SetValue,enabled:!!i.onChange},{name:"increment",description:`Increment the ${n.dataName} numeric input by one step`,commandType:on.Increment,enabled:!!i.onChange},{name:"decrement",description:`Decrement the ${n.dataName} numeric input by one step`,commandType:on.Decrement,enabled:!!i.onChange},{name:"clear",description:`Clear the ${n.dataName} numeric input`,commandType:on.Clear,enabled:!!i.onChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{var o,a,i,c;const l=t.current;switch(n){case on.SetValue:return l.onChange&&l.onChange({value:r.value,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Value set to ${String(r.value)}.`}]};case on.Increment:{const t=(null!=(o=l.value)?o:0)+(null!=(a=l.step)?a:1);return l.onChange&&l.onChange({value:t,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Incremented to ${t}.`}]}}case on.Decrement:{const t=(null!=(i=l.value)?i:0)-(null!=(c=l.step)?c:1);return l.onChange&&l.onChange({value:t,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Decremented to ${t}.`}]}}case on.Clear:return l.onChange&&l.onChange({value:null,syntheticEvent:null,target:e}),{content:[{type:"text",text:"Value cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=an(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},ln={SetValue:"SliderSetValue"};function sn(e){return{type:"object",properties:{value:{type:"number",description:"The numeric value to set."}},required:["value"]}}const dn={componentSuffix:"slider",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=void 0!==i.min&&void 0!==i.max?` Range: ${i.min}-${i.max}.`:"",l=[{name:"set_value",description:`Set the ${n.dataName} slider to a specific value.${c}`,commandType:ln.SetValue,enabled:!!i.onChange}],s=i.webMcp,d="object"==typeof s&&null!==s&&"function"==typeof s.tools?s.tools:void 0,p=d?d(l):l,u=async(n,r)=>{if(n===ln.SetValue){const n=t.current;return n.onChange&&n.onChange({value:r.value,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Slider set to ${String(r.value)}.`}]}}return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of p){if(!e.enabled)continue;const t=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:sn(),execute:async e=>u(t,e||{})}))}catch{}}return o}},pn={SetValue:"RangeSliderSetValue"};function un(e){return{type:"object",properties:{startValue:{type:"number",description:"The start value of the range."},endValue:{type:"number",description:"The end value of the range."}},required:["startValue","endValue"]}}const mn={componentSuffix:"rangeslider",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the ${n.dataName} range slider values.`,commandType:pn.SetValue,enabled:!!i.onChange}],l=i.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{if(n===pn.SetValue){const n=t.current;return n.onChange&&n.onChange({value:{start:r.startValue,end:r.endValue},syntheticEvent:null,target:e}),{content:[{type:"text",text:`Range set to ${String(r.startValue)}-${String(r.endValue)}.`}]}}return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of d){if(!e.enabled)continue;const t=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:un(),execute:async e=>p(t,e||{})}))}catch{}}return o}},gn={Toggle:"CheckBoxToggle",SetValue:"CheckBoxSetValue"};function fn(e){switch(e){case gn.Toggle:return{type:"object",properties:{}};case gn.SetValue:return{type:"object",properties:{value:{type:"boolean",description:"The boolean value to set (true or false)."}},required:["value"]};default:return{type:"object",properties:{}}}}const hn={componentSuffix:"checkbox",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"toggle",description:`Toggle the ${n.dataName} checkbox.`,commandType:gn.Toggle,enabled:!!i.onChange},{name:"set_value",description:`Set the ${n.dataName} checkbox to a specific checked or unchecked state.`,commandType:gn.SetValue,enabled:!!i.onChange}],l=i.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{var o,a;if(n===gn.Toggle){const n=t.current,r=null!=(a=null!=(o=n.checked)?o:n.value)&&a;return n.onChange&&n.onChange({value:!r,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Checkbox toggled to ${r?"unchecked":"checked"}.`}]}}if(n===gn.SetValue){const n=t.current,o=!!r.value;return n.onChange&&n.onChange({value:o,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Checkbox set to ${o?"checked":"unchecked"}.`}]}}return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of d){if(!e.enabled)continue;const t=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:fn(t),execute:async e=>p(t,e||{})}))}catch{}}return o}},yn={SetValue:"ColorPickerSetValue",Clear:"ColorPickerClear"};function xn(e){return e===yn.SetValue?{type:"object",properties:{value:{type:"string",description:'The color value as a hex string (e.g. "#ff6358") or named CSS color.'}},required:["value"]}:{type:"object",properties:{}}}const Cn={componentSuffix:"colorpicker",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the color in the ${n.dataName} color picker. Use hex format (e.g. #ff0000).`,commandType:yn.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear the ${n.dataName} color picker.`,commandType:yn.Clear,enabled:!!i.onChange}],l=i.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{switch(n){case yn.SetValue:{const n=t.current;return n.onChange&&n.onChange({value:r.value,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Color set to ${String(r.value)}.`}]}}case yn.Clear:{const n=t.current;return n.onChange&&n.onChange({value:"",syntheticEvent:null,target:e}),{content:[{type:"text",text:"Color cleared."}]}}default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:xn(t),execute:async e=>p(t,e||{})}))}catch{}}return o}},Sn={Toggle:"SwitchToggle",SetValue:"SwitchSetValue"};function bn(e){switch(e){case Sn.Toggle:return{type:"object",properties:{}};case Sn.SetValue:return{type:"object",properties:{value:{type:"boolean",description:"The boolean value to set (true or false)."}},required:["value"]};default:return{type:"object",properties:{}}}}const vn={componentSuffix:"switch",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"toggle",description:`Toggle the ${n.dataName} switch on or off.`,commandType:Sn.Toggle,enabled:!!i.onChange},{name:"set_value",description:`Set the ${n.dataName} switch to a specific on or off state.`,commandType:Sn.SetValue,enabled:!!i.onChange}],l=i.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{var o,a;if(n===Sn.Toggle){const n=t.current,r=null!=(a=null!=(o=n.checked)?o:n.value)&&a;return n.onChange&&n.onChange({value:!r,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Switch toggled to ${r?"off":"on"}.`}]}}if(n===Sn.SetValue){const n=t.current,o=!!r.value;return n.onChange&&n.onChange({value:o,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Switch set to ${o?"on":"off"}.`}]}}return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of d){if(!e.enabled)continue;const t=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:bn(t),execute:async e=>p(t,e||{})}))}catch{}}return o}},Tn={SetValue:"RatingSetValue",Clear:"RatingClear"};function wn(e){return e===Tn.SetValue?{type:"object",properties:{value:{type:"number",description:"The numeric value to set."}},required:["value"]}:{type:"object",properties:{}}}const $n={componentSuffix:"rating",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the ${n.dataName} rating to a specific value.`,commandType:Tn.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear the ${n.dataName} rating.`,commandType:Tn.Clear,enabled:!!i.onChange}],l=i.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{switch(n){case Tn.SetValue:{const n=t.current;return n.onChange&&n.onChange({value:r.value,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Rating set to ${String(r.value)}.`}]}}case Tn.Clear:{const n=t.current;return n.onChange&&n.onChange({value:null,syntheticEvent:null,target:e}),{content:[{type:"text",text:"Rating cleared."}]}}default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:wn(t),execute:async e=>p(t,e||{})}))}catch{}}return o}},En={SetValue:"TextAreaSetValue",Clear:"TextAreaClear"};function Nn(e){return e===En.SetValue?{type:"object",properties:{value:{type:"string",description:"The text value to set."}},required:["value"]}:{type:"object",properties:{}}}const kn={componentSuffix:"textarea",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set text in the ${n.dataName} text area.`,commandType:En.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear the ${n.dataName} text area.`,commandType:En.Clear,enabled:!!i.onChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;switch(n){case En.SetValue:return o.onChange&&o.onChange({value:r.value,syntheticEvent:null,target:e}),{content:[{type:"text",text:"Value set."}]};case En.Clear:return o.onChange&&o.onChange({value:"",syntheticEvent:null,target:e}),{content:[{type:"text",text:"Text area cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=Nn(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},jn={SetValue:"MaskedTextBoxSetValue",Clear:"MaskedTextBoxClear"};function Dn(e){return e===jn.SetValue?{type:"object",properties:{value:{type:"string",description:"The text value to set."}},required:["value"]}:{type:"object",properties:{}}}const Gn={componentSuffix:"maskedtextbox",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=i.mask?` Mask: ${i.mask}`:"",l=[{name:"set_value",description:`Enter a value in the ${n.dataName} masked input.${c}`,commandType:jn.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear the ${n.dataName} masked input.`,commandType:jn.Clear,enabled:!!i.onChange}],s=t.current.webMcp,d="object"==typeof s&&null!==s&&"function"==typeof s.tools?s.tools:void 0,p=d?d(l):l,u=async(n,r)=>{const o=t.current;switch(n){case jn.SetValue:return o.onChange&&o.onChange({value:r.value,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Value set to "${String(r.value)}".`}]};case jn.Clear:return o.onChange&&o.onChange({value:"",syntheticEvent:null,target:e}),{content:[{type:"text",text:"Masked input cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of p){if(!e.enabled)continue;const t=Dn(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>u(n,e||{})}))}catch{}}return o}},An={Clear:"SignatureClear"};function Vn(e){return{type:"object",properties:{}}}const Mn={componentSuffix:"signature",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=[{name:"clear",description:`Clear the ${n.dataName} signature pad`,commandType:An.Clear,enabled:!!t.current.onChange}],c=t.current.webMcp,l="object"==typeof c&&null!==c&&"function"==typeof c.tools?c.tools:void 0,s=l?l(i):i,d=async(n,r)=>{if(n===An.Clear){const n=t.current;return n.onChange&&n.onChange({value:"",syntheticEvent:null,target:e}),{content:[{type:"text",text:"Signature cleared."}]}}return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of s){if(!e.enabled)continue;const t=Vn(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>d(n)}))}catch{}}return o}},In={Clear:"UploadClear"};function qn(e){return{type:"object",properties:{}}}const _n={componentSuffix:"upload",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"clear",description:`Clear all files from the ${n.dataName} upload`,commandType:In.Clear,enabled:!!i.onRemove}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{if(n===In.Clear){const n=t.current;return n.onRemove&&n.onRemove({newState:[],affectedFiles:[],syntheticEvent:null,target:e}),{content:[{type:"text",text:"Upload files cleared."}]}}return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of d){if(!e.enabled)continue;const t=qn(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n)}))}catch{}}return o}},Rn={Transfer:"ListBoxTransfer",Reorder:"ListBoxReorder"};function On(e){switch(e){case Rn.Transfer:return{type:"object",properties:{direction:{type:"string",description:'The transfer direction: "to" (items to connected list box), "from" (items from connected list box), "allTo" (all items to connected list box), or "allFrom" (all items from connected list box)',enum:["to","from","allTo","allFrom"]},items:{type:"array",items:{type:"string"},description:'The names of the items to transfer. Required for "to" and "from" directions. Not needed for "allTo" and "allFrom".'}},required:["direction"]};case Rn.Reorder:return{type:"object",properties:{direction:{type:"string",description:'The direction to move the item: "up" or "down"',enum:["up","down"]},items:{type:"array",items:{type:"string"},description:"The names of the items to reorder. If not provided, operates on the currently selected items."}},required:["direction"]};default:return{type:"object",properties:{}}}}function Pn(e){if(e.onToolBarClick)return e.onToolBarClick;const t=e.webMcp;return"object"==typeof t&&null!==t&&"function"==typeof t.onToolBarClick?t.onToolBarClick:void 0}const Fn={componentSuffix:"listbox",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=!!Pn(t.current),c=[{name:"transfer",description:`Transfer items between the ${n.dataName} list boxes`,commandType:Rn.Transfer,enabled:i},{name:"reorder",description:`Reorder an item in the ${n.dataName} list box`,commandType:Rn.Reorder,enabled:i}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{switch(n){case Rn.Transfer:return function(e,t,n){const r=Pn(t.current),o={to:"transferTo",from:"transferFrom",allTo:"transferAllTo",allFrom:"transferAllFrom"}[e.direction]||e.direction;return r&&r({toolName:o,syntheticEvent:null,target:n}),{content:[{type:"text",text:`Transfer action "${String(e.direction)}" executed.`}]}}(r,t,e);case Rn.Reorder:return function(e,t,n){const r=Pn(t.current),o={up:"moveUp",down:"moveDown"}[e.direction]||e.direction;return r&&r({toolName:o,syntheticEvent:null,target:n}),{content:[{type:"text",text:`Reorder "${String(e.direction)}" executed.`}]}}(r,t,e);default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=On(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},Un={Page:"ListViewPage"};function zn(e){return e===Un.Page?{type:"object",properties:{page:{type:"number",description:"The 1-based page number to navigate to"}},required:["page"]}:{type:"object",properties:{}}}function Ln(e,t){const n=e[t];if("function"==typeof n)return n;const r=e.webMcp;return"object"==typeof r&&null!==r&&"function"==typeof r[t]?r[t]:void 0}function Bn(e,t){const n=e.webMcp;if("object"==typeof n&&null!==n)return n[t]}const Hn={componentSuffix:"listview",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"page",description:`Navigate to a specific page in the ${n.dataName} list view`,commandType:Un.Page,enabled:!!Ln(i,"onPageChange")},{name:"select",description:`Select an item in the ${n.dataName} list view`,commandType:"ListViewSelect",enabled:!!Ln(i,"onSelectionChange")}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;switch(n){case Un.Page:{const t=Number(r.page);if(!t||t<1)return{content:[{type:"text",text:"Invalid page number."}],isError:!0};const n=Bn(o,"take")||o.take||10,a=(t-1)*n,i=Ln(o,"onPageChange");return i&&i({page:{skip:a,take:n},syntheticEvent:null,target:e}),{content:[{type:"text",text:`Navigated to page ${t}.`}]}}case"ListViewSelect":{const t=Bn(o,"dataItemKey")||o.dataItemKey||"id",n=(o.data||[]).find(e=>function(e){return"object"==typeof e&&null!==e}(e)&&String(e[t])===String(r.id)),a=Ln(o,"onSelectionChange");return n?(a&&a({dataItem:n,target:e}),{content:[{type:"text",text:"Item selected."}]}):(a&&a({dataItem:{[t]:r.id},target:e}),{content:[{type:"text",text:`Selected item ${t}=${String(r.id)}.`}]})}default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=zn(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},Wn={Confirm:"DialogConfirm",Cancel:"DialogCancel"};function Jn(e){return{type:"object",properties:{}}}const Kn={componentSuffix:"dialog",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"confirm",description:`Click the confirm/OK button on the ${n.dataName} dialog`,commandType:Wn.Confirm,enabled:!0},{name:"cancel",description:`Click the cancel button on the ${n.dataName} dialog`,commandType:Wn.Cancel,enabled:!!i.onClose}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(e,n)=>{switch(e){case Wn.Confirm:return{content:[{type:"text",text:"Confirm action triggered."}]};case Wn.Cancel:{const e=t.current;return e.onClose&&e.onClose({}),{content:[{type:"text",text:"Dialog cancelled."}]}}default:return{content:[{type:"text",text:`Unknown command: ${e}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=Jn(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n)}))}catch{}}return o}},Zn={SelectItem:"MenuSelectItem"};function Yn(e){return e===Zn.SelectItem?{type:"object",properties:{text:{type:"string",description:"The text of the menu item to select"}},required:["text"]}:{type:"object",properties:{}}}const Xn={componentSuffix:"menu",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"select_item",description:`Select an item from the ${n.dataName} menu`,commandType:Zn.SelectItem,enabled:!!i.onSelect}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;if(n===Zn.SelectItem){if(!r.text||"string"!=typeof r.text)return{content:[{type:"text",text:"Missing required argument: text"}],isError:!0};const t=r.text;return o.onSelect&&o.onSelect({item:{text:t},syntheticEvent:null,target:e}),{content:[{type:"text",text:`Selected "${t}".`}]}}return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of d){if(!e.enabled)continue;const t=Yn(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},Qn={Next:"ScrollViewNext",Previous:"ScrollViewPrevious",Navigate:"ScrollViewNavigate"};function er(e){return e===Qn.Navigate?{type:"object",properties:{index:{type:"number",description:"Zero-based slide index to navigate to"}},required:["index"]}:{type:"object",properties:{}}}function tr(e,t){var n;const r=null==(n=null==e?void 0:e.element)?void 0:n.querySelector(t);return!!r&&(r.click(),!0)}const nr={componentSuffix:"scrollview",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=[{name:"next",description:`Go to the next slide in the ${n.dataName} carousel.`,commandType:Qn.Next,enabled:!0},{name:"previous",description:`Go to the previous slide in the ${n.dataName} carousel.`,commandType:Qn.Previous,enabled:!0},{name:"navigate",description:`Jump to a specific slide in the ${n.dataName} carousel.`,commandType:Qn.Navigate,enabled:!0}],c=t.current.webMcp,l="object"==typeof c&&null!==c&&"function"==typeof c.tools?c.tools:void 0,s=l?l(i):i,d=async(t,n)=>{var r;const o=e;switch(t){case Qn.Next:return tr(o,".k-scrollview-next")?{content:[{type:"text",text:"Moved to next slide."}]}:{content:[{type:"text",text:"Already on the last slide."}],isError:!0};case Qn.Previous:return tr(o,".k-scrollview-prev")?{content:[{type:"text",text:"Moved to previous slide."}]}:{content:[{type:"text",text:"Already on the first slide."}],isError:!0};case Qn.Navigate:{const e=Number(n.index),t=null==(r=null==o?void 0:o.element)?void 0:r.querySelectorAll(".k-scrollview-nav .k-link");return t&&e>=0&&e<t.length?(t[e].click(),{content:[{type:"text",text:`Jumped to slide ${e+1}.`}]}):{content:[{type:"text",text:`Invalid slide index: ${e}`}],isError:!0}}default:return{content:[{type:"text",text:`Unknown command: ${t}`}],isError:!0}}};for(const e of s){if(!e.enabled)continue;const t=er(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>d(n,e||{})}))}catch{}}return o}},rr={Reorder:"SortableReorder"};function or(e){return e===rr.Reorder?{type:"object",properties:{oldIndex:{type:"number",description:"Current zero-based index of the item"},newIndex:{type:"number",description:"Target zero-based index to move the item to"}},required:["oldIndex","newIndex"]}:{type:"object",properties:{}}}const ar={componentSuffix:"sortable",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=!!i.onDragOver||!!i.onNavigate,l=[{name:"reorder",description:`Move an item to a new position in the ${n.dataName} sortable list`,commandType:rr.Reorder,enabled:c}],s=t.current.webMcp,d="object"==typeof s&&null!==s&&"function"==typeof s.tools?s.tools:void 0,p=d?d(l):l,u=async(n,r)=>{const o=t.current;if(n===rr.Reorder){const t=Number(r.oldIndex),n=Number(r.newIndex),a=o.data?[...o.data]:[],[i]=a.splice(t,1);return void 0!==i&&a.splice(n,0,i),o.onNavigate?o.onNavigate({oldIndex:t,newIndex:n,newState:a,syntheticEvent:null,target:e}):o.onDragOver&&o.onDragOver({oldIndex:t,newIndex:n,newState:a,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Moved item from position ${String(r.oldIndex)} to ${String(r.newIndex)}.`}]}}return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of p){if(!e.enabled)continue;const t=or(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>u(n,e||{})}))}catch{}}return o}},ir={SetCenter:"MapSetCenter",SetZoom:"MapSetZoom",AddMarker:"MapAddMarker",ClearMarkers:"MapClearMarkers"};function cr(e){switch(e){case ir.SetCenter:return{type:"object",properties:{lat:{type:"number",description:"Latitude"},lng:{type:"number",description:"Longitude"}},required:["lat","lng"]};case ir.SetZoom:return{type:"object",properties:{zoom:{type:"number",description:"Zoom level"}},required:["zoom"]};case ir.AddMarker:return{type:"object",properties:{lat:{type:"number",description:"Marker latitude"},lng:{type:"number",description:"Marker longitude"},title:{type:"string",description:"Marker tooltip text (optional)"}},required:["lat","lng"]};default:return{type:"object",properties:{}}}}const lr={componentSuffix:"map",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=[{name:"set_center",description:`Set the map center of the ${n.dataName} map`,commandType:ir.SetCenter,enabled:!0},{name:"set_zoom",description:`Set the zoom level of the ${n.dataName} map`,commandType:ir.SetZoom,enabled:!0},{name:"add_marker",description:`Add a marker to the ${n.dataName} map at a given coordinate`,commandType:ir.AddMarker,enabled:!0},{name:"clear_markers",description:`Remove all markers from the ${n.dataName} map`,commandType:ir.ClearMarkers,enabled:!0}],c=t.current.webMcp,l="object"==typeof c&&null!==c&&"function"==typeof c.tools?c.tools:void 0,s=l?l(i):i,d=[],p=async(t,n)=>{var r,o,a,i,c,l;switch(t){case ir.SetCenter:{const t=null==e?void 0:e.mapInstance;return t&&t.center([Number(n.lat),Number(n.lng)]),{content:[{type:"text",text:`Map centered on [${String(n.lat)}, ${String(n.lng)}].`}]}}case ir.SetZoom:{const t=null==e?void 0:e.mapInstance;return t&&t.zoom(Number(n.zoom)),{content:[{type:"text",text:`Zoom set to ${String(n.zoom)}.`}]}}case ir.AddMarker:{const t=e,s=(null==(a=null==(o=null==(r=null==t?void 0:t.mapInstance)?void 0:r.markers)?void 0:o.options)?void 0:a.locationField)||"location",p=(null==(l=null==(c=null==(i=null==t?void 0:t.mapInstance)?void 0:i.markers)?void 0:c.options)?void 0:l.titleField)||"title",u={[s]:[Number(n.lat),Number(n.lng)]};return"string"==typeof n.title&&(u[p]=n.title),d.push(u),"function"==typeof(null==t?void 0:t.loadMarkers)&&t.loadMarkers(d),{content:[{type:"text",text:`Marker added at [${String(n.lat)}, ${String(n.lng)}].`}]}}case ir.ClearMarkers:{d.length=0;const t=e;return"function"==typeof(null==t?void 0:t.loadMarkers)&&t.loadMarkers([]),{content:[{type:"text",text:"All markers cleared."}]}}default:return{content:[{type:"text",text:`Unknown command: ${t}`}],isError:!0}}};for(const e of s){if(!e.enabled)continue;const t=cr(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},sr={Show:"NotificationShow",Dismiss:"NotificationDismiss"};function dr(e){return e===sr.Show?{type:"object",properties:{message:{type:"string",description:"Notification message text"},type:{type:"string",description:"Notification type: none, success, error, warning, info"}},required:["message"]}:{type:"object",properties:{}}}const pr={componentSuffix:"notification",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=[{name:"show",description:`Show a notification in the ${n.dataName} notification group.`,commandType:sr.Show,enabled:!0},{name:"dismiss",description:`Dismiss all notifications in the ${n.dataName} notification group.`,commandType:sr.Dismiss,enabled:!0}],c=t.current.webMcp,l="object"==typeof c&&null!==c&&"function"==typeof c.tools?c.tools:void 0,s=l?l(i):i,d=async(n,r)=>{var o,a;switch(n){case sr.Show:return{content:[{type:"text",text:`Notification shown: "${String(r.message)}".`}]};case sr.Dismiss:return null==(a=(o=t.current).onClose)||a.call(o,{syntheticEvent:null,target:e}),{content:[{type:"text",text:"Notification dismissed."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of s){if(!e.enabled)continue;const t=dr(e.commandType),n=e.commandType,i=e.execute;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:i?async e=>await i(e):async e=>d(n,e||{})}))}catch{}}return o}},ur={Drilldown:"ChartDrilldown",Export:"ChartExport"};function mr(e){return e===ur.Drilldown?{type:"object",properties:{category:{type:"string",description:"Category value to drill into"},seriesName:{type:"string",description:"Name of the series to drill down from"}},required:["category"]}:{type:"object",properties:{}}}const gr={componentSuffix:"chart",createTools(e,t,n,r){var o;const a=[],i=e=>`${n.groupName}_${e}`,c=t.current,l=[{name:"drilldown",description:`Drill down into the selected chart series or category of the ${n.dataName} chart`,commandType:ur.Drilldown,enabled:!!c.onDrilldown},{name:"export",description:`Export the ${n.dataName} chart as an image`,commandType:ur.Export,enabled:!(null==(o=null==e?void 0:e.chartInstance)||!o.exportVisual)}],s=t.current.webMcp,d="object"==typeof s&&null!==s&&"function"==typeof s.tools?s.tools:void 0,p=d?d(l,{tname:i}):l,u=async(n,r)=>{switch(n){case ur.Drilldown:return function(e,t,n){var r,o,a,i,c;const l={steps:[...null!=(o=null==(r=t.current.drilldownState)?void 0:r.steps)?o:[],{seriesName:"string"==typeof e.seriesName?e.seriesName:"",drilldownValue:e.category}]};return null==(c=(i=t.current).onDrilldown)||c.call(i,{nextState:l,currentState:null!=(a=t.current.drilldownState)?a:{steps:[]},value:e.category,target:n}),{content:[{type:"text",text:`Drilled down into category "${String(e.category)}".`}]}}(r,t,e);case ur.Export:return async function(e,t){var n,r;const o=null==(r=null==(n=null==t?void 0:t.chartInstance)?void 0:n.exportVisual)?void 0:r.call(n,{});if(!o)return{content:[{type:"text",text:"Chart visual not available for export."}],isError:!0};try{const{exportImage:e}=await import("@progress/kendo-drawing"),{saveAs:t}=await import("@progress/kendo-file-saver");return t(await e(o),"chart.png"),{content:[{type:"text",text:"Chart exported as chart.png."}]}}catch{return{content:[{type:"text",text:"Export failed — @progress/kendo-drawing or @progress/kendo-file-saver not available."}],isError:!0}}}(0,e);default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of p){if(!e.enabled)continue;const t=mr(e.commandType),n=e.commandType;try{a.push(r.registerTool({name:i(e.name),description:e.description,inputSchema:t,execute:async e=>u(n,e||{})}))}catch{}}return a}},fr={AddCard:"TaskBoardAddCard",MoveCard:"TaskBoardMoveCard",EditCard:"TaskBoardEditCard",DeleteCard:"TaskBoardDeleteCard"};function hr(e){switch(e){case fr.AddCard:return{type:"object",properties:{title:{type:"string",description:"Card title"},status:{type:"string",description:"Target column/status identifier"},description:{type:"string",description:"Card description (optional)"}},required:["title","status"]};case fr.MoveCard:return{type:"object",properties:{cardId:{type:"string",description:"Identifier of the card to move"},targetStatus:{type:"string",description:"Target column/status identifier"}},required:["cardId","targetStatus"]};case fr.EditCard:return{type:"object",properties:{cardId:{type:"string",description:"Identifier of the card to edit"},title:{type:"string",description:"New card title (optional)"},description:{type:"string",description:"New card description (optional)"}},required:["cardId"]};case fr.DeleteCard:return{type:"object",properties:{cardId:{type:"string",description:"Identifier of the card to delete"}},required:["cardId"]};default:return{type:"object",properties:{}}}}const yr={componentSuffix:"taskboard",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"add_card",description:`Add a new card to a column in the ${n.dataName} task board`,commandType:fr.AddCard,enabled:!!i.onCardAdd},{name:"move_card",description:`Move a card to a different column in the ${n.dataName} task board`,commandType:fr.MoveCard,enabled:!!i.onCardMove},{name:"edit_card",description:`Edit a card's details in the ${n.dataName} task board`,commandType:fr.EditCard,enabled:!!i.onCardChange},{name:"delete_card",description:`Delete a card from the ${n.dataName} task board`,commandType:fr.DeleteCard,enabled:!!i.onCardRemove}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{var o,a,i,c,l,s,d,p;switch(n){case fr.AddCard:return null==(a=(o=t.current).onCardAdd)||a.call(o,{item:{title:r.title,status:r.status,description:r.description},syntheticEvent:null,target:e}),{content:[{type:"text",text:`Card "${String(r.title)}" added to column "${String(r.status)}".`}]};case fr.MoveCard:return null==(c=(i=t.current).onCardMove)||c.call(i,{item:{id:r.cardId},status:r.targetStatus,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Card "${String(r.cardId)}" moved to "${String(r.targetStatus)}".`}]};case fr.EditCard:return null==(s=(l=t.current).onCardChange)||s.call(l,{item:{id:r.cardId,title:r.title,description:r.description},syntheticEvent:null,target:e}),{content:[{type:"text",text:`Card "${String(r.cardId)}" updated.`}]};case fr.DeleteCard:return null==(p=(d=t.current).onCardRemove)||p.call(d,{item:{id:r.cardId},syntheticEvent:null,target:e}),{content:[{type:"text",text:`Card "${String(r.cardId)}" deleted.`}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=hr(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},xr={SetRows:"PivotSetRows",SetColumns:"PivotSetColumns",SetMeasures:"PivotSetMeasures",Expand:"PivotExpand",Collapse:"PivotCollapse"};function Cr(e){switch(e){case xr.SetRows:case xr.SetColumns:case xr.SetMeasures:return{type:"object",properties:{fields:{type:"array",items:{type:"string"},description:"Array of field names"}},required:["fields"]};case xr.Expand:case xr.Collapse:return{type:"object",properties:{field:{type:"string",description:"Field name of the header"},value:{type:"string",description:"Value of the header"}},required:["field","value"]};default:return{type:"object",properties:{}}}}const Sr={componentSuffix:"pivotgrid",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=[{name:"set_rows",description:`Set the row fields of the ${n.dataName} pivot grid`,commandType:xr.SetRows,enabled:!0},{name:"set_columns",description:`Set the column fields of the ${n.dataName} pivot grid`,commandType:xr.SetColumns,enabled:!0},{name:"set_measures",description:`Set the measure fields of the ${n.dataName} pivot grid`,commandType:xr.SetMeasures,enabled:!0},{name:"expand",description:`Expand a row or column header in the ${n.dataName} pivot grid`,commandType:xr.Expand,enabled:!0},{name:"collapse",description:`Collapse a row or column header in the ${n.dataName} pivot grid`,commandType:xr.Collapse,enabled:!0}],c=t.current.webMcp,l="object"==typeof c&&null!==c&&"function"==typeof c.tools?c.tools:void 0,s=l?l(i):i,d=async(n,r)=>{var o,a,i,c,l,s,d,p,u,m;switch(n){case xr.SetRows:return null==(a=(o=t.current).onConfigChange)||a.call(o,{type:"rows",fields:r.fields,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Pivot grid rows set to: ${JSON.stringify(r.fields)}.`}]};case xr.SetColumns:return null==(c=(i=t.current).onConfigChange)||c.call(i,{type:"columns",fields:r.fields,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Pivot grid columns set to: ${JSON.stringify(r.fields)}.`}]};case xr.SetMeasures:return null==(s=(l=t.current).onConfigChange)||s.call(l,{type:"measures",fields:r.fields,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Pivot grid measures set to: ${JSON.stringify(r.fields)}.`}]};case xr.Expand:return null==(p=(d=t.current).onExpandChange)||p.call(d,{field:r.field,value:r.value,expanded:!0,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Expanded "${String(r.field)}: ${String(r.value)}".`}]};case xr.Collapse:return null==(m=(u=t.current).onExpandChange)||m.call(u,{field:r.field,value:r.value,expanded:!1,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Collapsed "${String(r.field)}: ${String(r.value)}".`}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of s){if(!e.enabled)continue;const t=e.inputSchema||Cr(e.commandType),n=e.commandType,i=e.execute;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:i?async e=>await i(e||{}):async e=>d(n,e||{})}))}catch{}}return o}},br={SendPrompt:"AIPromptSendPrompt",SetSuggestions:"AIPromptSetSuggestions"};function vr(e){switch(e){case br.SendPrompt:return{type:"object",properties:{prompt:{type:"string",description:"The prompt text to send"}},required:["prompt"]};case br.SetSuggestions:return{type:"object",properties:{suggestions:{type:"array",items:{type:"string"},description:"Array of suggestion strings to display"}},required:["suggestions"]};default:return{type:"object",properties:{}}}}const Tr={componentSuffix:"aiprompt",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=[{name:"send_prompt",description:`Send a prompt to the ${n.dataName} AI prompt component.`,commandType:br.SendPrompt,enabled:!0},{name:"set_suggestions",description:`Set the prompt suggestions shown in the ${n.dataName} AI prompt component.`,commandType:br.SetSuggestions,enabled:!0}],c=t.current.webMcp,l="object"==typeof c&&null!==c&&"function"==typeof c.tools?c.tools:void 0,s=l?l(i):i,d=async(n,r)=>{var o,a;switch(n){case br.SendPrompt:return null==(a=(o=t.current).onRequest)||a.call(o,{value:r.prompt,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Prompt sent: "${String(r.prompt)}".`}]};case br.SetSuggestions:return{content:[{type:"text",text:`Suggestions updated: ${JSON.stringify(r.suggestions)}.`}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of s){if(!e.enabled)continue;const t=vr(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>d(n,e||{})}))}catch{}}return o}},wr={SetValue:"OTPInputSetValue",Clear:"OTPInputClear"};function $r(e){return e===wr.SetValue?{type:"object",properties:{value:{type:"string",description:"The text value to set."}},required:["value"]}:{type:"object",properties:{}}}const Er={componentSuffix:"otpinput",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the value of the ${n.dataName} OTP input. Use spaces for unfilled cells (e.g. "12 4" for a 4-cell input with the third cell empty).`,commandType:wr.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear all cells of the ${n.dataName} OTP input.`,commandType:wr.Clear,enabled:!!i.onChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(t,n)=>{switch(t){case wr.SetValue:{const t=n.value;return null==t?{content:[{type:"text",text:"Missing required argument: value"}],isError:!0}:(i.onChange&&i.onChange({value:t,target:e}),{content:[{type:"text",text:`Value set to "${t}".`}]})}case wr.Clear:return i.onChange&&i.onChange({value:"",target:e}),{content:[{type:"text",text:"Value cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${t}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=$r(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},Nr=new Map([["textbox",j],["button",A],["treeview",R],["chat",F],["form",L],["editor",W],["spreadsheet",Y],["scheduler",ce],["gantt",ke],["grid",Fe],["treelist",nt],["tabstrip",at],["panelbar",lt],["stepper",pt],["drawer",ft],["window",xt],["dropdownlist",bt],["combobox",$t],["multicolumncombobox",kt],["autocomplete",At],["multiselect",qt],["dropdowntree",Ut],["datepicker",Bt],["daterangepicker",Jt],["timepicker",Yt],["datetimepicker",en],["calendar",rn],["numerictextbox",cn],["slider",dn],["rangeslider",mn],["colorpicker",Cn],["switch",vn],["checkbox",hn],["rating",$n],["textarea",kn],["maskedtextbox",Gn],["signature",Mn],["upload",_n],["listbox",Fn],["listview",Hn],["dialog",Kn],["menu",Xn],["scrollview",nr],["sortable",ar],["map",lr],["notification",pr],["chart",gr],["taskboard",yr],["pivotgrid",Sr],["aiprompt",Tr],["otpinput",Er]]);e.AIPromptCommands=br,e.AutoCompleteCommands=jt,e.ButtonCommands=D,e.CalendarCommands=tn,e.ChartCommands=ur,e.ChatCommands=O,e.CheckBoxCommands=gn,e.ColorPickerCommands=yn,e.ComboBoxCommands=vt,e.DatePickerCommands=zt,e.DateRangePickerCommands=Ht,e.DateTimePickerCommands=Xt,e.DialogCommands=Wn,e.DrawerCommands=ut,e.DropDownListCommands=Ct,e.DropDownTreeCommands=_t,e.EditorCommands=B,e.FILTER_OPERATORS=i,e.FormCommands=U,e.GanttCommands=fe,e.GridCommands=Ae,e.ListBoxCommands=Rn,e.ListViewCommands=Un,e.MapCommands=ir,e.MaskedTextBoxCommands=jn,e.MenuCommands=Zn,e.MultiColumnComboBoxCommands=Et,e.MultiSelectCommands=Vt,e.NotificationCommands=sr,e.NumericTextBoxCommands=on,e.OTPInputCommands=wr,e.PanelBarCommands=it,e.PivotGridCommands=xr,e.RangeSliderCommands=pn,e.RatingCommands=Tn,e.SchedulerCommands=re,e.ScrollViewCommands=Qn,e.SignatureCommands=An,e.SliderCommands=ln,e.SortableCommands=rr,e.SpreadsheetCommands=J,e.StepperCommands=st,e.SwitchCommands=Sn,e.TabStripCommands=rt,e.TaskBoardCommands=fr,e.TextAreaCommands=En,e.TextBoxCommands=N,e.TimePickerCommands=Kt,e.TreeListCommands=Ue,e.TreeViewCommands=V,e.UploadCommands=In,e.WebMcpProvider=({children:e,dataName:t})=>{const r=a.useRef(t);r.current=t;const o=a.useCallback((e,t,o,a)=>{const i=Nr.get(e);if(!i)return()=>{};const c=n.getModelContext();if(!c)return()=>{};const l=a,s=("string"==typeof(null==l?void 0:l.dataName)?l.dataName:void 0)||r.current;if(!s)return()=>{};const d={dataName:s,groupName:`${s}_${i.componentSuffix}`},p=i.createTools(t,o,d,c);return()=>{p.forEach(e=>null==e?void 0:e.unregister())}},[]),i=a.useMemo(()=>({register:o}),[o]);return a.createElement(n.WebMcpContext.Provider,{value:i},e)},e.WindowCommands=ht,e.aipromptAdapter=Tr,e.autoCompleteAdapter=At,e.buildExpandCollapsePayload=function(e){return m(e)},e.buildFilterPayload=m,e.buildGridCommandJson=function(e,t){const n={type:e};switch(e){case"GridFilter":if(!t.field||!t.operator)return null;n.filter={logic:"and",filters:[{field:t.field,operator:t.operator,value:t.value}]};break;case"GridSort":if(!t.field)return null;n.sort={field:t.field,dir:t.dir};break;case"GridGroup":if(!t.field)return null;n.group={field:t.field,dir:t.dir||"asc"};break;case"GridHighlight":case"GridSelect":return function(e,t){if(!t.field||!t.operator)return null;const n="GridHighlight"===e?"highlight":"select",r={logic:"and",filters:[{field:t.field,operator:t.operator,value:t.value}]};return t.cells&&(r.cells=t.cells.reduce((e,t)=>(e[t]=!0,e),{})),JSON.stringify({commands:[{type:e,[n]:r}]})}(e,t);case"GridPage":n.page=t.page;break;case"GridPageSize":n.pageSize=t.pageSize;break;case"GridColumnReorder":n.id=t.id,n.position=t.position;break;case"GridColumnResize":n.id=t.id,n.size=t.size;break;case"GridColumnShow":case"GridColumnHide":case"GridColumnLock":case"GridColumnUnlock":n.id=t.id;break;case"GridExportExcel":case"GridExportPDF":case"GridExportCSV":t.fileName&&(n.fileName=t.fileName)}return JSON.stringify({commands:[n]})},e.buildRowMatchPayload=function(e){if(!e.field||!e.operator)return null;const t={logic:"and",filters:[{field:e.field,operator:e.operator,value:e.value}]};return e.cells&&(t.cells=e.cells.reduce((e,t)=>(e[t]=!0,e),{})),t},e.buildSortPayload=function(e){return e.field?{field:e.field,dir:e.dir}:null},e.buttonAdapter=A,e.calendarAdapter=rn,e.chartAdapter=gr,e.chatAdapter=F,e.checkboxAdapter=hn,e.colorPickerAdapter=Cn,e.comboBoxAdapter=$t,e.datePickerAdapter=Bt,e.dateRangePickerAdapter=Jt,e.dateTimePickerAdapter=en,e.dialogAdapter=Kn,e.drawerAdapter=ft,e.dropDownListAdapter=bt,e.dropDownTreeAdapter=Ut,e.editorAdapter=W,e.formAdapter=L,e.ganttAdapter=ke,e.getAIPromptToolSchema=vr,e.getAggregateSchema=De,e.getAutoCompleteToolSchema=Dt,e.getBooleanValueSchema=y,e.getButtonToolSchema=G,e.getCalendarToolSchema=nn,e.getChartToolSchema=mr,e.getChatToolSchema=P,e.getCheckBoxToolSchema=fn,e.getColorPickerToolSchema=xn,e.getColorValueSchema=T,e.getColumnIdSchema=le,e.getColumnReorderSchema=se,e.getColumnResizeSchema=de,e.getComboBoxToolSchema=Tt,e.getDatePickerToolSchema=Lt,e.getDateRangePickerToolSchema=Wt,e.getDateRangeValueSchema=b,e.getDateTimePickerToolSchema=Qt,e.getDateTimeValueSchema=S,e.getDateValueSchema=x,e.getDialogToolSchema=Jn,e.getDrawerToolSchema=mt,e.getDropDownListToolSchema=St,e.getDropDownTreeToolSchema=Rt,e.getDropDownValueSchema=w,e.getEditorToolSchema=H,e.getEmptySchema=c,e.getExpandCollapseSchema=g,e.getExportSchema=u,e.getFilterSchema=l,e.getFormToolSchema=z,e.getGanttChangeViewSchema=ue,e.getGanttCreateTaskSchema=me,e.getGanttDeleteTaskSchema=ge,e.getGanttToolSchema=he,e.getGridToolSchema=Ve,e.getGroupExpandSchema=Ge,e.getGroupSchema=je,e.getListBoxToolSchema=On,e.getListViewToolSchema=zn,e.getMapToolSchema=cr,e.getMaskedTextBoxToolSchema=Dn,e.getMenuToolSchema=Yn,e.getMultiColumnComboBoxToolSchema=Nt,e.getMultiSelectAddValueSchema=$,e.getMultiSelectRemoveValueSchema=E,e.getMultiSelectToolSchema=Mt,e.getNotificationToolSchema=dr,e.getNumberValueSchema=h,e.getNumericRangeValueSchema=v,e.getNumericTextBoxToolSchema=an,e.getOTPInputToolSchema=$r,e.getPageSchema=d,e.getPageSizeSchema=p,e.getPanelBarToolSchema=ct,e.getPivotGridToolSchema=Cr,e.getRangeSliderToolSchema=un,e.getRatingToolSchema=wn,e.getRowMatchSchema=pe,e.getSchedulerCreateSchema=Q,e.getSchedulerDeleteSchema=ee,e.getSchedulerNavigateSchema=te,e.getSchedulerToolSchema=oe,e.getSchedulerViewSchema=ne,e.getScrollViewToolSchema=er,e.getSignatureToolSchema=Vn,e.getSliderToolSchema=sn,e.getSortSchema=s,e.getSortableToolSchema=or,e.getSpreadsheetToolSchema=K,e.getStepperToolSchema=dt,e.getStringValueSchema=f,e.getSwitchToolSchema=bn,e.getTabStripToolSchema=ot,e.getTaskBoardToolSchema=hr,e.getTextAreaToolSchema=Nn,e.getTextBoxToolSchema=k,e.getTimePickerToolSchema=Zt,e.getTimeValueSchema=C,e.getTreeListToolSchema=ze,e.getTreeViewToolSchema=M,e.getUploadToolSchema=qn,e.getWindowToolSchema=yt,e.gridAdapter=Fe,e.listBoxAdapter=Fn,e.listViewAdapter=Hn,e.mapAdapter=lr,e.maskedTextBoxAdapter=Gn,e.menuAdapter=Xn,e.multiColumnComboBoxAdapter=kt,e.multiSelectAdapter=qt,e.notificationAdapter=pr,e.numericTextBoxAdapter=cn,e.otpInputAdapter=Er,e.panelBarAdapter=lt,e.pivotgridAdapter=Sr,e.rangeSliderAdapter=mn,e.ratingAdapter=$n,e.schedulerAdapter=ce,e.scrollViewAdapter=nr,e.signatureAdapter=Mn,e.sliderAdapter=dn,e.sortableAdapter=ar,e.spreadsheetAdapter=Y,e.stepperAdapter=pt,e.switchAdapter=vn,e.tabStripAdapter=at,e.taskboardAdapter=yr,e.textAreaAdapter=kn,e.textBoxAdapter=j,e.timePickerAdapter=Yt,e.treeListAdapter=nt,e.treeViewAdapter=R,e.uploadAdapter=_n,e.windowAdapter=xt});
|
|
15
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@progress/kendo-react-common"),require("@progress/kendo-react-editor")):"function"==typeof define&&define.amd?define(["exports","react","@progress/kendo-react-common","@progress/kendo-react-editor"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactWebmcp={},e.React,e.KendoReactCommon,e.KendoReactEditor)}(this,function(e,t,n,r){"use strict";function o(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var a=o(t);const i=["eq","neq","gt","gte","lt","lte","contains","doesnotcontain","startswith","endswith","isnull","isnotnull","isempty","isnotempty"];function c(){return{type:"object",properties:{}}}function l(e){return{type:"object",properties:{field:{type:"string",enum:e,description:"Column field name to filter"},operator:{type:"string",enum:i,description:"Filter operator"},value:{description:"Filter value (string, number, or boolean depending on column type)"}},required:["field","operator","value"]}}function s(e){return{type:"object",properties:{field:{type:"string",enum:e,description:"Column field name to sort by"},dir:{type:"string",enum:["asc","desc"],description:"Sort direction"}},required:["field","dir"]}}function d(){return{type:"object",properties:{page:{type:"number",description:"Page number (1-based)"}},required:["page"]}}function p(e){return{type:"object",properties:{pageSize:{type:"number",enum:e,description:"Number of items per page"}},required:["pageSize"]}}function u(){return{type:"object",properties:{fileName:{type:"string",description:"Name of the exported file (optional)"}}}}function m(e){return e.field&&e.operator?{logic:"and",filters:[{field:e.field,operator:e.operator,value:e.value}]}:null}function g(e){return l(e)}function f(){return{type:"object",properties:{value:{type:"string",description:"The text value to set."}},required:["value"]}}function h(){return{type:"object",properties:{value:{type:"number",description:"The numeric value to set."}},required:["value"]}}function y(){return{type:"object",properties:{value:{type:"boolean",description:"The boolean value to set (true or false)."}},required:["value"]}}function x(){return{type:"object",properties:{value:{type:"string",description:'The date value in ISO 8601 format (e.g. "2026-04-23").'}},required:["value"]}}function C(){return{type:"object",properties:{value:{type:"string",description:'The time value in ISO 8601 format (e.g. "14:30:00").'}},required:["value"]}}function S(){return{type:"object",properties:{value:{type:"string",description:'The date and time value in ISO 8601 format (e.g. "2026-04-23T14:30:00").'}},required:["value"]}}function b(){return{type:"object",properties:{startValue:{type:"string",description:'The start date in ISO 8601 format (e.g. "2026-04-01").'},endValue:{type:"string",description:'The end date in ISO 8601 format (e.g. "2026-04-30").'}},required:["startValue","endValue"]}}function v(){return{type:"object",properties:{startValue:{type:"number",description:"The start value of the range."},endValue:{type:"number",description:"The end value of the range."}},required:["startValue","endValue"]}}function T(){return{type:"object",properties:{value:{type:"string",description:'The color value as a hex string (e.g. "#ff6358") or named CSS color.'}},required:["value"]}}function w(){return{type:"object",properties:{value:{type:"string",description:"The value to select from the available options."}},required:["value"]}}function $(){return{type:"object",properties:{value:{type:"string",description:"The value to add to the selection."}},required:["value"]}}function E(){return{type:"object",properties:{value:{type:"string",description:"The value to remove from the selection."}},required:["value"]}}const N={SetValue:"TextBoxSetValue",Clear:"TextBoxClear"};function k(e){return e===N.SetValue?{type:"object",properties:{value:{type:"string",description:"The text value to set."}},required:["value"]}:{type:"object",properties:{}}}const j={componentSuffix:"textbox",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the value of the ${n.dataName} text box.`,commandType:N.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear the value of the ${n.dataName} text box.`,commandType:N.Clear,enabled:!!i.onChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(t,n)=>{switch(t){case N.SetValue:{const t=n.value;return null==t?{content:[{type:"text",text:"Missing required argument: value"}],isError:!0}:(i.onChange&&i.onChange({value:t,target:e}),{content:[{type:"text",text:`Value set to "${t}".`}]})}case N.Clear:return i.onChange&&i.onChange({value:"",target:e}),{content:[{type:"text",text:"Value cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${t}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=k(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},D={Click:"ButtonClick"};function G(e){return{type:"object",properties:{}}}const A={componentSuffix:"button",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=[{name:"click",description:`Click the ${n.dataName} button.`,commandType:D.Click,enabled:!0}],c=t.current.webMcp,l="object"==typeof c&&null!==c&&"function"==typeof c.tools?c.tools:void 0,s=l?l(i):i,d=async(r,o)=>r!==D.Click?{content:[{type:"text",text:`Unknown command: ${r}`}],isError:!0}:t.current.disabled?{content:[{type:"text",text:"Button is disabled."}],isError:!0}:null!=e&&e.click?(e.click(),{content:[{type:"text",text:`Clicked the ${n.dataName} button.`}]}):{content:[{type:"text",text:"Button ref not available."}],isError:!0};for(const e of s){if(!e.enabled)continue;const t=G(e.commandType),n=e.commandType,i=e.execute;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:i?async e=>await i(e):async e=>d(n)}))}catch{}}return o}},V={Expand:"TreeViewExpand",Collapse:"TreeViewCollapse",Select:"TreeViewSelect",Check:"TreeViewCheck"};function M(e){switch(e){case V.Expand:return{type:"object",properties:{nodeText:{type:"string",description:"The text of the tree node to expand"}},required:["nodeText"]};case V.Collapse:return{type:"object",properties:{nodeText:{type:"string",description:"The text of the tree node to collapse"}},required:["nodeText"]};case V.Select:return{type:"object",properties:{nodeText:{type:"string",description:"The text of the tree node to select"}},required:["nodeText"]};case V.Check:return{type:"object",properties:{nodeText:{type:"string",description:"The text of the tree node to check or uncheck"},checkChildren:{type:"boolean",description:"When true, also checks or unchecks all child nodes recursively. Defaults to false."}},required:["nodeText"]};default:return{type:"object",properties:{}}}}function I(e){if("string"==typeof e)return e;if(null===e)return"null";if(void 0===e)return"undefined";if("number"==typeof e||"boolean"==typeof e)return e.toString();try{return JSON.stringify(e)}catch{return"[object]"}}function q(e,t,n,r,o=""){for(let a=0;a<e.length;a++){const i=e[a],c=o?`${o}_${a}`:`${a}`;if(I(i[n])===t)return{node:i,path:c};const l=i[r];if(l&&Array.isArray(l)&&l.length>0){const e=q(l,t,n,r,c);if(e)return e}}}function _(e,t,n){switch(e){case V.Expand:return function(e,t){const n=e.nodeText;if(!n)return{content:[{type:"text",text:"Missing required argument: nodeText"}],isError:!0};const r=t.current,o=r.textField||"text",a=r.childrenField||"items",i=r.data;if(!i)return{content:[{type:"text",text:"TreeView has no data."}]};const c=q(i,n,o,a);return c?(r.onExpandChange&&r.onExpandChange({item:c.node,itemHierarchicalIndex:c.path,nativeEvent:null,target:null,syntheticEvent:null}),{content:[{type:"text",text:`Expanded node "${n}".`}]}):{content:[{type:"text",text:`Node "${n}" not found.`}],isError:!0}}(t,n);case V.Collapse:return function(e,t){const n=e.nodeText;if(!n)return{content:[{type:"text",text:"Missing required argument: nodeText"}],isError:!0};const r=t.current,o=r.textField||"text",a=r.childrenField||"items",i=r.data;if(!i)return{content:[{type:"text",text:"TreeView has no data."}]};const c=q(i,n,o,a);return c?(r.onExpandChange&&r.onExpandChange({item:c.node,itemHierarchicalIndex:c.path,nativeEvent:null,target:null,syntheticEvent:null}),{content:[{type:"text",text:`Collapsed node "${n}".`}]}):{content:[{type:"text",text:`Node "${n}" not found.`}],isError:!0}}(t,n);case V.Select:return function(e,t){const n=e.nodeText;if(!n)return{content:[{type:"text",text:"Missing required argument: nodeText"}],isError:!0};const r=t.current,o=r.textField||"text",a=r.childrenField||"items",i=r.data;if(!i)return{content:[{type:"text",text:"TreeView has no data."}]};const c=q(i,n,o,a);return c?(r.onItemClick&&r.onItemClick({item:c.node,itemHierarchicalIndex:c.path,nativeEvent:null,target:null,syntheticEvent:null}),{content:[{type:"text",text:`Selected node "${n}".`}]}):{content:[{type:"text",text:`Node "${n}" not found.`}],isError:!0}}(t,n);default:return{content:[{type:"text",text:`Unknown command: ${e}`}],isError:!0}}}const R={componentSuffix:"treeview",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"expand_node",description:`Expand a node in the ${n.dataName} treeview`,commandType:V.Expand,enabled:!!i.onExpandChange},{name:"collapse_node",description:`Collapse a node in the ${n.dataName} treeview`,commandType:V.Collapse,enabled:!!i.onExpandChange},{name:"select_node",description:`Select a node in the ${n.dataName} treeview`,commandType:V.Select,enabled:!!i.onItemClick}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c,{tname:a}):c,p=async(e,n)=>_(e,n,t);if(i.onFilterChange)try{o.push(r.registerTool({name:a("search"),description:`Search for nodes matching a text pattern in the ${n.dataName} treeview.`,inputSchema:{type:"object",properties:{query:{type:"string",description:"Text to search for (case-insensitive)"}},required:["query"]},async execute(e){const n=(e.query||"").toLowerCase();if(!n)return{content:[{type:"text",text:"Missing required argument: query"}],isError:!0};const r=t.current,o=r.textField||"text",a=r.childrenField||"items",i=r.data;if(!i)return{content:[{type:"text",text:"TreeView has no data."}]};const c=[],l=(e,t)=>{e.forEach((e,r)=>{const i=t?`${t}_${r}`:`${r}`,s=e[o]||"";"string"==typeof s&&s.toLowerCase().includes(n)&&c.push({text:s,path:i});const d=e[a];d&&Array.isArray(d)&&l(d,i)})};return l(i,""),0===c.length?{content:[{type:"text",text:`No nodes matching "${n}".`}]}:{content:[{type:"text",text:`${c.length} match(es):\n${JSON.stringify(c,null,2)}`}]}}}))}catch{}for(const e of d){if(!e.enabled)continue;const t=M(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},O={SendMessage:"ChatSendMessage"};function P(e){return e===O.SendMessage?{type:"object",properties:{text:{type:"string",description:"The message text to send"}},required:["text"]}:{type:"object",properties:{}}}const F={componentSuffix:"chat",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"send_message",description:`Send a message to the ${n.dataName} conversation`,commandType:O.SendMessage,enabled:!!i.onSendMessage}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(e,n)=>{if(e===O.SendMessage){const e=n.text;if(!e)return{content:[{type:"text",text:"Missing required argument: text"}],isError:!0};const r=t.current;if(!r.onSendMessage)return{content:[{type:"text",text:"Chat has no onSendMessage handler."}],isError:!0};const o={id:Date.now(),author:{id:r.authorId},text:e,timestamp:new Date};return r.onSendMessage({message:o,nativeEvent:null,target:null,syntheticEvent:null}),{content:[{type:"text",text:`Message sent: "${e}"`}]}}return{content:[{type:"text",text:`Unknown command: ${e}`}],isError:!0}};for(const e of d){if(!e.enabled)continue;const t=P(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},U={Fill:"FormFill",Validate:"FormValidate",Submit:"FormSubmit",Reset:"FormReset"};function z(e,t){return e===U.Fill?{type:"object",properties:{values:{type:"object",description:"Key-value pairs of field names to values."+(t&&t.length>0?` Available fields: ${t.join(", ")}.`:"")}},additionalProperties:!0,description:"Provide either a `values` object, or pass field/value pairs directly as top-level properties."}:{type:"object",properties:{}}}const L={componentSuffix:"form",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=(null==e?void 0:e.fields)||[],c=i.length>0?` Available fields: ${i.join(", ")}.`:"",l=[{name:"fill",description:`Fill the ${n.dataName} form fields with the provided values.${c}`,commandType:U.Fill,enabled:!0},{name:"validate",description:`Validate the ${n.dataName} form and return any errors.`,commandType:U.Validate,enabled:!0},{name:"submit",description:`Submit the ${n.dataName} form.`,commandType:U.Submit,enabled:!0},{name:"reset",description:`Reset the ${n.dataName} form to its initial values.`,commandType:U.Reset,enabled:!0}],s=t.current.webMcp,d="object"==typeof s&&null!==s&&"function"==typeof s.tools?s.tools:void 0,p=d?d(l):l,u=async(t,n)=>{switch(t){case U.Fill:return function(e,t){var n;if(!t)return{content:[{type:"text",text:"Form ref not available."}],isError:!0};const r=e.values,o=r&&"object"==typeof r&&!Array.isArray(r)?r:Object.fromEntries(Object.entries(e).filter(([e])=>"values"!==e&&"target"!==e&&"syntheticEvent"!==e));if(!o||"object"!=typeof o||0===Object.keys(o).length)return{content:[{type:"text",text:"Missing required argument: values (object)"}],isError:!0};const a=new Set(t.fields||[]),i=a.size>0,c=[];for(const[e,r]of Object.entries(o))!i||a.has(e)?(t.onChange(e,{value:r}),null==(n=t.onBlur)||n.call(t,e,!0)):c.push(e);const l=Object.keys(o).filter(e=>!c.includes(e));return 0===l.length?{content:[{type:"text",text:"No matching form fields were filled."}],isError:!0}:c.length>0?{content:[{type:"text",text:`Filled ${l.length} field(s): ${l.join(", ")}. Skipped unknown field(s): ${c.join(", ")}.`}]}:{content:[{type:"text",text:`Filled ${l.length} field(s): ${l.join(", ")}.`}]}}(n,e);case U.Validate:return function(e){if(!e)return{content:[{type:"text",text:"Form ref not available."}],isError:!0};(e.fields||[]).forEach(t=>{var n;return null==(n=e.onBlur)?void 0:n.call(e,t)});const t=e.errors||{},n=Object.entries(t).filter(([,e])=>!!e);return 0===n.length?{content:[{type:"text",text:"Form is valid."}]}:{content:[{type:"text",text:"Validation errors:\n"+n.map(([e,t])=>` ${e}: ${t}`).join("\n")}]}}(e);case U.Submit:return function(e){return e?(e.onSubmit({preventDefault:()=>{},stopPropagation:()=>{}}),{content:[{type:"text",text:"Form submitted."}]}):{content:[{type:"text",text:"Form ref not available."}],isError:!0}}(e);case U.Reset:return function(e){return e?(e.onReset(),{content:[{type:"text",text:"Form reset to initial values."}]}):{content:[{type:"text",text:"Form ref not available."}],isError:!0}}(e);default:return{content:[{type:"text",text:`Unknown command: ${t}`}],isError:!0}}};for(const e of p){if(!e.enabled)continue;const t=e.inputSchema||z(e.commandType,i),n=e.commandType,c=e.execute;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:c?async e=>await c(e||{}):async e=>u(n,e||{})}))}catch{}}return o}},B={GetValue:"EditorGetValue",SetValue:"EditorSetValue"};function H(e){return e===B.SetValue?{type:"object",properties:{value:{type:"string",description:"The text value to set."}},required:["value"]}:{type:"object",properties:{}}}const W={componentSuffix:"editor",createTools(e,t,n,o){const a=[],i=e=>`${n.groupName}_${e}`,c=t.current,l=!(null==e||!e.view),s=!!c.onChange,d=[{name:"get_content",description:`Get the current HTML content of the ${n.dataName} editor.`,commandType:B.GetValue,enabled:!1},{name:"set_content",description:`Replace the entire content of the ${n.dataName} editor with the provided HTML.`,commandType:B.SetValue,enabled:l||s},{name:"insert_html",description:`Insert HTML content at the cursor position in the ${n.dataName} editor.`,commandType:B.SetValue,enabled:l||s},{name:"clear_content",description:`Clear all content from the ${n.dataName} editor.`,commandType:B.GetValue,enabled:l||s}],p=t.current.webMcp,u="object"==typeof p&&null!==p&&"function"==typeof p.tools?p.tools:void 0,m=u?u(d):d,g={content:[{type:"text",text:"Editor ref or view not available."}],isError:!0};const f=(t,n,o)=>{switch(n){case"get_content":return null!=e&&e.view?{content:[{type:"text",text:r.EditorUtils.getHtml(e.view.state)||"(empty)"}]}:g;case"set_content":return function(t){if(null==e||!e.view)return g;const n=t.value;return null==n?{content:[{type:"text",text:"Missing required argument: value"}],isError:!0}:(r.EditorUtils.setHtml(e.view,n),{content:[{type:"text",text:"Content replaced."}]})}(o);case"insert_html":return function(t){if(null==e||!e.view)return g;const n=t.value;if(!n)return{content:[{type:"text",text:"Missing required argument: value"}],isError:!0};const o=r.EditorUtils.createDocument(e.view.state.schema,n);return o&&r.EditorUtils.insertNode(e.view,o),{content:[{type:"text",text:"HTML inserted at cursor position."}]}}(o);case"clear_content":return null!=e&&e.view?(r.EditorUtils.setHtml(e.view,""),{content:[{type:"text",text:"Content cleared."}]}):g;default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of m){if(!e.enabled)continue;const t=H(e.commandType),n=(e.commandType,e.name);try{a.push(o.registerTool({name:i(e.name),description:e.description,inputSchema:t,execute:e=>Promise.resolve(f(0,n,e||{}))}))}catch{}}return a}},J={SetCell:"SpreadsheetSetCell",SetCells:"SpreadsheetSetCells",GetCell:"SpreadsheetGetCell",GetData:"SpreadsheetGetData",SetData:"SpreadsheetSetData",GetSheets:"SpreadsheetGetSheets",SwitchSheet:"SpreadsheetSwitchSheet",NavigateSheet:"SpreadsheetNavigateSheet",AddSheet:"SpreadsheetAddSheet",RenameSheet:"SpreadsheetRenameSheet",ExecuteCommand:"SpreadsheetExecuteCommand",Export:"SpreadsheetExport"};function K(e){switch(e){case J.SetCell:return{type:"object",properties:{ref:{type:"string",description:'Cell reference (e.g. "A1", "B2:B10")'},value:{description:"The value to set (string, number, or formula)"}},required:["ref","value"]};case J.SetCells:return{type:"object",properties:{cells:{type:"array",description:"Array of cell updates to apply in batch",items:{type:"object",properties:{ref:{type:"string",description:'Cell reference (e.g. "A1")'},value:{description:"The value to set"}},required:["ref","value"]}}},required:["cells"]};case J.GetCell:return{type:"object",properties:{ref:{type:"string",description:'Cell reference to read (e.g. "A1")'}},required:["ref"]};case J.SetData:return{type:"object",properties:{data:{description:"Workbook JSON object to load (replaces all sheets)"}},required:["data"]};case J.SwitchSheet:case J.NavigateSheet:return{type:"object",properties:{name:{type:"string",description:"The name of the sheet to activate"}},required:["name"]};case J.RenameSheet:return{type:"object",properties:{name:{type:"string",description:"The new name for the active sheet"}},required:["name"]};case J.AddSheet:return{type:"object",properties:{name:{type:"string",description:"Optional name for the new sheet"}}};case J.GetData:case J.GetSheets:case J.Export:return{type:"object",properties:{}};case J.ExecuteCommand:return{type:"object",properties:{command:{type:"string",description:'The command name to execute (e.g. "bold", "italic", "underline", "undo", "redo")'},options:{description:"Optional command-specific options object"}},required:["command"]};default:return{type:"object",properties:{}}}}const Z={bold:!0,italic:!0,underline:!0};const Y={componentSuffix:"spreadsheet",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=[{name:"set_cell",description:`Set a cell value in the ${n.dataName} spreadsheet.`,commandType:J.SetCell,enabled:!0},{name:"set_cells",description:`Set multiple cell values at once in the ${n.dataName} spreadsheet. Preferred over multiple set_cell calls.`,commandType:J.SetCells,enabled:!0},{name:"get_cell",description:`Get the value of a cell in the ${n.dataName} spreadsheet.`,commandType:J.GetCell,enabled:!1},{name:"get_data",description:`Get the full workbook data from the ${n.dataName} spreadsheet as JSON.`,commandType:J.GetData,enabled:!1},{name:"set_data",description:`Load workbook data into the ${n.dataName} spreadsheet from a JSON object.`,commandType:J.SetData,enabled:!0},{name:"get_sheets",description:`Get the names of all sheets in the ${n.dataName} spreadsheet.`,commandType:J.GetSheets,enabled:!1},{name:"switch_sheet",description:`Switch the active sheet in the ${n.dataName} spreadsheet by name.`,commandType:J.SwitchSheet,enabled:!0},{name:"navigate_sheet",description:`Switch the active sheet in the ${n.dataName} spreadsheet.`,commandType:J.NavigateSheet,enabled:!0},{name:"add_sheet",description:`Add a new sheet to the ${n.dataName} spreadsheet.`,commandType:J.AddSheet,enabled:!0},{name:"rename_sheet",description:`Rename the active sheet in the ${n.dataName} spreadsheet.`,commandType:J.RenameSheet,enabled:!0},{name:"export",description:`Export the ${n.dataName} spreadsheet (triggers Excel download).`,commandType:J.Export,enabled:!0},{name:"execute_command",description:`Execute a command (e.g. bold, italic, underline, undo, redo) on the selected cells in the ${n.dataName} spreadsheet.`,commandType:J.ExecuteCommand,enabled:!0}],c=t.current.webMcp,l="object"==typeof c&&null!==c&&"function"==typeof c.tools?c.tools:void 0,s=l?l(i):i,d=async(t,n)=>{switch(t){case J.SetCell:return function(e,t){if(null==t||!t.instance)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const n=e.ref;if(!n)return{content:[{type:"text",text:'Missing required argument: ref (e.g. "A1")'}],isError:!0};const r=t.activeSheet();return r?(r.range(n).value(e.value),{content:[{type:"text",text:`Set ${n} = ${JSON.stringify(e.value)}.`}]}):{content:[{type:"text",text:"No active sheet."}],isError:!0}}(n,e);case J.SetCells:return function(e,t){if(null==t||!t.instance)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const n=e.cells;if(!Array.isArray(n)||0===n.length)return{content:[{type:"text",text:"Missing required argument: cells (array of {ref, value})"}],isError:!0};const r=t.activeSheet();if(!r)return{content:[{type:"text",text:"No active sheet."}],isError:!0};for(const e of n)e.ref&&r.range(e.ref).value(e.value);return{content:[{type:"text",text:`Set ${n.length} cell(s).`}]}}(n,e);case J.GetCell:return function(e,t){if(null==t||!t.instance)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const n=e.ref;if(!n)return{content:[{type:"text",text:'Missing required argument: ref (e.g. "A1")'}],isError:!0};const r=t.activeSheet();if(!r)return{content:[{type:"text",text:"No active sheet."}],isError:!0};const o=r.range(n).value();return{content:[{type:"text",text:JSON.stringify(o)}]}}(n,e);case J.GetData:return function(e){if(!e)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const t=e.toJSON();return{content:[{type:"text",text:JSON.stringify(t)}]}}(e);case J.SetData:return function(e,t){if(!t)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const n=e.data;return n&&"object"==typeof n?(t.fromJSON(n),{content:[{type:"text",text:"Workbook data loaded."}]}):{content:[{type:"text",text:"Missing required argument: data (object)"}],isError:!0}}(n,e);case J.GetSheets:return function(e){if(!e)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const t=e.sheets().map(e=>e.name());return{content:[{type:"text",text:JSON.stringify(t)}]}}(e);case J.SwitchSheet:case J.NavigateSheet:return function(e,t){if(!t)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const n=e.name;if(!n)return{content:[{type:"text",text:"Missing required argument: name"}],isError:!0};const r=t.sheets().find(e=>e.name()===n);return r?(t.activeSheet(r),{content:[{type:"text",text:`Switched to sheet "${n}".`}]}):{content:[{type:"text",text:`Sheet "${n}" not found.`}],isError:!0}}(n,e);case J.AddSheet:return function(e,t){if(null==t||!t.instance)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const n=t.instance;if(n.insertSheet){const t=e.name;n.insertSheet(t?{name:t}:void 0)}const r=e.name;return{content:[{type:"text",text:r?'Sheet "'+r+'" added.':"Sheet added."}]}}(n,e);case J.RenameSheet:return function(e,t){if(null==t||!t.instance)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const n=e.name;if(!n)return{content:[{type:"text",text:"Missing required argument: name"}],isError:!0};const r=t.activeSheet();if(!r)return{content:[{type:"text",text:"No active sheet."}],isError:!0};const o=t.instance;return o.renameSheet?(o.renameSheet(r,n),{content:[{type:"text",text:`Sheet renamed to "${n}".`}]}):{content:[{type:"text",text:"Rename sheet is not supported by this instance."}],isError:!0}}(n,e);case J.ExecuteCommand:return function(e,t){var n,r;if(!t)return{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0};const o=e.command;if(!o)return{content:[{type:"text",text:"Missing required argument: command"}],isError:!0};if(Z[o]){const e=t.activeSheet();if(!e)return{content:[{type:"text",text:"No active sheet."}],isError:!0};const a=e.activeCell(),i=!!a&&(null==(r=(n=e.range(a))[o])?void 0:r.call(n));t.executeCommand({command:"PropertyChangeCommand",options:{property:o,value:!i}})}else{const n=e.options||void 0;t.executeCommand(n?{command:o,...n}:{command:o})}return{content:[{type:"text",text:`Command "${o}" executed.`}]}}(n,e);case J.Export:return function(e){return null!=e&&e.instance?(e.saveAsExcel({}),{content:[{type:"text",text:"Export triggered."}]}):{content:[{type:"text",text:"Spreadsheet ref not available."}],isError:!0}}(e);default:return{content:[{type:"text",text:`Unknown command: ${t}`}],isError:!0}}};for(const e of s){if(!e.enabled)continue;const t=K(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>d(n,e||{})}))}catch{}}return o}},X=["Day","MultiDay","Week","Month","Timeline","Agenda"];function Q(){return{type:"object",properties:{title:{type:"string",description:"Title of the new event"},start:{type:"string",description:'Start date and time in ISO 8601 format (e.g. "2026-04-08T09:00:00")'},end:{type:"string",description:'End date and time in ISO 8601 format (e.g. "2026-04-08T10:00:00")'},isAllDay:{type:"boolean",description:"Whether the event spans the entire day"},description:{type:"string",description:"Optional description of the event"}},required:["title","start","end"]}}function ee(){return{type:"object",properties:{title:{type:"string",description:"Title of the event to delete"},start:{type:"string",description:"Start date/time of the event to identify it (ISO 8601)"}},required:["title"]}}function te(){return{type:"object",properties:{date:{type:"string",description:'Date to navigate to in ISO 8601 format (e.g. "2026-04-15")'}},required:["date"]}}function ne(){return{type:"object",properties:{view:{type:"string",enum:X,description:"The scheduler view to switch to"}},required:["view"]}}const re={Create:"SchedulerCreate",Delete:"SchedulerDelete",Navigate:"SchedulerNavigate",Update:"SchedulerUpdate",View:"SchedulerView"};function oe(e){switch(e){case re.Create:return{type:"object",properties:{title:{type:"string",description:"Title of the new event"},start:{type:"string",description:'Start date and time in ISO 8601 format (e.g. "2026-04-08T09:00:00")'},end:{type:"string",description:'End date and time in ISO 8601 format (e.g. "2026-04-08T10:00:00")'},isAllDay:{type:"boolean",description:"Whether the event spans the entire day"},description:{type:"string",description:"Optional description of the event"}},required:["title","start","end"]};case re.Delete:return{type:"object",properties:{title:{type:"string",description:"Title of the event to delete"},start:{type:"string",description:"Start date/time of the event to identify it (ISO 8601)"}},required:["title"]};case re.Update:return{type:"object",properties:{title:{type:"string",description:"Title of the event to update (used to find the event)"},start:{type:"string",description:"Current start date/time to identify the event (ISO 8601)"},newTitle:{type:"string",description:"New title for the event"},newStart:{type:"string",description:"New start date-time in ISO 8601 format"},newEnd:{type:"string",description:"New end date-time in ISO 8601 format"},isAllDay:{type:"boolean",description:"Whether the event spans the entire day"},description:{type:"string",description:"New description for the event"}},required:["title"]};case re.Navigate:return{type:"object",properties:{date:{type:"string",description:'Date to navigate to in ISO 8601 format (e.g. "2026-04-15")'}},required:["date"]};case re.View:return ne();default:return{type:"object",properties:{}}}}function ae(e){const t=e.modelFields;return{id:(null==t?void 0:t.id)||"id",title:(null==t?void 0:t.title)||"title",start:(null==t?void 0:t.start)||"start",end:(null==t?void 0:t.end)||"end",isAllDay:(null==t?void 0:t.isAllDay)||"isAllDay",description:(null==t?void 0:t.description)||"description"}}function ie(e,t,n){switch(e){case re.Navigate:return function(e,t){const n=e.date;if(!n)return{content:[{type:"text",text:"Missing required argument: date"}],isError:!0};const r=new Date(n);if(Number.isNaN(r.getTime()))return{content:[{type:"text",text:`Invalid date: ${n}`}],isError:!0};const o=t.current;return o.onDateChange&&o.onDateChange({value:r}),{content:[{type:"text",text:`Navigated to ${r.toISOString().split("T")[0]}.`}]}}(t,n);case re.View:return function(e,t){const n=e.view;if(!n)return{content:[{type:"text",text:"Missing required argument: view"}],isError:!0};const r=t.current;return r.onViewChange&&r.onViewChange({value:n}),{content:[{type:"text",text:`Switched to ${n} view.`}]}}(t,n);case re.Create:return function(e,t){const n=t.current;if(!n.onDataChange)return{content:[{type:"text",text:"Scheduler is not editable (no onDataChange handler)."}],isError:!0};const r=ae(n),o=e.title||"New Event",a=e.start,i=e.end;if(!a||!i)return{content:[{type:"text",text:"Missing required arguments: start and end (ISO strings)"}],isError:!0};const c=new Date(a),l=new Date(i);if(Number.isNaN(c.getTime())||Number.isNaN(l.getTime()))return{content:[{type:"text",text:"Invalid start or end date."}],isError:!0};const s={[r.id]:Date.now(),[r.title]:o,[r.start]:c,[r.end]:l,[r.isAllDay]:!0===e.isAllDay};return e.description&&(s[r.description]=e.description),n.onDataChange({created:[s],updated:[],deleted:[]}),{content:[{type:"text",text:`Created event "${o}" from ${a} to ${i}.`}]}}(t,n);case re.Update:return function(e,t){const n=t.current;if(!n.onDataChange)return{content:[{type:"text",text:"Scheduler is not editable (no onDataChange handler)."}],isError:!0};const r=ae(n),o=e.title;if(!o)return{content:[{type:"text",text:"Missing required argument: title"}],isError:!0};const a=n.data||[],i=e.start,c=a.find(e=>{if(I(e[r.title])!==o)return!1;if(i){const t=e[r.start];return(t instanceof Date?t.toISOString():I(t)).startsWith(i)}return!0});if(!c)return{content:[{type:"text",text:`Event "${o}" not found.`}],isError:!0};const l={...c};if(e.newTitle&&(l[r.title]=e.newTitle),e.newStart){const t=new Date(e.newStart);Number.isNaN(t.getTime())||(l[r.start]=t)}if(e.newEnd){const t=new Date(e.newEnd);Number.isNaN(t.getTime())||(l[r.end]=t)}return void 0!==e.isAllDay&&(l[r.isAllDay]=!0===e.isAllDay),void 0!==e.description&&(l[r.description]=e.description),n.onDataChange({created:[],updated:[l],deleted:[]}),{content:[{type:"text",text:`Updated event "${I(l[r.title])}".`}]}}(t,n);case re.Delete:return function(e,t){const n=t.current;if(!n.onDataChange)return{content:[{type:"text",text:"Scheduler is not editable (no onDataChange handler)."}],isError:!0};const r=ae(n),o=e.title;if(!o)return{content:[{type:"text",text:"Missing required argument: title"}],isError:!0};const a=n.data||[],i=e.start,c=a.find(e=>{if(I(e[r.title])!==o)return!1;if(i){const t=e[r.start];return(t instanceof Date?t.toISOString():I(t)).startsWith(i)}return!0});return c?(n.onDataChange({created:[],updated:[],deleted:[c]}),{content:[{type:"text",text:`Deleted event "${I(c[r.title])}".`}]}):{content:[{type:"text",text:`Event "${o}" not found.`}],isError:!0}}(t,n);default:return{content:[{type:"text",text:`Unknown command: ${e}`}],isError:!0}}}const ce={componentSuffix:"scheduler",createTools(e,t,n,r){const o=[],i=e=>`${n.groupName}_${e}`,c=t.current,l=function(e){const t=[];return a.Children.forEach(e,e=>{if(a.isValidElement(e)){const n=e.props.name;n&&t.push(n)}}),t}(c.children),s=l.length>0?` Available views: ${l.join(", ")}.`:"",d=[{name:"navigate",description:`Navigate the ${n.dataName} scheduler to a specific date.`,commandType:re.Navigate,enabled:!!c.onDateChange},{name:"set_view",description:`Switch the ${n.dataName} scheduler view.${s}`,commandType:re.View,enabled:!!c.onViewChange},{name:"create_event",description:`Create a new event in the ${n.dataName} scheduler.`,commandType:re.Create,enabled:!!c.onDataChange},{name:"update_event",description:`Update an existing event in the ${n.dataName} scheduler.`,commandType:re.Update,enabled:!!c.onDataChange},{name:"delete_event",description:`Delete an event from the ${n.dataName} scheduler.`,commandType:re.Delete,enabled:!!c.onDataChange}],p=t.current.webMcp,u="object"==typeof p&&null!==p&&"function"==typeof p.tools?p.tools:void 0,m={tname:i,data:c.data},g=u?u(d,m):d;for(const e of g){if(!e.enabled)continue;const n=oe(e.commandType),a=e.commandType;try{o.push(r.registerTool({name:i(e.name),description:e.description,inputSchema:n,execute:async e=>ie(a,e||{},t)}))}catch{}}return o}};function le(e){return{type:"object",properties:{id:{type:"string",description:"Column identifier",...e.length>0?{enum:e}:{}}},required:["id"]}}function se(e){return{type:"object",properties:{id:{type:"string",description:"Column identifier to move",...e.length>0?{enum:e}:{}},position:{type:"number",description:"Target position index (0-based)"}},required:["id","position"]}}function de(e){return{type:"object",properties:{id:{type:"string",description:"Column identifier to resize",...e.length>0?{enum:e}:{}},size:{type:"string",description:'New column width (e.g. "200px")'}},required:["id","size"]}}function pe(e){return{type:"object",properties:{field:{type:"string",enum:e,description:"Column field name to match"},operator:{type:"string",enum:i,description:"Filter operator"},value:{description:"Filter value (string, number, or boolean depending on column type)"},cells:{type:"array",items:{type:"string",enum:e},description:"Optional list of column fields to target. When provided, only the specified cells in matching rows are affected instead of entire rows."}},required:["field","operator","value"]}}function ue(){return{type:"object",properties:{view:{type:"string",description:"The Gantt view to switch to",enum:["Day","Week","Month","Year"]}},required:["view"]}}function me(){return{type:"object",properties:{title:{type:"string",description:"The title of the new task"},start:{type:"string",format:"date-time",description:"The start date of the task (ISO 8601 format)"},end:{type:"string",format:"date-time",description:"The end date of the task (ISO 8601 format)"}},required:["title"]}}function ge(e){return{type:"object",properties:{field:{type:"string",description:"The field used to identify the task to delete (use with operator and value)",enum:e.length>0?e:void 0},operator:{type:"string",description:"Filter operator to match the task",enum:["eq","neq","contains","startswith","gt","gte","lt","lte"]},value:{description:"The value to match in the field"},id:{description:"The task ID (alternative to field/operator/value)"}}}}const fe={Filter:"GanttFilter",ClearFilter:"GanttClearFilter",Sort:"GanttSort",ClearSort:"GanttClearSort",ColumnReorder:"GanttColumnReorder",ColumnResize:"GanttColumnResize",ColumnShow:"GanttColumnShow",ColumnHide:"GanttColumnHide",Expand:"GanttExpand",Collapse:"GanttCollapse",ExpandAll:"GanttExpandAll",CollapseAll:"GanttCollapseAll",ChangeView:"GanttChangeView",CreateTask:"GanttCreateTask",DeleteTask:"GanttDeleteTask"};function he(e,t){const n=t.map(e=>e.field).filter(Boolean),r=t.map(e=>e.id).filter(Boolean);switch(e){case fe.Filter:return l(n);case fe.ClearFilter:return{type:"object",properties:{}};case fe.Sort:return s(n);case fe.ClearSort:return{type:"object",properties:{}};case fe.ColumnReorder:return se(r);case fe.ColumnResize:return de(r);case fe.ColumnShow:case fe.ColumnHide:return le(r);case fe.Expand:case fe.Collapse:return g(n);case fe.ExpandAll:case fe.CollapseAll:return{type:"object",properties:{}};case fe.ChangeView:return{type:"object",properties:{view:{type:"string",description:"The Gantt view to switch to",enum:["Day","Week","Month","Year"]}},required:["view"]};case fe.CreateTask:return{type:"object",properties:{title:{type:"string",description:"The title of the new task"},start:{type:"string",format:"date-time",description:"The start date of the task (ISO 8601 format)"},end:{type:"string",format:"date-time",description:"The end date of the task (ISO 8601 format)"}},required:["title"]};case fe.DeleteTask:return ge(n);case"GanttUpdateTask":return function(e){return{type:"object",properties:{field:{type:"string",description:"The field used to identify the task to update (use with operator and value)",enum:e.length>0?e:void 0},operator:{type:"string",description:"Filter operator to match the task",enum:["eq","contains","startswith"]},value:{description:"The value to match in the field"},id:{description:"The task ID (alternative to field/operator/value)"},title:{type:"string",description:"New title for the task"},start:{type:"string",format:"date-time",description:"New start date (ISO 8601)"},end:{type:"string",format:"date-time",description:"New end date (ISO 8601)"},percentComplete:{type:"number",description:"New percent complete (0-1)"}}}}(n);case"GanttSelect":return function(e){return{type:"object",properties:{field:{type:"string",description:"The field used to identify the task to select (use with operator and value)",enum:e.length>0?e:void 0},operator:{type:"string",description:"Filter operator to match the task",enum:["eq","neq","contains","startswith","gt","gte","lt","lte"]},value:{description:"The value to match in the field"},id:{description:"The task ID (alternative to field/operator/value)"}}}}(n);default:return{type:"object",properties:{}}}}const ye="GanttUpdateTask",xe="GanttSelect";function Ce(e){return{id:(null==e?void 0:e.id)||"id",title:(null==e?void 0:e.title)||"title",start:(null==e?void 0:e.start)||"start",end:(null==e?void 0:e.end)||"end",percentComplete:(null==e?void 0:e.percentComplete)||"percentComplete",isExpanded:(null==e?void 0:e.isExpanded)||"isExpanded",children:(null==e?void 0:e.children)||"children"}}function Se(e,t){const n=[],r=e=>{for(const o of e){n.push(o);const e=o[t.children];Array.isArray(e)&&e.length>0&&r(e)}};return r(e),n}function be(e,t,n){const r="string"==typeof e?e.toLowerCase():e,o="string"==typeof n?n.toLowerCase():n;switch(t){case"eq":default:return r===o;case"neq":return r!==o;case"contains":return"string"==typeof r&&"string"==typeof o&&r.includes(o);case"startswith":return"string"==typeof r&&"string"==typeof o&&r.startsWith(o);case"endswith":return"string"==typeof r&&"string"==typeof o&&r.endsWith(o)}}function ve(e,t,n,r){const o=n.current,a=Ce(o.taskModelFields),i=Se(o.taskData||[],a);let c;return t.field&&t.operator?c=i.find(e=>be(e[t.field],t.operator,t.value)):void 0!==t.id&&(c=i.find(e=>String(e[a.id])===String(t.id))),c?(o.onExpandChange&&o.onExpandChange({dataItem:c,value:e,level:[],target:r}),{content:[{type:"text",text:`${e?"Expanded":"Collapsed"} task "${I(c[a.title])}".`}]}):{content:[{type:"text",text:"No matching task found."}],isError:!0}}function Te(e,t,n){const r=t.current,o=Ce(r.taskModelFields),a=Se(r.taskData||[],o).filter(e=>{const t=e[o.children];return Array.isArray(t)&&t.length>0});if(r.onExpandChange)for(const t of a)r.onExpandChange({dataItem:t,value:e,level:[],target:n});return{content:[{type:"text",text:`${e?"Expanded":"Collapsed"} ${a.length} parent task(s).`}]}}function we(e,t){return e.id===t||e.field===t}function $e(e,t,n){return e.map(e=>we(e,t)?n(e):e)}function Ee(e,t,n,r,o,a){var i;return a?(null==(i=n.onColumnsStateChange)||i.call(n,{columnsState:$e(o,e,e=>({...e,hidden:t})),target:r}),{content:[{type:"text",text:`Column ${e} is now ${t?"hidden":"visible"}.`}]}):{content:[{type:"text",text:"Column state changes not supported."}],isError:!0}}function Ne(e,t,n,r,o){const a=t.id;if(!a)return{content:[{type:"text",text:"Missing required argument: id"}],isError:!0};const i=n.current,c=!!i.onColumnsStateChange&&!!r,l=c&&(i.columnsState||(null==r?void 0:r.columns))||[];switch(e){case fe.ColumnReorder:return function(e,t,n,r,o,a,i){var c;const l=Number(t.position);if(Number.isNaN(l))return{content:[{type:"text",text:"Missing required argument: position"}],isError:!0};if(i){const t=o.findIndex(t=>we(t,e)),i=a[t];if(i){const e=[...a];e.splice(t,1),e.splice(l,0,i),null==(c=n.onColumnsStateChange)||c.call(n,{columnsState:e.map((e,t)=>({...e,orderIndex:t})),target:r})}}else{if(!n.onColumnReorder)return{content:[{type:"text",text:"Column reorder not supported."}],isError:!0};{const t=o.findIndex(t=>we(t,e));n.onColumnReorder({oldIndex:t,newIndex:l,target:r})}}return{content:[{type:"text",text:`Column ${e} moved to position ${l}.`}]}}(a,t,i,r,o,l,c);case fe.ColumnResize:return function(e,t,n,r,o,a,i){var c;const l=Number.parseInt(t.size,10);if(Number.isNaN(l))return{content:[{type:"text",text:"Missing required argument: size"}],isError:!0};if(i)null==(c=n.onColumnsStateChange)||c.call(n,{columnsState:$e(a,e,e=>({...e,width:l})),target:r});else{if(!n.onColumnResize)return{content:[{type:"text",text:"Column resize not supported."}],isError:!0};{const t=o.findIndex(t=>we(t,e)),a=(n.columns||[])[t],i=a&&a.width||0;n.onColumnResize({index:t,newWidth:l,oldWidth:i,end:!0,target:r})}}return{content:[{type:"text",text:`Column ${e} resized to ${l}px.`}]}}(a,t,i,r,o,l,c);case fe.ColumnShow:return Ee(a,!1,i,r,l,c);case fe.ColumnHide:return Ee(a,!0,i,r,l,c);default:return null}}const ke={componentSuffix:"gantt",createTools(e,t,n,r){const o=[],i=e=>`${n.groupName}_${e}`,c=t.current,l=function(e){const t=[];if(Array.isArray(e.columns))for(const n of e.columns)n.field&&t.push({field:n.field,id:n.id||n.field});return 0===t.length&&e.children&&a.Children.forEach(e.children,e=>{if(a.isValidElement(e)&&e.props.field){const n=e.props;t.push({field:n.field,id:n.id||n.field})}}),t}(c),s=!!c.sortable,d=!!c.onFilterChange,p=!!c.onExpandChange,u=!!c.onViewChange,m=!!c.onTaskChange||!!c.onDataStateChange,g=!!c.reorderable||!!c.onColumnReorder,f=!!c.resizable||!!c.onColumnResize,h=!!c.onColumnsStateChange,y=[{name:"sort",description:`Sort the ${n.dataName} gantt by a column`,commandType:fe.Sort,enabled:s},{name:"clear_sort",description:`Remove all sorting from the ${n.dataName} gantt`,commandType:fe.ClearSort,enabled:s},{name:"filter",description:`Filter the ${n.dataName} gantt on a column`,commandType:fe.Filter,enabled:d},{name:"clear_filters",description:`Remove all filters from the ${n.dataName} gantt`,commandType:fe.ClearFilter,enabled:d},{name:"expand",description:`Expand a task in the ${n.dataName} gantt`,commandType:fe.Expand,enabled:p},{name:"collapse",description:`Collapse a task in the ${n.dataName} gantt`,commandType:fe.Collapse,enabled:p},{name:"expand_all",description:`Expand all parent tasks in the ${n.dataName} gantt`,commandType:fe.ExpandAll,enabled:p},{name:"collapse_all",description:`Collapse all parent tasks in the ${n.dataName} gantt`,commandType:fe.CollapseAll,enabled:p},{name:"set_view",description:`Switch the ${n.dataName} gantt chart view`,commandType:fe.ChangeView,enabled:u},{name:"add_task",description:`Add a new task to the ${n.dataName} gantt`,commandType:fe.CreateTask,enabled:m},{name:"update_task",description:`Update an existing task in the ${n.dataName} gantt`,commandType:ye,enabled:m},{name:"delete_task",description:`Delete a task from the ${n.dataName} gantt`,commandType:fe.DeleteTask,enabled:m},{name:"select",description:`Select a task in the ${n.dataName} gantt`,commandType:xe,enabled:!!c.selectable||!!c.onSelectionChange||m},{name:"reorder_column",description:`Reorder a column in the ${n.dataName} gantt`,commandType:fe.ColumnReorder,enabled:g},{name:"resize_column",description:`Resize a column in the ${n.dataName} gantt`,commandType:fe.ColumnResize,enabled:f},{name:"show_column",description:`Show a hidden column in the ${n.dataName} gantt`,commandType:fe.ColumnShow,enabled:h},{name:"hide_column",description:`Hide a column in the ${n.dataName} gantt`,commandType:fe.ColumnHide,enabled:h}],x=t.current.webMcp,C="object"==typeof x&&null!==x&&"function"==typeof x.tools?x.tools:void 0,S={tname:i,columns:l,data:c.taskData},b=C?C(y,S):y,v=async(n,r)=>{const o=t.current;switch(n){case fe.Sort:return function(e,t,n){if(!e.field)return{content:[{type:"text",text:"Missing required argument: field"}],isError:!0};const r=e.field,o=e.dir||"asc",a=[{field:r,dir:o}];return t.current.onSortChange&&t.current.onSortChange({sort:a,field:r,target:n}),{content:[{type:"text",text:`Sorted by ${r} ${o}.`}]}}(r,t,e);case fe.ClearSort:return o.onSortChange&&o.onSortChange({sort:[],field:"",target:e}),{content:[{type:"text",text:"Sorting cleared."}]};case fe.Filter:return function(e,t,n){if(!e.field||!e.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const r=e.field,o=e.operator,a=e.value;return t.current.onFilterChange&&t.current.onFilterChange({filter:{logic:"and",filters:[{field:r,operator:o,value:a}]},target:n}),{content:[{type:"text",text:`Filter applied: ${r} ${o} "${I(a)}".`}]}}(r,t,e);case fe.ClearFilter:return o.onFilterChange&&o.onFilterChange({filter:{logic:"and",filters:[]},target:e}),{content:[{type:"text",text:"All filters cleared."}]};case fe.Expand:case fe.Collapse:case fe.ExpandAll:case fe.CollapseAll:return function(e,t,n,r){switch(e){case fe.Expand:return ve(!0,t,n,r);case fe.Collapse:return ve(!1,t,n,r);case fe.ExpandAll:return Te(!0,n,r);case fe.CollapseAll:return Te(!1,n,r);default:return{content:[{type:"text",text:`Unknown expand/collapse command: ${e}`}],isError:!0}}}(n,r,t,e);case fe.ChangeView:return function(e,t,n){const r=e.view;return r?(t.current.onViewChange&&t.current.onViewChange({value:r,target:n}),{content:[{type:"text",text:`Switched to ${r} view.`}]}):{content:[{type:"text",text:"Missing required argument: view"}],isError:!0}}(r,t,e);case fe.CreateTask:case fe.DeleteTask:case ye:{const e=function(e,t,n){var r;const o=n.current,a=o.onTaskChange||o.onDataStateChange;if(!a)return null;const i=Ce(o.taskModelFields);switch(e){case fe.CreateTask:{const e=t.title;return e?(a({created:[{[i.id]:Date.now(),[i.title]:e,[i.start]:t.start?new Date(t.start):void 0,[i.end]:t.end?new Date(t.end):void 0,[i.percentComplete]:null!=(r=t.percentComplete)?r:0}],updated:[],deleted:[]}),{content:[{type:"text",text:`Added task "${e}".`}]}):{content:[{type:"text",text:"Missing required argument: title"}],isError:!0}}case fe.DeleteTask:{const e=Se(o.taskData||[],i);let n;return t.field&&t.operator?n=e.find(e=>be(e[t.field],t.operator,t.value)):void 0!==t.id&&(n=e.find(e=>String(e[i.id])===String(t.id))),n?(a({created:[],updated:[],deleted:[n]}),{content:[{type:"text",text:`Deleted task "${I(n[i.title])}".`}]}):{content:[{type:"text",text:"No matching task found."}],isError:!0}}case ye:{const e=Se(o.taskData||[],i);let n;if(t.field&&t.operator?n=e.find(e=>be(e[t.field],t.operator,t.value)):void 0!==t.id&&(n=e.find(e=>String(e[i.id])===String(t.id))),!n)return{content:[{type:"text",text:"No matching task found."}],isError:!0};const r={...n};return void 0!==t.title&&(r[i.title]=t.title),void 0!==t.start&&(r[i.start]=new Date(t.start)),void 0!==t.end&&(r[i.end]=new Date(t.end)),void 0!==t.percentComplete&&(r[i.percentComplete]=t.percentComplete),a({created:[],updated:[r],deleted:[]}),{content:[{type:"text",text:`Updated task "${I(r[i.title])}".`}]}}default:return null}}(n,r,t);return e||{content:[{type:"text",text:"Task operations not supported."}],isError:!0}}case xe:{const n=t.current,o=Ce(n.taskModelFields),a=Se(n.taskData||[],o);let i;if(r.field&&r.operator?i=a.find(e=>be(e[r.field],r.operator,r.value)):void 0!==r.id&&(i=a.find(e=>String(e[o.id])===String(r.id))),!i)return{content:[{type:"text",text:"No matching task found."}],isError:!0};if(n.onSelectionChange)n.onSelectionChange({dataItem:i,dataItems:a,target:e});else{if(!n.onDataStateChange)return{content:[{type:"text",text:"Selection not supported. Add onSelectionChange or selectable prop."}],isError:!0};n.onDataStateChange({selected:[i],target:e})}return{content:[{type:"text",text:`Selected task "${I(i[o.title])}".`}]}}case fe.ColumnReorder:case fe.ColumnResize:case fe.ColumnShow:case fe.ColumnHide:return Ne(n,r,t,e,l)||{content:[{type:"text",text:`Unknown column command: ${n}`}],isError:!0};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of b){if(!e.enabled)continue;const t=e.inputSchema||he(e.commandType,l),n=e.commandType,a=e.execute;try{o.push(r.registerTool({name:i(e.name),description:e.description,inputSchema:t,execute:a?async e=>await a(e||{}):async e=>v(n,e||{})}))}catch{}}return o}};function je(e){return{type:"object",properties:{field:{type:"string",enum:e,description:"Column field name to group by"},dir:{type:"string",enum:["asc","desc"],description:"Sort direction within the group"}},required:["field"]}}function De(e){return{type:"object",properties:{field:{type:"string",enum:e,description:"Column field name to aggregate"},aggregate:{type:"string",enum:["sum","average","count","min","max"],description:"Aggregate function to apply"}},required:["field","aggregate"]}}function Ge(e){return{type:"object",properties:{field:{type:"string",enum:e,description:"The grouped field name"},value:{type:"string",description:"The group value to expand or collapse"}},required:["field","value"]}}const Ae={Filter:"GridFilter",ClearFilter:"GridClearFilter",Sort:"GridSort",ClearSort:"GridClearSort",Group:"GridGroup",ClearGroup:"GridClearGroup",Highlight:"GridHighlight",ClearHighlight:"GridClearHighlight",Select:"GridSelect",ClearSelect:"GridClearSelect",Page:"GridPage",PageSize:"GridPageSize",ColumnReorder:"GridColumnReorder",ColumnResize:"GridColumnResize",ColumnShow:"GridColumnShow",ColumnHide:"GridColumnHide",ColumnLock:"GridColumnLock",ColumnUnlock:"GridColumnUnlock",ExportPDF:"GridExportPDF",ExportCSV:"GridExportCSV",SelectAll:"GridSelectAll",DetailExpand:"GridDetailExpand",DetailCollapse:"GridDetailCollapse",DetailExpandAll:"GridDetailExpandAll",DetailCollapseAll:"GridDetailCollapseAll",GroupExpand:"GridGroupExpand",GroupCollapse:"GridGroupCollapse",GroupExpandAll:"GridGroupExpandAll",GroupCollapseAll:"GridGroupCollapseAll",SetAggregates:"GridSetAggregates",GetData:"GridGetData"};function Ve(e,t,n=[]){const r=t.map(e=>e.field).filter(Boolean),o=t.map(e=>e.id).filter(Boolean);switch(e){case Ae.Filter:return l(r);case Ae.ClearFilter:return{type:"object",properties:{}};case Ae.Sort:return s(r);case Ae.ClearSort:return{type:"object",properties:{}};case Ae.Group:return je(r);case Ae.ClearGroup:return{type:"object",properties:{}};case Ae.Highlight:return pe(r);case Ae.ClearHighlight:return{type:"object",properties:{}};case Ae.Select:return pe(r);case Ae.ClearSelect:return{type:"object",properties:{}};case Ae.Page:return{type:"object",properties:{page:{type:"number",description:"Page number (1-based)"}},required:["page"]};case Ae.PageSize:return p(n);case Ae.ColumnReorder:return se(o);case Ae.ColumnResize:return de(o);case Ae.ColumnShow:case Ae.ColumnHide:case Ae.ColumnLock:case Ae.ColumnUnlock:return le(o);case Ae.ExportPDF:case Ae.ExportCSV:return{type:"object",properties:{fileName:{type:"string",description:"Name of the exported file (optional)"}}};case Ae.SelectAll:return{type:"object",properties:{}};case Ae.DetailExpand:case Ae.DetailCollapse:return pe(r);case Ae.DetailExpandAll:case Ae.DetailCollapseAll:return{type:"object",properties:{}};case Ae.GroupExpand:case Ae.GroupCollapse:return Ge(r);case Ae.GroupExpandAll:case Ae.GroupCollapseAll:return{type:"object",properties:{}};case Ae.SetAggregates:return De(r);default:return{type:"object",properties:{}}}}function Me(e,t,n,r,o){const a=e.current;if(t)t({...n,target:o});else if(a.onDataStateChange){const e={filter:a.filter,sort:a.sort,skip:a.skip,take:a.take,group:a.group};a.onDataStateChange({dataState:{...e,...r},target:o})}}function Ie(e,t,n,r,o){const a=n.current;switch(e){case"GridSort":return function(e,t,n){if(!e.field)return{content:[{type:"text",text:"Missing required argument: field"}],isError:!0};const r=e.field,o=e.dir||"asc",a=[{field:r,dir:o}];return Me(t,t.current.onSortChange,{sort:a},{sort:a},n),{content:[{type:"text",text:`Sorted by ${r} ${o}.`}]}}(t,n,r);case"GridClearSort":return Me(n,a.onSortChange,{sort:[]},{sort:[]},r),{content:[{type:"text",text:"Sorting cleared."}]};case"GridFilter":return function(e,t,n,r){var o,a;if(!e.field||!e.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const i=e.field,c=e.operator,l=e.value,s=t.current,d={logic:"and",filters:[...null!=(a=null!=r?r:null==(o=s.filter)?void 0:o.filters)?a:[],{field:i,operator:c,value:l}]};return Me(t,s.onFilterChange,{filter:d},{filter:d,skip:0},n),{content:[{type:"text",text:`Filter applied: ${i} ${c} "${l}".`}]}}(t,n,r,o);case"GridClearFilter":{const e={logic:"and",filters:[]};return Me(n,a.onFilterChange,{filter:e},{filter:e,skip:0},r),{content:[{type:"text",text:"All filters cleared."}]}}case"GridGroup":return function(e,t,n){var r;if(!e.field)return{content:[{type:"text",text:"Missing required argument: field"}],isError:!0};const o=e.field,a=e.dir||"asc",i=t.current,c=[...null!=(r=i.group)?r:[],{field:o,dir:a}];return Me(t,i.onGroupChange,{group:c},{group:c},n),{content:[{type:"text",text:`Grouped by ${o} ${a}.`}]}}(t,n,r);case"GridClearGroup":return Me(n,a.onGroupChange,{group:[]},{group:[]},r),{content:[{type:"text",text:"Grouping cleared."}]};case"GridPage":return function(e,t,n){var r;const o=Number(e.page);if(!o||o<1)return{content:[{type:"text",text:"Invalid page number."}],isError:!0};const a=null!=(r=t.current.take)?r:10,i=(o-1)*a;return Me(t,t.current.onPageChange,{page:{skip:i,take:a}},{skip:i,take:a},n),{content:[{type:"text",text:`Navigated to page ${o}.`}]}}(t,n,r);case"GridPageSize":return function(e,t,n){const r=Number(e.pageSize);return!r||r<1?{content:[{type:"text",text:"Invalid page size."}],isError:!0}:(Me(t,t.current.onPageChange,{page:{skip:0,take:r}},{skip:0,take:r},n),{content:[{type:"text",text:`Page size set to ${r}.`}]})}(t,n,r);default:return null}}function qe(e){return Array.isArray(e)?e:e&&"object"==typeof e&&Array.isArray(e.data)?e.data:[]}function _e(e,t,n,r,o){switch(e){case"GridHighlight":return function(e,t,n){var r,o;if(!e.field||!e.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const a=e.field,i=e.operator,c=e.value,l=t.current.dataItemKey;if(!l)return{content:[{type:"text",text:"dataItemKey prop is required for highlighting."}],isError:!0};const s=null!=(o=null==(r=null==n?void 0:n.getLeafDataItems)?void 0:r.call(n))?o:qe(t.current.data),d={};for(const e of s){const t=e;if(Pe(t[a],i,c)){const e=Re(t[l]);null!==e&&(d[e]=!0)}}return t.current.onHighlightChange&&t.current.onHighlightChange({highlight:d}),{content:[{type:"text",text:`Highlighted rows where ${a} ${i} "${JSON.stringify(c)}".`}]}}(t,n,r);case"GridClearHighlight":return n.current.onHighlightChange&&n.current.onHighlightChange({highlight:{}}),{content:[{type:"text",text:"Highlights cleared."}]};case"GridSelect":return function(e,t,n){var r,o;if(!e.field||!e.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const a=e.field,i=e.operator,c=e.value,l=t.current.dataItemKey;if(!l)return{content:[{type:"text",text:"dataItemKey prop is required for selection."}],isError:!0};const s=null!=(o=null==(r=null==n?void 0:n.getLeafDataItems)?void 0:r.call(n))?o:qe(t.current.data),d={};for(const e of s){const t=e;if(Pe(t[a],i,c)){const e=Re(t[l]);null!==e&&(d[e]=!0)}}return t.current.onSelectionChange&&t.current.onSelectionChange({select:d,dataItem:null,dataItems:s,startDataItem:null,endDataItem:null,target:n}),{content:[{type:"text",text:`Selected rows where ${a} ${i} "${JSON.stringify(c)}".`}]}}(t,n,r);case"GridClearSelect":return n.current.onSelectionChange&&n.current.onSelectionChange({select:{},target:r}),{content:[{type:"text",text:"Selection cleared."}]};case"GridSelectAll":return function(e,t){var n,r;const o=e.current;if(!o.onHeaderSelectionChange&&!o.onSelectionChange)return{content:[{type:"text",text:"Selection not enabled."}],isError:!0};const a=null!=(r=null==(n=null==t?void 0:t.getLeafDataItems)?void 0:n.call(t))?r:[],i=o.dataItemKey;if(o.onHeaderSelectionChange){const e=i?Oe(a,i):{};o.onHeaderSelectionChange({select:e,field:void 0,dataItems:a,target:t})}else if(o.onSelectionChange){if(!i)return{content:[{type:"text",text:"dataItemKey prop is required for select all."}],isError:!0};o.onSelectionChange({select:Oe(a,i),dataItems:a,target:t})}return{content:[{type:"text",text:"All rows selected."}]}}(n,r);case"GridDetailExpand":case"GridDetailCollapse":case"GridDetailExpandAll":case"GridDetailCollapseAll":return function(e,t,n,r){var o,a;const i=n.current;if(!i.onDetailExpandChange)return{content:[{type:"text",text:"onDetailExpandChange callback not provided."}],isError:!0};const c=i.dataItemKey;if(!c)return{content:[{type:"text",text:"dataItemKey prop is required for detail expand."}],isError:!0};const l=null!=(a=null==(o=null==r?void 0:r.getLeafDataItems)?void 0:o.call(r))?a:[];switch(e){case"GridDetailExpandAll":return i.onDetailExpandChange({detailExpand:Oe(l,c),target:r}),{content:[{type:"text",text:"All detail rows expanded."}]};case"GridDetailCollapseAll":return i.onDetailExpandChange({detailExpand:{},target:r}),{content:[{type:"text",text:"All detail rows collapsed."}]};case"GridDetailExpand":case"GridDetailCollapse":return function(e,t,n,r,o,a){var i;if(!t.field||!t.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const c=t.field,l=t.operator,s=t.value,d="GridDetailExpand"===e,p={...null!=(i=n.detailExpand)?i:{}};for(const e of a){if(Pe(e[c],l,s)){const t=Re(e[o]);null!==t&&(d?p[t]=!0:delete p[t])}}return n.onDetailExpandChange&&n.onDetailExpandChange({detailExpand:p,target:r}),{content:[{type:"text",text:`Detail rows ${d?"expanded":"collapsed"} where ${c} ${l} "${s}".`}]}}(e,t,i,r,c,l);default:return{content:[{type:"text",text:`Unknown expand command: ${e}`}],isError:!0}}}(e,t,n,r);case"GridGroupExpand":case"GridGroupCollapse":case"GridGroupExpandAll":case"GridGroupCollapseAll":return function(e,t,n,r){var o,a,i;const c=n.current;if(!c.groupable)return{content:[{type:"text",text:"Grouping not enabled."}],isError:!0};if(!c.onGroupExpandChange)return{content:[{type:"text",text:"onGroupExpandChange callback not provided."}],isError:!0};switch(e){case"GridGroupExpandAll":return c.onGroupExpandChange({groupExpand:[],target:r}),{content:[{type:"text",text:"All groups expanded."}]};case"GridGroupCollapseAll":{if(!c.group||0===c.group.length)return{content:[{type:"text",text:"No active grouping."}],isError:!0};const e=null!=(a=null==(o=null==r?void 0:r.getLeafDataItems)?void 0:o.call(r))?a:qe(c.data),t=function(e,t){const n=[];for(const r of e){const e=new Set;for(const o of t){const t=o[r.field];e.has(t)||(e.add(t),n.push({field:r.field,value:t,expanded:!1}))}}return n}(c.group,e);return c.onGroupExpandChange({groupExpand:t,target:r}),{content:[{type:"text",text:"All groups collapsed."}]}}case"GridGroupExpand":case"GridGroupCollapse":{const n="GridGroupExpand"===e,o=function(e,t,n){if(!e.field||null==e.value)return null;const r=e.field,o=e.value,a="string"==typeof o||"number"==typeof o?String(o):JSON.stringify(o);return{updated:t.find(e=>e.field===r&&String(e.value)===a)?t.map(e=>e.field===r&&String(e.value)===a?{...e,expanded:n}:e):[...t,{field:r,value:o,expanded:n}],field:r,valueStr:a}}(t,null!=(i=c.groupExpand)?i:[],n);if(!o)return{content:[{type:"text",text:"Missing required arguments: field, value"}],isError:!0};c.onGroupExpandChange({groupExpand:o.updated,target:r});const a=n?"expanded":"collapsed";return{content:[{type:"text",text:`Group "${o.field}=${o.valueStr}" ${a}.`}]}}default:return{content:[{type:"text",text:`Unknown group expand command: ${e}`}],isError:!0}}}(e,t,n,r);case"GridSetAggregates":return function(e,t,n){const r=t.current;if(!r.groupable)return{content:[{type:"text",text:"Grouping not enabled — aggregates require grouped data."}],isError:!0};if(!r.group||0===r.group.length)return{content:[{type:"text",text:"No active grouping — group the data first."}],isError:!0};if(!e.field||!e.aggregate)return{content:[{type:"text",text:"Missing required arguments: field, aggregate"}],isError:!0};const o=e.field,a=e.aggregate,i={field:o,aggregate:a},c=r.group.map(e=>{var t;const n=null!=(t=e.aggregates)?t:[];return n.some(e=>e.field===o&&e.aggregate===a)?e:{...e,aggregates:[...n,i]}});return Me(t,r.onGroupChange,{group:c},{group:c},n),{content:[{type:"text",text:`Aggregate "${a}" added for column "${o}".`}]}}(t,n,r);case"GridExportPDF":return null!=r&&r.exportAsPdf&&r.exportAsPdf(),{content:[{type:"text",text:"PDF export triggered."}]};case"GridExportCSV":return null!=r&&r.saveAsCsv?r.saveAsCsv().then(()=>({content:[{type:"text",text:"CSV export triggered."}]})):{content:[{type:"text",text:"CSV export not available."}],isError:!0};case"GridColumnReorder":case"GridColumnResize":case"GridColumnShow":case"GridColumnHide":case"GridColumnLock":case"GridColumnUnlock":return function(e,t,n,r){const o=t.id;if(!o)return{content:[{type:"text",text:"Missing required argument: id"}],isError:!0};const a=n.current;if(!a.onColumnsStateChange||!r)return{content:[{type:"text",text:"Column state changes not supported."}],isError:!0};const i=a.columnsState||r.columns||[],c=e=>e.id===o||e.field===o;switch(e){case"GridColumnReorder":{const e=Number(t.position);if(Number.isNaN(e))return{content:[{type:"text",text:"Missing required argument: position"}],isError:!0};const n=i.findIndex(c),l=i[n];if(l){const t=[...i];t.splice(n,1),t.splice(e,0,l),a.onColumnsStateChange({columnsState:t.map((e,t)=>({...e,orderIndex:t})),target:r})}return{content:[{type:"text",text:`Column ${o} moved to position ${e}.`}]}}case"GridColumnResize":{const e=Number.parseInt(t.size,10);if(Number.isNaN(e))return{content:[{type:"text",text:"Missing required argument: size"}],isError:!0};const n=i.map(t=>c(t)?{...t,width:e}:t);return a.onColumnsStateChange({columnsState:n,target:r}),{content:[{type:"text",text:`Column ${o} resized to ${e}px.`}]}}case"GridColumnShow":{const e=i.map(e=>c(e)?{...e,hidden:!1}:e);return a.onColumnsStateChange({columnsState:e,target:r}),{content:[{type:"text",text:`Column ${o} is now visible.`}]}}case"GridColumnHide":{const e=i.map(e=>c(e)?{...e,hidden:!0}:e);return a.onColumnsStateChange({columnsState:e,target:r}),{content:[{type:"text",text:`Column ${o} is now hidden.`}]}}case"GridColumnLock":{const e=i.map(e=>c(e)?{...e,locked:!0}:e);return a.onColumnsStateChange({columnsState:e,target:r}),{content:[{type:"text",text:`Column ${o} locked.`}]}}case"GridColumnUnlock":{const e=i.map(e=>c(e)?{...e,locked:!1}:e);return a.onColumnsStateChange({columnsState:e,target:r}),{content:[{type:"text",text:`Column ${o} unlocked.`}]}}default:return null}}(e,t,n,r);case"GridAdd":case"GridUpdate":case"GridDelete":return function(e,t,n,r){const o=n.current;if(!o.onItemChange)return null;switch(e){case"GridAdd":return o.onItemChange({dataItem:t,dataIndex:-1,field:void 0,value:void 0,target:r}),{content:[{type:"text",text:"Record added."}]};case"GridUpdate":return o.onItemChange({dataItem:t,dataIndex:-1,field:void 0,value:void 0,target:r}),{content:[{type:"text",text:"Record updated."}]};case"GridDelete":return o.onItemChange({dataItem:t,dataIndex:-1,field:"_deleted",value:!0,target:r}),{content:[{type:"text",text:"Record deleted."}]};default:return null}}(e,t,n,r);default:return null}}function Re(e){return null==e?null:"string"==typeof e||"number"==typeof e?String(e):null}function Oe(e,t){const n={};for(const r of e){const e=Re(r[t]);null!==e&&(n[e]=!0)}return n}function Pe(e,t,n){switch(t){case"eq":return e===n||String(e)===String(n);case"neq":return e!==n&&String(e)!==String(n);case"contains":return"string"==typeof e&&"string"==typeof n&&e.toLowerCase().includes(n.toLowerCase());case"startswith":return"string"==typeof e&&"string"==typeof n&&e.toLowerCase().startsWith(n.toLowerCase());case"gt":return Number(e)>Number(n);case"gte":return Number(e)>=Number(n);case"lt":return Number(e)<Number(n);case"lte":return Number(e)<=Number(n);default:return!1}}const Fe={componentSuffix:"grid",createTools(e,t,n,r){const o=[],i=e=>`${n.groupName}_${e}`,c=t.current,l=function(e){const t=[];return a.Children.forEach(e,e=>{if(a.isValidElement(e)&&e.props.field){const n=e.props;t.push({field:n.field,id:n.id||n.field})}}),t}(c.children),s=!!c.onHighlightChange,d=!!c.selectable,p=d&&(!!c.onHeaderSelectionChange||!!c.dataItemKey),u=!!c.onDetailExpandChange,m=!!c.groupable&&!!c.onGroupExpandChange,g=!!c.pdf,f=!!c.csv,h=!!c.reorderable,y=!!c.resizable,x=!!c.onColumnsStateChange,C=!!c.onItemChange||!!c.editable,S=[{name:"sort",description:`Sort the ${n.dataName} grid by a column`,commandType:"GridSort",enabled:!(!c.sortable&&!c.columnMenu)},{name:"clear_sort",description:`Remove all sorting from the ${n.dataName} grid`,commandType:"GridClearSort",enabled:!(!c.sortable&&!c.columnMenu)},{name:"filter",description:`Filter the ${n.dataName} grid on a column`,commandType:"GridFilter",enabled:!(!c.filterable&&!c.columnMenu)},{name:"clear_filters",description:`Remove all filters from the ${n.dataName} grid`,commandType:"GridClearFilter",enabled:!(!c.filterable&&!c.columnMenu)},{name:"group",description:`Group the ${n.dataName} grid rows by a column`,commandType:"GridGroup",enabled:!(!c.groupable&&!c.columnMenu)},{name:"clear_group",description:`Remove all grouping from the ${n.dataName} grid`,commandType:"GridClearGroup",enabled:!(!c.groupable&&!c.columnMenu)},{name:"page",description:`Navigate to a specific page in the ${n.dataName} grid`,commandType:"GridPage",enabled:!!c.pageable},{name:"set_page_size",description:`Change the number of items per page in the ${n.dataName} grid`,commandType:"GridPageSize",enabled:!!c.pageable},{name:"highlight",description:`Visually highlight rows in the ${n.dataName} grid`,commandType:"GridHighlight",enabled:s},{name:"clear_highlight",description:`Remove all row highlighting from the ${n.dataName} grid`,commandType:"GridClearHighlight",enabled:s},{name:"select",description:`Select rows in the ${n.dataName} grid`,commandType:"GridSelect",enabled:d},{name:"clear_select",description:`Clear all row selections in the ${n.dataName} grid`,commandType:"GridClearSelect",enabled:d},{name:"select_all",description:`Select all rows in the ${n.dataName} grid`,commandType:"GridSelectAll",enabled:p},{name:"detail_expand",description:`Expand detail rows matching a condition in the ${n.dataName} grid`,commandType:"GridDetailExpand",enabled:u},{name:"detail_collapse",description:`Collapse detail rows matching a condition in the ${n.dataName} grid`,commandType:"GridDetailCollapse",enabled:u},{name:"detail_expand_all",description:`Expand all detail rows in the ${n.dataName} grid`,commandType:"GridDetailExpandAll",enabled:u},{name:"detail_collapse_all",description:`Collapse all detail rows in the ${n.dataName} grid`,commandType:"GridDetailCollapseAll",enabled:u},{name:"group_expand",description:`Expand a specific group in the ${n.dataName} grid`,commandType:"GridGroupExpand",enabled:m},{name:"group_collapse",description:`Collapse a specific group in the ${n.dataName} grid`,commandType:"GridGroupCollapse",enabled:m},{name:"group_expand_all",description:`Expand all groups in the ${n.dataName} grid`,commandType:"GridGroupExpandAll",enabled:m},{name:"group_collapse_all",description:`Collapse all groups in the ${n.dataName} grid`,commandType:"GridGroupCollapseAll",enabled:m},{name:"set_aggregates",description:`Add an aggregate function (sum, average, count, min, max) to a column in the ${n.dataName} grid. Requires active grouping.`,commandType:"GridSetAggregates",enabled:!!c.groupable},{name:"export_pdf",description:`Export the ${n.dataName} grid to PDF`,commandType:"GridExportPDF",enabled:g},{name:"export_csv",description:`Export the ${n.dataName} grid to CSV`,commandType:"GridExportCSV",enabled:f},{name:"reorder_column",description:`Reorder a column in the ${n.dataName} grid`,commandType:"GridColumnReorder",enabled:h},{name:"resize_column",description:`Resize a column in the ${n.dataName} grid`,commandType:"GridColumnResize",enabled:y},{name:"show_column",description:`Show a hidden column in the ${n.dataName} grid`,commandType:"GridColumnShow",enabled:x},{name:"hide_column",description:`Hide a column in the ${n.dataName} grid`,commandType:"GridColumnHide",enabled:x},{name:"lock_column",description:`Lock a column in the ${n.dataName} grid`,commandType:"GridColumnLock",enabled:x},{name:"unlock_column",description:`Unlock a column in the ${n.dataName} grid`,commandType:"GridColumnUnlock",enabled:x},{name:"add",description:`Add a new record to the ${n.dataName} grid`,commandType:"GridAdd",enabled:C},{name:"update",description:`Update a record in the ${n.dataName} grid`,commandType:"GridUpdate",enabled:C},{name:"delete",description:`Delete a record from the ${n.dataName} grid`,commandType:"GridDelete",enabled:C},{name:"get_data",description:`Read the data currently visible in the ${n.dataName} grid as JSON`,commandType:"GridGetData",enabled:!1}],b=t.current.webMcp,v="object"==typeof b&&null!==b&&"function"==typeof b.tools?b.tools:void 0,T={tname:i,columns:l,data:c.data},w=v?v(S,T):S;let $=null;const E=async(n,r)=>{var o,a,i,c,l,s,d;const p=null!=(a=null==$?void 0:$.filters)?a:null==(o=t.current.filter)?void 0:o.filters,u=Ie(n,r,t,e,p);if(u)return"GridFilter"===n&&r.field&&r.operator?$={logic:"and",filters:[...null!=(l=null!=(c=null==$?void 0:$.filters)?c:null==(i=t.current.filter)?void 0:i.filters)?l:[],{field:r.field,operator:r.operator,value:r.value}]}:"GridClearFilter"===n&&($={logic:"and",filters:[]}),u;const m=_e(n,r,t,e);if(m)return m;if("GridGetData"===n){$&&await new Promise(e=>setTimeout(e,100));const n=1e3,r=null!=(d=null==(s=null==e?void 0:e.getLeafDataItems)?void 0:s.call(e))?d:qe(t.current.data),o=Array.isArray(r)&&r.length>n?r.slice(0,n):r;return{content:[{type:"text",text:JSON.stringify(o!==r?{rows:o,truncated:!0,total:r.length}:r)}]}}return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of w){if(!e.enabled)continue;const t=Ve(e.commandType,l),n=e.commandType;try{o.push(r.registerTool({name:i(e.name),description:e.description,inputSchema:t,execute:async e=>E(n,e||{})}))}catch{}}return o}},Ue={Filter:"TreeListFilter",ClearFilter:"TreeListClearFilter",Sort:"TreeListSort",ClearSort:"TreeListClearSort",Select:"TreeListSelect",ClearSelect:"TreeListClearSelect",Page:"TreeListPage",PageSize:"TreeListPageSize",ColumnReorder:"TreeListColumnReorder",ColumnResize:"TreeListColumnResize",ColumnShow:"TreeListColumnShow",ColumnHide:"TreeListColumnHide",ColumnLock:"TreeListColumnLock",ColumnUnlock:"TreeListColumnUnlock",Expand:"TreeListExpand",Collapse:"TreeListCollapse",ExpandAll:"TreeListExpandAll",CollapseAll:"TreeListCollapseAll"};function ze(e,t,n=[]){const r=t.map(e=>e.field).filter(Boolean),o=t.map(e=>e.id).filter(Boolean);switch(e){case Ue.Filter:return l(r);case Ue.ClearFilter:return{type:"object",properties:{}};case Ue.Sort:return s(r);case Ue.ClearSort:return{type:"object",properties:{}};case Ue.Select:return pe(r);case Ue.ClearSelect:return{type:"object",properties:{}};case Ue.Page:return{type:"object",properties:{page:{type:"number",description:"Page number (1-based)"}},required:["page"]};case Ue.PageSize:return p(n);case Ue.ColumnReorder:return se(o);case Ue.ColumnResize:return de(o);case Ue.ColumnShow:case Ue.ColumnHide:case Ue.ColumnLock:case Ue.ColumnUnlock:return le(o);case Ue.Expand:case Ue.Collapse:return g(r);default:return{type:"object",properties:{}}}}function Le(e,t,n,r,o){const a=e.current;if(t)t({...n,target:o});else if(a.onDataStateChange){const e={filter:a.filter,sort:a.sort,skip:a.skip,take:a.take};a.onDataStateChange({dataState:{...e,...r},target:o})}}function Be(e){return"object"==typeof e&&null!==e}function He(e,t){const n=[],r=e=>{for(const o of e){if(!Be(o))continue;n.push(o);const e=o[t];Array.isArray(e)&&e.length>0&&r(e)}};return r(e),n}function We(e,t,n,r){const o=n.current;switch(e){case Ue.Sort:return function(e,t,n){if(!e.field)return{content:[{type:"text",text:"Missing required argument: field"}],isError:!0};const r=e.field,o=e.dir||"asc",a=[{field:r,dir:o}];return Le(t,t.current.onSortChange,{sort:a},{sort:a},n),{content:[{type:"text",text:`Sorted by ${r} ${o}.`}]}}(t,n,r);case Ue.ClearSort:return Le(n,o.onSortChange,{sort:[]},{sort:[]},r),{content:[{type:"text",text:"Sorting cleared."}]};case Ue.Filter:return function(e,t,n){var r,o;if(!e.field||!e.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const a=e.field,i=e.operator,c=e.value,l=t.current,s=[...Array.isArray(l.filter)?l.filter:null!=(o=null==(r=l.filter)?void 0:r.filters)?o:[],{field:a,operator:i,value:c}];return Le(t,l.onFilterChange,{filter:s},{filter:s,skip:0},n),{content:[{type:"text",text:`Filter applied: ${a} ${i} "${c}".`}]}}(t,n,r);case Ue.ClearFilter:{const e=[];return Le(n,o.onFilterChange,{filter:e},{filter:e,skip:0},r),{content:[{type:"text",text:"All filters cleared."}]}}case Ue.Page:return function(e,t,n){var r;const o=Number(e.page);if(!o||o<1)return{content:[{type:"text",text:"Invalid page number."}],isError:!0};const a=null!=(r=t.current.take)?r:10,i=(o-1)*a;return Le(t,t.current.onPageChange,{page:{skip:i,take:a}},{skip:i,take:a},n),{content:[{type:"text",text:`Navigated to page ${o}.`}]}}(t,n,r);case Ue.PageSize:return function(e,t,n){const r=Number(e.pageSize);return!r||r<1?{content:[{type:"text",text:"Invalid page size."}],isError:!0}:(Le(t,t.current.onPageChange,{page:{skip:0,take:r}},{skip:0,take:r},n),{content:[{type:"text",text:`Page size set to ${r}.`}]})}(t,n,r);default:return null}}function Je(e,t){return e.id===t||e.field===t}function Ke(e,t,n){return e.map(e=>Je(e,t)?n(e):e)}function Ze(e,t,n,r,o,a){var i;return a?(null==(i=n.onColumnsStateChange)||i.call(n,{columnsState:Ke(o,e,e=>({...e,hidden:t})),target:r}),{content:[{type:"text",text:`Column ${e} is now ${t?"hidden":"visible"}.`}]}):{content:[{type:"text",text:"Column state changes not supported."}],isError:!0}}function Ye(e,t,n,r,o,a){var i;return a?(null==(i=n.onColumnsStateChange)||i.call(n,{columnsState:Ke(o,e,e=>({...e,locked:t})),target:r}),{content:[{type:"text",text:`Column ${e} ${t?"locked":"unlocked"}.`}]}):{content:[{type:"text",text:"Column state changes not supported."}],isError:!0}}function Xe(e,t,n,r,o){const a=t.id;if(!a)return{content:[{type:"text",text:"Missing required argument: id"}],isError:!0};const i=n.current,c=!!i.onColumnsStateChange&&!!r,l=c&&(i.columnsState||(null==r?void 0:r.columns))||[];switch(e){case Ue.ColumnReorder:return function(e,t,n,r,o,a,i){var c;const l=Number(t.position);if(Number.isNaN(l))return{content:[{type:"text",text:"Missing required argument: position"}],isError:!0};if(i){const t=o.findIndex(t=>Je(t,e)),i=a[t];if(i){const e=[...a];e.splice(t,1),e.splice(l,0,i),null==(c=n.onColumnsStateChange)||c.call(n,{columnsState:e.map((e,t)=>({...e,orderIndex:t})),target:r})}}else{if(!n.onColumnReorder)return{content:[{type:"text",text:"Column reorder not supported."}],isError:!0};{const t=o.findIndex(t=>Je(t,e));n.onColumnReorder({oldIndex:t,newIndex:l,target:r})}}return{content:[{type:"text",text:`Column ${e} moved to position ${l}.`}]}}(a,t,i,r,o,l,c);case Ue.ColumnResize:return function(e,t,n,r,o,a,i){var c;const l=Number.parseInt(t.size,10);if(Number.isNaN(l))return{content:[{type:"text",text:"Missing required argument: size"}],isError:!0};if(i)null==(c=n.onColumnsStateChange)||c.call(n,{columnsState:Ke(a,e,e=>({...e,width:l})),target:r});else{if(!n.onColumnResize)return{content:[{type:"text",text:"Column resize not supported."}],isError:!0};{const t=o.findIndex(t=>Je(t,e)),a=(n.columns||[])[t],i=a&&a.width||0;n.onColumnResize({index:t,newWidth:l,oldWidth:i,end:!0,target:r})}}return{content:[{type:"text",text:`Column ${e} resized to ${l}px.`}]}}(a,t,i,r,o,l,c);case Ue.ColumnShow:return Ze(a,!1,i,r,l,c);case Ue.ColumnHide:return Ze(a,!0,i,r,l,c);case Ue.ColumnLock:return Ye(a,!0,i,r,l,c);case Ue.ColumnUnlock:return Ye(a,!1,i,r,l,c);default:return null}}function Qe(e,t,n,r){const o=n.current,a=o.subItemsField||"items",i=He(o.data||[],a);let c;if(t.field){const e=t.field,n=t.value;c=i.find(t=>String(t[e])===String(n))}else void 0!==t.id&&(c=i.find(e=>String(e.id)===String(t.id)));return c?(o.onExpandChange&&o.onExpandChange({dataItem:c,value:e,level:[],target:r}),{content:[{type:"text",text:e?"Row expanded.":"Row collapsed."}]}):{content:[{type:"text",text:"Item not found."}],isError:!0}}function et(e,t,n){const r=t.current,o=r.subItemsField||"items",a=He(r.data||[],o).filter(e=>{const t=e[o];return Array.isArray(t)&&t.length>0});if(r.onExpandChange)for(const t of a)r.onExpandChange({dataItem:t,value:e,level:[],target:n});return{content:[{type:"text",text:`${e?"Expanded":"Collapsed"} ${a.length} parent row(s).`}]}}function tt(e,t,n,r,o){switch(e){case Ue.Select:return function(e,t,n){if(!e.field||!e.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const r=e.field,o=e.operator;return t.current.onSelectionChange&&t.current.onSelectionChange({criteria:[{logic:"and",filters:[{field:r,operator:o,value:e.value}],cells:{}}],target:n}),{content:[{type:"text",text:`Selected rows where ${r} ${o} "${JSON.stringify(e.value)}".`}]}}(t,n,r);case Ue.ClearSelect:return n.current.onSelectionChange&&n.current.onSelectionChange({criteria:[],target:r}),{content:[{type:"text",text:"Selection cleared."}]};case Ue.ColumnReorder:case Ue.ColumnResize:case Ue.ColumnShow:case Ue.ColumnHide:case Ue.ColumnLock:case Ue.ColumnUnlock:return Xe(e,t,n,r,o);case Ue.Expand:case Ue.Collapse:case Ue.ExpandAll:case Ue.CollapseAll:return function(e,t,n,r){switch(e){case Ue.Expand:return Qe(!0,t,n,r);case Ue.Collapse:return Qe(!1,t,n,r);case Ue.ExpandAll:return et(!0,n,r);case Ue.CollapseAll:return et(!1,n,r);default:return null}}(e,t,n,r);default:return null}}const nt={componentSuffix:"treelist",createTools(e,t,n,r){const o=[],i=e=>`${n.groupName}_${e}`,c=t.current,l=function(e){const t=[];if(Array.isArray(e.columns))for(const n of e.columns)n.field&&t.push({field:n.field,id:n.id||n.field});return 0===t.length&&e.children&&a.Children.forEach(e.children,e=>{if(a.isValidElement(e)&&e.props.field){const n=e.props;t.push({field:n.field,id:n.id||n.field})}}),t}(c),s=!!c.onSelectionChange,d=!!c.reorderable,p=!!c.resizable,u=!!c.onColumnsStateChange,m=!!c.onExpandChange,g=c.pageable,f="object"==typeof g&&null!==g&&Array.isArray(g.pageSizes)?g.pageSizes:[],h=[{name:"sort",description:`Sort the ${n.dataName} tree list by a column`,commandType:Ue.Sort,enabled:!!c.sortable},{name:"clear_sort",description:`Remove all sorting from the ${n.dataName} tree list`,commandType:Ue.ClearSort,enabled:!!c.sortable},{name:"filter",description:`Filter the ${n.dataName} tree list on a column`,commandType:Ue.Filter,enabled:!!c.filterable},{name:"clear_filters",description:`Remove all filters from the ${n.dataName} tree list`,commandType:Ue.ClearFilter,enabled:!!c.filterable},{name:"page",description:`Navigate to a specific page in the ${n.dataName} tree list`,commandType:Ue.Page,enabled:!!c.pageable},{name:"set_page_size",description:`Change the number of items per page in the ${n.dataName} tree list`,commandType:Ue.PageSize,enabled:!!c.pageable},{name:"select",description:`Select rows in the ${n.dataName} tree list`,commandType:Ue.Select,enabled:s},{name:"clear_select",description:`Clear all row selections in the ${n.dataName} tree list`,commandType:Ue.ClearSelect,enabled:s},{name:"reorder_column",description:`Reorder a column in the ${n.dataName} tree list`,commandType:Ue.ColumnReorder,enabled:d},{name:"resize_column",description:`Resize a column in the ${n.dataName} tree list`,commandType:Ue.ColumnResize,enabled:p},{name:"show_column",description:`Show a hidden column in the ${n.dataName} tree list`,commandType:Ue.ColumnShow,enabled:u},{name:"hide_column",description:`Hide a column in the ${n.dataName} tree list`,commandType:Ue.ColumnHide,enabled:u},{name:"lock_column",description:`Lock a column in the ${n.dataName} tree list`,commandType:Ue.ColumnLock,enabled:u},{name:"unlock_column",description:`Unlock a column in the ${n.dataName} tree list`,commandType:Ue.ColumnUnlock,enabled:u},{name:"expand",description:`Expand a row in the ${n.dataName} tree list to show its children`,commandType:Ue.Expand,enabled:m},{name:"collapse",description:`Collapse a row in the ${n.dataName} tree list to hide its children`,commandType:Ue.Collapse,enabled:m},{name:"expand_all",description:`Expand all rows in the ${n.dataName} tree list`,commandType:Ue.ExpandAll,enabled:m},{name:"collapse_all",description:`Collapse all rows in the ${n.dataName} tree list`,commandType:Ue.CollapseAll,enabled:m}],y=t.current.webMcp,x="object"==typeof y&&null!==y&&"function"==typeof y.tools?y.tools:void 0,C={tname:i,columns:l,data:c.data},S=x?x(h,C):h,b=async(n,r)=>{const o=We(n,r,t,e);if(o)return o;return tt(n,r,t,e,l)||{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of S){if(!e.enabled)continue;const t=ze(e.commandType,l,f),n=e.commandType;try{o.push(r.registerTool({name:i(e.name),description:e.description,inputSchema:t,execute:async e=>b(n,e||{})}))}catch{}}return o}},rt={SelectTab:"TabStripSelectTab"};function ot(e){return e===rt.SelectTab?{type:"object",properties:{index:{type:"number",description:"The 0-based index of the visible tab to switch to"},title:{type:"string",description:"The title of the tab to switch to (case-insensitive)"}}}:{type:"object",properties:{}}}const at={componentSuffix:"tabstrip",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"select_tab",description:`Select a tab in the ${n.dataName} tab strip. Tab indices start at 0.`,commandType:rt.SelectTab,enabled:!!i.onSelect}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(e,n)=>{if(e===rt.SelectTab){const e=t.current,r=n.index;return e.onSelect&&e.onSelect({selected:r}),{content:[{type:"text",text:`Tab ${r} selected.`}]}}return{content:[{type:"text",text:`Unknown command: ${e}`}],isError:!0}};for(const e of d){if(!e.enabled)continue;const t=ot(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},it={Expand:"PanelBarExpand",Collapse:"PanelBarCollapse"};function ct(e){switch(e){case it.Expand:case it.Collapse:return{type:"object",properties:{id:{type:"string",description:"Unique panel id"}},required:["id"]};default:return{type:"object",properties:{}}}}const lt={componentSuffix:"panelbar",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"expand",description:`Expand a panel in the ${n.dataName} panel bar by its unique id.`,commandType:it.Expand,enabled:!!i.onSelect},{name:"collapse",description:`Collapse a panel in the ${n.dataName} panel bar by its unique id.`,commandType:it.Collapse,enabled:!!i.onSelect}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(e,n)=>{var r,o;const a=t.current,i=n.id;switch(e){case it.Expand:{const e=null!=(r=a.expanded)?r:[];if(!e.includes(i)){const t=[...e,i];a.onSelect&&a.onSelect({expanded:t})}return{content:[{type:"text",text:`Panel "${i}" expanded.`}]}}case it.Collapse:{const e=(null!=(o=a.expanded)?o:[]).filter(e=>e!==i);return a.onSelect&&a.onSelect({expanded:e}),{content:[{type:"text",text:`Panel "${i}" collapsed.`}]}}default:return{content:[{type:"text",text:`Unknown command: ${e}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=ct(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},st={Step:"StepperStep"};function dt(e,t){if(e===st.Step){const e={type:"number",description:"Zero-based step index to navigate to"};return void 0!==t&&(e.minimum=0,e.maximum=t),{type:"object",properties:{value:e},required:["value"]}}return{type:"object",properties:{}}}const pt={componentSuffix:"stepper",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=i.items?i.items.length-1:void 0,l=[{name:"step",description:`Navigate to a step in the ${n.dataName} stepper.`+(void 0!==c?` Valid values: 0-${c}.`:""),commandType:st.Step,enabled:!!i.onChange}],s=t.current.webMcp,d="object"==typeof s&&null!==s&&"function"==typeof s.tools?s.tools:void 0,p=d?d(l):l,u=async(e,n)=>{if(e===st.Step){const e=n.value,r=t.current;return r.onChange&&r.onChange({value:e}),{content:[{type:"text",text:`Navigated to step ${e}.`}]}}return{content:[{type:"text",text:`Unknown command: ${e}`}],isError:!0}};for(const e of p){if(!e.enabled)continue;const t=dt(e.commandType,c),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>u(n,e||{})}))}catch{}}return o}},ut={Open:"DrawerOpen",Close:"DrawerClose",SelectItem:"DrawerSelectItem"};function mt(e){return e===ut.SelectItem?{type:"object",properties:{text:{type:"string",description:"The text label of the drawer item to select"}},required:["text"]}:{type:"object",properties:{}}}function gt(e,t){const n=e[t];if("function"==typeof n)return n;const r=e.webMcp;return"object"==typeof r&&null!==r&&"function"==typeof r[t]?r[t]:void 0}const ft={componentSuffix:"drawer",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=!!gt(t.current,"onOverlayClick")||!!gt(t.current,"onExpandedChange"),c=[{name:"open",description:`Open the ${n.dataName} navigation drawer.`,commandType:ut.Open,enabled:i},{name:"close",description:`Close the ${n.dataName} navigation drawer.`,commandType:ut.Close,enabled:i},{name:"select_item",description:`Select an item in the ${n.dataName} navigation drawer by its text.`,commandType:ut.SelectItem,enabled:!!t.current.onSelect}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(e,n)=>{const r=t.current;switch(e){case ut.Open:{if(r.expanded)return{content:[{type:"text",text:"Drawer is already open."}]};const e=gt(r,"onExpandedChange")||gt(r,"onOverlayClick");return e&&e({expanded:!0}),{content:[{type:"text",text:"Drawer opened."}]}}case ut.Close:{if(!r.expanded)return{content:[{type:"text",text:"Drawer is already closed."}]};const e=gt(r,"onExpandedChange")||gt(r,"onOverlayClick");return e&&e({expanded:!1}),{content:[{type:"text",text:"Drawer closed."}]}}case ut.SelectItem:{const e=n.text;if(!e)return{content:[{type:"text",text:"Missing required argument: text"}],isError:!0};const t=(r.items||[]).find(t=>t.text===e);return t?(r.onSelect&&r.onSelect({itemTarget:{props:t}}),{content:[{type:"text",text:`Selected "${e}".`}]}):{content:[{type:"text",text:`Item "${e}" not found.`}],isError:!0}}default:return{content:[{type:"text",text:`Unknown command: ${e}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=mt(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},ht={Minimize:"WindowMinimize",Maximize:"WindowMaximize",Restore:"WindowRestore"};function yt(e){return{type:"object",properties:{}}}const xt={componentSuffix:"window",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"minimize",description:`Minimize the ${n.dataName} window`,commandType:ht.Minimize,enabled:!!i.onStageChange},{name:"maximize",description:`Maximize the ${n.dataName} window`,commandType:ht.Maximize,enabled:!!i.onStageChange},{name:"restore",description:`Restore the ${n.dataName} window to its default size`,commandType:ht.Restore,enabled:!!i.onStageChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(e,n)=>{const r=t.current;switch(e){case ht.Minimize:return r.onStageChange&&r.onStageChange({state:"MINIMIZED"}),{content:[{type:"text",text:"Window minimized."}]};case ht.Maximize:return r.onStageChange&&r.onStageChange({state:"MAXIMIZED"}),{content:[{type:"text",text:"Window maximized."}]};case ht.Restore:return r.onStageChange&&r.onStageChange({state:"DEFAULT"}),{content:[{type:"text",text:"Window restored."}]};default:return{content:[{type:"text",text:`Unknown command: ${e}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=yt(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n)}))}catch{}}return o}},Ct={SetValue:"DropDownListSetValue",Open:"DropDownListOpen",Close:"DropDownListClose"};function St(e){return e===Ct.SetValue?{type:"object",properties:{value:{type:"string",description:"The value to select from the available options."}},required:["value"]}:{type:"object",properties:{}}}const bt={componentSuffix:"dropdownlist",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"open",description:`Open the ${n.dataName} dropdown list`,commandType:Ct.Open,enabled:!!i.onOpen},{name:"select",description:`Select an item from the ${n.dataName} dropdown list`,commandType:Ct.SetValue,enabled:!!i.onChange},{name:"close",description:`Close the ${n.dataName} dropdown list`,commandType:Ct.Close,enabled:!!i.onClose}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{switch(n){case Ct.Open:{const n=t.current;return n.onOpen&&n.onOpen({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Dropdown opened."}]}}case Ct.SetValue:{const n=t.current,o=n.data||[],a=n.textField,i=r.value,c=o.find(e=>a&&"object"==typeof e&&null!==e?e[a]===i:e===i);return n.onChange&&n.onChange({value:null!=c?c:i,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Selected "${String(i)}".`}]}}case Ct.Close:{const n=t.current;return n.onClose&&n.onClose({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Dropdown closed."}]}}default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=St(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},vt={SetValue:"ComboBoxSetValue",Clear:"ComboBoxClear",Open:"ComboBoxOpen",Close:"ComboBoxClose"};function Tt(e){return e===vt.SetValue?{type:"object",properties:{value:{type:"string",description:"The value to select from the available options."}},required:["value"]}:{type:"object",properties:{}}}const wt="ComboBoxType",$t={componentSuffix:"combobox",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=!!i.onChange,l=[{name:"open",description:`Open the ${n.dataName} combo box popup`,commandType:vt.Open,enabled:!!i.onOpen},{name:"close",description:`Close the ${n.dataName} combo box popup`,commandType:vt.Close,enabled:!!i.onClose},{name:"type",description:`Type text to filter the ${n.dataName} combo box options`,commandType:wt,enabled:c},{name:"select",description:`Select an item from the ${n.dataName} combo box`,commandType:vt.SetValue,enabled:c},{name:"clear",description:`Clear the ${n.dataName} combo box selection`,commandType:vt.Clear,enabled:c}],s=t.current.webMcp,d="object"==typeof s&&null!==s&&"function"==typeof s.tools?s.tools:void 0,p=d?d(l):l,u=async(n,r)=>{const o=t.current;switch(n){case vt.Open:return o.onOpen&&o.onOpen({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Combo box opened."}]};case wt:return o.onChange&&o.onChange({value:r.text,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Typed "${String(r.text)}".`}]};case vt.SetValue:{const t=o.data||[],n=o.textField,a=r.value,i=t.find(e=>!(!n||"object"!=typeof e||null===e||e[n]!==a)||e===a),c=void 0===i?a:i;return o.onChange&&o.onChange({value:c,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Selected "${String(a)}".`}]}}case vt.Clear:return o.onChange&&o.onChange({value:null,syntheticEvent:null,target:e}),{content:[{type:"text",text:"Selection cleared."}]};case vt.Close:return o.onClose&&o.onClose({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Combo box closed."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of p){if(!e.enabled)continue;const t=e.commandType,n=t===wt?{type:"object",properties:{text:{type:"string",description:"Text to type for filtering"}},required:["text"]}:Tt(t);try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:n,execute:async e=>u(t,e||{})}))}catch{}}return o}},Et={SetValue:"MultiColumnComboBoxSetValue",Clear:"MultiColumnComboBoxClear",Open:"MultiColumnComboBoxOpen",Close:"MultiColumnComboBoxClose"};function Nt(e){return e===Et.SetValue?{type:"object",properties:{value:{type:"string",description:"The value to select from the available options."}},required:["value"]}:{type:"object",properties:{}}}const kt={componentSuffix:"multicolumncombobox",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=!!i.onChange,l=[{name:"open",description:`Open the ${n.dataName} multi-column combo box popup`,commandType:Et.Open,enabled:!!i.onOpen},{name:"close",description:`Close the ${n.dataName} multi-column combo box popup`,commandType:Et.Close,enabled:!!i.onClose},{name:"set_value",description:`Select an item from the ${n.dataName} multi-column combo box`,commandType:Et.SetValue,enabled:c},{name:"clear",description:`Clear the ${n.dataName} multi-column combo box selection`,commandType:Et.Clear,enabled:c}],s=t.current.webMcp,d="object"==typeof s&&null!==s&&"function"==typeof s.tools?s.tools:void 0,p=d?d(l):l,u=async(n,r)=>{const o=t.current;switch(n){case Et.Open:return o.onOpen&&o.onOpen({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Multi-column combo box opened."}]};case Et.SetValue:{const t=o.data||[],n=o.textField,a=r.value,i=t.find(e=>!(!n||"object"!=typeof e||null===e||e[n]!==a)||e===a),c=void 0===i?a:i;return o.onChange&&o.onChange({value:c,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Selected "${String(a)}".`}]}}case Et.Clear:return o.onChange&&o.onChange({value:null,syntheticEvent:null,target:e}),{content:[{type:"text",text:"Selection cleared."}]};case Et.Close:return o.onClose&&o.onClose({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Multi-column combo box closed."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of p){if(!e.enabled)continue;const t=e.commandType,n=Nt(t);try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:n,execute:async e=>u(t,e||{})}))}catch{}}return o}},jt={SetValue:"AutoCompleteSetValue",Clear:"AutoCompleteClear"};function Dt(e){return e===jt.SetValue?{type:"object",properties:{value:{type:"string",description:"The text value to set."}},required:["value"]}:{type:"object",properties:{}}}const Gt="AutoCompleteType",At={componentSuffix:"autocomplete",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=!!t.current.onChange,c=[{name:"type",description:`Type text in the ${n.dataName} autocomplete to trigger suggestions`,commandType:Gt,enabled:i},{name:"select",description:`Select a suggestion from the ${n.dataName} autocomplete`,commandType:jt.SetValue,enabled:i},{name:"clear",description:`Clear the ${n.dataName} autocomplete input`,commandType:jt.Clear,enabled:i}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;switch(n){case Gt:return o.onChange&&o.onChange({value:r.text,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Typed "${String(r.text)}".`}]};case jt.SetValue:return o.onChange&&o.onChange({value:r.value,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Selected "${String(r.value)}".`}]};case jt.Clear:return o.onChange&&o.onChange({value:"",syntheticEvent:null,target:e}),{content:[{type:"text",text:"Input cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=e.commandType,n=t===Gt?{type:"object",properties:{text:{type:"string",description:"Text to type"}},required:["text"]}:Dt(t);try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:n,execute:async e=>p(t,e||{})}))}catch{}}return o}},Vt={AddValue:"MultiSelectAddValue",RemoveValue:"MultiSelectRemoveValue",Clear:"MultiSelectClear",Open:"MultiSelectOpen",Close:"MultiSelectClose"};function Mt(e){switch(e){case Vt.AddValue:return{type:"object",properties:{value:{type:"string",description:"The value to add to the selection."}},required:["value"]};case Vt.RemoveValue:return{type:"object",properties:{value:{type:"string",description:"The value to remove from the selection."}},required:["value"]};default:return{type:"object",properties:{}}}}function It(e){return"object"==typeof e&&null!==e}const qt={componentSuffix:"multiselect",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current;if(!i.onChange)return o;const c=[{name:"add",description:`Add an item to the ${n.dataName} multi-select`,commandType:Vt.AddValue,enabled:!0},{name:"remove",description:`Remove an item from the ${n.dataName} multi-select`,commandType:Vt.RemoveValue,enabled:!0},{name:"clear",description:`Clear all selections from the ${n.dataName} multi-select`,commandType:Vt.Clear,enabled:!0},{name:"open",description:`Open the ${n.dataName} multi-select popup`,commandType:Vt.Open,enabled:!!i.onOpen},{name:"close",description:`Close the ${n.dataName} multi-select popup`,commandType:Vt.Close,enabled:!!i.onClose}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;switch(n){case Vt.AddValue:{const t=o.textField,n=o.dataItemKey,a=o.data||[],i=r.value,c=a.find(e=>!(!It(e)||!(t&&e[t]===i||n&&e[n]===i))||e===i),l=void 0===c?i:c,s=o.value||[];return o.onChange&&o.onChange({value:[...s,l],syntheticEvent:null,target:e}),{content:[{type:"text",text:`Added "${String(i)}".`}]}}case Vt.RemoveValue:{const t=o.textField,n=o.dataItemKey,a=r.value,i=(o.value||[]).filter(e=>(!It(e)||!(t&&e[t]===a||n&&e[n]===a))&&e!==a);return o.onChange&&o.onChange({value:i,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Removed "${String(a)}".`}]}}case Vt.Clear:return o.onChange&&o.onChange({value:[],syntheticEvent:null,target:e}),{content:[{type:"text",text:"All selections cleared."}]};case Vt.Open:return o.onOpen&&o.onOpen({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Multi-select popup opened."}]};case Vt.Close:return o.onClose&&o.onClose({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Multi-select popup closed."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=Mt(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},_t={SetValue:"DropDownTreeSetValue",Clear:"DropDownTreeClear",Open:"DropDownTreeOpen",Close:"DropDownTreeClose"};function Rt(e){return e===_t.SetValue?{type:"object",properties:{value:{type:"string",description:"The value to select from the available options."}},required:["value"]}:{type:"object",properties:{}}}const Ot="DropDownTreeExpand",Pt="DropDownTreeCollapse";function Ft(e,t,n,r){for(const o of e)if("object"==typeof o&&null!==o){const e=o;if(String(e[t])===String(n))return o;const a=e[r];if(Array.isArray(a)){const e=Ft(a,t,n,r);if(e)return e}}}const Ut={componentSuffix:"dropdowntree",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=!!i.onChange,l=[{name:"open",description:`Open the ${n.dataName} dropdown tree`,commandType:_t.Open,enabled:!!i.onOpen},{name:"expand",description:`Expand a node in the ${n.dataName} dropdown tree`,commandType:Ot,enabled:!!i.onExpandChange},{name:"collapse",description:`Collapse a node in the ${n.dataName} dropdown tree`,commandType:Pt,enabled:!!i.onExpandChange},{name:"select",description:`Select a node in the ${n.dataName} dropdown tree`,commandType:_t.SetValue,enabled:c},{name:"clear",description:`Clear the ${n.dataName} dropdown tree selection`,commandType:_t.Clear,enabled:c},{name:"close",description:`Close the ${n.dataName} dropdown tree`,commandType:_t.Close,enabled:!0}],s=t.current.webMcp,d="object"==typeof s&&null!==s&&"function"==typeof s.tools?s.tools:void 0,p=d?d(l):l,u=async(n,r)=>{switch(n){case _t.Open:{const n=t.current;return n.onOpen&&n.onOpen({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Dropdown tree opened."}]}}case Ot:{const n=t.current,o=n.dataItemKey||"id",a=n.subItemsField||"items",i=Ft(n.data||[],o,r.id,a);return n.onExpandChange&&i&&n.onExpandChange({item:i,expanded:!0,syntheticEvent:null,target:e}),{content:[{type:"text",text:i?"Node expanded.":`Node with id "${String(r.id)}" not found.`}]}}case Pt:{const n=t.current,o=n.dataItemKey||"id",a=n.subItemsField||"items",i=Ft(n.data||[],o,r.id,a);return n.onExpandChange&&i&&n.onExpandChange({item:i,expanded:!1,syntheticEvent:null,target:e}),{content:[{type:"text",text:i?"Node collapsed.":`Node with id "${String(r.id)}" not found.`}]}}case _t.SetValue:{const n=t.current,o=n.dataItemKey||"id",a=n.textField||"text",i=n.subItemsField||"items",c=n.data||[],l=Ft(c,o,r.value,i)||Ft(c,a,r.value,i);return n.onChange&&n.onChange({value:l||r.value,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Selected "${String(r.value)}".`}]}}case _t.Close:{const n=t.current;return n.onClose&&n.onClose({syntheticEvent:null,target:e}),{content:[{type:"text",text:"Dropdown tree closed."}]}}case _t.Clear:{const n=t.current;return n.onChange&&n.onChange({value:null,syntheticEvent:null,target:e}),{content:[{type:"text",text:"Selection cleared."}]}}default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of p){if(!e.enabled)continue;const t=e.commandType,n=t===Ot||t===Pt?{type:"object",properties:{id:{type:"string",description:"The data item key of the node to expand/collapse"}},required:["id"]}:Rt(t);try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:n,execute:async e=>u(t,e||{})}))}catch{}}return o}},zt={SetValue:"DatePickerSetValue",Clear:"DatePickerClear"};function Lt(e){return e===zt.SetValue?{type:"object",properties:{value:{type:"string",description:'The date value in ISO 8601 format (e.g. "2026-04-23").'}},required:["value"]}:{type:"object",properties:{}}}const Bt={componentSuffix:"datepicker",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the date in the ${n.dataName} date picker. Use ISO 8601 format (YYYY-MM-DD).`,commandType:zt.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear the ${n.dataName} date picker.`,commandType:zt.Clear,enabled:!!i.onChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;switch(n){case zt.SetValue:{const t=new Date(r.value);return o.onChange&&o.onChange({value:t,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Date set to ${t.toISOString().slice(0,10)}.`}]}}case zt.Clear:return o.onChange&&o.onChange({value:null,syntheticEvent:null,target:e}),{content:[{type:"text",text:"Date cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=Lt(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},Ht={SetValue:"DateRangePickerSetValue",Clear:"DateRangePickerClear"};function Wt(e){return e===Ht.SetValue?{type:"object",properties:{startValue:{type:"string",description:'The start date in ISO 8601 format (e.g. "2026-04-01").'},endValue:{type:"string",description:'The end date in ISO 8601 format (e.g. "2026-04-30").'}},required:["startValue","endValue"]}:{type:"object",properties:{}}}const Jt={componentSuffix:"daterangepicker",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the date range in the ${n.dataName} date range picker. Use ISO 8601 format.`,commandType:Ht.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear the ${n.dataName} date range picker.`,commandType:Ht.Clear,enabled:!!i.onChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;switch(n){case Ht.SetValue:{const t=new Date(r.startValue),n=new Date(r.endValue);return o.onChange&&o.onChange({value:{start:t,end:n},syntheticEvent:null,target:e}),{content:[{type:"text",text:`Range set: ${t.toISOString().slice(0,10)} to ${n.toISOString().slice(0,10)}.`}]}}case Ht.Clear:return o.onChange&&o.onChange({value:{start:null,end:null},syntheticEvent:null,target:e}),{content:[{type:"text",text:"Date range cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=Wt(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},Kt={SetValue:"TimePickerSetValue",Clear:"TimePickerClear"};function Zt(e){return e===Kt.SetValue?{type:"object",properties:{value:{type:"string",description:'The time value in ISO 8601 format (e.g. "14:30:00").'}},required:["value"]}:{type:"object",properties:{}}}const Yt={componentSuffix:"timepicker",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the time in the ${n.dataName} time picker. Use HH:mm or ISO format.`,commandType:Kt.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear the ${n.dataName} time picker.`,commandType:Kt.Clear,enabled:!!i.onChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;switch(n){case Kt.SetValue:{const t=r.value,n=new Date(t.includes("T")?t:"1970-01-01T"+t);return o.onChange&&o.onChange({value:n,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Time set to ${t}.`}]}}case Kt.Clear:return o.onChange&&o.onChange({value:null,syntheticEvent:null,target:e}),{content:[{type:"text",text:"Time cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=Zt(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},Xt={SetValue:"DateTimePickerSetValue",Clear:"DateTimePickerClear"};function Qt(e){return e===Xt.SetValue?{type:"object",properties:{value:{type:"string",description:'The date and time value in ISO 8601 format (e.g. "2026-04-23T14:30:00").'}},required:["value"]}:{type:"object",properties:{}}}const en={componentSuffix:"datetimepicker",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the date and time in the ${n.dataName} date-time picker. Use ISO 8601 format.`,commandType:Xt.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear the ${n.dataName} date-time picker.`,commandType:Xt.Clear,enabled:!!i.onChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;switch(n){case Xt.SetValue:{const t=new Date(r.value);return o.onChange&&o.onChange({value:t,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Date-time set to ${t.toISOString()}.`}]}}case Xt.Clear:return o.onChange&&o.onChange({value:null,syntheticEvent:null,target:e}),{content:[{type:"text",text:"Date-time cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=Qt(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},tn={Navigate:"CalendarNavigate",SelectDate:"CalendarSelectDate"};function nn(e){switch(e){case tn.Navigate:return{type:"object",properties:{date:{type:"string",description:'The date to navigate to (ISO 8601 format, e.g. "2026-05-15")'}},required:["date"]};case tn.SelectDate:return{type:"object",properties:{date:{type:"string",description:'The date to select (ISO 8601 format, e.g. "2026-05-15")'}},required:["date"]};default:return{type:"object",properties:{}}}}const rn={componentSuffix:"calendar",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"navigate",description:`Navigate the ${n.dataName} calendar to a specific month/year`,commandType:tn.Navigate,enabled:!!i.onChange},{name:"select_date",description:`Select a date on the ${n.dataName} calendar`,commandType:tn.SelectDate,enabled:!!i.onChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;switch(n){case tn.Navigate:{const t=new Date(r.date);return o.onChange&&o.onChange({value:t,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Navigated to ${t.toISOString().slice(0,10)}.`}]}}case tn.SelectDate:{const t=new Date(r.date);return o.onChange&&o.onChange({value:t,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Selected ${t.toISOString().slice(0,10)}.`}]}}default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=nn(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},on={SetValue:"NumericTextBoxSetValue",Clear:"NumericTextBoxClear",Increment:"NumericTextBoxIncrement",Decrement:"NumericTextBoxDecrement"};function an(e){return e===on.SetValue?{type:"object",properties:{value:{type:"number",description:"The numeric value to set."}},required:["value"]}:{type:"object",properties:{}}}const cn={componentSuffix:"numerictextbox",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the value of the ${n.dataName} numeric input`,commandType:on.SetValue,enabled:!!i.onChange},{name:"increment",description:`Increment the ${n.dataName} numeric input by one step`,commandType:on.Increment,enabled:!!i.onChange},{name:"decrement",description:`Decrement the ${n.dataName} numeric input by one step`,commandType:on.Decrement,enabled:!!i.onChange},{name:"clear",description:`Clear the ${n.dataName} numeric input`,commandType:on.Clear,enabled:!!i.onChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{var o,a,i,c;const l=t.current;switch(n){case on.SetValue:return l.onChange&&l.onChange({value:r.value,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Value set to ${String(r.value)}.`}]};case on.Increment:{const t=(null!=(o=l.value)?o:0)+(null!=(a=l.step)?a:1);return l.onChange&&l.onChange({value:t,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Incremented to ${t}.`}]}}case on.Decrement:{const t=(null!=(i=l.value)?i:0)-(null!=(c=l.step)?c:1);return l.onChange&&l.onChange({value:t,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Decremented to ${t}.`}]}}case on.Clear:return l.onChange&&l.onChange({value:null,syntheticEvent:null,target:e}),{content:[{type:"text",text:"Value cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=an(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},ln={SetValue:"SliderSetValue"};function sn(e){return{type:"object",properties:{value:{type:"number",description:"The numeric value to set."}},required:["value"]}}const dn={componentSuffix:"slider",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=void 0!==i.min&&void 0!==i.max?` Range: ${i.min}-${i.max}.`:"",l=[{name:"set_value",description:`Set the ${n.dataName} slider to a specific value.${c}`,commandType:ln.SetValue,enabled:!!i.onChange}],s=i.webMcp,d="object"==typeof s&&null!==s&&"function"==typeof s.tools?s.tools:void 0,p=d?d(l):l,u=async(n,r)=>{if(n===ln.SetValue){const n=t.current;return n.onChange&&n.onChange({value:r.value,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Slider set to ${String(r.value)}.`}]}}return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of p){if(!e.enabled)continue;const t=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:sn(),execute:async e=>u(t,e||{})}))}catch{}}return o}},pn={SetValue:"RangeSliderSetValue"};function un(e){return{type:"object",properties:{startValue:{type:"number",description:"The start value of the range."},endValue:{type:"number",description:"The end value of the range."}},required:["startValue","endValue"]}}const mn={componentSuffix:"rangeslider",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the ${n.dataName} range slider values.`,commandType:pn.SetValue,enabled:!!i.onChange}],l=i.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{if(n===pn.SetValue){const n=t.current;return n.onChange&&n.onChange({value:{start:r.startValue,end:r.endValue},syntheticEvent:null,target:e}),{content:[{type:"text",text:`Range set to ${String(r.startValue)}-${String(r.endValue)}.`}]}}return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of d){if(!e.enabled)continue;const t=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:un(),execute:async e=>p(t,e||{})}))}catch{}}return o}},gn={Toggle:"CheckBoxToggle",SetValue:"CheckBoxSetValue"};function fn(e){switch(e){case gn.Toggle:return{type:"object",properties:{}};case gn.SetValue:return{type:"object",properties:{value:{type:"boolean",description:"The boolean value to set (true or false)."}},required:["value"]};default:return{type:"object",properties:{}}}}const hn={componentSuffix:"checkbox",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"toggle",description:`Toggle the ${n.dataName} checkbox.`,commandType:gn.Toggle,enabled:!!i.onChange},{name:"set_value",description:`Set the ${n.dataName} checkbox to a specific checked or unchecked state.`,commandType:gn.SetValue,enabled:!!i.onChange}],l=i.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{var o,a;if(n===gn.Toggle){const n=t.current,r=null!=(a=null!=(o=n.checked)?o:n.value)&&a;return n.onChange&&n.onChange({value:!r,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Checkbox toggled to ${r?"unchecked":"checked"}.`}]}}if(n===gn.SetValue){const n=t.current,o=!!r.value;return n.onChange&&n.onChange({value:o,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Checkbox set to ${o?"checked":"unchecked"}.`}]}}return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of d){if(!e.enabled)continue;const t=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:fn(t),execute:async e=>p(t,e||{})}))}catch{}}return o}},yn={SetValue:"ColorPickerSetValue",Clear:"ColorPickerClear"};function xn(e){return e===yn.SetValue?{type:"object",properties:{value:{type:"string",description:'The color value as a hex string (e.g. "#ff6358") or named CSS color.'}},required:["value"]}:{type:"object",properties:{}}}const Cn={componentSuffix:"colorpicker",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the color in the ${n.dataName} color picker. Use hex format (e.g. #ff0000).`,commandType:yn.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear the ${n.dataName} color picker.`,commandType:yn.Clear,enabled:!!i.onChange}],l=i.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{switch(n){case yn.SetValue:{const n=t.current;return n.onChange&&n.onChange({value:r.value,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Color set to ${String(r.value)}.`}]}}case yn.Clear:{const n=t.current;return n.onChange&&n.onChange({value:"",syntheticEvent:null,target:e}),{content:[{type:"text",text:"Color cleared."}]}}default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:xn(t),execute:async e=>p(t,e||{})}))}catch{}}return o}},Sn={Toggle:"SwitchToggle",SetValue:"SwitchSetValue"};function bn(e){switch(e){case Sn.Toggle:return{type:"object",properties:{}};case Sn.SetValue:return{type:"object",properties:{value:{type:"boolean",description:"The boolean value to set (true or false)."}},required:["value"]};default:return{type:"object",properties:{}}}}const vn={componentSuffix:"switch",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"toggle",description:`Toggle the ${n.dataName} switch on or off.`,commandType:Sn.Toggle,enabled:!!i.onChange},{name:"set_value",description:`Set the ${n.dataName} switch to a specific on or off state.`,commandType:Sn.SetValue,enabled:!!i.onChange}],l=i.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{var o,a;if(n===Sn.Toggle){const n=t.current,r=null!=(a=null!=(o=n.checked)?o:n.value)&&a;return n.onChange&&n.onChange({value:!r,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Switch toggled to ${r?"off":"on"}.`}]}}if(n===Sn.SetValue){const n=t.current,o=!!r.value;return n.onChange&&n.onChange({value:o,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Switch set to ${o?"on":"off"}.`}]}}return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of d){if(!e.enabled)continue;const t=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:bn(t),execute:async e=>p(t,e||{})}))}catch{}}return o}},Tn={SetValue:"RatingSetValue",Clear:"RatingClear"};function wn(e){return e===Tn.SetValue?{type:"object",properties:{value:{type:"number",description:"The numeric value to set."}},required:["value"]}:{type:"object",properties:{}}}const $n={componentSuffix:"rating",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the ${n.dataName} rating to a specific value.`,commandType:Tn.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear the ${n.dataName} rating.`,commandType:Tn.Clear,enabled:!!i.onChange}],l=i.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{switch(n){case Tn.SetValue:{const n=t.current;return n.onChange&&n.onChange({value:r.value,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Rating set to ${String(r.value)}.`}]}}case Tn.Clear:{const n=t.current;return n.onChange&&n.onChange({value:null,syntheticEvent:null,target:e}),{content:[{type:"text",text:"Rating cleared."}]}}default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:wn(t),execute:async e=>p(t,e||{})}))}catch{}}return o}},En={SetValue:"TextAreaSetValue",Clear:"TextAreaClear"};function Nn(e){return e===En.SetValue?{type:"object",properties:{value:{type:"string",description:"The text value to set."}},required:["value"]}:{type:"object",properties:{}}}const kn={componentSuffix:"textarea",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set text in the ${n.dataName} text area.`,commandType:En.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear the ${n.dataName} text area.`,commandType:En.Clear,enabled:!!i.onChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;switch(n){case En.SetValue:return o.onChange&&o.onChange({value:r.value,syntheticEvent:null,target:e}),{content:[{type:"text",text:"Value set."}]};case En.Clear:return o.onChange&&o.onChange({value:"",syntheticEvent:null,target:e}),{content:[{type:"text",text:"Text area cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=Nn(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},jn={SetValue:"MaskedTextBoxSetValue",Clear:"MaskedTextBoxClear"};function Dn(e){return e===jn.SetValue?{type:"object",properties:{value:{type:"string",description:"The text value to set."}},required:["value"]}:{type:"object",properties:{}}}const Gn={componentSuffix:"maskedtextbox",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=i.mask?` Mask: ${i.mask}`:"",l=[{name:"set_value",description:`Enter a value in the ${n.dataName} masked input.${c}`,commandType:jn.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear the ${n.dataName} masked input.`,commandType:jn.Clear,enabled:!!i.onChange}],s=t.current.webMcp,d="object"==typeof s&&null!==s&&"function"==typeof s.tools?s.tools:void 0,p=d?d(l):l,u=async(n,r)=>{const o=t.current;switch(n){case jn.SetValue:return o.onChange&&o.onChange({value:r.value,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Value set to "${String(r.value)}".`}]};case jn.Clear:return o.onChange&&o.onChange({value:"",syntheticEvent:null,target:e}),{content:[{type:"text",text:"Masked input cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of p){if(!e.enabled)continue;const t=Dn(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>u(n,e||{})}))}catch{}}return o}},An={Clear:"SignatureClear"};function Vn(e){return{type:"object",properties:{}}}const Mn={componentSuffix:"signature",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=[{name:"clear",description:`Clear the ${n.dataName} signature pad`,commandType:An.Clear,enabled:!!t.current.onChange}],c=t.current.webMcp,l="object"==typeof c&&null!==c&&"function"==typeof c.tools?c.tools:void 0,s=l?l(i):i,d=async(n,r)=>{if(n===An.Clear){const n=t.current;return n.onChange&&n.onChange({value:"",syntheticEvent:null,target:e}),{content:[{type:"text",text:"Signature cleared."}]}}return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of s){if(!e.enabled)continue;const t=Vn(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>d(n)}))}catch{}}return o}},In={Clear:"UploadClear"};function qn(e){return{type:"object",properties:{}}}const _n={componentSuffix:"upload",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"clear",description:`Clear all files from the ${n.dataName} upload`,commandType:In.Clear,enabled:!!i.onRemove}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{if(n===In.Clear){const n=t.current;return n.onRemove&&n.onRemove({newState:[],affectedFiles:[],syntheticEvent:null,target:e}),{content:[{type:"text",text:"Upload files cleared."}]}}return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of d){if(!e.enabled)continue;const t=qn(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n)}))}catch{}}return o}},Rn={Transfer:"ListBoxTransfer",Reorder:"ListBoxReorder"};function On(e){switch(e){case Rn.Transfer:return{type:"object",properties:{direction:{type:"string",description:'The transfer direction: "to" (items to connected list box), "from" (items from connected list box), "allTo" (all items to connected list box), or "allFrom" (all items from connected list box)',enum:["to","from","allTo","allFrom"]},items:{type:"array",items:{type:"string"},description:'The names of the items to transfer. Required for "to" and "from" directions. Not needed for "allTo" and "allFrom".'}},required:["direction"]};case Rn.Reorder:return{type:"object",properties:{direction:{type:"string",description:'The direction to move the item: "up" or "down"',enum:["up","down"]},items:{type:"array",items:{type:"string"},description:"The names of the items to reorder. If not provided, operates on the currently selected items."}},required:["direction"]};default:return{type:"object",properties:{}}}}function Pn(e){if(e.onToolBarClick)return e.onToolBarClick;const t=e.webMcp;return"object"==typeof t&&null!==t&&"function"==typeof t.onToolBarClick?t.onToolBarClick:void 0}const Fn={componentSuffix:"listbox",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=!!Pn(t.current),c=[{name:"transfer",description:`Transfer items between the ${n.dataName} list boxes`,commandType:Rn.Transfer,enabled:i},{name:"reorder",description:`Reorder an item in the ${n.dataName} list box`,commandType:Rn.Reorder,enabled:i}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{switch(n){case Rn.Transfer:return function(e,t,n){const r=Pn(t.current),o={to:"transferTo",from:"transferFrom",allTo:"transferAllTo",allFrom:"transferAllFrom"}[e.direction]||e.direction;return r&&r({toolName:o,syntheticEvent:null,target:n}),{content:[{type:"text",text:`Transfer action "${String(e.direction)}" executed.`}]}}(r,t,e);case Rn.Reorder:return function(e,t,n){const r=Pn(t.current),o={up:"moveUp",down:"moveDown"}[e.direction]||e.direction;return r&&r({toolName:o,syntheticEvent:null,target:n}),{content:[{type:"text",text:`Reorder "${String(e.direction)}" executed.`}]}}(r,t,e);default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=On(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},Un={Page:"ListViewPage"};function zn(e){return e===Un.Page?{type:"object",properties:{page:{type:"number",description:"The 1-based page number to navigate to"}},required:["page"]}:{type:"object",properties:{}}}function Ln(e,t){const n=e[t];if("function"==typeof n)return n;const r=e.webMcp;return"object"==typeof r&&null!==r&&"function"==typeof r[t]?r[t]:void 0}function Bn(e,t){const n=e.webMcp;if("object"==typeof n&&null!==n)return n[t]}const Hn={componentSuffix:"listview",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"page",description:`Navigate to a specific page in the ${n.dataName} list view`,commandType:Un.Page,enabled:!!Ln(i,"onPageChange")},{name:"select",description:`Select an item in the ${n.dataName} list view`,commandType:"ListViewSelect",enabled:!!Ln(i,"onSelectionChange")}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;switch(n){case Un.Page:{const t=Number(r.page);if(!t||t<1)return{content:[{type:"text",text:"Invalid page number."}],isError:!0};const n=Bn(o,"take")||o.take||10,a=(t-1)*n,i=Ln(o,"onPageChange");return i&&i({page:{skip:a,take:n},syntheticEvent:null,target:e}),{content:[{type:"text",text:`Navigated to page ${t}.`}]}}case"ListViewSelect":{const t=Bn(o,"dataItemKey")||o.dataItemKey||"id",n=(o.data||[]).find(e=>function(e){return"object"==typeof e&&null!==e}(e)&&String(e[t])===String(r.id)),a=Ln(o,"onSelectionChange");return n?(a&&a({dataItem:n,target:e}),{content:[{type:"text",text:"Item selected."}]}):(a&&a({dataItem:{[t]:r.id},target:e}),{content:[{type:"text",text:`Selected item ${t}=${String(r.id)}.`}]})}default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=zn(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},Wn={Confirm:"DialogConfirm",Cancel:"DialogCancel"};function Jn(e){return{type:"object",properties:{}}}const Kn={componentSuffix:"dialog",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"confirm",description:`Click the confirm/OK button on the ${n.dataName} dialog`,commandType:Wn.Confirm,enabled:!0},{name:"cancel",description:`Click the cancel button on the ${n.dataName} dialog`,commandType:Wn.Cancel,enabled:!!i.onClose}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(e,n)=>{switch(e){case Wn.Confirm:return{content:[{type:"text",text:"Confirm action triggered."}]};case Wn.Cancel:{const e=t.current;return e.onClose&&e.onClose({}),{content:[{type:"text",text:"Dialog cancelled."}]}}default:return{content:[{type:"text",text:`Unknown command: ${e}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=Jn(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n)}))}catch{}}return o}},Zn={SelectItem:"MenuSelectItem"};function Yn(e){return e===Zn.SelectItem?{type:"object",properties:{text:{type:"string",description:"The text of the menu item to select"}},required:["text"]}:{type:"object",properties:{}}}const Xn={componentSuffix:"menu",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"select_item",description:`Select an item from the ${n.dataName} menu`,commandType:Zn.SelectItem,enabled:!!i.onSelect}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{const o=t.current;if(n===Zn.SelectItem){if(!r.text||"string"!=typeof r.text)return{content:[{type:"text",text:"Missing required argument: text"}],isError:!0};const t=r.text;return o.onSelect&&o.onSelect({item:{text:t},syntheticEvent:null,target:e}),{content:[{type:"text",text:`Selected "${t}".`}]}}return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of d){if(!e.enabled)continue;const t=Yn(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},Qn={Next:"ScrollViewNext",Previous:"ScrollViewPrevious",Navigate:"ScrollViewNavigate"};function er(e){return e===Qn.Navigate?{type:"object",properties:{index:{type:"number",description:"Zero-based slide index to navigate to"}},required:["index"]}:{type:"object",properties:{}}}function tr(e,t){var n;const r=null==(n=null==e?void 0:e.element)?void 0:n.querySelector(t);return!!r&&(r.click(),!0)}const nr={componentSuffix:"scrollview",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=[{name:"next",description:`Go to the next slide in the ${n.dataName} carousel.`,commandType:Qn.Next,enabled:!0},{name:"previous",description:`Go to the previous slide in the ${n.dataName} carousel.`,commandType:Qn.Previous,enabled:!0},{name:"navigate",description:`Jump to a specific slide in the ${n.dataName} carousel.`,commandType:Qn.Navigate,enabled:!0}],c=t.current.webMcp,l="object"==typeof c&&null!==c&&"function"==typeof c.tools?c.tools:void 0,s=l?l(i):i,d=async(t,n)=>{var r;const o=e;switch(t){case Qn.Next:return tr(o,".k-scrollview-next")?{content:[{type:"text",text:"Moved to next slide."}]}:{content:[{type:"text",text:"Already on the last slide."}],isError:!0};case Qn.Previous:return tr(o,".k-scrollview-prev")?{content:[{type:"text",text:"Moved to previous slide."}]}:{content:[{type:"text",text:"Already on the first slide."}],isError:!0};case Qn.Navigate:{const e=Number(n.index),t=null==(r=null==o?void 0:o.element)?void 0:r.querySelectorAll(".k-scrollview-nav .k-link");return t&&e>=0&&e<t.length?(t[e].click(),{content:[{type:"text",text:`Jumped to slide ${e+1}.`}]}):{content:[{type:"text",text:`Invalid slide index: ${e}`}],isError:!0}}default:return{content:[{type:"text",text:`Unknown command: ${t}`}],isError:!0}}};for(const e of s){if(!e.enabled)continue;const t=er(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>d(n,e||{})}))}catch{}}return o}},rr={Reorder:"SortableReorder"};function or(e){return e===rr.Reorder?{type:"object",properties:{oldIndex:{type:"number",description:"Current zero-based index of the item"},newIndex:{type:"number",description:"Target zero-based index to move the item to"}},required:["oldIndex","newIndex"]}:{type:"object",properties:{}}}const ar={componentSuffix:"sortable",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=!!i.onDragOver||!!i.onNavigate,l=[{name:"reorder",description:`Move an item to a new position in the ${n.dataName} sortable list`,commandType:rr.Reorder,enabled:c}],s=t.current.webMcp,d="object"==typeof s&&null!==s&&"function"==typeof s.tools?s.tools:void 0,p=d?d(l):l,u=async(n,r)=>{const o=t.current;if(n===rr.Reorder){const t=Number(r.oldIndex),n=Number(r.newIndex),a=o.data?[...o.data]:[],[i]=a.splice(t,1);return void 0!==i&&a.splice(n,0,i),o.onNavigate?o.onNavigate({oldIndex:t,newIndex:n,newState:a,syntheticEvent:null,target:e}):o.onDragOver&&o.onDragOver({oldIndex:t,newIndex:n,newState:a,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Moved item from position ${String(r.oldIndex)} to ${String(r.newIndex)}.`}]}}return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}};for(const e of p){if(!e.enabled)continue;const t=or(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>u(n,e||{})}))}catch{}}return o}},ir={SetCenter:"MapSetCenter",SetZoom:"MapSetZoom",AddMarker:"MapAddMarker",ClearMarkers:"MapClearMarkers"};function cr(e){switch(e){case ir.SetCenter:return{type:"object",properties:{lat:{type:"number",description:"Latitude"},lng:{type:"number",description:"Longitude"}},required:["lat","lng"]};case ir.SetZoom:return{type:"object",properties:{zoom:{type:"number",description:"Zoom level"}},required:["zoom"]};case ir.AddMarker:return{type:"object",properties:{lat:{type:"number",description:"Marker latitude"},lng:{type:"number",description:"Marker longitude"},title:{type:"string",description:"Marker tooltip text (optional)"}},required:["lat","lng"]};default:return{type:"object",properties:{}}}}const lr={componentSuffix:"map",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=[{name:"set_center",description:`Set the map center of the ${n.dataName} map`,commandType:ir.SetCenter,enabled:!0},{name:"set_zoom",description:`Set the zoom level of the ${n.dataName} map`,commandType:ir.SetZoom,enabled:!0},{name:"add_marker",description:`Add a marker to the ${n.dataName} map at a given coordinate`,commandType:ir.AddMarker,enabled:!0},{name:"clear_markers",description:`Remove all markers from the ${n.dataName} map`,commandType:ir.ClearMarkers,enabled:!0}],c=t.current.webMcp,l="object"==typeof c&&null!==c&&"function"==typeof c.tools?c.tools:void 0,s=l?l(i):i,d=[],p=async(t,n)=>{var r,o,a,i,c,l;switch(t){case ir.SetCenter:{const t=null==e?void 0:e.mapInstance;return t&&t.center([Number(n.lat),Number(n.lng)]),{content:[{type:"text",text:`Map centered on [${String(n.lat)}, ${String(n.lng)}].`}]}}case ir.SetZoom:{const t=null==e?void 0:e.mapInstance;return t&&t.zoom(Number(n.zoom)),{content:[{type:"text",text:`Zoom set to ${String(n.zoom)}.`}]}}case ir.AddMarker:{const t=e,s=(null==(a=null==(o=null==(r=null==t?void 0:t.mapInstance)?void 0:r.markers)?void 0:o.options)?void 0:a.locationField)||"location",p=(null==(l=null==(c=null==(i=null==t?void 0:t.mapInstance)?void 0:i.markers)?void 0:c.options)?void 0:l.titleField)||"title",u={[s]:[Number(n.lat),Number(n.lng)]};return"string"==typeof n.title&&(u[p]=n.title),d.push(u),"function"==typeof(null==t?void 0:t.loadMarkers)&&t.loadMarkers(d),{content:[{type:"text",text:`Marker added at [${String(n.lat)}, ${String(n.lng)}].`}]}}case ir.ClearMarkers:{d.length=0;const t=e;return"function"==typeof(null==t?void 0:t.loadMarkers)&&t.loadMarkers([]),{content:[{type:"text",text:"All markers cleared."}]}}default:return{content:[{type:"text",text:`Unknown command: ${t}`}],isError:!0}}};for(const e of s){if(!e.enabled)continue;const t=cr(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},sr={Show:"NotificationShow",Dismiss:"NotificationDismiss"};function dr(e){return e===sr.Show?{type:"object",properties:{message:{type:"string",description:"Notification message text"},type:{type:"string",description:"Notification type: none, success, error, warning, info"}},required:["message"]}:{type:"object",properties:{}}}const pr={componentSuffix:"notification",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=[{name:"show",description:`Show a notification in the ${n.dataName} notification group.`,commandType:sr.Show,enabled:!0},{name:"dismiss",description:`Dismiss all notifications in the ${n.dataName} notification group.`,commandType:sr.Dismiss,enabled:!0}],c=t.current.webMcp,l="object"==typeof c&&null!==c&&"function"==typeof c.tools?c.tools:void 0,s=l?l(i):i,d=async(n,r)=>{var o,a;switch(n){case sr.Show:return{content:[{type:"text",text:`Notification shown: "${String(r.message)}".`}]};case sr.Dismiss:return null==(a=(o=t.current).onClose)||a.call(o,{syntheticEvent:null,target:e}),{content:[{type:"text",text:"Notification dismissed."}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of s){if(!e.enabled)continue;const t=dr(e.commandType),n=e.commandType,i=e.execute;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:i?async e=>await i(e):async e=>d(n,e||{})}))}catch{}}return o}},ur={Drilldown:"ChartDrilldown",Export:"ChartExport"};function mr(e){return e===ur.Drilldown?{type:"object",properties:{category:{type:"string",description:"Category value to drill into"},seriesName:{type:"string",description:"Name of the series to drill down from"}},required:["category"]}:{type:"object",properties:{}}}const gr={componentSuffix:"chart",createTools(e,t,n,r){var o;const a=[],i=e=>`${n.groupName}_${e}`,c=t.current,l=[{name:"drilldown",description:`Drill down into the selected chart series or category of the ${n.dataName} chart`,commandType:ur.Drilldown,enabled:!!c.onDrilldown},{name:"export",description:`Export the ${n.dataName} chart as an image`,commandType:ur.Export,enabled:!(null==(o=null==e?void 0:e.chartInstance)||!o.exportVisual)}],s=t.current.webMcp,d="object"==typeof s&&null!==s&&"function"==typeof s.tools?s.tools:void 0,p=d?d(l,{tname:i}):l,u=async(n,r)=>{switch(n){case ur.Drilldown:return function(e,t,n){var r,o,a,i,c;const l={steps:[...null!=(o=null==(r=t.current.drilldownState)?void 0:r.steps)?o:[],{seriesName:"string"==typeof e.seriesName?e.seriesName:"",drilldownValue:e.category}]};return null==(c=(i=t.current).onDrilldown)||c.call(i,{nextState:l,currentState:null!=(a=t.current.drilldownState)?a:{steps:[]},value:e.category,target:n}),{content:[{type:"text",text:`Drilled down into category "${String(e.category)}".`}]}}(r,t,e);case ur.Export:return async function(e,t){var n,r;const o=null==(r=null==(n=null==t?void 0:t.chartInstance)?void 0:n.exportVisual)?void 0:r.call(n,{});if(!o)return{content:[{type:"text",text:"Chart visual not available for export."}],isError:!0};try{const{exportImage:e}=await(import("@progress/kendo-drawing")),{saveAs:t}=await(import("@progress/kendo-file-saver"));return t(await e(o),"chart.png"),{content:[{type:"text",text:"Chart exported as chart.png."}]}}catch{return{content:[{type:"text",text:"Export failed — @progress/kendo-drawing or @progress/kendo-file-saver not available."}],isError:!0}}}(0,e);default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of p){if(!e.enabled)continue;const t=mr(e.commandType),n=e.commandType;try{a.push(r.registerTool({name:i(e.name),description:e.description,inputSchema:t,execute:async e=>u(n,e||{})}))}catch{}}return a}},fr={AddCard:"TaskBoardAddCard",MoveCard:"TaskBoardMoveCard",EditCard:"TaskBoardEditCard",DeleteCard:"TaskBoardDeleteCard"};function hr(e){switch(e){case fr.AddCard:return{type:"object",properties:{title:{type:"string",description:"Card title"},status:{type:"string",description:"Target column/status identifier"},description:{type:"string",description:"Card description (optional)"}},required:["title","status"]};case fr.MoveCard:return{type:"object",properties:{cardId:{type:"string",description:"Identifier of the card to move"},targetStatus:{type:"string",description:"Target column/status identifier"}},required:["cardId","targetStatus"]};case fr.EditCard:return{type:"object",properties:{cardId:{type:"string",description:"Identifier of the card to edit"},title:{type:"string",description:"New card title (optional)"},description:{type:"string",description:"New card description (optional)"}},required:["cardId"]};case fr.DeleteCard:return{type:"object",properties:{cardId:{type:"string",description:"Identifier of the card to delete"}},required:["cardId"]};default:return{type:"object",properties:{}}}}const yr={componentSuffix:"taskboard",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"add_card",description:`Add a new card to a column in the ${n.dataName} task board`,commandType:fr.AddCard,enabled:!!i.onCardAdd},{name:"move_card",description:`Move a card to a different column in the ${n.dataName} task board`,commandType:fr.MoveCard,enabled:!!i.onCardMove},{name:"edit_card",description:`Edit a card's details in the ${n.dataName} task board`,commandType:fr.EditCard,enabled:!!i.onCardChange},{name:"delete_card",description:`Delete a card from the ${n.dataName} task board`,commandType:fr.DeleteCard,enabled:!!i.onCardRemove}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(n,r)=>{var o,a,i,c,l,s,d,p;switch(n){case fr.AddCard:return null==(a=(o=t.current).onCardAdd)||a.call(o,{item:{title:r.title,status:r.status,description:r.description},syntheticEvent:null,target:e}),{content:[{type:"text",text:`Card "${String(r.title)}" added to column "${String(r.status)}".`}]};case fr.MoveCard:return null==(c=(i=t.current).onCardMove)||c.call(i,{item:{id:r.cardId},status:r.targetStatus,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Card "${String(r.cardId)}" moved to "${String(r.targetStatus)}".`}]};case fr.EditCard:return null==(s=(l=t.current).onCardChange)||s.call(l,{item:{id:r.cardId,title:r.title,description:r.description},syntheticEvent:null,target:e}),{content:[{type:"text",text:`Card "${String(r.cardId)}" updated.`}]};case fr.DeleteCard:return null==(p=(d=t.current).onCardRemove)||p.call(d,{item:{id:r.cardId},syntheticEvent:null,target:e}),{content:[{type:"text",text:`Card "${String(r.cardId)}" deleted.`}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=hr(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},xr={SetRows:"PivotSetRows",SetColumns:"PivotSetColumns",SetMeasures:"PivotSetMeasures",Expand:"PivotExpand",Collapse:"PivotCollapse"};function Cr(e){switch(e){case xr.SetRows:case xr.SetColumns:case xr.SetMeasures:return{type:"object",properties:{fields:{type:"array",items:{type:"string"},description:"Array of field names"}},required:["fields"]};case xr.Expand:case xr.Collapse:return{type:"object",properties:{field:{type:"string",description:"Field name of the header"},value:{type:"string",description:"Value of the header"}},required:["field","value"]};default:return{type:"object",properties:{}}}}const Sr={componentSuffix:"pivotgrid",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=[{name:"set_rows",description:`Set the row fields of the ${n.dataName} pivot grid`,commandType:xr.SetRows,enabled:!0},{name:"set_columns",description:`Set the column fields of the ${n.dataName} pivot grid`,commandType:xr.SetColumns,enabled:!0},{name:"set_measures",description:`Set the measure fields of the ${n.dataName} pivot grid`,commandType:xr.SetMeasures,enabled:!0},{name:"expand",description:`Expand a row or column header in the ${n.dataName} pivot grid`,commandType:xr.Expand,enabled:!0},{name:"collapse",description:`Collapse a row or column header in the ${n.dataName} pivot grid`,commandType:xr.Collapse,enabled:!0}],c=t.current.webMcp,l="object"==typeof c&&null!==c&&"function"==typeof c.tools?c.tools:void 0,s=l?l(i):i,d=async(n,r)=>{var o,a,i,c,l,s,d,p,u,m;switch(n){case xr.SetRows:return null==(a=(o=t.current).onConfigChange)||a.call(o,{type:"rows",fields:r.fields,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Pivot grid rows set to: ${JSON.stringify(r.fields)}.`}]};case xr.SetColumns:return null==(c=(i=t.current).onConfigChange)||c.call(i,{type:"columns",fields:r.fields,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Pivot grid columns set to: ${JSON.stringify(r.fields)}.`}]};case xr.SetMeasures:return null==(s=(l=t.current).onConfigChange)||s.call(l,{type:"measures",fields:r.fields,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Pivot grid measures set to: ${JSON.stringify(r.fields)}.`}]};case xr.Expand:return null==(p=(d=t.current).onExpandChange)||p.call(d,{field:r.field,value:r.value,expanded:!0,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Expanded "${String(r.field)}: ${String(r.value)}".`}]};case xr.Collapse:return null==(m=(u=t.current).onExpandChange)||m.call(u,{field:r.field,value:r.value,expanded:!1,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Collapsed "${String(r.field)}: ${String(r.value)}".`}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of s){if(!e.enabled)continue;const t=e.inputSchema||Cr(e.commandType),n=e.commandType,i=e.execute;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:i?async e=>await i(e||{}):async e=>d(n,e||{})}))}catch{}}return o}},br={SendPrompt:"AIPromptSendPrompt",SetSuggestions:"AIPromptSetSuggestions"};function vr(e){switch(e){case br.SendPrompt:return{type:"object",properties:{prompt:{type:"string",description:"The prompt text to send"}},required:["prompt"]};case br.SetSuggestions:return{type:"object",properties:{suggestions:{type:"array",items:{type:"string"},description:"Array of suggestion strings to display"}},required:["suggestions"]};default:return{type:"object",properties:{}}}}const Tr={componentSuffix:"aiprompt",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=[{name:"send_prompt",description:`Send a prompt to the ${n.dataName} AI prompt component.`,commandType:br.SendPrompt,enabled:!0},{name:"set_suggestions",description:`Set the prompt suggestions shown in the ${n.dataName} AI prompt component.`,commandType:br.SetSuggestions,enabled:!0}],c=t.current.webMcp,l="object"==typeof c&&null!==c&&"function"==typeof c.tools?c.tools:void 0,s=l?l(i):i,d=async(n,r)=>{var o,a;switch(n){case br.SendPrompt:return null==(a=(o=t.current).onRequest)||a.call(o,{value:r.prompt,syntheticEvent:null,target:e}),{content:[{type:"text",text:`Prompt sent: "${String(r.prompt)}".`}]};case br.SetSuggestions:return{content:[{type:"text",text:`Suggestions updated: ${JSON.stringify(r.suggestions)}.`}]};default:return{content:[{type:"text",text:`Unknown command: ${n}`}],isError:!0}}};for(const e of s){if(!e.enabled)continue;const t=vr(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>d(n,e||{})}))}catch{}}return o}},wr={SetValue:"OTPInputSetValue",Clear:"OTPInputClear"};function $r(e){return e===wr.SetValue?{type:"object",properties:{value:{type:"string",description:"The text value to set."}},required:["value"]}:{type:"object",properties:{}}}const Er={componentSuffix:"otpinput",createTools(e,t,n,r){const o=[],a=e=>`${n.groupName}_${e}`,i=t.current,c=[{name:"set_value",description:`Set the value of the ${n.dataName} OTP input. Use spaces for unfilled cells (e.g. "12 4" for a 4-cell input with the third cell empty).`,commandType:wr.SetValue,enabled:!!i.onChange},{name:"clear",description:`Clear all cells of the ${n.dataName} OTP input.`,commandType:wr.Clear,enabled:!!i.onChange}],l=t.current.webMcp,s="object"==typeof l&&null!==l&&"function"==typeof l.tools?l.tools:void 0,d=s?s(c):c,p=async(t,n)=>{switch(t){case wr.SetValue:{const t=n.value;return null==t?{content:[{type:"text",text:"Missing required argument: value"}],isError:!0}:(i.onChange&&i.onChange({value:t,target:e}),{content:[{type:"text",text:`Value set to "${t}".`}]})}case wr.Clear:return i.onChange&&i.onChange({value:"",target:e}),{content:[{type:"text",text:"Value cleared."}]};default:return{content:[{type:"text",text:`Unknown command: ${t}`}],isError:!0}}};for(const e of d){if(!e.enabled)continue;const t=$r(e.commandType),n=e.commandType;try{o.push(r.registerTool({name:a(e.name),description:e.description,inputSchema:t,execute:async e=>p(n,e||{})}))}catch{}}return o}},Nr=new Map([["textbox",j],["button",A],["treeview",R],["chat",F],["form",L],["editor",W],["spreadsheet",Y],["scheduler",ce],["gantt",ke],["grid",Fe],["treelist",nt],["tabstrip",at],["panelbar",lt],["stepper",pt],["drawer",ft],["window",xt],["dropdownlist",bt],["combobox",$t],["multicolumncombobox",kt],["autocomplete",At],["multiselect",qt],["dropdowntree",Ut],["datepicker",Bt],["daterangepicker",Jt],["timepicker",Yt],["datetimepicker",en],["calendar",rn],["numerictextbox",cn],["slider",dn],["rangeslider",mn],["colorpicker",Cn],["switch",vn],["checkbox",hn],["rating",$n],["textarea",kn],["maskedtextbox",Gn],["signature",Mn],["upload",_n],["listbox",Fn],["listview",Hn],["dialog",Kn],["menu",Xn],["scrollview",nr],["sortable",ar],["map",lr],["notification",pr],["chart",gr],["taskboard",yr],["pivotgrid",Sr],["aiprompt",Tr],["otpinput",Er]]);e.AIPromptCommands=br,e.AutoCompleteCommands=jt,e.ButtonCommands=D,e.CalendarCommands=tn,e.ChartCommands=ur,e.ChatCommands=O,e.CheckBoxCommands=gn,e.ColorPickerCommands=yn,e.ComboBoxCommands=vt,e.DatePickerCommands=zt,e.DateRangePickerCommands=Ht,e.DateTimePickerCommands=Xt,e.DialogCommands=Wn,e.DrawerCommands=ut,e.DropDownListCommands=Ct,e.DropDownTreeCommands=_t,e.EditorCommands=B,e.FILTER_OPERATORS=i,e.FormCommands=U,e.GanttCommands=fe,e.GridCommands=Ae,e.ListBoxCommands=Rn,e.ListViewCommands=Un,e.MapCommands=ir,e.MaskedTextBoxCommands=jn,e.MenuCommands=Zn,e.MultiColumnComboBoxCommands=Et,e.MultiSelectCommands=Vt,e.NotificationCommands=sr,e.NumericTextBoxCommands=on,e.OTPInputCommands=wr,e.PanelBarCommands=it,e.PivotGridCommands=xr,e.RangeSliderCommands=pn,e.RatingCommands=Tn,e.SchedulerCommands=re,e.ScrollViewCommands=Qn,e.SignatureCommands=An,e.SliderCommands=ln,e.SortableCommands=rr,e.SpreadsheetCommands=J,e.StepperCommands=st,e.SwitchCommands=Sn,e.TabStripCommands=rt,e.TaskBoardCommands=fr,e.TextAreaCommands=En,e.TextBoxCommands=N,e.TimePickerCommands=Kt,e.TreeListCommands=Ue,e.TreeViewCommands=V,e.UploadCommands=In,e.WebMcpProvider=({children:e,dataName:t})=>{const r=a.useRef(t);r.current=t;const o=a.useCallback((e,t,o,a)=>{const i=Nr.get(e);if(!i)return()=>{};const c=n.getModelContext();if(!c)return()=>{};const l=a,s=("string"==typeof(null==l?void 0:l.dataName)?l.dataName:void 0)||r.current;if(!s)return()=>{};const d={dataName:s,groupName:`${s}_${i.componentSuffix}`},p=i.createTools(t,o,d,c);return()=>{p.forEach(e=>null==e?void 0:e.unregister())}},[]),i=a.useMemo(()=>({register:o}),[o]);return a.createElement(n.WebMcpContext.Provider,{value:i},e)},e.WindowCommands=ht,e.aipromptAdapter=Tr,e.autoCompleteAdapter=At,e.buildExpandCollapsePayload=function(e){return m(e)},e.buildFilterPayload=m,e.buildGridCommandJson=function(e,t){const n={type:e};switch(e){case"GridFilter":if(!t.field||!t.operator)return null;n.filter={logic:"and",filters:[{field:t.field,operator:t.operator,value:t.value}]};break;case"GridSort":if(!t.field)return null;n.sort={field:t.field,dir:t.dir};break;case"GridGroup":if(!t.field)return null;n.group={field:t.field,dir:t.dir||"asc"};break;case"GridHighlight":case"GridSelect":return function(e,t){if(!t.field||!t.operator)return null;const n="GridHighlight"===e?"highlight":"select",r={logic:"and",filters:[{field:t.field,operator:t.operator,value:t.value}]};return t.cells&&(r.cells=t.cells.reduce((e,t)=>(e[t]=!0,e),{})),JSON.stringify({commands:[{type:e,[n]:r}]})}(e,t);case"GridPage":n.page=t.page;break;case"GridPageSize":n.pageSize=t.pageSize;break;case"GridColumnReorder":n.id=t.id,n.position=t.position;break;case"GridColumnResize":n.id=t.id,n.size=t.size;break;case"GridColumnShow":case"GridColumnHide":case"GridColumnLock":case"GridColumnUnlock":n.id=t.id;break;case"GridExportExcel":case"GridExportPDF":case"GridExportCSV":t.fileName&&(n.fileName=t.fileName)}return JSON.stringify({commands:[n]})},e.buildRowMatchPayload=function(e){if(!e.field||!e.operator)return null;const t={logic:"and",filters:[{field:e.field,operator:e.operator,value:e.value}]};return e.cells&&(t.cells=e.cells.reduce((e,t)=>(e[t]=!0,e),{})),t},e.buildSortPayload=function(e){return e.field?{field:e.field,dir:e.dir}:null},e.buttonAdapter=A,e.calendarAdapter=rn,e.chartAdapter=gr,e.chatAdapter=F,e.checkboxAdapter=hn,e.colorPickerAdapter=Cn,e.comboBoxAdapter=$t,e.datePickerAdapter=Bt,e.dateRangePickerAdapter=Jt,e.dateTimePickerAdapter=en,e.dialogAdapter=Kn,e.drawerAdapter=ft,e.dropDownListAdapter=bt,e.dropDownTreeAdapter=Ut,e.editorAdapter=W,e.formAdapter=L,e.ganttAdapter=ke,e.getAIPromptToolSchema=vr,e.getAggregateSchema=De,e.getAutoCompleteToolSchema=Dt,e.getBooleanValueSchema=y,e.getButtonToolSchema=G,e.getCalendarToolSchema=nn,e.getChartToolSchema=mr,e.getChatToolSchema=P,e.getCheckBoxToolSchema=fn,e.getColorPickerToolSchema=xn,e.getColorValueSchema=T,e.getColumnIdSchema=le,e.getColumnReorderSchema=se,e.getColumnResizeSchema=de,e.getComboBoxToolSchema=Tt,e.getDatePickerToolSchema=Lt,e.getDateRangePickerToolSchema=Wt,e.getDateRangeValueSchema=b,e.getDateTimePickerToolSchema=Qt,e.getDateTimeValueSchema=S,e.getDateValueSchema=x,e.getDialogToolSchema=Jn,e.getDrawerToolSchema=mt,e.getDropDownListToolSchema=St,e.getDropDownTreeToolSchema=Rt,e.getDropDownValueSchema=w,e.getEditorToolSchema=H,e.getEmptySchema=c,e.getExpandCollapseSchema=g,e.getExportSchema=u,e.getFilterSchema=l,e.getFormToolSchema=z,e.getGanttChangeViewSchema=ue,e.getGanttCreateTaskSchema=me,e.getGanttDeleteTaskSchema=ge,e.getGanttToolSchema=he,e.getGridToolSchema=Ve,e.getGroupExpandSchema=Ge,e.getGroupSchema=je,e.getListBoxToolSchema=On,e.getListViewToolSchema=zn,e.getMapToolSchema=cr,e.getMaskedTextBoxToolSchema=Dn,e.getMenuToolSchema=Yn,e.getMultiColumnComboBoxToolSchema=Nt,e.getMultiSelectAddValueSchema=$,e.getMultiSelectRemoveValueSchema=E,e.getMultiSelectToolSchema=Mt,e.getNotificationToolSchema=dr,e.getNumberValueSchema=h,e.getNumericRangeValueSchema=v,e.getNumericTextBoxToolSchema=an,e.getOTPInputToolSchema=$r,e.getPageSchema=d,e.getPageSizeSchema=p,e.getPanelBarToolSchema=ct,e.getPivotGridToolSchema=Cr,e.getRangeSliderToolSchema=un,e.getRatingToolSchema=wn,e.getRowMatchSchema=pe,e.getSchedulerCreateSchema=Q,e.getSchedulerDeleteSchema=ee,e.getSchedulerNavigateSchema=te,e.getSchedulerToolSchema=oe,e.getSchedulerViewSchema=ne,e.getScrollViewToolSchema=er,e.getSignatureToolSchema=Vn,e.getSliderToolSchema=sn,e.getSortSchema=s,e.getSortableToolSchema=or,e.getSpreadsheetToolSchema=K,e.getStepperToolSchema=dt,e.getStringValueSchema=f,e.getSwitchToolSchema=bn,e.getTabStripToolSchema=ot,e.getTaskBoardToolSchema=hr,e.getTextAreaToolSchema=Nn,e.getTextBoxToolSchema=k,e.getTimePickerToolSchema=Zt,e.getTimeValueSchema=C,e.getTreeListToolSchema=ze,e.getTreeViewToolSchema=M,e.getUploadToolSchema=qn,e.getWindowToolSchema=yt,e.gridAdapter=Fe,e.listBoxAdapter=Fn,e.listViewAdapter=Hn,e.mapAdapter=lr,e.maskedTextBoxAdapter=Gn,e.menuAdapter=Xn,e.multiColumnComboBoxAdapter=kt,e.multiSelectAdapter=qt,e.notificationAdapter=pr,e.numericTextBoxAdapter=cn,e.otpInputAdapter=Er,e.panelBarAdapter=lt,e.pivotgridAdapter=Sr,e.rangeSliderAdapter=mn,e.ratingAdapter=$n,e.schedulerAdapter=ce,e.scrollViewAdapter=nr,e.signatureAdapter=Mn,e.sliderAdapter=dn,e.sortableAdapter=ar,e.spreadsheetAdapter=Y,e.stepperAdapter=pt,e.switchAdapter=vn,e.tabStripAdapter=at,e.taskboardAdapter=yr,e.textAreaAdapter=kn,e.textBoxAdapter=j,e.timePickerAdapter=Yt,e.treeListAdapter=nt,e.treeViewAdapter=R,e.uploadAdapter=_n,e.windowAdapter=xt});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-react-webmcp",
|
|
3
|
-
"version": "16.2.0-develop.
|
|
3
|
+
"version": "16.2.0-develop.9",
|
|
4
4
|
"description": "Web MCP Provider for KendoReact. Registers browser-native AI agent tools for KendoReact components.",
|
|
5
5
|
"author": "Progress",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@progress/kendo-licensing": "^1.7.2",
|
|
29
|
-
"@progress/kendo-react-common": "16.2.0-develop.
|
|
30
|
-
"@progress/kendo-react-editor": "16.2.0-develop.
|
|
29
|
+
"@progress/kendo-react-common": "16.2.0-develop.9",
|
|
30
|
+
"@progress/kendo-react-editor": "16.2.0-develop.9",
|
|
31
31
|
"react": "^18.0.0 || ^19.0.0",
|
|
32
32
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
33
33
|
},
|