@vertesia/ui 1.5.0-dev.20260910.052912Z → 1.5.0
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.
- package/lib/core/components/Link.js +1 -1
- package/lib/core/components/Link.js.map +1 -1
- package/lib/core/components/Spinner.js +1 -1
- package/lib/core/components/Spinner.js.map +1 -1
- package/lib/core/components/TagsInput.js +7 -7
- package/lib/core/components/TagsInput.js.map +1 -1
- package/lib/core/components/shadcn/badge.js +1 -1
- package/lib/core/components/shadcn/badge.js.map +1 -1
- package/lib/core/components/shadcn/button.d.ts.map +1 -1
- package/lib/core/components/shadcn/button.js +2 -2
- package/lib/core/components/shadcn/button.js.map +1 -1
- package/lib/core/components/shadcn/filters/comboBox/DateCombobox.js +2 -2
- package/lib/core/components/shadcn/filters/comboBox/DateCombobox.js.map +1 -1
- package/lib/core/components/shadcn/filters/comboBox/SelectCombobox.js +1 -1
- package/lib/core/components/shadcn/filters/comboBox/SelectCombobox.js.map +1 -1
- package/lib/core/components/shadcn/filters/comboBox/StringListCombobox.js +1 -1
- package/lib/core/components/shadcn/filters/comboBox/StringListCombobox.js.map +1 -1
- package/lib/core/components/shadcn/filters/comboBox/TextCombobox.js +1 -1
- package/lib/core/components/shadcn/filters/comboBox/TextCombobox.js.map +1 -1
- package/lib/core/components/shadcn/filters/filter/dateFilter.js +1 -1
- package/lib/core/components/shadcn/filters/filter/dateFilter.js.map +1 -1
- package/lib/core/components/shadcn/filters/filters.js +1 -1
- package/lib/core/components/shadcn/filters/filters.js.map +1 -1
- package/lib/core/components/shadcn/overflowTabs.js +2 -2
- package/lib/core/components/shadcn/overflowTabs.js.map +1 -1
- package/lib/core/components/shadcn/tabs.js +1 -1
- package/lib/core/components/shadcn/tabs.js.map +1 -1
- package/lib/features/activity-doc/ActivityDoc.js +1 -1
- package/lib/features/activity-doc/ActivityDoc.js.map +1 -1
- package/lib/features/agent/chat/AskUserWidget.d.ts +1 -0
- package/lib/features/agent/chat/AskUserWidget.d.ts.map +1 -1
- package/lib/features/agent/chat/AskUserWidget.js +15 -4
- package/lib/features/agent/chat/AskUserWidget.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.d.ts.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js +5 -3
- package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/MessageItem.d.ts.map +1 -1
- package/lib/features/agent/chat/ModernAgentOutput/MessageItem.js +3 -2
- package/lib/features/agent/chat/ModernAgentOutput/MessageItem.js.map +1 -1
- package/lib/features/layout/GenericPageNavHeader.js +1 -1
- package/lib/features/layout/GenericPageNavHeader.js.map +1 -1
- package/lib/features/magic-pdf/AnnotatedImageSlider.js +1 -1
- package/lib/features/magic-pdf/AnnotatedImageSlider.js.map +1 -1
- package/lib/features/magic-pdf/GroundedExtractionView.js +3 -3
- package/lib/features/magic-pdf/GroundedExtractionView.js.map +1 -1
- package/lib/features/permissions/UserPermissionsProvider.js +1 -1
- package/lib/features/permissions/UserPermissionsProvider.js.map +1 -1
- package/lib/features/store/objects/DocumentPreviewPanel.js +5 -5
- package/lib/features/store/objects/DocumentPreviewPanel.js.map +1 -1
- package/lib/features/store/objects/components/DocumentInput.js +1 -1
- package/lib/features/store/objects/components/DocumentInput.js.map +1 -1
- package/lib/features/store/objects/upload/DocumentUploadModal.js +1 -1
- package/lib/features/store/objects/upload/DocumentUploadModal.js.map +1 -1
- package/lib/features/user/UserInfo.d.ts +2 -0
- package/lib/features/user/UserInfo.d.ts.map +1 -1
- package/lib/features/user/UserInfo.js +1 -1
- package/lib/features/user/UserInfo.js.map +1 -1
- package/lib/router/RouteComponent.d.ts.map +1 -1
- package/lib/router/RouteComponent.js +15 -12
- package/lib/router/RouteComponent.js.map +1 -1
- package/lib/session/UserSession.d.ts.map +1 -1
- package/lib/session/UserSession.js +4 -0
- package/lib/session/UserSession.js.map +1 -1
- package/lib/shell/SplashScreen.js +1 -1
- package/lib/shell/SplashScreen.js.map +1 -1
- package/lib/vertesia-ui-core.js +3 -3
- package/lib/vertesia-ui-core.js.map +1 -1
- package/lib/vertesia-ui-features.js +32 -32
- package/lib/vertesia-ui-features.js.map +1 -1
- package/lib/vertesia-ui-router.js +1 -1
- package/lib/vertesia-ui-router.js.map +1 -1
- package/lib/vertesia-ui-session.js +1 -1
- package/lib/vertesia-ui-session.js.map +1 -1
- package/lib/vertesia-ui-shell.js +1 -1
- package/lib/vertesia-ui-shell.js.map +1 -1
- package/lib/vertesia-ui-widgets.js +2 -2
- package/lib/vertesia-ui-widgets.js.map +1 -1
- package/lib/widgets/json-view/JSONCode.js +1 -1
- package/lib/widgets/json-view/JSONCode.js.map +1 -1
- package/lib/widgets/upload/DropZone.d.ts.map +1 -1
- package/lib/widgets/upload/DropZone.js +1 -1
- package/lib/widgets/upload/DropZone.js.map +1 -1
- package/package.json +7 -7
- package/src/core/components/Link.tsx +1 -1
- package/src/core/components/Spinner.tsx +1 -1
- package/src/core/components/TagsInput.tsx +7 -7
- package/src/core/components/shadcn/badge.tsx +1 -1
- package/src/core/components/shadcn/button.tsx +2 -3
- package/src/core/components/shadcn/filters/comboBox/DateCombobox.tsx +2 -2
- package/src/core/components/shadcn/filters/comboBox/SelectCombobox.tsx +1 -1
- package/src/core/components/shadcn/filters/comboBox/StringListCombobox.tsx +1 -1
- package/src/core/components/shadcn/filters/comboBox/TextCombobox.tsx +1 -1
- package/src/core/components/shadcn/filters/filter/dateFilter.tsx +1 -1
- package/src/core/components/shadcn/filters/filters.tsx +1 -1
- package/src/core/components/shadcn/overflowTabs.tsx +2 -2
- package/src/core/components/shadcn/tabs.tsx +1 -1
- package/src/css/utilities.css +7 -0
- package/src/features/activity-doc/ActivityDoc.tsx +1 -1
- package/src/features/agent/chat/AskUserWidget.test.tsx +24 -2
- package/src/features/agent/chat/AskUserWidget.tsx +19 -4
- package/src/features/agent/chat/ModernAgentOutput/AllMessagesMixed.test.tsx +62 -0
- package/src/features/agent/chat/ModernAgentOutput/AllMessagesMixed.tsx +8 -7
- package/src/features/agent/chat/ModernAgentOutput/MessageItem.tsx +4 -3
- package/src/features/layout/GenericPageNavHeader.test.tsx +36 -0
- package/src/features/layout/GenericPageNavHeader.tsx +1 -1
- package/src/features/magic-pdf/AnnotatedImageSlider.tsx +1 -1
- package/src/features/magic-pdf/GroundedExtractionView.tsx +3 -3
- package/src/features/permissions/UserPermissionsProvider.tsx +1 -1
- package/src/features/store/objects/DocumentPreviewPanel.tsx +10 -10
- package/src/features/store/objects/components/DocumentInput.tsx +1 -1
- package/src/features/store/objects/upload/DocumentUploadModal.tsx +1 -1
- package/src/features/user/UserInfo.tsx +1 -1
- package/src/router/RouteComponent.test.tsx +65 -1
- package/src/router/RouteComponent.tsx +18 -15
- package/src/session/UserSession.test.ts +65 -0
- package/src/session/UserSession.ts +4 -0
- package/src/shell/SplashScreen.tsx +1 -1
- package/src/widgets/json-view/JSONCode.test.tsx +2 -2
- package/src/widgets/json-view/JSONCode.tsx +1 -1
- package/src/widgets/upload/DropZone.tsx +2 -4
|
@@ -271,7 +271,7 @@ let n=F(({className:n,...r},i)=>P(He,{ref:i,iconNode:t,className:Pe(`lucide-${Fe
|
|
|
271
271
|
*/
|
|
272
272
|
;function Et(){let e=re(wt);if(!e)throw Error(`useFieldSet must be used within a Form or FieldSet element`);return e}var Dt=class{object;components;disabled;constructor(e,t={},n=!1){this.object=e,this.components=t,this.disabled=n}};const Ot=N(void 0);function kt(){let e=re(Ot);if(!e)throw Error(`useForm must be used within a Form element`);return e}const At=Ot.Provider,jt=M.forwardRef(({object:e,type:n=`text`,onChange:r,...i},a)=>{let[o,s]=B(e.value==null?``:String(e.value)),[c,l]=B(e.schema.isBoolean&&e.value===!0);i.className=i.className?k(v.INPUT,i.className):v.INPUT;let u=t=>{i.disabled||(s(t.target.value),e.schema.isBoolean?(e.value=t.target.checked,l(e.value)):e.value=t.target.value,r?.(t))};return n===`textarea`?t(`textarea`,{ref:a,...i,value:o,onChange:u}):n===`checkbox`?t(`input`,{ref:a,...i,type:`checkbox`,checked:c,onChange:u,className:`form-check-input`}):t(`input`,{ref:a,...i,type:n,value:o,onChange:u})});function Mt({object:e,components:n,onSubmit:r,children:i,onChange:a,disabled:o}){return e.observer=a,t(At,{value:new Dt(e,n||{},o??!1),children:t(`form`,{className:`w-full`,onSubmit:t=>{t.stopPropagation(),t.preventDefault(),r?.(e.value)},children:i})})}function Nt(){let e=kt();return t(`div`,{className:`flex flex-col gap-4 w-full`,children:e.object.properties.map(Ft)})}function Pt({children:e,...r}){return n(Mt,{...r,children:[t(Nt,{}),e]})}function Ft(e){return e.isList?t(zt,{object:e},e.name):e.isObject?t(Rt,{object:e},e.name):t(Lt,{object:e},e.name)}function It(e,n){return e.isList?t(zt,{object:e}):e.isObject?t(Rt,{object:e}):t(Lt,{object:e,editor:n})}function Lt({object:e,editor:n,inline:r=!1}){n||=e.schema.editor;let{components:i,disabled:a}=kt(),o=n&&i[n]||jt,s=e.getInputType();s===`checkbox`&&(r=!0);let c=t=>{a||(e.value=e.schema.isBoolean?t.target instanceof HTMLInputElement&&t.target.checked:e.schema.isNumber?parseFloat(t.target.value):t.target.value)};return e.isListItem?t(o,{object:e,type:s,onChange:c,disabled:a}):t(u,{label:e.title,required:e.schema.isRequired,description:e.schema.description,className:k(`flex`,r?`flex-row items-center`:`flex-col`),children:t(o,{object:e,type:s,onChange:c,disabled:a})})}function Rt({object:e}){return n(`div`,{className:`flex flex-col gap-4 my-4 py-2 ps-4 border-s-4 border-s-solid border-s-border`,children:[!e.isListItem&&t(`div`,{className:`text-foreground font-semibold`,children:e.title}),e.properties.map(Ft)]})}function zt({object:e}){let{disabled:i}=kt(),a=z((e.value??[]).length),[o,s]=B(()=>(e.value??[]).map((e,t)=>t)),c=()=>{i||(e.add(),s(e=>[...e,a.current++]))},l=t=>{i||(e.remove(t),s(e=>e.filter((e,n)=>n!==t)))};return n(`div`,{className:`flex flex-col gap-4 my-4 py-2 ps-4 border-s-4 border-s-solid border-s-border darK:border-s-border`,children:[!e.isListItem&&t(`div`,{className:`text-foreground font-semibold`,children:e.title}),e.items.map((n,r)=>{let a=o[r];return t(Bt,{object:n,list:e,onDelete:()=>l(r),disabled:i},a)}),t(`div`,{children:n(r,{variant:`outline`,onClick:c,disabled:i,children:[t(mt,{className:`size-6`}),` Add`]})})]})}function Bt({list:e,object:i,onDelete:a,disabled:o}){let s=typeof e.schema.arraySchema.editor==`string`?e.schema.arraySchema.editor:void 0;return n(`div`,{className:`flex gap-2 w-full`,children:[t(`div`,{className:`flex-1`,children:It(i,s)}),t(r,{variant:`ghost`,onClick:a,disabled:o,title:`Delete`,children:t(xt,{className:`size-4 text-destructive`})})]})}function Vt({label:e,required:n,children:r}){return t(u,{label:e,required:n,children:r})}function Ht({children:e}){return t(`p`,{className:`mt-2 text-sm text-muted`,children:e})}function Ut({children:e}){return t(`p`,{className:`mt-2 text-sm text-destructive`,children:e})}function Wt(e){return e===`object`?{type:`object`,properties:{}}:e===`array`?{type:`array`,items:{}}:{type:e}}var Gt=class{schema;properties={};_validator;constructor(e){this.schema=e||{type:`object`,properties:{}},this.load()}get validator(){if(!this._validator){let e=new ae({allErrors:!0,strict:!1});oe(e),this._validator=e.compile(this.schema)}return this._validator}load(){if(this.schema.properties){let e=this.schema.properties;Object.keys(e).forEach(t=>{this.loadProperty(t,e[t])})}}hasProperties(){return Object.keys(this.properties).length>0}get title(){let e=this.schema.title;if(typeof e==`string`)return e;let t=this.schema.name;return typeof t==`string`?t:void 0}get description(){return this.schema.description}loadProperty(e,t){let n;return n=t.type===`array`?new Jt(this,e,t):new Kt(this,e,t),this.properties[e]=n,n}get type(){return this.schema.type}validate(e){return this.validator(e)?null:this.validator.errors||[]}addProperty(e,t,n=!1){this.schema.type!==`object`&&(this.schema.type=`object`),this.schema.properties||(this.schema.properties={});let r=typeof t==`string`?Wt(t):t,i=this.loadProperty(e,r);return this.schema.properties[i.name]=i.schema,n&&(i.isRequired=!0),i}removeProperty(e){this.schema.properties&&(delete this.schema.properties[e],Array.isArray(this.schema.required)&&(this.schema.required=this.schema.required.filter(t=>t!==e))),delete this.properties[e]}getProperty(e){return this.properties[e]}get editor(){return typeof this.schema.editor==`string`?this.schema.editor:void 0}},Kt=class extends Gt{parent;name;constructor(e,t,n){if(super(n),this.parent=e,this.name=t,n.type===`array`)throw Error(`Array property must be instantiated using ArrayPropertySchema`);n.type===`object`&&!n.properties&&(n.properties={})}get isMulti(){return!1}get isReadOnly(){return!!this.schema.readOnly}set isReadOnly(e){this.schema.readOnly=e}get defaultValue(){return this.schema.default}set defaultValue(e){this.schema.default=e}get enum(){return this.schema.enum}set enum(e){this.schema.enum=e}get isRequired(){let e=this.parent.schema.required;return e?e.includes(this.name):!1}set isRequired(e){let t=Array.isArray(this.parent.schema.required)?this.parent.schema.required:[];t=e?t.concat(this.name):t.filter(e=>e!==this.name),this.parent.schema.required=t}get type(){return this.schema.type}set type(e){this.schema.type!==e&&(this.schema.type=e,e!==`object`&&(this.properties={},this.schema.properties=void 0))}remove(){this.parent.removeProperty(this.name)}get isBoolean(){return this.type===`boolean`}get isString(){return this.type===`string`}get isNumber(){return this.type===`number`||this.type===`integer`}get isObject(){return this.type===`object`}};function qt(e){if(e.type!==`array`)throw Error(`Expecting an array schema`);if(!e.items)e.items={};else if(Array.isArray(e.items))throw Error(`Tuple arrays are not supported`);return e.items}var Jt=class extends Kt{arraySchema;constructor(e,t,n){super(e,t,qt(n)),this.arraySchema=n}get isMulti(){return!0}};function Yt(e){return e=e.replace(/_/g,` `).replace(/([a-z0-9])&([A-Z])/g,`$1 $2`),e[0].toUpperCase()+e.slice(1)}function Xt(e,t){if(t.editor)return t.editor;if(t.schema.format)return t.schema.format;switch(t.type){case`number`:case`integer`:return`number`;case`boolean`:return`checkbox`;case`string`:return`text`;default:return`text`}}var Zt=class{parent;schema;name;observer;constructor(e,t,n){this.parent=e,this.schema=t,this.name=n}get isRoot(){return!this.parent}get root(){return this.parent?this.parent.root:this}get path(){return this.parent?this.parent.path.concat(this.name):[]}get isScalar(){return!1}get isListItem(){return!1}get isObject(){return!1}get isList(){return!1}get title(){return this.schema.title||Yt(this.name)}onChange(e){this.observer&&this.observer(this)===!1||this.parent?.onChange(e)}},Qt=class extends Zt{get isObject(){return!0}getProperty(e){let t=this.schema.properties[e];return t.isMulti?new nn(this,t,this.getOrInitArrayProperty(e)):t.isObject?new en(this,t,t.name,this.getOrInitObjectProperty(e)):new tn(this,t)}getOrInitObjectProperty(e){let t=this.value[e];return t||(this.value[e]=t={}),t}getOrInitArrayProperty(e){let t=this.value[e];return t||(this.value[e]=t=[]),t}setPropertyValue(e,t){return this.value[e]!==t&&(this.value[e]=t,!0)}getPropertyValue(e){return this.value[e]}get properties(){let e=[];for(let t of Object.values(this.schema.properties))t.isMulti?e.push(new nn(this,t,this.getOrInitArrayProperty(t.name))):t.isObject?e.push(new en(this,t,t.name,this.getOrInitObjectProperty(t.name))):e.push(new tn(this,t));return e}[Symbol.iterator](){return this.properties[Symbol.iterator]()}},$t=class extends Qt{value;constructor(e,t={}){super(null,e instanceof Gt?e:new Gt(e),`#root`),this.value=t}},en=class extends Qt{value;constructor(e,t,n,r){super(e,t,n),this.value=r}},tn=class extends Zt{constructor(e,t){super(e,t,t.name),e.value[this.name]===void 0&&t.defaultValue!==void 0&&(e.value[this.name]=t.defaultValue)}get isScalar(){return!0}set value(e){this.parent.setPropertyValue(this.name,e)&&this.onChange(this)}get value(){return this.parent.getPropertyValue(this.name)}getInputType(){return Xt(this.name,this.schema)}},nn=class extends Zt{value;items=[];constructor(e,t,n){super(e,t,t.name),this.value=n;for(let e of this.value)this.add()}get isList(){return!0}newItem(e){return this.schema.isObject?new rn(this,e):new an(this,e)}add(){let e=this.newItem(this.items.length);return this.items.push(e),e}remove(e){let t=this.value;if(e>=0&&e<this.items.length){this.items.splice(e,1);for(let e=0,t=this.items.length;e<t;e++){let t=this.items[e];t.index=e,t.name=String(e)}}Array.isArray(t)&&e>=0&&e<t.length&&(t.splice(e,1),this.onChange(this))}[Symbol.iterator](){return this.items[Symbol.iterator]()}item(e){if(e<0||e>=this.value.length)return;let t=this.value[e];return this.schema.isObject?new en(this,this.schema,String(e),t):new an(this,e)}trim(){for(;this.items[this.items.length-1]===void 0;)this.items.pop()}},rn=class extends Qt{index;key;constructor(e,t){super(e,e.schema,String(t)),this.index=t,e.value[t]===void 0&&(e.value[t]={}),this.key=`${this.name}@${Date.now()}`}get isListItem(){return!0}set value(e){this.parent.value[this.index]=e}get value(){return this.parent.value[this.index]}},an=class extends Zt{index;key;constructor(e,t){super(e,e.schema,String(t)),this.index=t,e.value[t]===void 0&&e.schema.defaultValue!==void 0&&(e.value[t]=e.schema.defaultValue),this.key=`${this.name}@${Date.now()}`}get isScalar(){return!0}get isListItem(){return!0}set value(e){this.parent.value[this.index]=e}get value(){return this.parent.value[this.index]}getInputType(){return Xt(this.name,this.schema)}};function on({data:e,className:r}){let i=R(()=>{try{return JSON.stringify(e,null,2)}catch(e){return console.error(`Failed to stringify JSON:`,e),`{}`}},[e]),a=R(()=>i.split(`
|
|
273
273
|
`),[i]);return t(`pre`,{className:`h-full overflow-auto rounded-md border bg-background p-3 font-mono text-xs leading-5 text-foreground ${r||``}`,children:t(`code`,{children:a.map((e,t)=>n(`span`,{children:[ln(e),t<a.length-1?`
|
|
274
|
-
`:null]},`line-${t}`))})})}const sn=/("(?:\\.|[^"\\])*"?)|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g,cn=/^\s*:/;function ln(e){sn.lastIndex=0;let n=[],r=0,i=sn.exec(e);for(;i!==null;){i.index>r&&n.push(e.slice(r,i.index));let[a,o,s,c]=i,l=o!==void 0&&cn.test(e.slice(i.index+a.length))?`text-info`:o?`text-success`:s?`text-
|
|
274
|
+
`:null]},`line-${t}`))})})}const sn=/("(?:\\.|[^"\\])*"?)|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g,cn=/^\s*:/;function ln(e){sn.lastIndex=0;let n=[],r=0,i=sn.exec(e);for(;i!==null;){i.index>r&&n.push(e.slice(r,i.index));let[a,o,s,c]=i,l=o!==void 0&&cn.test(e.slice(i.index+a.length))?`text-info`:o?`text-success`:s?`text-info`:c?`text-attention`:void 0;n.push(t(`span`,{className:l,children:a},`${i.index}-${a}`)),r=i.index+a.length,i=sn.exec(e)}return r<e.length&&n.push(e.slice(r)),n.length?n:e}function un({value:e}){return Array.isArray(e)?t(`div`,{className:`flex flex-col gap-4 px-2 h-full overflow-auto`,children:t(mn,{value:e})}):typeof e!=`object`||!e?t(`div`,{className:`flex flex-col gap-4 px-2 h-full overflow-auto`,children:t(pn,{name:`value`,value:e})}):t(`div`,{className:`flex flex-col gap-4 px-2 h-full overflow-auto`,children:Object.entries(e).map(([e,n])=>t(pn,{name:e,value:n},e))})}function dn({name:e}){return t(`div`,{className:`text-sm font-semibold`,children:Yt(e)})}function fn({children:e,className:n}){return t(`div`,{className:k(`flex flex-col gap-4 py-2 ps-4 border-s-4 border-s-solid border-s-border`,n),children:e})}function pn({name:e,value:r}){let i=_n(r);switch(i.type){case gn.Inline:return n(`div`,{className:`w-full flex gap-2 text-sm`,children:[t(dn,{name:`${e}:`}),t(`p`,{children:i.value})]});case gn.Paragraph:return n(`div`,{className:`w-full flex flex-col gap-2 text-sm`,children:[t(dn,{name:e}),t(`p`,{children:i.value})]});case gn.Prose:return n(`div`,{className:`prose dark:prose-invert`,children:[t(dn,{name:e}),t(`div`,{className:`vprose prose-sm dark:prose-invert`,children:i.value})]});case gn.Array:return t(mn,{name:e,value:r});case gn.Object:return n(`div`,{className:`w-full flex flex-col gap-2 text-sm`,children:[t(dn,{name:e}),t(fn,{className:`mt-2`,children:Object.entries(r).map(([e,n])=>t(pn,{name:e,value:n},e))})]})}}function mn({name:e,value:r}){let i=r.join(` `).length,o=i/r.length,s=typeof r[0]==`string`&&(i<80||i<400&&o<32),c=r.length>9,l=r.map((e,t)=>({item:e,index:t,key:`${t}-${JSON.stringify(e)}`}));return s?n(`div`,{className:`flex gap-2 flex-wrap`,children:[e&&t(dn,{name:`${e}:`}),l.map(({item:e,key:n})=>t(a,{children:String(e)},n))]}):n(`div`,{children:[e&&t(dn,{name:e}),t(`div`,{className:`flex flex-col gap-2`,children:l.map(({item:e,index:n,key:r})=>t(hn,{index:n,value:e,useBullet:c},r))})]})}function hn({index:e,value:r,useBullet:i}){let a=i?t(`span`,{className:`text-xl`,children:`•`}):n(`span`,{children:[e+1,`.`]}),o=_n(r),s;switch(o.type){case gn.Object:s=t(fn,{children:Object.entries(r).map(([e,n])=>t(pn,{name:e,value:n},e))});break;case gn.Array:s=t(mn,{value:r});break;case gn.Prose:s=t(`div`,{className:`prose dark:prose-invert`,children:o.value});break;default:s=t(`div`,{children:o.value})}return n(`div`,{className:`flex gap-4 hover:bg-muted py-2 pe-2 ps-4`,children:[t(`div`,{className:`font-semibold text-muted`,children:a}),t(`div`,{children:s})]})}var gn;(function(e){e[e.Inline=0]=`Inline`,e[e.Paragraph=1]=`Paragraph`,e[e.Prose=2]=`Prose`,e[e.Array=3]=`Array`,e[e.Object=4]=`Object`})(gn||={});function _n(e){if(e==null)return{value:`-`,type:gn.Inline};if(Array.isArray(e))return{value:e,type:gn.Array};if(typeof e==`string`){let t=e.length,n,r=e;return t<80?n=gn.Inline:t>400?n=gn.Prose:(n=gn.Paragraph,r=e.replace(/(?:\n\n)+/g,`
|
|
275
275
|
|
|
276
276
|
`)),{type:n,value:r}}return typeof e==`number`||typeof e==`boolean`?{value:String(e),type:gn.Inline}:{value:e,type:gn.Object}}function vn({value:e,viewCode:n=!1}){let{t:r}=se();return e?t(`div`,{className:`relative w-full h-full flex flex-col`,children:n||!yn(e)?t(on,{data:e}):t(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:t(un,{value:e})})}):t(`pre`,{className:`whitespace-pre-wrap`,children:r(`misc.noData`)})}function yn(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`?!0:Array.isArray(e)?e.every(yn):typeof e==`object`&&Object.values(e).every(yn)}const bn=new Set;function xn(e){bn.has(`markdown`)||(bn.add(`markdown`),e.languages.registerFoldingRangeProvider(`markdown`,{provideFoldingRanges(e){let t=[],n=e.getLinesContent(),r=/^(#{1,6})\s/,i=[];for(let e=0;e<n.length;e++){let a=e+1,o=r.exec(n[e]);if(o){let e=o[1].length;for(;i.length>0&&i[i.length-1].level>=e;){let e=i.pop();e&&a-1>e.line&&t.push({start:e.line,end:a-1})}i.push({level:e,line:a})}}let a=n.length;for(;i.length>0;){let e=i.pop();e&&a>e.line&&t.push({start:e.line,end:a})}return t}}));for(let t of[`javascript`,`typescript`])bn.has(t)||(bn.add(t),e.languages.registerFoldingRangeProvider(t,{provideFoldingRanges(e){let t=e.getLinesContent(),n=/^(#{1,6})\s/,r=[],i=[],a=[],o=[],s=!1,c=!1,l=``;for(let e=0;e<t.length;e++){let u=e+1,d=t[e],f=s;for(let e=0;e<d.length;e++){let t=d[e];if(t===`\\`){e++;continue}if(c){t===l&&(c=!1);continue}if(s){t==="`"&&(s=!1);continue}if(t==="`"){s=!0;continue}if(t===`"`||t===`'`){c=!0,l=t;continue}if(t===`{`&&a.push(u),t===`}`&&a.length>0){let t=a.pop(),n=d.slice(e+1).trimStart().length>0?u-1:u;t!==void 0&&n>t&&r.push({start:t,end:n})}}if(f){let e=n.exec(d);if(e){let t=e[1].length;for(;o.length>0&&o[o.length-1].level>=t;){let e=o.pop();e&&u-1>e.line&&i.push({start:e.line,end:u-1})}o.push({level:t,line:u})}if(!s)for(;o.length>0;){let e=o.pop();e&&u>e.line&&i.push({start:e.line,end:u})}}}return[...r,...i]}}))}let Sn=!1;function Cn(e){Sn||=(e.config({paths:{vs:`https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs`}}),!0)}let wn;function Tn(){return wn??=import(`@monaco-editor/react`).then(e=>(Cn(e.loader),e)).catch(e=>{throw wn=void 0,e}),wn}const En=te(()=>Tn().then(({Editor:e})=>({default:e})));let Dn;function On(){if(!(typeof document>`u`)){if(!Dn){let e=document.createElement(`div`);e.className=`monaco-editor`,e.style.position=`absolute`,e.style.top=`0`,e.style.left=`0`,e.style.zIndex=`10000`,document.body.appendChild(e),Dn=e}return Dn}}const kn=new Map;let An=0;function jn(e){(e.languages.json?.jsonDefaults)?.setDiagnosticsOptions({validate:!0,enableSchemaRequest:!1,schemas:Array.from(kn.entries()).map(([e,t])=>({uri:`vertesia://schemas/${encodeURIComponent(e)}`,fileMatch:[e],schema:t}))})}var Mn=class{VgetValue;VsetValue;constructor(e,t){this.VgetValue=e,this.VsetValue=t}getValue(){return this.VgetValue()}setValue(e){this.VsetValue(e||``)}};function Nn({onChange:e,value:n,className:r,editorRef:i,language:a=`javascript`,path:o,debounceTimeout:s=0,options:c={},beforeMount:l,onMount:u,defaultValue:d,useCustomFolding:f=!1,jsonSchema:p}){let[m,h]=B(n||d||``),g=z(null),_=z(null),[v]=B(()=>p?`inmemory://vertesia/json/${++An}.json`:void 0),y=o??v,{theme:b}=D(),x=b===`system`?window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:b,S=n||d||``,C=z(()=>m),w=z(e=>{h(e),g.current&&g.current.setValue(e)});L(()=>{C.current=()=>m},[m]),L(()=>(i&&(i.current=new Mn(()=>C.current(),e=>w.current(e))),()=>{i&&(i.current=void 0)}),[i]);let T=R(()=>{if(e)return s>0?ce(t=>e(t),s):e},[e,s]),E=I(async(e,t)=>{let n=e.getModel();if(n)for(let r of n.getValue().matchAll(/```[\s\S]*?```/g)){let i=n.getPositionAt(r.index).lineNumber,a=n.getPositionAt(r.index+r[0].length).lineNumber;e.setSelection(new t.Selection(i,1,a,1)),await e.getAction(`editor.createFoldingRangeFromSelection`)?.run()}},[]),O=I(e=>{let t=e||``;if(h(t),T){let e={docChanged:!0,state:{doc:{toString:()=>t,length:t.length}}};T(e)}},[T]),A=I((e,t)=>{g.current=e,_.current=t,p&&y&&a===`json`&&(kn.set(y,p),jn(t)),f&&xn(t),w.current=t=>{h(t),e.setValue(t)},t.editor.defineTheme(`errorLineTheme`,{base:x===`dark`?`vs-dark`:`vs`,inherit:!0,rules:[],colors:{"editorError.background":`#ffebee`,"editorError.border":`#f44336`}}),t.editor.setTheme(`errorLineTheme`),f&&setTimeout(()=>E(e,t),300),u?.(e,t)},[u,x,f,E,p,y,a]);L(()=>()=>{p&&y&&kn.delete(y)&&_.current&&jn(_.current)},[p,y]),L(()=>{g.current?.hasTextFocus()||h(e=>S===e?e:(g.current&&g.current.setValue(S),S))},[S]),L(()=>{if(!S||!f||!g.current||!_.current||g.current.hasTextFocus())return;let e=g.current,t=_.current,n=setTimeout(()=>E(e,t),300);return()=>clearTimeout(n)},[S,f,E]);let j={fontSize:14,fontFamily:`monospace`,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:`on`,lineNumbers:`on`,folding:!0,lineDecorationsWidth:10,lineNumbersMinChars:3,automaticLayout:!0,formatOnPaste:!0,formatOnType:!0,tabSize:2,insertSpaces:!0,fixedOverflowWidgets:!0,overflowWidgetsDomNode:On(),glyphMargin:!0,renderValidationDecorations:`on`,renderLineHighlight:`line`,hover:{enabled:`on`,delay:100},quickSuggestions:{other:!0,comments:!0,strings:!0},...c};return t(`div`,{className:k(r,`w-full h-full!`),children:t(ee,{fallback:t(`div`,{className:`h-full w-full`}),children:t(En,{className:`h-full w-full`,height:`100%`,theme:x===`dark`?`vs-dark`:`light`,language:a,path:y,onChange:O,onMount:A,beforeMount:l,options:j,defaultValue:S})})})}function Pn({value:e,onChange:r,onValidChange:i,readonly:a=!1,height:o=`200px`,placeholder:s,className:c}){let{theme:l}=D(),u=z(void 0),[d,f]=B(null),p=R(()=>{if(e==null)return s??`{}`;try{return JSON.stringify(e,null,2)}catch{return`{}`}},[e,s]),m=I(()=>{if(!u.current||a)return;let e=u.current.getValue();try{let t=JSON.parse(e);f(null),i?.(t)}catch{f(`Invalid JSON`)}},[a,i]);return n(`div`,{className:c,children:[t(`div`,{className:`border rounded overflow-hidden`,style:{height:o},children:t(Nn,{defaultValue:p,editorRef:u,language:`json`,theme:l===`dark`?`vs-dark`:`vs`,onChange:m,options:a?{readOnly:!0,domReadOnly:!0}:void 0})}),d&&t(`p`,{className:`text-xs text-destructive mt-1`,children:d})]})}function Fn(e){if(!e.current)return null;try{return JSON.parse(e.current.getValue())}catch{return null}}function In({title:e,viewCode:i,setViewCode:a}){return n(`div`,{className:`flex items-center gap-1 bg-muted mb-2 p-1 rounded`,children:[t(r,{variant:i?`ghost`:`primary`,size:`sm`,title:`Preview properties`,onClick:()=>a(!1),children:e}),t(r,{variant:i?`primary`:`ghost`,size:`sm`,title:`View in JSON format`,onClick:()=>a(!0),children:`JSON`})]})}function Ln(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).replace(/\s+/g,` `).trim().replace(/^./,e=>e.toUpperCase())}function Rn(r){return r==null?`Failed to query`:typeof r==`string`?r:Array.isArray(r)?r.length===0?`None`:r.some(e=>e&&typeof e==`object`)?t(e,{children:r.map((e,r)=>n(`div`,{className:`flex gap-1`,children:[n(`span`,{className:`text-xs align-top pe-2 font-medium`,children:[r+1,`:`]}),t(`span`,{className:`text-xs`,children:Rn(e)})]},`item-${r}`))}):r.map(e=>String(e)).join(`, `):typeof r==`object`?t(e,{children:Object.entries(r).map(([e,r])=>n(`div`,{className:`flex gap-1`,children:[n(`span`,{className:`text-xs align-top pe-2 font-medium`,children:[Ln(e),`:`]}),t(`span`,{className:`text-xs`,children:Rn(r)})]},e))}):String(r)}function zn({data:e,className:r}){let i=e?Object.entries(e):[];return t(`table`,{className:r||`mb-2 text-xs bg-muted rounded-sm w-full`,children:t(`tbody`,{children:i.map(([e,r])=>n(`tr`,{className:`align-top hover:bg-background border-y`,children:[t(`td`,{className:`align-top pe-4 p-2`,children:Ln(e)}),t(`td`,{className:`p-2`,children:Rn(r)})]},e))})})}const Bn=N(()=>({kind:`none`})),Vn=Bn.Provider;function Hn(){return re(Bn)}const Un={store:`document`,document:`document`,collection:`collection`,interaction:`interaction`,prompt:`prompt`,agent:`agent`,workflow:`workflow`,process:`process`,run:`interaction_run`};function Wn(e){let t=e.indexOf(`:`);if(t<=0)return;let n=e.slice(0,t);if(!Object.hasOwn(Un,n))return;let r=e.slice(t+1).trim().replace(/^\/+/,``);if(r)return{type:Un[n],id:r}}var Gn=Object.defineProperty,Kn=(e,t)=>Gn(e,`name`,{value:t,configurable:!0}),qn=!!(typeof window<`u`&&window.document&&window.document.createElement);function Jn(e,t,{checkForDefaultPrevented:n=!0}={}){return Kn(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}Kn(Jn,`composeEventHandlers`);function Yn(e){if(!qn)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}Kn(Yn,`getOwnerWindow`);function Xn(e){if(!qn)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}Kn(Xn,`getOwnerDocument`);function Zn(e,t=!1){let{activeElement:n}=Xn(e);if(!n?.nodeName)return null;if(Qn(n)&&n.contentDocument)return Zn(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=Xn(n).getElementById(e);if(t)return t}}return n}Kn(Zn,`getActiveElement`);function Qn(e){return e.tagName===`IFRAME`}Kn(Qn,`isFrame`);var $n=Object.defineProperty,er=(e,t)=>$n(e,`name`,{value:t,configurable:!0});function tr(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}er(tr,`setRef`);function nr(...e){return t=>{let n=!1,r=e.map(e=>{let r=tr(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():tr(e[t],null)}}}}er(nr,`composeRefs`);function rr(...e){return j.useCallback(nr(...e),e)}er(rr,`useComposedRefs`);var ir=Object.defineProperty,ar=(e,t)=>ir(e,`name`,{value:t,configurable:!0});function or(e,n){let r=j.createContext(n);r.displayName=e+`Context`;let i=ar(e=>{let{children:n,...i}=e,a=j.useMemo(()=>i,Object.values(i));return t(r.Provider,{value:a,children:n})},`Provider`);i.displayName=e+`Provider`;function a(t,i={}){let{optional:a=!1}=i,o=j.useContext(r);if(o)return o;if(n!==void 0)return n;if(!a)throw Error(`\`${t}\` must be used within \`${e}\``)}return ar(a,`useContext`),[i,a]}ar(or,`createContext`);function sr(e,n=[]){let r=[];function i(n,i){let a=j.createContext(i);a.displayName=n+`Context`;let o=r.length;r=[...r,i];let s=ar(n=>{let{scope:r,children:i,...s}=n,c=r?.[e]?.[o]||a,l=j.useMemo(()=>s,Object.values(s));return t(c.Provider,{value:l,children:i})},`Provider`);s.displayName=n+`Provider`;function c(t,r,s={}){let{optional:c=!1}=s,l=r?.[e]?.[o]||a,u=j.useContext(l);if(u)return u;if(i!==void 0)return i;if(!c)throw Error(`\`${t}\` must be used within \`${n}\``)}return ar(c,`useContext`),[s,c]}ar(i,`createContext`);let a=ar(()=>{let t=r.map(e=>j.createContext(e));return ar(function(n){let r=n?.[e]||t;return j.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return a.scopeName=e,[i,cr(a,...n)]}ar(sr,`createContextScope`);function cr(...e){let t=e[0];if(e.length===1)return t;let n=ar(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return ar(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return j.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}ar(cr,`composeContextScopes`);var lr=globalThis?.document?j.useLayoutEffect:()=>{},ur=Object.defineProperty,dr=(e,t)=>ur(e,`name`,{value:t,configurable:!0}),fr=j.useId||(()=>void 0),pr=0;function mr(e){let[t,n]=j.useState(fr());return lr(()=>{e||n(e=>e??String(pr++))},[e]),e||(t?`radix-${t}`:``)}dr(mr,`useId`);var hr=Object.defineProperty,gr=(e,t)=>hr(e,`name`,{value:t,configurable:!0}),_r=j.useEffectEvent,vr=j.useInsertionEffect;function yr(e){if(typeof _r==`function`)return _r(e);let t=j.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof vr==`function`?vr(()=>{t.current=e}):lr(()=>{t.current=e}),j.useMemo(()=>((...e)=>t.current?.(...e)),[])}gr(yr,`useEffectEvent`);var br=Object.defineProperty,xr=(e,t)=>br(e,`name`,{value:t,configurable:!0}),Sr=j.useInsertionEffect||lr;function Cr({prop:e,defaultProp:t,onChange:n=xr(()=>{},`onChange`),caller:r}){let[i,a,o]=wr({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,j.useCallback(t=>{if(s){let n=Tr(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}xr(Cr,`useControllableState`);function wr({defaultProp:e,onChange:t}){let[n,r]=j.useState(e),i=j.useRef(n),a=j.useRef(t);return Sr(()=>{a.current=t},[t]),j.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}xr(wr,`useUncontrolledState`);function Tr(e){return typeof e==`function`}xr(Tr,`isFunction`);var Er=Symbol(`RADIX:SYNC_STATE`);function Dr(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=yr(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=j.useReducer((t,n)=>{if(n.type===Er)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=j.useRef(p);j.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=j.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return j.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:Er,state:i})},[i,d.state,c]),[h,f]}xr(Dr,`useControllableStateReducer`);var Or=Object.defineProperty,kr=(e,t)=>Or(e,`name`,{value:t,configurable:!0});function Ar(e){let t=j.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];Rr(r)&&typeof Hr==`function`&&(r=Hr(r._payload)),j.Children.forEach(r,e=>{if(Ir(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;Rr(n)&&typeof Hr==`function`&&(n=Hr(n._payload)),a=Nr(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=j.cloneElement(a,void 0,s):!o&&j.Children.count(r)===1&&j.isValidElement(r)&&(a=r);let c=a?Fr(a):void 0,l=rr(n,c);if(!a){if(r||r===0)throw Error(o?Vr(e):Br(e));return r}let u=Pr(i,a.props??{});return a.type!==j.Fragment&&(u.ref=n?l:c),j.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}kr(Ar,`createSlot`);var jr=Symbol.for(`radix.slottable`);function Mr(e){let t=kr(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=jr,t}kr(Mr,`createSlottable`);var Nr=kr((e,t)=>{if(`child`in e.props){let t=e.props.child;return j.isValidElement(t)?j.cloneElement(t,void 0,e.props.children(t.props.children)):null}return j.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function Pr(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}kr(Pr,`mergeProps`);function Fr(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}kr(Fr,`getElementRef`);function Ir(e){return j.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===jr}kr(Ir,`isSlottable`);var Lr=Symbol.for(`react.lazy`);function Rr(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Lr&&`_payload`in e&&zr(e._payload)}kr(Rr,`isLazyComponent`);function zr(e){return typeof e==`object`&&!!e&&`then`in e}kr(zr,`isPromiseLike`);var Br=kr(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),Vr=kr(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),Hr=j.use,Ur=Object.defineProperty,Wr=(e,t)=>Ur(e,`name`,{value:t,configurable:!0}),Gr=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,n)=>{let r=Ar(`Primitive.${n}`),i=j.forwardRef((e,i)=>{let{asChild:a,...o}=e,s=a?r:n;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),t(s,{...o,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});function Kr(e,t){e&&he.flushSync(()=>e.dispatchEvent(t))}Wr(Kr,`dispatchDiscreteCustomEvent`);var qr=Object.defineProperty,Jr=j.forwardRef(((e,t)=>qr(e,`name`,{value:t,configurable:!0}))(function(e,n){let{container:r,...i}=e,[a,o]=j.useState(!1);lr(()=>o(!0),[]);let s=r||a&&globalThis?.document?.body;return s?he.createPortal(t(Gr.div,{...i,ref:n}),s):null},`Portal`)),Yr=Object.defineProperty,Xr=(e,t)=>Yr(e,`name`,{value:t,configurable:!0});function Zr(e,t){return j.useReducer((e,n)=>t[e][n]??e,e)}Xr(Zr,`useStateMachine`);var Qr=Xr(e=>{let{present:t,children:n}=e,r=$r(t),i=typeof n==`function`?n({present:r.isPresent}):j.Children.only(n),a=ti(r.ref,ri(i));return typeof n==`function`||r.isPresent?j.cloneElement(i,{ref:a}):null},`Presence`);function $r(e){let[t,n]=j.useState(),r=j.useRef(null),i=j.useRef(e),a=j.useRef(`none`),o=j.useRef(void 0),[s,c]=Zr(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return j.useEffect(()=>{s===`mounted`?(a.current=o.current??ni(r.current),o.current=void 0):a.current=`none`},[s]),lr(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=ni(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),lr(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=Xr(a=>{let o=ni(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=Xr(e=>{e.target===t&&(a.current=ni(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:j.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=ni(t)}else r.current=null;n(e)},[])}}Xr($r,`usePresence`);function ei(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}Xr(ei,`setRef`);function ti(...e){let t=j.useRef(e);return t.current=e,j.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=ei(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():ei(n[e],null)}}},[])}Xr(ti,`useStableComposedRefs`);function ni(e){return e?.animationName||`none`}Xr(ni,`getAnimationName`);function ri(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Xr(ri,`getElementRef`);var ii=Object.defineProperty,ai=(e,t)=>ii(e,`name`,{value:t,configurable:!0}),oi=`Dialog`,[si,ci]=sr(oi),[li,ui]=si(oi),di=ai(e=>{let{__scopeDialog:n,children:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=j.useRef(null),l=j.useRef(null),[u,d]=Cr({prop:i,defaultProp:a??!1,onChange:o,caller:oi}),[f,p]=j.useState(0),[m,h]=j.useState(0);return t(li,{scope:n,triggerRef:c,contentRef:l,contentId:mr(),titleId:mr(),descriptionId:mr(),titlePresent:f>0,descriptionPresent:m>0,setTitleCount:p,setDescriptionCount:h,open:u,onOpenChange:d,onOpenToggle:j.useCallback(()=>d(e=>!e),[d]),modal:s,children:r})},`Dialog`),fi=`DialogPortal`,[pi,mi]=si(fi,{forceMount:void 0}),hi=ai(e=>{let{__scopeDialog:n,forceMount:r,children:i,container:a}=e,o=ui(fi,n);return t(pi,{scope:n,forceMount:r,children:j.Children.map(i,e=>t(Qr,{present:r||o.open,children:t(Jr,{asChild:!0,container:a,children:e})}))})},`DialogPortal`),gi=`DialogOverlay`,_i=j.forwardRef(ai(function(e,n){let r=mi(gi,e.__scopeDialog),{forceMount:i=r.forceMount,...a}=e,o=ui(gi,e.__scopeDialog);return o.modal?t(Qr,{present:i||o.open,children:t(yi,{...a,ref:n})}):null},`DialogOverlay`)),vi=Ar(`DialogOverlay.RemoveScroll`),yi=j.forwardRef(ai(function(e,n){let{__scopeDialog:r,...i}=e,a=ui(gi,r),o=rr(n,pe());return t(_e,{as:vi,allowPinchZoom:!0,shards:[a.contentRef],children:t(Gr.div,{"data-state":ji(a.open),...i,ref:o,style:{pointerEvents:`auto`,...i.style}})})},`DialogOverlayImpl`)),bi=`DialogContent`,xi=j.forwardRef(ai(function(e,n){let r=mi(bi,e.__scopeDialog),{forceMount:i=r.forceMount,...a}=e,o=ui(bi,e.__scopeDialog);return t(Qr,{present:i||o.open,children:o.modal?t(Si,{...a,ref:n}):t(Ci,{...a,ref:n})})},`DialogContent`)),Si=j.forwardRef(ai(function(e,n){let r=ui(bi,e.__scopeDialog),i=j.useRef(null),a=rr(n,r.contentRef,i);return j.useEffect(()=>{let e=i.current;if(e)return ve(e)},[]),t(wi,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,onCloseAutoFocus:Jn(e.onCloseAutoFocus,e=>{e.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:Jn(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:Jn(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Ci=j.forwardRef(ai(function(e,n){let r=ui(bi,e.__scopeDialog),i=j.useRef(!1),a=j.useRef(!1);return t(wi,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(i.current||r.triggerRef.current?.focus(),t.preventDefault()),i.current=!1,a.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(i.current=!0,t.detail.originalEvent.type===`pointerdown`&&(a.current=!0));let n=t.target;r.triggerRef.current?.contains(n)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&a.current&&t.preventDefault()}})},`DialogContentNonModal`)),wi=j.forwardRef(ai(function(n,r){let{__scopeDialog:i,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:s,...c}=n,l=ui(bi,i);return ge(),t(e,{children:t(me,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:o,onUnmountAutoFocus:s,children:t(fe,{role:`dialog`,id:l.contentId,"aria-describedby":l.descriptionPresent?l.descriptionId:void 0,"aria-labelledby":l.titlePresent?l.titleId:void 0,"data-state":ji(l.open),...c,ref:r,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})},`DialogContentImpl`)),Ti=`DialogTitle`,Ei=j.forwardRef(ai(function(e,n){let{__scopeDialog:r,...i}=e,a=ui(Ti,r),{setTitleCount:o}=a;return lr(()=>(o(e=>e+1),()=>o(e=>e-1)),[o]),t(Gr.h2,{id:a.titleId,...i,ref:n})},`DialogTitle`)),Di=`DialogDescription`,Oi=j.forwardRef(ai(function(e,n){let{__scopeDialog:r,...i}=e,a=ui(Di,r),{setDescriptionCount:o}=a;return lr(()=>(o(e=>e+1),()=>o(e=>e-1)),[o]),t(Gr.p,{id:a.descriptionId,...i,ref:n})},`DialogDescription`)),ki=`DialogClose`,Ai=j.forwardRef(ai(function(e,n){let{__scopeDialog:r,...i}=e,a=ui(ki,r);return t(Gr.button,{type:`button`,...i,ref:n,onClick:Jn(e.onClick,()=>a.onOpenChange(!1))})},`DialogClose`));function ji(e){return e?`open`:`closed`}ai(ji,`getState`);function Mi(...e){return be(A(e))}const Ni=N(null);function Pi(){return re(Ni)}function Fi(e){return e.startsWith(`agents/`)||e.startsWith(`documents/`)}function Ii(e,t,n=`inline`){return`artifact:${e}:${t}:${n}`}function Li(e){return`file:${e}`}const Ri=te(()=>import(`react-vega`).then(({VegaEmbed:e})=>({default:e})));function zi({error:e,chartTitle:r}){return t(`div`,{className:`flex items-center justify-center h-full bg-red-50 dark:bg-red-950 rounded-md p-4`,children:n(`div`,{className:`text-center`,children:[n(`p`,{className:`text-sm font-medium text-red-600 dark:text-red-400`,children:[`Cannot render `,r||`Vega-Lite`,` chart`]}),t(`p`,{className:`text-xs text-red-500 dark:text-red-500 mt-1 max-w-xs truncate`,children:e})]})})}function Bi(){return t(`output`,{className:`flex items-center justify-center w-full h-full`,children:t(ct,{className:`w-5 h-5 animate-spin text-gray-500 dark:text-gray-400`})})}function Vi({isOpen:e,onClose:i,title:a,description:o,children:s}){let{t:c}=se();return t(di,{open:e,onOpenChange:e=>!e&&i(),children:n(hi,{children:[t(_i,{className:`fixed inset-0 z-50 bg-black/80 backdrop-blur-sm transition-all duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`}),n(xi,{className:`fixed inset-2 sm:inset-4 z-50 flex flex-col bg-white dark:bg-gray-900 rounded-xl shadow-2xl transition-all duration-300 ease-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-98 data-[state=open]:zoom-in-98 data-[state=closed]:slide-out-to-bottom-2 data-[state=open]:slide-in-from-bottom-2`,onEscapeKeyDown:i,children:[t(Ai,{asChild:!0,children:t(r,{variant:`unstyled`,onClick:i,className:`absolute top-3 end-3 z-10 p-2 rounded-lg bg-white/80 dark:bg-gray-800/80 backdrop-blur-sm hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors duration-150 shadow-sm`,"aria-label":c(`agent.closeFullscreen`),children:t(Ct,{className:`w-5 h-5 text-gray-600 dark:text-gray-300`})})}),t(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6 animate-in fade-in-0 duration-500 delay-150`,children:s}),t(`div`,{className:`flex items-center justify-between px-4 sm:px-6 py-3 border-t border-gray-200 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-800/50 rounded-b-xl`,children:n(`div`,{className:`flex flex-col`,children:[t(Ei,{className:`text-base font-semibold text-gray-900 dark:text-gray-100`,children:a||c(`agent.dashboard`)}),o&&t(Oi,{className:`text-sm text-gray-500 dark:text-gray-400 mt-0.5`,children:o})]})})]})]})})}function Hi(e,t){if(t===`chart`)return 280;let n=1;if(e.vconcat)n=Array.isArray(e.vconcat)?e.vconcat.length:1;else if(e.concat){let t=e.columns||2,r=Array.isArray(e.concat)?e.concat.length:1;n=Math.ceil(r/t)}else e.facet&&(n=2);return Math.max(500,n*280+40)}const Ui={categorical:[`#6366f1`,`#8b5cf6`,`#ec4899`,`#f43f5e`,`#f97316`,`#eab308`,`#22c55e`,`#14b8a6`,`#06b6d4`,`#3b82f6`],blues:[`#dbeafe`,`#93c5fd`,`#3b82f6`,`#1d4ed8`,`#1e3a8a`],purples:[`#f3e8ff`,`#c4b5fd`,`#8b5cf6`,`#6d28d9`,`#4c1d95`],greens:[`#dcfce7`,`#86efac`,`#22c55e`,`#15803d`,`#14532d`],diverging:[`#ef4444`,`#fca5a5`,`#fef3c7`,`#86efac`,`#22c55e`]};function Wi(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Gi(e){return Wi(e)}function Ki(e){let t=JSON.parse(JSON.stringify(e)),n=[`vconcat`,`hconcat`,`concat`];if(!n.some(e=>Array.isArray(t[e])))return t;let r=[];if(Array.isArray(t.params))for(let e of t.params)e&&typeof e==`object`&&e.name&&e.select&&r.push({name:e.name,param:e});if(r.length===0)return t;for(let{name:e,param:i}of r){let r=i.select?.fields||[],a=i.select?.bind===`legend`,o=null;for(let e of n)if(Array.isArray(t[e])){o=t[e];break}if(!o||o.length===0)continue;let s=0;for(let e=0;e<o.length;e++){let t=o[e];if(Ji(t,r)||a&&Yi(t,r)){s=e;break}}let c=o[s];c.params||=[],c.params.push(i),t.params=(t.params??[]).filter(t=>t.name!==e)}return Array.isArray(t.params)&&t.params.length===0&&delete t.params,t}function qi(e,t){if(!t||Object.keys(t).length===0)return e;let n=JSON.parse(JSON.stringify(e)),r=e=>{for(let n of e)n.name&&n.name in t&&(n.value=t[n.name])};Array.isArray(n.params)&&r(n.params);let i=e=>{if(Array.isArray(e)){for(let t of e)if(Array.isArray(t.params)&&r(t.params),t.vconcat&&i(t.vconcat),t.hconcat&&i(t.hconcat),t.concat&&i(t.concat),Array.isArray(t.layer))for(let e of t.layer)Array.isArray(e.params)&&r(e.params)}};if(n.vconcat&&i(n.vconcat),n.hconcat&&i(n.hconcat),n.concat&&i(n.concat),Array.isArray(n.layer))for(let e of n.layer)e&&Array.isArray(e.params)&&r(e.params);return n}function Ji(e,t){if(!e?.encoding)return!1;for(let n of t)for(let t of Object.values(e.encoding))if(t.field===n)return!0;if(Array.isArray(e.layer)){for(let n of e.layer)if(Ji(n,t))return!0}return!1}function Yi(e,t){if(!e)return!1;let n=e=>{if(!e)return!1;let n=e.color?.field;return!!n&&t.includes(n)};if(n(e.encoding))return!0;if(Array.isArray(e.layer)){for(let t of e.layer)if(n(t.encoding))return!0}return!1}function Xi(e,t=[]){let n=[];if(!e||typeof e!=`object`)return n;if(e.data&&typeof e.data==`object`){let r=e.data.url;typeof r==`string`&&r.startsWith(`artifact:`)&&n.push({path:[...t,`data`],artifactPath:r.replace(/^artifact:/,``).trim()})}for(let r of[`layer`,`vconcat`,`hconcat`,`concat`,`spec`,`repeat`,`facet`])if(r in e){let i=e[r];Array.isArray(i)?i.forEach((e,i)=>{Gi(e)&&n.push(...Xi(e,[...t,r,String(i)]))}):Gi(i)&&n.push(...Xi(i,[...t,r]))}return n}function Zi(e,t){let n=JSON.parse(JSON.stringify(e));for(let[e,r]of t){let t=e.split(`.`),i=n;for(let e=0;e<t.length-1;e++){let n=i[t[e]];if(!Wi(n))break;i=n}let a=t[t.length-1],o=i[a];Wi(o)&&(delete o.url,o.values=r)}return n}function Qi(e){let t={background:`transparent`,view:{stroke:`transparent`},range:{category:Ui.categorical,diverging:Ui.diverging,heatmap:Ui.purples,ramp:Ui.blues},mark:{tooltip:!0},bar:{tooltip:!0,cornerRadiusTopLeft:4,cornerRadiusTopRight:4},line:{tooltip:!0,strokeWidth:2.5,strokeCap:`round`},point:{tooltip:!0,size:60,filled:!0},area:{tooltip:!0,fillOpacity:.7,line:!0},rect:{tooltip:!0,cornerRadius:2},arc:{tooltip:!0,cornerRadius:4},circle:{tooltip:!0,size:80}};return e?{...t,axis:{labelColor:`#a1a1aa`,titleColor:`#e4e4e7`,gridColor:`#3f3f46`,domainColor:`#52525b`,tickColor:`#52525b`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:`#a1a1aa`,titleColor:`#e4e4e7`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:`#fafafa`,font:`Inter, system-ui, sans-serif`,fontSize:14,fontWeight:600}}:{...t,axis:{labelColor:`#71717a`,titleColor:`#3f3f46`,gridColor:`#e4e4e7`,domainColor:`#d4d4d8`,tickColor:`#d4d4d8`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:`#71717a`,titleColor:`#3f3f46`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:`#18181b`,font:`Inter, system-ui, sans-serif`,fontSize:14,fontWeight:600}}}const $i=ne(function({spec:i,artifactRunId:a}){let{t:o}=se(),{title:s,description:c,options:l}=i,u=i.spec,[d,f]=B(!1),[p,m]=B(!1),[h,g]=B(null),[_,v]=B(!1),y=z(null),b=z(null),x=z(null),{client:S}=ye(),C=Pi(),w=z(S);w.current=S;let T=z(C);T.current=C;let[E,D]=B(null),[O,k]=B(!1),[A,j]=B(null),M=l?.mode||`chart`,N=M===`dashboard`,P=l?.enableFullscreen??N,F=l?.height||Hi(u,M);L(()=>{let e=Xi(u);if(e.length===0){D(u),k(!1),j(null);return}a?console.info(`[VegaLiteChart] resolving artifacts with runId:`,a,e.map(e=>e.artifactPath)):console.warn(`[VegaLiteChart] artifact references found but artifactRunId is missing!`,{references:e.map(e=>e.artifactPath),artifactRunId:a});let t=!1;return k(!0),j(null),(async()=>{let n=new Map,r=w.current,i=T.current;for(let o of e)try{let e=o.path.join(`.`),t;if(a&&!Fi(o.artifactPath)){let e=Ii(a,o.artifactPath,`inline`);t=i?await i.getOrFetch(e,async()=>(await r.files.getArtifactDownloadUrl(a,o.artifactPath,`inline`)).url):(await r.files.getArtifactDownloadUrl(a,o.artifactPath,`inline`)).url}else{let e=Li(o.artifactPath);t=i?await i.getOrFetch(e,async()=>(await r.files.getDownloadUrl(o.artifactPath)).url):(await r.files.getDownloadUrl(o.artifactPath)).url}let s=await fetch(t);if(!s.ok)throw Error(`Failed to fetch artifact data: ${s.statusText}`);let c=o.artifactPath.toLowerCase().endsWith(`.csv`),l;if(c){let{default:e}=await import(`papaparse`),t=await s.text();l=e.parse(t,{header:!0,skipEmptyLines:!0,dynamicTyping:!0}).data}else{let e=await s.json();l=Array.isArray(e)?e:[e]}n.set(e,l)}catch(e){console.error(`Failed to resolve artifact: ${o.artifactPath}`,e),t||j(`Failed to load data from artifact: ${o.artifactPath}`);return}if(!t){let e=Zi(u,n);D(e),k(!1)}})(),()=>{t=!0}},[u,a]);let[te,ne]=B(!1),re=z(!1);L(()=>{let e=()=>{let e=document.documentElement.classList.contains(`dark`);e!==re.current&&(re.current=e,ne(e))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},[]);let[ie,ae]=B(0),oe=z(0);L(()=>{if(!x.current)return;let e,t=new ResizeObserver(t=>{clearTimeout(e),e=setTimeout(()=>{let e=t[0]?.contentRect.width;e&&e!==oe.current&&(oe.current=e,ae(e))},100)});t.observe(x.current);let n=x.current.clientWidth;return oe.current=n,ae(n),()=>{clearTimeout(e),t.disconnect()}},[]);let ce=R(()=>Xi(u).length>0,[u]),le=R(()=>{if(ce&&!E)return null;let e=E||u;return e?(l?.parameterValues&&(e=qi(e,l.parameterValues)),Ki(e)):null},[E,u,ce,l?.parameterValues]),ue=I((e,t)=>{if(!e||typeof e!=`object`)return e;if(e.hconcat&&Array.isArray(e.hconcat)){let n=e.hconcat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,hconcat:e.hconcat.map(e=>ue(e,i))}}if(e.vconcat&&Array.isArray(e.vconcat))return{...e,vconcat:e.vconcat.map(e=>ue(e,t))};if(e.concat&&Array.isArray(e.concat)){let n=e.columns??e.concat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,concat:e.concat.map(e=>ue(e,i))}}let n=e.width;return n===`container`||typeof n==`number`&&n>t?{...e,width:t}:e},[]),de=I((e,t=!1)=>{if(!le)return null;let n=Qi(te),r=t?typeof window<`u`?Math.min(window.innerWidth-80,1400):1200:ie>0?ie-24:500,i=`vconcat`in le||`hconcat`in le||`concat`in le,a=i?{type:`pad`,contains:`padding`}:{type:`fit`,contains:`padding`},o=le;i&&r&&(o=ue(le,r));let c=o.width,l=i?void 0:c===`container`?r:c??r,{width:u,...d}=o;return{$schema:`https://vega.github.io/schema/vega-lite/v6.json`,...!i&&l?{width:l}:{},height:t?void 0:e,autosize:a,...i?o:d,...s&&!le.title?{title:s}:{},config:{...n,...le.config}}},[le,s,te,ie,ue]),fe=I(async()=>{let e=_?b.current:y.current;if(!(!e||p))try{(await e.toCanvas(2)).toBlob(async e=>{e&&(await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),m(!0),setTimeout(()=>m(!1),2e3))},`image/png`)}catch(e){console.error(`Failed to copy chart:`,e)}},[p,_]),pe=I(async()=>{let e=_?b.current:y.current;if(!(!e||d)){f(!0);try{let t=await e.toImageURL(`png`,2),n=document.createElement(`a`);n.download=`${s||`chart`}.png`,n.href=t,n.click()}catch(e){console.error(`Failed to export chart:`,e)}finally{f(!1)}}},[s,d,_]),me=I(e=>{y.current=e,g(null)},[]),he=I(e=>{b.current=e},[]),ge=I(e=>{console.error(`Vega-Lite rendering error:`,e),g(e instanceof Error?e.message:`Unknown error`)},[]),_e=I(()=>{v(e=>!e)},[]);L(()=>{g(null)},[u]);let ve=({className:e})=>n(`div`,{className:Mi(`flex items-center gap-2`,e),children:[n(r,{variant:`unstyled`,onClick:fe,disabled:p,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 flex items-center gap-1`,title:o(`agent.copyToClipboard`),children:[t(p?We:Qe,{className:`w-3 h-3`}),o(p?`agent.copied`:`agent.copy`)]}),n(r,{variant:`unstyled`,onClick:pe,disabled:d,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-1`,title:o(`agent.exportAsPng`),children:[t($e,{className:`w-3 h-3`}),o(d?`agent.exporting`:`agent.export`)]}),P&&n(r,{variant:`unstyled`,onClick:_e,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors flex items-center gap-1`,title:o(_?`agent.exitFullscreen`:`agent.fullscreen`),children:[t(_?dt:lt,{className:`w-3 h-3`}),o(_?`agent.exit`:`agent.fullscreen`)]})]});if(O||ce&&!E)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{className:`flex items-center justify-center bg-gray-50 dark:bg-gray-800 rounded`,style:{width:`100%`,height:F},children:n(`div`,{className:`flex items-center gap-2 text-gray-500 dark:text-gray-400`,children:[t(ct,{className:`w-5 h-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading data from artifacts...`})]})})]})});if(A)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:F},children:t(zi,{error:A,chartTitle:s})})]})});if(h)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:F},children:t(zi,{error:h,chartTitle:s})})]})});let be=de(F),xe=de(0,!0);return be?(typeof window<`u`&&localStorage.getItem(`DEBUG_VEGA_RENDERS`)&&console.log(`VegaLite rendering with spec:`,{title:s,hasData:!!be.data?.values,dataLength:be.data?.values?.length}),n(e,{children:[t(`div`,{className:Mi(`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,N&&`border-2`),children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[n(`div`,{className:`flex items-center justify-between`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||(N?`Dashboard`:`Chart`)}),N&&t(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-indigo-100 dark:bg-indigo-900 text-indigo-700 dark:text-indigo-300`,children:`Interactive`})]}),t(ve,{})]}),c&&t(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:c}),t(`div`,{ref:x,className:`bg-white dark:bg-gray-900 rounded overflow-hidden`,style:{width:`100%`,height:F,minWidth:0},children:t(ee,{fallback:t(Bi,{}),children:t(Ri,{spec:be,onEmbed:e=>me(e.view),onError:ge,options:{renderer:l?.renderer||`canvas`,actions:!1}})})})]})}),n(Vi,{isOpen:_,onClose:()=>v(!1),title:s||(N?`Dashboard`:`Chart`),description:c,children:[t(`div`,{className:`w-full h-full min-h-[calc(100vh-200px)]`,children:xe&&t(ee,{fallback:t(Bi,{}),children:t(Ri,{spec:xe,onEmbed:e=>he(e.view),onError:ge,options:{renderer:l?.renderer||`canvas`,actions:!1}})})}),t(`div`,{className:`absolute bottom-6 end-6`,children:t(ve,{className:`bg-white dark:bg-gray-800 rounded-lg shadow-lg p-2 border border-gray-200 dark:border-gray-700`})})]})]})):null},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId),ea=M.createContext({});function ta({children:e,artifactRunId:n,onProposalSelect:r,onProposalSubmit:i,MarkdownRenderer:a}){let o=R(()=>({artifactRunId:n,onProposalSelect:r,onProposalSubmit:i,MarkdownRenderer:a}),[n,r,i,a]);return t(ea.Provider,{value:o,children:e})}function na(){return M.useContext(ea)}const ra={chart:{icon:Ue,label:`chart`,defaultHeight:200},mermaid:{icon:tt,label:`diagram`,defaultHeight:150},proposal:{icon:ut,label:`options`,defaultHeight:100},code:{icon:Ze,label:`code`,defaultHeight:80},image:{icon:it,label:`image`,defaultHeight:150},link:{icon:ot,label:`link`,defaultHeight:24},expand:{icon:$e,label:`content`,defaultHeight:100},table:{icon:yt,label:`table`,defaultHeight:150},markdown:{icon:et,label:`content`,defaultHeight:100},"fusion-fragment":{icon:Ze,label:`fragment`,defaultHeight:150}};function U({type:e,error:i,onRetry:a,message:o,height:s}){let c=ra[e],l=s??c.defaultHeight,u=e===`link`;if(i)return n(`div`,{className:`flex items-center gap-2 rounded border border-destructive/30 bg-destructive/5 text-destructive ${u?`inline-flex px-2 py-1 text-sm`:`p-4`}`,style:u?void 0:{minHeight:l},children:[n(`span`,{className:`text-destructive`,children:[`Failed to load `,c.label]}),a&&t(r,{variant:`unstyled`,onClick:a,className:`ms-2 rounded bg-destructive/10 px-2 py-1 text-xs hover:bg-destructive/20 transition-colors text-destructive`,children:`Retry`})]});let d=c.icon;return u?n(`span`,{className:`inline-flex items-center gap-1 text-muted animate-pulse`,children:[t(d,{className:`h-3 w-3`}),t(`span`,{children:o||`Loading ${c.label}...`})]}):n(`div`,{className:`flex flex-col items-center justify-center gap-3 rounded border border-border bg-muted/30 animate-pulse`,style:{minHeight:l},children:[t(d,{className:`h-8 w-8 text-muted`}),t(`span`,{className:`text-sm text-muted`,children:o||`Loading ${c.label}...`}),t(`div`,{className:`flex gap-1`,children:[...[,,,]].map((e,n)=>t(`div`,{className:`h-2 w-2 rounded-full bg-muted animate-bounce`,style:{animationDelay:`${n*150}ms`}},`dot-${n}`))})]})}var ia=class extends M.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`CodeBlock rendering error (${this.props.type}):`,e,t),this.props.onError?.(e)}handleRetry=()=>{this.setState({hasError:!1,error:void 0})};render(){if(this.state.hasError){let{type:e,fallbackCode:r}=this.props;return n(`div`,{className:`space-y-2`,children:[t(U,{type:e,error:this.state.error?.message||`Rendering failed`,onRetry:this.handleRetry}),r&&n(`details`,{className:`text-sm`,children:[t(`summary`,{className:`cursor-pointer text-muted hover:text-foreground`,children:`Show raw content`}),t(`pre`,{className:`mt-2 overflow-x-auto rounded bg-muted/50 p-2 text-xs`,children:t(`code`,{children:r})})]})]})}return this.props.children}};function aa(e,t,n){let r=t.split(`.`).pop()?.toLowerCase();if(r===`svg`)return`mockup`;if([`png`,`jpg`,`jpeg`,`gif`,`webp`].includes(r||``))return`image`;if(r===`md`)return`markdown`;if(r===`csv`)return`table`;if(n===`json`&&typeof e==`object`&&e){let t=e;if(typeof t.$schema==`string`&&t.$schema.includes(`vega`)||t.library===`vega-lite`&&`spec`in t)return`vega-lite`;if(`template`in t&&`data`in t)return`fusion-fragment`;if(Array.isArray(e)&&e.length>0&&typeof e[0]==`object`)return`table`}return`code`}function oa(e){if(typeof e!=`object`||!e)return null;let t=e;return t.library===`vega-lite`&&`spec`in t&&typeof t.spec==`object`&&t.spec!==null?t:typeof t.$schema==`string`&&t.$schema.includes(`vega`)?{library:`vega-lite`,spec:t}:null}function sa({content:e}){let{headers:r,rows:i}=R(()=>{if(!Array.isArray(e)||e.length===0)return{headers:[],rows:[]};let t=e[0];if(typeof t!=`object`||!t)return{headers:[],rows:[]};let n=Object.keys(t);return{headers:n,rows:e.map(e=>n.map(t=>{let n=e[t];return n==null?``:typeof n==`object`?JSON.stringify(n):String(n)}))}},[e]);return r.length===0?t(U,{type:`table`,error:`No table data found`}):n(`div`,{className:`overflow-x-auto`,children:[n(`table`,{className:`min-w-full text-sm border-collapse`,children:[t(`thead`,{children:t(`tr`,{className:`border-b`,children:r.map(e=>t(`th`,{className:`px-3 py-2 text-start font-medium text-muted`,children:e},e))})}),t(`tbody`,{children:i.slice(0,100).map((e,n)=>t(`tr`,{className:`border-b border-muted/20`,children:e.map((e,n)=>t(`td`,{className:`px-3 py-2`,children:e},`cell-${n}`))},`row-${n}`))})]}),i.length>100&&n(`div`,{className:`text-sm text-muted py-2`,children:[`Showing 100 of `,i.length,` rows`]})]})}function ca({content:e,path:n}){let r=n.split(`.`).pop()?.toLowerCase()||``,i=typeof e==`string`?e:JSON.stringify(e,null,2);return t(`pre`,{className:`overflow-x-auto p-3 bg-muted/10 rounded text-sm`,children:t(`code`,{className:`language-${r}`,children:i})})}function la(e){return de.sanitize(e,{USE_PROFILES:{svg:!0,svgFilters:!0},ADD_TAGS:[`use`],FORBID_TAGS:[`foreignObject`]})}function ua(e){return e.replace(/<svg([^>]*)>/i,(e,t)=>{let n=t;if(!/viewBox/i.test(n)){let e=/\swidth\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(n),t=/\sheight\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(n);e&&t&&(n+=` viewBox="0 0 ${e[1]} ${t[1]}"`)}return n=n.replace(/\swidth\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,``).replace(/\sheight\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,``),/style="/i.test(n)?n=n.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):n+=` style="width:100%;height:auto;display:block;max-width:100%;"`,/preserveAspectRatio=/i.test(n)||(n+=` preserveAspectRatio="xMidYMid meet"`),`<svg${n}>`})}function da({content:e}){let n=R(()=>{let t=typeof e==`string`?e.trim():``;return t?ua(la(t)):null},[e]);return n?t(`div`,{style:{margin:`16px 0`,width:`100%`,overflowX:`auto`},dangerouslySetInnerHTML:{__html:n}}):t(U,{type:`expand`,error:`Empty mockup`})}function fa({content:e,path:n}){let r=typeof e==`string`?e:``,i=n.split(`/`).pop()||`Artifact image`;return t(`img`,{src:r,alt:i,className:`max-w-full h-auto rounded`,loading:`lazy`})}function pa({content:e,renderType:n,path:r,runId:i,contentType:a}){let{MarkdownRenderer:o}=na();switch(R(()=>n===`auto`?aa(e,r,a):n,[e,r,a,n])){case`chart`:{let n=oa(e);return n?t(ia,{type:`chart`,fallbackCode:JSON.stringify(e,null,2),children:t($i,{spec:n,artifactRunId:i})}):t(U,{type:`chart`,error:`Only Vega-Lite charts are supported. Recharts rendering has been retired.`})}case`vega-lite`:{let n=oa(e);return n?t(ia,{type:`chart`,fallbackCode:JSON.stringify(e,null,2),children:t($i,{spec:n,artifactRunId:i})}):t(U,{type:`chart`,error:`Invalid Vega-Lite specification`})}case`fusion-fragment`:{let n=e;return console.log(`[ArtifactContentRenderer] fusion-fragment:`,{hasTemplate:!!n.template,hasData:!!n.data,runId:i,hasVegaLiteChart:!!$i}),n.template&&n.data?t(ia,{type:`fusion-fragment`,fallbackCode:JSON.stringify(e,null,2),children:t(ue,{data:n.data,ChartComponent:$i,artifactRunId:i,children:t(le,{code:JSON.stringify(n.template),data:n.data})})}):t(ia,{type:`fusion-fragment`,fallbackCode:JSON.stringify(e,null,2),children:t(le,{code:JSON.stringify(e)})})}case`table`:return t(ia,{type:`table`,fallbackCode:JSON.stringify(e,null,2),children:t(sa,{content:e})});case`markdown`:{let n=typeof e==`string`?e:String(e);return t(ia,{type:`markdown`,fallbackCode:n,children:o?t(o,{artifactRunId:i,children:n}):t(`pre`,{className:`overflow-x-auto p-3 bg-muted/10 rounded text-sm`,children:t(`code`,{children:n})})})}case`mockup`:return t(ia,{type:`expand`,fallbackCode:typeof e==`string`?e:r,children:t(da,{content:e})});case`image`:return t(ia,{type:`image`,fallbackCode:r,children:t(fa,{content:e,path:r})});default:return t(ca,{content:e,path:r})}}function ma(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}const ha=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ga=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_a={};function va(e,t){return((t||_a).jsx?ga:ha).test(e)}const ya=/[ \t\n\f\r]/g;function ba(e){return typeof e==`object`?e.type===`text`&&xa(e.value):xa(e)}function xa(e){return e.replace(ya,``)===``}var Sa=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};Sa.prototype.normal={},Sa.prototype.property={},Sa.prototype.space=void 0;function Ca(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new Sa(n,r,t)}function wa(e){return e.toLowerCase()}var Ta=class{constructor(e,t){this.attribute=t,this.property=e}};Ta.prototype.attribute=``,Ta.prototype.booleanish=!1,Ta.prototype.boolean=!1,Ta.prototype.commaOrSpaceSeparated=!1,Ta.prototype.commaSeparated=!1,Ta.prototype.defined=!1,Ta.prototype.mustUseProperty=!1,Ta.prototype.number=!1,Ta.prototype.overloadedBoolean=!1,Ta.prototype.property=``,Ta.prototype.spaceSeparated=!1,Ta.prototype.space=void 0;var Ea=Ae({boolean:()=>W,booleanish:()=>G,commaOrSpaceSeparated:()=>Aa,commaSeparated:()=>ka,number:()=>K,overloadedBoolean:()=>Oa,spaceSeparated:()=>q});let Da=0;const W=ja(),G=ja(),Oa=ja(),K=ja(),q=ja(),ka=ja(),Aa=ja();function ja(){return 2**++Da}const Ma=Object.keys(Ea);var Na=class extends Ta{constructor(e,t,n,r){let i=-1;if(super(e,t),Pa(this,`space`,r),typeof n==`number`)for(;++i<Ma.length;){let e=Ma[i];Pa(this,Ma[i],(n&Ea[e])===Ea[e])}}};Na.prototype.defined=!0;function Pa(e,t,n){n&&(e[t]=n)}function Fa(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Na(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[wa(r)]=r,n[wa(a.attribute)]=r}return new Sa(t,n,e.space)}const Ia=Fa({properties:{ariaActiveDescendant:null,ariaAtomic:G,ariaAutoComplete:null,ariaBusy:G,ariaChecked:G,ariaColCount:K,ariaColIndex:K,ariaColSpan:K,ariaControls:q,ariaCurrent:null,ariaDescribedBy:q,ariaDetails:null,ariaDisabled:G,ariaDropEffect:q,ariaErrorMessage:null,ariaExpanded:G,ariaFlowTo:q,ariaGrabbed:G,ariaHasPopup:null,ariaHidden:G,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:q,ariaLevel:K,ariaLive:null,ariaModal:G,ariaMultiLine:G,ariaMultiSelectable:G,ariaOrientation:null,ariaOwns:q,ariaPlaceholder:null,ariaPosInSet:K,ariaPressed:G,ariaReadOnly:G,ariaRelevant:null,ariaRequired:G,ariaRoleDescription:q,ariaRowCount:K,ariaRowIndex:K,ariaRowSpan:K,ariaSelected:G,ariaSetSize:K,ariaSort:null,ariaValueMax:K,ariaValueMin:K,ariaValueNow:K,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function La(e,t){return t in e?e[t]:t}function Ra(e,t){return La(e,t.toLowerCase())}const za=Fa({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:ka,acceptCharset:q,accessKey:q,action:null,allow:null,allowFullScreen:W,allowPaymentRequest:W,allowUserMedia:W,alt:null,as:null,async:W,autoCapitalize:null,autoComplete:q,autoFocus:W,autoPlay:W,blocking:q,capture:null,charSet:null,checked:W,cite:null,className:q,cols:K,colSpan:null,content:null,contentEditable:G,controls:W,controlsList:q,coords:K|ka,crossOrigin:null,data:null,dateTime:null,decoding:null,default:W,defer:W,dir:null,dirName:null,disabled:W,download:Oa,draggable:G,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:W,formTarget:null,headers:q,height:K,hidden:Oa,high:K,href:null,hrefLang:null,htmlFor:q,httpEquiv:q,id:null,imageSizes:null,imageSrcSet:null,inert:W,inputMode:null,integrity:null,is:null,isMap:W,itemId:null,itemProp:q,itemRef:q,itemScope:W,itemType:q,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:W,low:K,manifest:null,max:null,maxLength:K,media:null,method:null,min:null,minLength:K,multiple:W,muted:W,name:null,nonce:null,noModule:W,noValidate:W,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:W,optimum:K,pattern:null,ping:q,placeholder:null,playsInline:W,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:W,referrerPolicy:null,rel:q,required:W,reversed:W,rows:K,rowSpan:K,sandbox:q,scope:null,scoped:W,seamless:W,selected:W,shadowRootClonable:W,shadowRootDelegatesFocus:W,shadowRootMode:null,shape:null,size:K,sizes:null,slot:null,span:K,spellCheck:G,src:null,srcDoc:null,srcLang:null,srcSet:null,start:K,step:null,style:null,tabIndex:K,target:null,title:null,translate:null,type:null,typeMustMatch:W,useMap:null,value:G,width:K,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:q,axis:null,background:null,bgColor:null,border:K,borderColor:null,bottomMargin:K,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:W,declare:W,event:null,face:null,frame:null,frameBorder:null,hSpace:K,leftMargin:K,link:null,longDesc:null,lowSrc:null,marginHeight:K,marginWidth:K,noResize:W,noHref:W,noShade:W,noWrap:W,object:null,profile:null,prompt:null,rev:null,rightMargin:K,rules:null,scheme:null,scrolling:G,standby:null,summary:null,text:null,topMargin:K,valueType:null,version:null,vAlign:null,vLink:null,vSpace:K,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:W,disableRemotePlayback:W,prefix:null,property:null,results:K,security:null,unselectable:null},space:`html`,transform:Ra}),Ba=Fa({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:Aa,accentHeight:K,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:K,amplitude:K,arabicForm:null,ascent:K,attributeName:null,attributeType:null,azimuth:K,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:K,by:null,calcMode:null,capHeight:K,className:q,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:K,diffuseConstant:K,direction:null,display:null,dur:null,divisor:K,dominantBaseline:null,download:W,dx:null,dy:null,edgeMode:null,editable:null,elevation:K,enableBackground:null,end:null,event:null,exponent:K,externalResourcesRequired:null,fill:null,fillOpacity:K,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:ka,g2:ka,glyphName:ka,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:K,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:K,horizOriginX:K,horizOriginY:K,id:null,ideographic:K,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:K,k:K,k1:K,k2:K,k3:K,k4:K,kernelMatrix:Aa,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:K,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:K,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:K,overlineThickness:K,paintOrder:null,panose1:null,path:null,pathLength:K,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:q,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:K,pointsAtY:K,pointsAtZ:K,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Aa,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Aa,rev:Aa,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Aa,requiredFeatures:Aa,requiredFonts:Aa,requiredFormats:Aa,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:K,specularExponent:K,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:K,strikethroughThickness:K,string:null,stroke:null,strokeDashArray:Aa,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:K,strokeOpacity:K,strokeWidth:null,style:null,surfaceScale:K,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Aa,tabIndex:K,tableValues:null,target:null,targetX:K,targetY:K,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Aa,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:K,underlineThickness:K,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:K,values:null,vAlphabetic:K,vMathematical:K,vectorEffect:null,vHanging:K,vIdeographic:K,version:null,vertAdvY:K,vertOriginX:K,vertOriginY:K,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:K,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:La}),Va=Fa({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),Ha=Fa({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Ra}),Ua=Fa({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Wa={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},Ga=/[A-Z]/g,Ka=/-[a-z]/g,qa=/^data[-\w.:]+$/i;function Ja(e,t){let n=wa(t),r=t,i=Ta;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&qa.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Ka,Xa);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Ka.test(e)){let n=e.replace(Ga,Ya);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Na}return new i(r,t)}function Ya(e){return`-`+e.toLowerCase()}function Xa(e){return e.charAt(1).toUpperCase()}const Za=Ca([Ia,za,Va,Ha,Ua],`html`),Qa=Ca([Ia,Ba,Va,Ha,Ua],`svg`);function $a(e){return e.join(` `).trim()}function eo(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var n=1,r=1;function i(e){var t=e.match(ro);t&&(n+=t.length);var i=e.lastIndexOf(uo);r=~i?e.length-i:r+e.length}function a(){var e={line:n,column:r};return function(t){return t.position=new o(e),l(),t}}function o(e){this.start=e,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function s(i){var a=Error(t.source+`:`+n+`:`+r+`: `+i);if(a.reason=i,a.filename=t.source,a.line=n,a.column=r,a.source=e,!t.silent)throw a}function c(t){var n=t.exec(e);if(n){var r=n[0];return i(r),e=e.slice(r.length),n}}function l(){c(io)}function u(e){var t;for(e||=[];t=d();)t!==!1&&e.push(t);return e}function d(){var t=a();if(fo==e.charAt(0)&&po==e.charAt(1)){for(var n=2;mo!=e.charAt(n)&&(po!=e.charAt(n)||fo!=e.charAt(n+1));)++n;if(n+=2,mo===e.charAt(n-1))return s(`End of comment missing`);var o=e.slice(2,n-2);return r+=2,i(o),e=e.slice(n),r+=2,t({type:ho,comment:o})}}function f(){var e=a(),t=c(ao);if(t){if(d(),!c(oo))return s(`property missing ':'`);var n=c(so),r=e({type:go,property:to(t[0].replace(no,mo)),value:n?to(n[0].replace(no,mo)):mo});return c(co),r}}function p(){var e=[];u(e);for(var t;t=f();)t!==!1&&(e.push(t),u(e));return e}return l(),p()}function to(e){return e?e.replace(lo,mo):mo}var no,ro,io,ao,oo,so,co,lo,uo,fo,po,mo,ho,go,_o=Oe((()=>{no=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,ro=/\n/g,io=/^\s*/,ao=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,oo=/^:\s*/,so=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,co=/^[;\s]*/,lo=/^\s+|\s+$/g,uo=`
|
|
277
277
|
`,fo=`/`,po=`*`,mo=``,ho=`comment`,go=`declaration`})),vo=Ae({default:()=>yo});function yo(e,t){let n=null;if(!e||typeof e!=`string`)return n;let r=eo(e),i=typeof t==`function`;return r.forEach(e=>{if(e.type!==`declaration`)return;let{property:r,value:a}=e;i?t(r,a,e):a&&(n||={},n[r]=a)}),n}var bo=Oe((()=>{_o()})),xo=ke((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),So=ke(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})((bo(),Ne(vo))),r=xo();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i}));const Co=To(`end`),wo=To(`start`);function To(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function Eo(e){let t=wo(e),n=Co(e);if(t&&n)return{start:t,end:n}}function Do(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?ko(e.position):`start`in e||`end`in e?ko(e):`line`in e||`column`in e?Oo(e):``}function Oo(e){return Ao(e&&e.line)+`:`+Ao(e&&e.column)}function ko(e){return Oo(e&&e.start)+`-`+Oo(e&&e.end)}function Ao(e){return e&&typeof e==`number`?e:1}var jo=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=Do(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};jo.prototype.file=``,jo.prototype.name=``,jo.prototype.reason=``,jo.prototype.message=``,jo.prototype.stack=``,jo.prototype.column=void 0,jo.prototype.line=void 0,jo.prototype.ancestors=void 0,jo.prototype.cause=void 0,jo.prototype.fatal=void 0,jo.prototype.place=void 0,jo.prototype.ruleId=void 0,jo.prototype.source=void 0;var Mo=Me(So(),1);const No={}.hasOwnProperty,Po=new Map,Fo=/[A-Z]/g,Io=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),Lo=new Set([`td`,`th`]);function Ro(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=Yo(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=Jo(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?Qa:Za,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=zo(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function zo(e,t,n){if(t.type===`element`)return Bo(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return Vo(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return Uo(e,t,n);if(t.type===`mdxjsEsm`)return Ho(e,t);if(t.type===`root`)return Wo(e,t,n);if(t.type===`text`)return Go(e,t)}function Bo(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=Qa,e.schema=i),e.ancestors.push(t);let a=ts(e,t.tagName,!1),o=Xo(e,t),s=Qo(e,t);return Io.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!ba(e)})),Ko(e,o,a,t),qo(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Vo(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}ns(e,t.position)}function Ho(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ns(e,t.position)}function Uo(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=Qa,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:ts(e,t.name,!0),o=Zo(e,t),s=Qo(e,t);return Ko(e,o,a,t),qo(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Wo(e,t,n){let r={};return qo(r,Qo(e,t)),e.create(t,e.Fragment,r,n)}function Go(e,t){return t.value}function Ko(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function qo(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function Jo(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function Yo(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=wo(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function Xo(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&No.call(t.properties,i)){let a=$o(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&Lo.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function Zo(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else ns(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else ns(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function Qo(e,t){let n=[],r=-1,i=e.passKeys?new Map:Po;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=zo(e,a,o);s!==void 0&&n.push(s)}return n}function $o(e,t,n){let r=Ja(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?ma(n):$a(n)),r.property===`style`){let t=typeof n==`object`?n:es(e,String(n));return e.stylePropertyNameCase===`css`&&(t=rs(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?Wa[r.property]||r.property:r.attribute,n]}}function es(e,t){try{return(0,Mo.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new jo("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-parse-style-attribute`,r}}function ts(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=va(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=va(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return No.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);ns(e)}function ns(e,t){let n=new jo("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-handle-mdx-estrees-without-createevaluater`,n}function rs(e){let t={},n;for(n in e)No.call(e,n)&&(t[is(n)]=e[n]);return t}function is(e){let t=e.replace(Fo,as);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function as(e){return`-`+e.toLowerCase()}const os={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},ss={};function cs(e,t){let n=t||ss;return ls(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function ls(e,t,n){if(ds(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return us(e.children,t,n)}return Array.isArray(e)?us(e,t,n):``}function us(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=ls(e[i],t,n);return r.join(``)}function ds(e){return!!(e&&typeof e==`object`)}const fs=document.createElement(`i`);function ps(e){let t=`&`+e+`;`;fs.innerHTML=t;let n=fs.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function J(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function ms(e,t){return e.length>0?(J(e,e.length,0,t),e):t}const hs={}.hasOwnProperty;function gs(e){let t={},n=-1;for(;++n<e.length;)_s(t,e[n]);return t}function _s(e,t){let n;for(n in t){let r=(hs.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){hs.call(r,a)||(r[a]=[]);let e=i[a];vs(r[a],Array.isArray(e)?e:e?[e]:[])}}}function vs(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);J(e,0,0,r)}function ys(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function bs(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}const xs=As(/[A-Za-z]/),Ss=As(/[\dA-Za-z]/),Cs=As(/[#-'*+\--9=?A-Z^-~]/);function ws(e){return e!==null&&(e<32||e===127)}const Ts=As(/\d/),Es=As(/[\dA-Fa-f]/),Ds=As(/[!-/:-@[-`{-~]/);function Y(e){return e!==null&&e<-2}function X(e){return e!==null&&(e<0||e===32)}function Z(e){return e===-2||e===-1||e===32}const Os=As(/\p{P}|\p{S}/u),ks=As(/\s/);function As(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function js(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&Ss(e.charCodeAt(n+1))&&Ss(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function Q(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return Z(r)?(e.enter(n),s(r)):t(r)}function s(r){return Z(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}const Ms={tokenize:Ns};function Ns(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Q(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return Y(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}const Ps={tokenize:Is},Fs={tokenize:Ls};function Is(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return J(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Fs,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(Fs,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return Y(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;J(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Ls(e,t,n){return Q(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function Rs(e){if(e===null||X(e)||ks(e))return 1;if(Os(e))return 2}function zs(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const Bs={name:`attention`,resolveAll:Vs,tokenize:Hs};function Vs(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};Us(d,-c),Us(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=ms(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=ms(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=ms(l,zs(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=ms(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=ms(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,J(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function Hs(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Rs(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=Rs(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function Us(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Ws={name:`autolink`,tokenize:Gs};function Gs(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return xs(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||Ss(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||Ss(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||ws(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):Cs(t)?(e.consume(t),l):n(t)}function u(e){return Ss(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||Ss(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}const Ks={partial:!0,tokenize:qs};function qs(e,t,n){return r;function r(t){return Z(t)?Q(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||Y(e)?t(e):n(e)}}const Js={continuation:{tokenize:Xs},exit:Zs,name:`blockQuote`,tokenize:Ys};function Ys(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return Z(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Xs(e,t,n){let r=this;return i;function i(t){return Z(t)?Q(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Js,t,n)(r)}}function Zs(e){e.exit(`blockQuote`)}const Qs={name:`characterEscape`,tokenize:$s};function $s(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return Ds(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}const ec={name:`characterReference`,tokenize:tc};function tc(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=Ss,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=Es,u):(e.enter(`characterReferenceValue`),a=7,o=Ts,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===Ss&&!ps(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}const nc={partial:!0,tokenize:ac},rc={concrete:!0,name:`codeFenced`,tokenize:ic};function ic(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),Z(t)?Q(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||Y(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(nc,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||Y(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):Z(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),Q(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||Y(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||Y(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&Z(t)?Q(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||Y(t)?e.check(nc,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||Y(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),Z(t)?Q(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),Z(t)?Q(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||Y(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function ac(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}const oc={name:`codeIndented`,tokenize:cc},sc={partial:!0,tokenize:lc};function cc(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),Q(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):Y(t)?e.attempt(sc,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||Y(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function lc(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):Y(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):Q(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):Y(e)?i(e):n(e)}}const uc={name:`codeText`,previous:fc,resolve:dc,tokenize:pc};function dc(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function fc(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function pc(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):Y(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||Y(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var mc=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&hc(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),hc(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),hc(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);hc(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);hc(this.left,t.reverse())}}}};function hc(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function gc(e){let t={},n=-1,r,i,a,o,s,c,l,u=new mc(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,_c(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return J(e,0,1/0,u.slice(0)),!l}function _c(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}const vc={resolve:bc,tokenize:xc},yc={partial:!0,tokenize:Sc};function bc(e){return gc(e),e}function xc(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):Y(t)?e.check(yc,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function Sc(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Q(e,a,`linePrefix`)}function a(i){if(i===null||Y(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Cc(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||ws(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||Y(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||X(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||ws(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function wc(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):Y(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||Y(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!Z(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Tc(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):Y(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Q(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||Y(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function Ec(e,t){let n;return r;function r(i){return Y(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):Z(i)?Q(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}const Dc={name:`definition`,tokenize:kc},Oc={partial:!0,tokenize:Ac};function kc(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return wc.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=bs(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return X(t)?Ec(e,l)(t):l(t)}function l(t){return Cc(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Oc,d,d)(t)}function d(t){return Z(t)?Q(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||Y(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Ac(e,t,n){return r;function r(t){return X(t)?Ec(e,i)(t):n(t)}function i(t){return Tc(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return Z(t)?Q(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||Y(e)?t(e):n(e)}}const jc={name:`hardBreakEscape`,tokenize:Mc};function Mc(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return Y(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}const Nc={name:`headingAtx`,resolve:Pc,tokenize:Fc};function Pc(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},J(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Fc(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||X(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||Y(n)?(e.exit(`atxHeading`),t(n)):Z(n)?Q(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||X(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}const Ic=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Lc=[`pre`,`script`,`style`,`textarea`],Rc={concrete:!0,name:`htmlFlow`,resolveTo:Vc,tokenize:Hc},zc={partial:!0,tokenize:Wc},Bc={partial:!0,tokenize:Uc};function Vc(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Hc(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:F):xs(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):xs(a)?(e.consume(a),i=4,r.interrupt?t:F):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:F):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return xs(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||X(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Lc.includes(l)?(i=1,r.interrupt?t(s):O(s)):Ic.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||Ss(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return Z(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||xs(t)?(e.consume(t),b):Z(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||Ss(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):Z(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):Z(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||Y(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||X(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||Z(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||Y(t)?O(t):Z(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),ee):t===62&&i===4?(e.consume(t),te):t===63&&i===3?(e.consume(t),F):t===93&&i===5?(e.consume(t),P):Y(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(zc,ne,k)(t)):t===null||Y(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(Bc,A,ne)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||Y(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),F):O(t)}function ee(t){return t===47?(e.consume(t),o=``,N):O(t)}function N(t){if(t===62){let n=o.toLowerCase();return Lc.includes(n)?(e.consume(t),te):O(t)}return xs(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),N):O(t)}function P(t){return t===93?(e.consume(t),F):O(t)}function F(t){return t===62?(e.consume(t),te):t===45&&i===2?(e.consume(t),F):O(t)}function te(t){return t===null||Y(t)?(e.exit(`htmlFlowData`),ne(t)):(e.consume(t),te)}function ne(n){return e.exit(`htmlFlow`),t(n)}}function Uc(e,t,n){let r=this;return i;function i(t){return Y(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function Wc(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Ks,t,n)}}const Gc={name:`htmlText`,tokenize:Kc};function Kc(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):xs(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):xs(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):Y(t)?(o=d,ee(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):Y(t)?(o=h,ee(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):Y(t)?(o=v,ee(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):Y(t)?(o=y,ee(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return xs(t)?(e.consume(t),S):n(t)}function S(t){return t===45||Ss(t)?(e.consume(t),S):C(t)}function C(t){return Y(t)?(o=C,ee(t)):Z(t)?(e.consume(t),C):M(t)}function w(t){return t===45||Ss(t)?(e.consume(t),w):t===47||t===62||X(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||xs(t)?(e.consume(t),E):Y(t)?(o=T,ee(t)):Z(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||Ss(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):Y(t)?(o=D,ee(t)):Z(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):Y(t)?(o=O,ee(t)):Z(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):Y(t)?(o=k,ee(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||X(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||X(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function ee(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),N}function N(t){return Z(t)?Q(e,P,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):P(t)}function P(t){return e.enter(`htmlTextData`),o(t)}}const qc={name:`labelEnd`,resolveAll:Zc,resolveTo:Qc,tokenize:$c},Jc={tokenize:el},Yc={tokenize:tl},Xc={tokenize:nl};function Zc(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&J(e,0,e.length,n),e}function Qc(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=ms(s,e.slice(a+1,a+r+3)),s=ms(s,[[`enter`,u,t]]),s=ms(s,zs(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=ms(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=ms(s,e.slice(o+1)),s=ms(s,[[`exit`,c,t]]),J(e,a,e.length,s),e}function $c(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(bs(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Jc,u,o?u:d)(t):t===91?e.attempt(Yc,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Xc,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function el(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return X(t)?Ec(e,a)(t):a(t)}function a(t){return t===41?u(t):Cc(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return X(t)?Ec(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Tc(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return X(t)?Ec(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function tl(e,t,n){let r=this;return i;function i(t){return wc.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(bs(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function nl(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}const rl={name:`labelStartImage`,resolveAll:qc.resolveAll,tokenize:il};function il(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}const al={name:`labelStartLink`,resolveAll:qc.resolveAll,tokenize:ol};function ol(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}const sl={name:`lineEnding`,tokenize:cl};function cl(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Q(e,t,`linePrefix`)}}const ll={name:`thematicBreak`,tokenize:ul};function ul(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||Y(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),Z(t)?Q(e,s,`whitespace`)(t):s(t))}}const dl={continuation:{tokenize:hl},exit:_l,name:`list`,tokenize:ml},fl={partial:!0,tokenize:vl},pl={partial:!0,tokenize:gl};function ml(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:Ts(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(ll,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return Ts(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(Ks,r.interrupt?n:u,e.attempt(fl,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return Z(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function hl(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Ks,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Q(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!Z(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(pl,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,Q(e,e.attempt(dl,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function gl(e,t,n){let r=this;return Q(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function _l(e){e.exit(this.containerState.type)}function vl(e,t,n){let r=this;return Q(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!Z(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}const yl={name:`setextUnderline`,resolveTo:bl,tokenize:xl};function bl(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function xl(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),Z(t)?Q(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||Y(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}const Sl={tokenize:Cl};function Cl(e){let t=this,n=e.attempt(Ks,r,e.attempt(this.parser.constructs.flowInitial,i,Q(e,e.attempt(this.parser.constructs.flow,i,e.attempt(vc,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}const wl={resolveAll:Ol()},Tl=Dl(`string`),El=Dl(`text`);function Dl(e){return{resolveAll:Ol(e===`text`?kl:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function Ol(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function kl(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var Al=Ae({attentionMarkers:()=>Rl,contentInitial:()=>Ml,disable:()=>zl,document:()=>jl,flow:()=>Pl,flowInitial:()=>Nl,insideSpan:()=>Ll,string:()=>Fl,text:()=>Il});const jl={42:dl,43:dl,45:dl,48:dl,49:dl,50:dl,51:dl,52:dl,53:dl,54:dl,55:dl,56:dl,57:dl,62:Js},Ml={91:Dc},Nl={[-2]:oc,[-1]:oc,32:oc},Pl={35:Nc,42:ll,45:[yl,ll],60:Rc,61:yl,95:ll,96:rc,126:rc},Fl={38:ec,92:Qs},Il={[-5]:sl,[-4]:sl,[-3]:sl,33:rl,38:ec,42:Bs,60:[Ws,Gc],91:al,92:[jc,Qs],93:qc,95:Bs,96:uc},Ll={null:[Bs,wl]},Rl={null:[42,95]},zl={null:[]};function Bl(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=ms(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=zs(a,l.events,l),l.events):[]}function f(e,t){return Hl(p(e),t)}function p(e){return Vl(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){Y(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&J(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Vl(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Hl(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
@@ -337,7 +337,7 @@ let n=F(({className:n,...r},i)=>P(He,{ref:i,iconNode:t,className:Pe(`lucide-${Fe
|
|
|
337
337
|
`),t.split(`
|
|
338
338
|
`)),a=[];for(let e=0;e<i.length;e++){if(i[e].type===`equal`)continue;let t=a[a.length-1];t&&e-t.end<=r*2?t.end=e+1:a.push({start:e,end:e+1})}if(a.length===0)return;let o=[],s=1,c=1,l=0;for(let e of a){let t=Math.max(e.start-r,l===0?0:l);for(;l<t;l++)i[l].type!==`added`&&s++,i[l].type!==`removed`&&c++;let n=Math.min(e.end+r,i.length),a=0,u=0,d=[];for(let e=t;e<n;e++){let t=i[e];t.type===`equal`?(d.push(` ${t.line}`),a++,u++):t.type===`removed`?(d.push(`-${t.line}`),a++):(d.push(`+${t.line}`),u++)}for(o.push(`@@ -${s},${a} +${c},${u} @@`,...d);l<n;l++)i[l].type!==`added`&&s++,i[l].type!==`removed`&&c++}let u=o.join(`
|
|
339
339
|
`);if(!(n.maxChars!==void 0&&u.length>n.maxChars))return u}const Iy=te(()=>import(`@vertesia/ui/rich-text`).then(e=>({default:e.VertesiaMarkdownDocumentEditor})));function Ly(e,t){return e?.path===t?e.event_class===`artifact_updated`||e.event_class===`activity`&&e.tool_status===`completed`&&(e.tool===`edit_artifact`||e.tool===`write_artifact`):!1}function Ry(e,t){if(!Array.isArray(t?.changes)||t.changes.length===0)return;let n=e;for(let e of t.changes){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(t.operation!==`replace`||typeof t.before!=`string`||typeof t.after!=`string`||!n.includes(t.before))return;if(t.replace_all===!0)n=n.split(t.before).join(t.after);else{if(n.indexOf(t.before)!==n.lastIndexOf(t.before))return;n=n.replace(t.before,t.after)}}return n}function zy(e){if(!(!e||typeof e!=`object`||!(`status`in e)))return typeof e.status==`number`?e.status:void 0}function By({regions:e,totalLines:n,onNavigate:r}){let{t:i}=se();return e.length===0?null:t(`nav`,{className:`absolute inset-y-12 end-1 z-10 w-3 rounded-full border border-mixer-muted/25 bg-muted/20`,"aria-label":i(`agent.changeRuler`),children:e.map(e=>{let a=e.startLine/Math.max(1,n)*100,o=Math.max(1.5,(e.endLine-e.startLine+1)/Math.max(1,n)*100);return t(S,{description:i(`agent.changedRegion`,{line:e.startLine+1}),asChild:!0,children:t(`button`,{type:`button`,className:`absolute inset-x-0 rounded-full bg-attention transition-colors hover:bg-info focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-info`,style:{top:`${Math.min(98.5,a)}%`,height:`${Math.min(100-a,o)}%`},onClick:()=>r(e.startLine),"aria-label":i(`agent.changedRegion`,{line:e.startLine+1})})},`${e.startLine}:${e.endLine}`)})})}function Vy(e,t){return Ay(e,t)}function Hy({runId:e,path:a,initialContent:o=``,refreshKey:s=0,refreshDetails:c,readOnly:l=!1,allowComments:u=!1,viewMode:f=`components`,baselineContent:p,className:m,onAction:h,onSendMessage:g,onSendChangesToAgent:v,hasUnsentChanges:y=!1,isSendingChanges:b=!1,sendChangesDisabled:x=!1,toolbarStatus:S,onContentChange:T,onDocumentEdit:E,onSaveStatusChange:D,flushChangesRef:k}){let{client:A}=ye(),{t:j}=se(),M=O(),[N,P]=B(o),[F,te]=B(),[ne,re]=B(),[ie,ae]=B(0),[oe,ce]=B(!!e),[le,ue]=B(!1),[de,fe]=B(!1),[pe,me]=B(),[he,ge]=B(),[_e,ve]=B(!1),be=!l||u,xe=f!==`document`||he?`idle`:le||de?`saving`:F?`saved`:`idle`;L(()=>{D?.(xe)},[xe,D]);let V=z(N),Se=z(F),Ce=z(0),we=z(void 0),Te=z(void 0),Ee=z(!1),De=z(void 0),Oe=z(()=>Promise.resolve(!1)),ke=z(!1),Ae=z(!1),je=z(null),Me=z(F),Ne=z(o),Pe=z(void 0),Fe=z(o),Ie=z(null),Le=R(()=>Vy(p??N,N),[p,N]),Re=R(()=>N.split(`
|
|
340
|
-
`).length,[N]),ze=I(e=>{Pe.current=e,ge(e)},[]);L(()=>{V.current=N},[N]),L(()=>{Se.current=F},[F]),L(()=>{f===`document`&&(Ae.current=!1,ke.current=!1)},[f]);let Be=I(async t=>{if(!e)return;let n=++Ce.current;ce(!0),me(void 0);for(let r=0;r<=60;r++)try{let t=await A.agents.getArtifactContent(e,a);if(Ce.current!==n)return;let r=V.current;r&&r!==t.content&&(re(r),ae(e=>e+1)),V.current=t.content,Se.current=t.generation,Fe.current=t.content,!ke.current&&Te.current===void 0&&!Ee.current&&(Me.current=t.generation,Ne.current=t.content),P(t.content),te(t.generation),me(void 0),ce(!1),T?.(t.content,t.generation);return}catch(e){if(Ce.current!==n||!t||zy(e)!==404||r===60){if(Ce.current!==n)return;me(w(e,j(`agent.failedToLoadArtifact`))),ce(!1);return}await new Promise(e=>setTimeout(e,500))}},[A,T,a,e,j]);L(()=>(Ce.current++,V.current=o,Se.current=void 0,Fe.current=o,Me.current=void 0,Ne.current=o,Pe.current=void 0,ke.current=!1,Ae.current=!1,P(o),te(void 0),re(void 0),me(void 0),ge(void 0),ve(!1),fe(!1),ce(!!e),e&&Be(!0),()=>{Ce.current++}),[o,Be,e]),L(()=>{if(!e||s<=0||Pe.current)return;let t=V.current,n=Ry(t,c);n!==void 0&&n!==t&&(V.current=n,Se.current=void 0,re(t),ae(e=>e+1),P(n),te(void 0),T?.(n)),Be(!1)},[Be,T,c,s,e]);let Ve=I((e,t)=>{let n=V.current;V.current=e,Se.current=t,Ne.current=e,Me.current=t,Te.current=void 0,ze(void 0),je.current?.getMarkdown()!==e&&je.current?.commands.setContent(e,{contentType:`markdown`,emitUpdate:!1}),n!==e&&(re(n),ae(e=>e+1)),P(e),te(t),fe(!1),T?.(e,t)},[T,ze]),He=I(async(t,n,r)=>{if(!e)return!1;V.current=n,Te.current=void 0,P(n),fe(!1),ve(!0);let i,o;try{let s=await A.agents.getArtifactContent(e,a);i=s.content,o=s.generation,Fe.current=s.content;let c=Py(t,n,s.content);if(c.status===`conflict`)return ze({baseContent:t,localContent:n,remoteContent:s.content,remoteGeneration:s.generation,pendingAction:r}),!1;let l=s.generation;if(c.content!==s.content)try{l=(await A.agents.updateArtifactContent(e,a,{content:c.content,generation:s.generation})).generation}catch(e){if(zy(e)===412)return ze({baseContent:s.content,localContent:c.content,remoteContent:s.content,remoteGeneration:s.generation,pendingAction:r}),!1;throw e}return Ve(c.content,l),M({status:`success`,title:j(`agent.artifactConflictRebased`),duration:3e3}),{content:c.content,generation:l}}catch(e){return ze({baseContent:t,localContent:n,remoteContent:i,remoteGeneration:o,pendingAction:r}),M({status:`error`,title:j(`agent.artifactConflictTitle`),description:w(e,j(`agent.failedToLoadArtifact`)),duration:5e3}),!1}finally{ve(!1)}},[Ve,A.agents,a,e,j,M,ze]),H=I(async t=>{if(t.action===`comment`){await h?.(t);return}if(Pe.current){M({status:`warning`,title:j(`agent.artifactConflictTitle`),duration:3e3});return}if(!e||!Se.current){M({status:`warning`,title:j(`agent.artifactEditingUnavailable`),duration:3e3});return}let n=V.current,r=_y(n,t);if(r===void 0){M({status:`error`,title:j(`agent.documentEditApplyFailed`),description:j(`agent.documentEditApplyFailedDescription`),duration:5e3});return}try{let i=await A.agents.updateArtifactContent(e,a,{content:r,generation:Se.current});V.current=r,Se.current=i.generation,Ne.current=r,Me.current=i.generation,re(n),ae(e=>e+1),P(r),te(i.generation),T?.(r,i.generation),await h?.({...t,applied:!0,base_version:i.generation}),Fe.current=r}catch(e){if(zy(e)===412){let e=await He(n,r,t);e&&(await h?.({...t,applied:!0,base_version:e.generation}),Fe.current=e.content);return}M({status:`error`,title:j(`agent.documentEditApplyFailed`),description:w(e,j(`store.errorSavingTextDefault`)),duration:5e3})}},[A,h,T,a,He,e,j,M]),Ue=I(()=>{if(!e)return Promise.resolve(!1);if(De.current)return De.current;let t=(async()=>{Ee.current=!0,ue(!0);try{for(;Te.current!==void 0;){let t=Te.current;Te.current=void 0;let n=Me.current;if(!n)throw Error(j(`agent.artifactEditingUnavailable`));let r=await A.agents.updateArtifactContent(e,a,{content:t,generation:n});Se.current=r.generation,Me.current=r.generation,Ne.current=t,te(r.generation),T?.(V.current,r.generation)}return fe(!1),!0}catch(e){return zy(e)===412?!!await He(Ne.current,V.current):(M({status:`error`,title:j(`agent.documentEditApplyFailed`),description:w(e,j(`store.errorSavingTextDefault`)),duration:5e3}),!1)}finally{Ee.current=!1,ue(!1)}})();return De.current=t,t.finally(()=>{De.current===t&&(De.current=void 0)}),t},[A.agents,T,a,He,e,j,M]);Oe.current=Ue;let Ge=I(async()=>{we.current!==void 0&&(clearTimeout(we.current),we.current=void 0);let t=je.current?.getMarkdown();t!==void 0&&t!==V.current&&(V.current=t,P(t),T?.(t,Se.current),Te.current=t);let n=Pe.current;if(n&&!await He(n.baseContent,V.current))return!1;for(;Te.current!==void 0||De.current;)if(!await Ue())return!1;if(!e||!Se.current)return!1;let r=Fe.current;return Fe.current=V.current,{previous:r,current:V.current}},[T,Ue,He,e]);L(()=>{if(k)return k.current=Ge,()=>{k.current===Ge&&(k.current=null)}},[k,Ge]);let Ke=I(e=>{if(e===V.current||ke.current&&Te.current===void 0&&!Ee.current&&e===Ne.current)return;if(!Ae.current){V.current=e,P(e);return}V.current=e,P(e),E?.(),T?.(e,Se.current);let t=Pe.current;if(t){ze({...t,localContent:e}),fe(!1);return}fe(!0),Te.current=e,we.current!==void 0&&clearTimeout(we.current),we.current=setTimeout(()=>{we.current=void 0,Ue()},400)},[T,E,Ue,ze]),qe=I(e=>{ke.current=e,e&&(Ae.current=!0),(e||Te.current===void 0&&!Ee.current)&&(Me.current=Se.current,Ne.current=V.current)},[]),Je=I(async()=>{let e=Pe.current;if(!e||_e)return;let t=await He(e.baseContent,V.current,e.pendingAction);t&&e.pendingAction&&(await h?.({...e.pendingAction,applied:!0,base_version:t.generation}),Fe.current=t.content)},[_e,h,He]),Ye=I(e=>{let t=Ie.current?.querySelector(`.vertesia-markdown-document-editor-content`);if(!t)return;let n=Math.min(1,e/Math.max(1,Re-1));t.scrollTo({top:n*Math.max(0,t.scrollHeight-t.clientHeight),behavior:`smooth`})},[Re]);return L(()=>()=>{we.current!==void 0&&clearTimeout(we.current);let e=je.current?.getMarkdown();e!==void 0&&e!==V.current&&(V.current=e,Te.current=e),Te.current!==void 0&&Oe.current()},[]),n(`div`,{className:m??`relative h-full min-h-0 overflow-y-auto px-4 py-3`,children:[he?t(`div`,{className:`absolute inset-x-4 top-3 z-30`,role:`alert`,children:t(d,{status:`warning`,title:j(`agent.artifactConflictTitle`),className:`shadow-lg`,children:n(`div`,{className:`space-y-3`,children:[t(`p`,{children:j(`agent.artifactConflictDescription`)}),t(`div`,{className:`flex justify-end`,children:n(r,{variant:`outline`,size:`sm`,disabled:_e,onClick:()=>void Je(),children:[_e?t(_,{size:`sm`}):null,j(`agent.artifactConflictRetry`)]})})]})})}):null,oe&&!N?t(i,{className:`h-full min-h-[200px]`,children:t(_,{size:`lg`})}):pe&&!N?n(i,{className:`h-full min-h-[200px] flex-col gap-3 text-center text-muted`,children:[t(`span`,{children:pe}),t(r,{variant:`outline`,size:`sm`,onClick:()=>void Be(!1),children:j(`agent.retry`)})]}):f===`document`?t(ee,{fallback:t(i,{className:`h-full min-h-[200px]`,children:t(_,{size:`lg`})}),children:t(`div`,{className:`flex h-full min-h-0 flex-col`,children:n(`div`,{ref:Ie,className:`relative min-h-0 flex-1`,children:[t(Iy,{value:N,onChange:Ke,artifactRunId:e,editable:!l&&!!e,externalValueSync:`when-blurred`,onFocusChange:qe,onEditor:e=>{je.current=e},onSendComment:g&&e&&!he&&be?g:void 0,onSendChangesToAgent:v,hasUnsentChanges:y,isSendingChanges:b,sendChangesDisabled:x||!e||!!he,toolbarStatus:S,contentClassName:`pe-5`}),t(By,{regions:Le,totalLines:Re,onNavigate:Ye}),!D&&xe!==`idle`?n(`div`,{className:C(`pointer-events-none absolute bottom-3 end-6 flex items-center gap-1.5 rounded-full`,`border border-mixer-muted/25 bg-background/90 px-2.5 py-1 text-[11px] shadow-sm`,le||de?`text-muted`:`text-success`),children:[le||de?t(_,{size:`sm`}):t(We,{className:`size-3`}),j(le||de?`agent.savingWorkingCopy`:`agent.savedToWorkingCopy`)]}):null]})})}):t(`div`,{className:`vprose prose-sm mx-auto max-w-5xl`,children:t(Sy,{artifactRunId:e,resource:{kind:`agent_artifact`,run_id:e??`pending`,path:a},baseVersion:F,readOnly:l||!e||!!he,allowComments:be&&!!e&&!he,highlightChangesFrom:ne,highlightVersion:ie,onAction:H,children:N})}),oe&&N?t(`div`,{className:`absolute end-3 top-3 rounded-full bg-background/80 p-2 shadow-sm`,children:t(nt,{className:`size-4 animate-pulse text-muted`})}):null]})}function Uy({percent:e}){return t(`div`,{className:`w-full bg-muted rounded-full h-2.5`,children:t(`div`,{className:`bg-primary h-2.5 rounded-full`,style:{width:`${e}%`}})})}function Wy({className:e,properties:r}){return t(b,{className:e,children:t(`tbody`,{children:r.map(e=>n(`tr`,{children:[n(`td`,{className:`w-1/3 font-semibold gap-2`,children:[t(`span`,{children:e.name}),e.description&&t(S,{description:e.description,placement:`top`,children:t(at,{className:`size-3 ms-2 text-muted`})})]}),t(`td`,{className:`w-2/3`,children:e.value??`undefined`})]},e.name))})})}function Gy({content:e,...n}){let r=z(null);return L(()=>{if(!r.current)return;let t=new DOMParser().parseFromString(e,`image/svg+xml`).querySelector(`svg`);if(!t){console.warn(`SvgIcon: No <svg> element found in provided string`),r.current.innerHTML=``;return}Object.entries(n).forEach(([e,n])=>{if(n==null)return;let r=e===`className`?`class`:e;t.setAttribute(r,String(n))}),r.current.innerHTML=``,r.current.appendChild(t)}),t(`span`,{ref:r})}function Ky(e){return n=>t(Gy,{content:e,...n})}function qy(e){return{name:e.getNameSignature(),type:e.getTypeSignature(),description:e.description,extractable:e.extractable}}var Jy;(function(e){e.string=`string`,e.number=`number`,e.integer=`integer`,e.boolean=`boolean`,e.object=`object`,e.any=`any`,e.text=`text`,e.media=`media`,e.document=`document`})(Jy||={});function Yy(e){e=e.trim();let t=!1,n=!1;e.endsWith(`?`)&&(n=!0,e=e.substring(0,e.length-1).trim()),e.endsWith(`[]`)&&(t=!0,e=e.substring(0,e.length-2).trim());let r=Jy[e];if(!r)throw Error(`Unknown type "${e}"`);return{name:r,isArray:t,isNullable:n,isObject:r===Jy.object}}function Xy(){let e=Object.values(Jy),t=[...e];for(let n of e)t.push(`${n}[]`);return e.sort(),t}const Zy=Xy();function Qy({value:e,onChange:i,onCancel:a,onSave:o}){let{t:s}=se(),[c,l]=B(!1);return e?n(`div`,{className:`flex items-center`,children:[t(`div`,{className:`flex-1`,children:t($y,{value:e.name,onChange:t=>{i({...e,name:t})},onCancel:a,onSave:o})}),t(`div`,{className:`px-1 font-semibold`,children:`:`}),t(`div`,{className:`flex-1`,children:t(eb,{value:e.type,onChange:t=>{i({...e,type:t})},onCancel:a,onSave:o})}),n(`div`,{children:[t(r,{variant:`ghost`,size:`xs`,onClick:()=>l(!0),title:s(`widgets.schema.editDescription`),children:t(bt,{className:`size-4`})}),t(tb,{value:e.description,isOpen:c,onClose:t=>{t!==void 0&&typeof t==`string`&&i({...e,description:t},!0),l(!1)}})]})]}):null}function $y({value:e,onChange:n,onCancel:r,onSave:i}){let a=z(null);return L(()=>{a.current?.focus()},[]),t(`input`,{onKeyUp:e=>{switch(e.key){case`Enter`:i?.();break;case`Escape`:r?.()}},ref:a,value:e,onChange:e=>{n(e.target.value)},className:v.INPUT_UNSTYLED,style:{fontSize:`inherit`,width:``,display:`inline`}})}function eb({value:e,onChange:n,onCancel:r,onSave:i}){return t(g,{className:v.INPUT_UNSTYLED,options:Zy,value:e||``,onBlur:()=>{i?.()},onChange:n,onKeyDown:(e,t)=>{t||(e.key===`Enter`?i?.():e.key===`Escape`&&r?.())},popupClass:`schema-type-suggest-popup z-90`})}function tb({value:e,isOpen:r,onClose:i}){let{t:a}=se();return n(f,{isOpen:r,onClose:i,children:[t(h,{children:a(`widgets.schema.editDescription`)}),t(nb,{value:e,onSave:i})]})}function nb({value:i,onSave:a}){let{t:o}=se(),s=z(null),[c,l]=B(i||``);return L(()=>{s.current?.focus()},[]),n(e,{children:[t(p,{className:`h-max`,children:t(`textarea`,{ref:s,className:`dark:bg-muted w-full h-full dark:text-white`,value:c,onChange:e=>l(e.target.value)})}),t(m,{children:t(r,{onClick:()=>a(c),children:o(`store.saveChanges`)})})]})}function rb({value:e}){let{t:r}=se();if(!e)return null;let i=e.extractable===!1;return n(`div`,{className:`w-full flex items-baseline gap-2 min-w-0`,children:[t(`div`,{className:`truncate`,children:e.name||``}),t(`div`,{className:`text-sm text-muted shrink-0`,children:e.type||``}),i&&t(`span`,{className:`shrink-0 text-[10px] uppercase tracking-wide text-attention border border-attention/40 bg-attention/10 rounded px-1.5 py-0.5`,title:r(`widgets.schema.extractFromDocumentHint`),children:r(`widgets.schema.noExtract`)})]})}function ib(e,t,n){if(e.properties){let r=e.properties,i={};for(let e of Object.keys(r)){let a=r[e];e===t?i[n]=a:i[e]=a}e.properties=i}e.required&&=e.required.map(e=>e===t?n:e)}function ab(e,t,n){if(Array.isArray(e.required)){let r=e.required.indexOf(t);n?r<0&&e.required.push(t):r>-1&&e.required.splice(r,1)}else n&&(e.required=[t])}function ob(e,t){let n=t.name===`any`?void 0:t.isNullable?[t.name,`null`]:t.name;if(t.isArray){if(e.type=`array`,e.properties=void 0,!e.items||Array.isArray(e.items))e.items={type:n,properties:t.isObject?{}:void 0};else{let r=e.items;r.type=n,t.isObject&&!r.properties&&(r.properties={})}}else e.type=n,e.items=void 0,t.isObject?e.properties||={}:e.properties=void 0}function sb(e,t){e.properties&&(delete e.properties[t],Array.isArray(e.required)&&(e.required=e.required.filter(e=>e!==t)))}function cb(e,t,n,r=!1){if(e.type!==`object`)throw Error(`Cannot add property to a non-object schema`);e.properties||={};let i={};return ob(i,n),e.properties[t]=i,r&&(Array.isArray(e.required)?fb(e.required,t):e.required=[t]),i}function lb(e){let t=!1,n=!1,r,i=e.type;if(Array.isArray(i))for(let e of i)e===`null`?t=!0:r||=e;else r=i;r||=`any`,r===`array`&&(n=!0,r=ub(e.items));let a=r;switch(e.editor){case`textarea`:a=`text`;break;case`media`:a=`media`;break;case`document`:a=`document`}return{isNullable:t,isArray:n,isObject:r===`object`,name:a}}function ub(e){if(!e)return`any`;let t;return t=db(Array.isArray(e)?e[0].type:e.type),(t===`array`||t===`null`)&&(t=`any`),t}function db(e){return e?Array.isArray(e)?e.find(e=>e!==`null`)||`any`:e:`any`}function fb(e,t){e.includes(t)||e.push(t)}let pb=0;var mb=class e{source;onChange=()=>{};schema;root;constructor(e,t){this.schema=e?typeof e==`string`?JSON.parse(e):e:{title:t,type:`object`,properties:{}},this.schema.properties||(this.schema.properties={}),this.root=new hb(``,this.schema,this),this.root.loadChildren()}get isEmpty(){return!this.root.children||this.root.children.length===0}get children(){return this.root.children??[]}reload(){return this.root=new hb(``,this.schema,this),this.root.loadChildren(),this.onChange?.(this),this}withSource(e,t){return this.source={uri:t,name:e},this}withChangeListener(e){return this.onChange=e,this}replaceSchema(e){this.schema=e||{title:this.schema.title,type:`object`,properties:{}},this.reload()}clone(){let t=new e(this.schema);return t.source=this.source,this.onChange&&t.withChangeListener(this.onChange),t}},hb=class e{schema;loader;parent;name;isRequired=!1;type;children;constructor(e,t,n,r){if(this.schema=t,this.loader=n,this.parent=r,this.name=e,this.type=lb(t),this.parent){let t=this.parent._getPropertiesSchema().required;this.isRequired=t&&Array.isArray(t)?t.includes(e):!1}}get title(){return typeof this.schema.title==`string`?this.schema.title:void 0}set title(e){this.schema.title=e}get description(){return this.schema.description}set description(e){this.schema.description=e}get extractable(){return this.schema[`x-extract`]!==!1}set extractable(e){e?delete this.schema[`x-extract`]:this.schema[`x-extract`]=!1}get isParent(){return this.type.isObject}get isNew(){return!!this.schema.isNew}set isNew(e){e?this.schema.isNew=!0:delete this.schema.isNew}resetIsNew(){let e=this.isNew;return this.isNew=!1,e}getNameSignature(){return`${this.name}${this.isRequired?``:`?`}`}getTypeSignature(){return`${this.type.name}${this.type.isArray?`[]`:``}${this.type.isNullable?`?`:``}`}getSignature(){return`${this.getNameSignature()}: ${this.getTypeSignature()}`}reloadTree(){this.loader.reload()}loadChildren(){this.children=[];let e=this.schema.items?.properties;this.schema.items&&e?this._loadChildren(e,this.children):this.schema.properties&&this._loadChildren(this.schema.properties,this.children)}_loadChildren(t,n){for(let r of Object.keys(t)){let i=t[r],a=new e(r,i,this.loader,this);n.push(a),a.isParent&&a.loadChildren()}}_getPropertiesSchema(){return this.type.isArray&&this.type.isObject?this.schema.items:this.schema}findAvailableChildName(e){let t=this._getPropertiesSchema().properties||{},n;do n=e+ ++pb;while(t[n]);return n}addChild(t,n,r=!1){if(!this.type.isObject)throw Error(`Cannot add child to a non object node`);this.children||=[];let i=cb(this._getPropertiesSchema(),t,n,r),a=new e(t,i,this.loader,this);return this.children.push(a),a}remove(){return this.parent?.type.isObject?(sb(this.parent._getPropertiesSchema(),this.name),this.parent.children&&(this.parent.children=this.parent.children.filter(e=>e.name!==this.name)),!0):!1}update(e){let t=!1;e.name!=null&&this.name!==e.name&&(this.parent&&ib(this.parent._getPropertiesSchema(),this.name,e.name),this.name=e.name,t=!0),e.isRequired!=null&&this.isRequired!==e.isRequired&&(this.parent&&ab(this.parent._getPropertiesSchema(),this.name,e.isRequired),this.isRequired=e.isRequired,t=!0);let n=e.type?.name;n===`any`&&(n=void 0);let r=n!==this.schema.type;return e.type&&(ob(this.schema,e.type),this.type=e.type,this.type.isObject?this.children||=[]:this.children=void 0,t=!0),this.schema.editor&&e.editor===null?(this.schema.editor=void 0,t=!0):e.editor?(this.schema.editor=e.editor,t=!0):r&&(this.schema.editor=void 0,t=!0),e.description!==this.description&&(this.description=e.description,t=!0),e.extractable!=null&&this.extractable!==e.extractable&&(this.extractable=e.extractable,t=!0),t}getUpdateFromNameAndTypeSignature(e,t){let n=e.trim(),r=!0;n.endsWith(`?`)&&(n=n.substring(0,n.length-1).trim(),r=!1);let i=Yy(t),a;return i.name===`text`?(i.name=Jy.string,a=`textarea`):i.name===`media`?(i.name=Jy.any,a=`media`):i.name===`document`?(i.name=Jy.any,a=`document`):a=null,{name:n,type:i,isRequired:r,editor:a}}updateFromNameAndTypeSignature(e,t){return this.update(this.getUpdateFromNameAndTypeSignature(e,t))}updateFromSignature(e){e=e.trim();let t=e.indexOf(`:`);if(t<0)throw Error(`Expecting a name and a type separated by a colon`);let n=e.substring(0,t),r=e.substring(t+1);return this.updateFromNameAndTypeSignature(n,r)}};function gb(e){let[t,n]=B(new mb(e||{type:`object`,properties:{}}).withChangeListener(e=>{n(e.clone())}));return t}const _b=`block text-sm sm:leading-6 rounded-md border-0 py-1.5 px-4`,vb=`${_b} hover:shadow-xs hover:ring-1 hover:ring-inset hover:ring-ring`,yb=`${_b} shadow-xs ring-1 ring-inset ring-ring`;function bb({value:e,onChange:r,onDelete:i,outlineOnHover:a=!1,editOnClick:o=!0,placeholder:s,viewer:c,editor:l,skipClickOutside:u,isEditing:d=!1,readonly:f=!1,onValidate:p}){let{on:m,off:h,isOn:g}=E(d),[_,v]=B();return n(`div`,{className:``,children:[g&&!f?t(Sb,{value:e,onSave:e=>{if(p){let t=p(e);if(t){v(t);return}v(void 0)}r(e)&&h()},onCancel:h,editor:l,skipClickOutside:e=>u?u(e):!1}):t(xb,{value:e,onEdit:m,viewer:c,placeholder:s,outlineOnHover:a,editOnClick:o,onDelete:i,readonly:f}),_&&t(`div`,{className:`text-destructive text-sm`,children:_})]})}function xb({viewer:e,value:i,onEdit:a,editOnClick:o,outlineOnHover:s,placeholder:c,onDelete:l,readonly:u}){let d=()=>{o&&a()},f=e=>{e.key===`Enter`&&a()},p=`invisible group-hover:visible`;return n(`div`,{role:o?`button`:void 0,tabIndex:0,onKeyUp:f,onClick:d,className:k(`flex justify-start items-center group`,s?vb:_b,{"cursor-pointer":o}),children:[t(e,{value:i,placeholder:c}),n(`div`,{className:`ms-auto flex gap-2`,children:[!u&&l&&t(r,{variant:`ghost`,size:`sm`,className:p,onClick:l,children:t(xt,{className:`size-4`})}),u?null:t(r,{variant:`ghost`,size:`sm`,className:p,onClick:a,children:t(_t,{className:`size-4`})})]})]})}function Sb({editor:e,value:n,onSave:r,onCancel:i,skipClickOutside:a}){let[o,s]=B(n),c=z(n),[l,u]=B(null),d=()=>{r(c.current)},f=T(d,a);return t(`div`,{ref:f,children:t(`div`,{className:yb,children:t(`div`,{className:`w-full`,onClick:e=>e.stopPropagation(),children:t(e,{value:o,onChange:(e,t=!1)=>{s(e),c.current=e,t&&(l&&clearTimeout(l),u(setTimeout(()=>{r(e)},500)))},onSave:d,onCancel:i})})})})}function Cb(e){return!!e.target.closest?.(`.schema-type-suggest-popup`)}function wb({schema:e,readonly:r=!1}){let{t:i}=se();return n(`div`,{className:`space-y-1`,children:[n(`div`,{className:`flex items-center gap-2 px-2 py-1 text-xs font-medium text-muted border-b border-border`,children:[t(`div`,{className:`flex-1 min-w-0`,children:i(`widgets.schema.propertyColumn`)}),!r&&t(`div`,{className:`shrink-0 w-28 text-end pe-1`,title:i(`widgets.schema.extractFromDocumentHint`),children:i(`widgets.schema.extractFromDocument`)}),t(`div`,{className:`w-8 shrink-0`})]}),n(`ul`,{className:``,children:[e.children.map(e=>Tb(e,r)),r?null:t(Ab,{parent:e.root})]})]})}function Tb(e,n){return e.isParent?t(Db,{property:e,readonly:n},e.name):t(Eb,{node:e,readonly:n},e.name)}function Eb({node:e,readonly:n}){return t(`li`,{className:`border-b border-border/40 last:border-0`,children:t(kb,{property:e,readonly:n})})}function Db({property:e,readonly:i}){let[a,o]=B(!0),s=a?Ge:Ke;return n(`li`,{className:`border-b border-border/40 last:border-0`,children:[n(`div`,{className:`flex items-center w-full gap-1`,children:[t(`div`,{className:`flex-1 min-w-0`,children:t(kb,{property:e,readonly:i})}),t(r,{variant:`ghost`,size:`icon`,onClick:()=>o(!a),"aria-label":a?`Collapse ${e.name}`:`Expand ${e.name}`,"aria-expanded":a,className:`shrink-0`,children:t(s,{className:`size-4 cn-rtl-flip`})})]}),a&&n(`ul`,{className:`ms-4 border-s border-border border-dashed`,children:[(e.children||[]).map(e=>Tb(e,i)),i?null:t(Ab,{parent:e})]})]})}function Ob(e){if(!e)return`Name is required`;if(!/^[a-zA-Z0-9_]+[?]?$/.test(e))return`Only letters, numbers, underscores or question mark are allowed (a-zA-Z0-9_?)`}function kb({property:e,readonly:r}){let{t:i}=se(),a=O(),o=t=>{try{t.description&&typeof t.description!=`string`&&(t.description=void 0);let n=e.getUpdateFromNameAndTypeSignature(t.name,t.type);e.update({...n,description:t.description,extractable:t.extractable})&&e.reloadTree()}catch(e){return a({status:`error`,title:i(`widgets.schema.invalidPropertyDeclaration`),description:w(e),duration:9e3}),!1}return!0},s=t=>{e.update({extractable:t})&&e.reloadTree()},c=e.resetIsNew(),l=qy(e);return n(`div`,{className:`flex items-center gap-2 w-full min-w-0 py-0.5`,children:[t(`div`,{className:`flex-1 min-w-0`,children:t(bb,{value:l,onChange:o,onDelete:()=>{e.remove(),e.reloadTree()},editor:Qy,viewer:rb,outlineOnHover:!0,isEditing:c,skipClickOutside:Cb,readonly:r,onValidate:e=>Ob(e.name)})}),r?e.extractable===!1?t(`div`,{className:`shrink-0 w-28 flex justify-end pe-1`,children:t(`span`,{className:`text-[10px] uppercase tracking-wide text-attention border border-attention/40 bg-attention/10 rounded px-1.5 py-0.5`,title:i(`widgets.schema.extractFromDocumentHint`),children:i(`widgets.schema.noExtract`)})}):null:t(`div`,{className:`shrink-0 w-28 flex items-center justify-end gap-1.5 pe-1`,children:t(y,{size:`sm`,value:e.extractable,onChange:s,"aria-label":`${i(`widgets.schema.extractFromDocument`)}: ${e.name}`})})]})}function Ab({parent:e}){return n(r,{variant:`ghost`,onClick:()=>{let t=e.findAvailableChildName(`new_property_`),n=e.addChild(t,{isObject:!1,isArray:!1,isNullable:!1,name:Jy.string},!0);n.isNew=!0,e.reloadTree()},children:[t(mt,{className:`size-4`}),`Add property`]})}function jb(e){return e.isFile}function Mb(e){return e.isDirectory}function Nb({onDrop:e,message:i,buttonLabel:a,allowFolders:o=!0,className:s=``}){let{t:c}=se(),l=a??c(`upload.uploadFiles`),[u,d]=B(!1),f=z(null),p=e=>{e.preventDefault(),e.dataTransfer.types.includes(`Files`)&&d(!0)},m=e=>{e.preventDefault(),f.current&&!f.current.contains(e.relatedTarget)&&d(!1)},h=async t=>{if(t.preventDefault(),d(!1),t.dataTransfer.items&&t.dataTransfer.items.length>0){let n=Array.from(t.dataTransfer.items),r=[],i=new Set,a=async e=>{if(jb(e)){let t=await new Promise(t=>{e.file(n=>{Object.defineProperty(n,"webkitRelativePath",{writable:!0,value:e.fullPath.substring(1)}),t(n)})});!t.name.startsWith(`.`)&&t.size>0&&r.push(t);let n=e.fullPath.substring(1).split(`/`).slice(0,-1).join(`/`);n&&i.add(n)}else if(Mb(e)){let t=e.createReader(),n=await new Promise(e=>{t.readEntries(t=>{e(t)})});await Promise.all(n.map(a));let r=e.fullPath.substring(1);r&&i.add(r)}};try{if(await Promise.all(n.map(e=>{let t=e.webkitGetAsEntry?e.webkitGetAsEntry():e;return t?a(t):Promise.resolve()})),r.length>0){let t=new Set(Array.from(i).map(e=>e.split(`/`)[0]).filter(Boolean)).size,n=r.length,a=``;a=t>0?c(`upload.preparingFolder`,{count:t,folderCount:t,fileCount:n}):c(`upload.preparingFiles`,{count:n}),e(r,{count:r.length,message:a})}}catch(n){console.error(`Error processing dropped files:`,n);let r=Array.from(t.dataTransfer.files);r.length>0&&e(r)}}else t.dataTransfer.files&&t.dataTransfer.files.length>0&&e(Array.from(t.dataTransfer.files))},g=t=>{if(t&&t.length>0){let n=Array.from(t);if(n.some(e=>e.webkitRelativePath?.includes(`/`))){let t=new Set(n.map(e=>e.webkitRelativePath.split(`/`)[0]).filter(Boolean)).size,r=n.length,i=c(`upload.preparingFolder`,{count:t,folderCount:t,fileCount:r});e(n,{count:n.length,message:i})}else e(n,{count:n.length,message:c(`upload.preparingFiles`,{count:n.length})})}};return n(`div`,{className:`flex flex-col items-center justify-center py-12 border-2 rounded-lg transition-colors ${u?`border-primary bg-primary/10`:`border-dashed border-border`} ${s}`,onDragOver:p,onDragLeave:m,onDrop:h,children:[t(St,{className:`h-12 w-12 mb-3 transition-colors ${u?`text-primary`:`text-muted/50`}`}),t(`p`,{className:`text-muted`,children:i}),n(`div`,{className:`flex gap-2 justify-center mt-2`,children:[t(r,{onClick:()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=!0,e.accept=`*`,e?.click(),e.onchange=()=>{g(e.files)}},children:l}),o&&t(r,{onClick:()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=!0,e.accept=`*`,e.webkitdirectory=!0,e?.click(),e.onchange=()=>{g(e.files)}},children:c(`upload.selectFolder`)})]})]})}function Pb({title:e,count:r,icon:i=t(Je,{className:`h-4 w-4 text-success`}),items:a}){let{t:o}=se(),[s,c]=B(!1),l=ie();return n(`div`,{className:`border border-border rounded-md overflow-hidden`,children:[n(`button`,{type:`button`,"aria-expanded":s,"aria-controls":l,className:`w-full flex items-center justify-between p-3 bg-muted/10 cursor-pointer text-start bg-transparent border-0 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,onClick:()=>c(!s),children:[n(`span`,{className:`flex items-center`,children:[t(`span`,{className:`me-2`,children:i}),t(`span`,{className:`font-medium`,children:e}),t(`span`,{className:`ms-2 px-2 py-0.5 bg-muted/20 rounded-full text-xs`,children:r})]}),t(`span`,{className:`text-muted`,"aria-hidden":`true`,children:t(`svg`,{className:`h-5 w-5 transition-transform ${s?`transform rotate-180`:``}`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`,children:t(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 9l-7 7-7-7`})})})]}),s&&t(`div`,{id:l,className:`p-3 border-t border-border max-h-48 overflow-y-auto`,children:a.length>0?t(`ul`,{className:`space-y-1`,children:a.map(e=>t(`li`,{className:`text-sm py-1 px-2 rounded hover:bg-muted/10`,children:e},e))}):t(`div`,{className:`text-sm text-muted py-2`,children:o(`upload.noItems`)})})]})}function Fb({files:e,className:r=``,location:i,collection:a}){let{t:o}=se(),s=e.filter(e=>e.status===`success`),c=e.filter(e=>e.status===`updated`),l=e.filter(e=>e.status===`skipped`),u=e.filter(e=>e.status===`failed`),d=s.length,f=c.length,p=l.length,m=u.length,h=e.length;return n(`div`,{className:`flex flex-col py-2 ${r}`,children:[n(`div`,{className:`flex items-center mb-4`,children:[t(`div`,{className:`size-8 me-4 rounded-full bg-success/10 flex items-center justify-center`,children:t(Je,{className:`size-4 text-success`})}),t(`div`,{children:n(`p`,{className:`text-muted`,children:[o(`upload.filesProcessed`,{count:h}),a?o(`upload.inCollection`,{collection:a}):``,i?o(`upload.inFolder`,{location:i}):``]})})]}),n(`div`,{className:`space-y-3 mt-2`,children:[d>0&&t(Pb,{title:o(`upload.successfullyUploaded`),count:d,icon:t(Je,{className:`h-4 w-4 text-success`}),items:s.map(e=>e.name)}),f>0&&t(Pb,{title:o(`upload.successfullyUpdated`),count:f,icon:t(Je,{className:`h-4 w-4 text-info`}),items:c.map(e=>e.name)}),p>0&&t(Pb,{title:o(`upload.skippedAlreadyExisted`),count:p,icon:t(qe,{className:`h-4 w-4 text-attention`}),items:l.map(e=>e.name)}),m>0&&t(Pb,{title:o(`upload.failedToUpload`),count:m,icon:t(Ye,{className:`h-4 w-4 text-destructive`}),items:u.map(e=>e.name)})]})]})}const Ib=`#text`,Lb=`#comment`,Rb=`#cdata`,zb=`DECLARATION_TAG`,Bb={tagColor:`#d43900`,textColor:`#333`,attributeKeyColor:`#2a7ab0`,attributeValueColor:`#008000`,separatorColor:`#333`,commentColor:`#aaa`,cdataColor:`#1d781d`,fontFamily:`monospace`},Vb={attributeKeyColor:`#FFD700`,attributeValueColor:`#FF4500`,tagColor:`#87CEFA`,textColor:`#00FF00`,separatorColor:`#FFD700`,commentColor:`#BEBEBE`,cdataColor:`#33CC66`,fontFamily:`monospace`},Hb=N({theme:Bb,collapsible:!1,indentSize:2}),Ub=()=>re(Hb);let Wb;function Gb(){return Wb??=import(`fast-xml-parser`).then(({XMLParser:e})=>new e({preserveOrder:!0,ignoreAttributes:!1,attributeNamePrefix:``,allowBooleanAttributes:!0,commentPropName:Lb,cdataPropName:Rb,parseTagValue:!1})).catch(e=>{throw Wb=void 0,e}),Wb}async function Kb(e){try{let t=new DOMParser().parseFromString(e,`application/xml`),n=t.documentElement.localName===`parsererror`?t.documentElement:void 0;if(n)throw Error(n.textContent?.trim()||`Invalid XML!`);let r=(await Gb()).parse(e);if(e.trim().length>0&&r.length===0)throw Error(`Invalid XML!`);return{json:r,valid:!0}}catch(e){return{json:null,valid:!1,errorMessage:`Fail to parse: ${e instanceof Error?e.message:String(e)}`}}}function qb(e){let[t,n]=B(void 0);return L(()=>{let t=!1;return n(void 0),Kb(e).then(e=>{t||n(e)}),()=>{t=!0}},[e]),t}function Jb(e){let{indentation:r,children:i,isInline:a}=e,{theme:o}=Ub();return n(`div`,{style:{color:o.cdataColor},children:[t(`span`,{children:`${r}<![CDATA[`}),i,t(`span`,{children:`${a?``:r}]]>`})]})}function Yb(e){let{collapsible:n,theme:r}=Ub(),{collapsed:i}=e;return n?t(`span`,{style:{position:`relative`},children:t(`span`,{style:{position:`absolute`,right:`0`,border:0,padding:0,background:`none`},children:t(Xb,{fill:r.separatorColor,style:{transform:`rotate(${i?0:90}deg)`,transition:`transform 0.2s`}})})}):null}function Xb({...e}){return t(`svg`,{width:`16px`,height:`16px`,viewBox:`0 0 24 24`,"aria-hidden":`true`,...e,children:t(`path`,{d:`M9 17.898C9 18.972 10.2649 19.546 11.0731 18.8388L17.3838 13.3169C18.1806 12.6197 18.1806 11.3801 17.3838 10.6829L11.0731 5.16108C10.2649 4.45388 9 5.02785 9 6.1018V17.898Z`})})}function Zb(e){let{collapsible:t,initialCollapsedDepth:n}=Ub(),[r,i]=B(()=>xe(n)||!t?!1:e>=n);return L(()=>{i(xe(n)||!t?!1:e>=n)},[n,e,t]),{collapsed:r,buttonProps:t?{onClick:()=>i(e=>!e),role:`button`,style:{cursor:`pointer`}}:{}}}function Qb(e){let{indentation:r,children:i,isInline:a,level:o}=e,{theme:s}=Ub(),{collapsed:c,buttonProps:l}=Zb(o);return n(`div`,{style:{color:s.commentColor},children:[n(`span`,{...l,children:[t(`span`,{children:r}),t(Yb,{collapsed:c}),t(`span`,{children:`<!-- `})]}),!c&&i,c&&`...`,t(`span`,{children:`${a||c?` `:r}-->`})]})}function $b(e){let{attributes:r}=e,{theme:i}=Ub();return r?t(`span`,{children:Object.entries(r).map(([e,r])=>n(`span`,{children:[t(`span`,{style:{color:i.attributeKeyColor},children:` ${e}`}),t(`span`,{style:{color:i.separatorColor},children:`=`}),t(`span`,{style:{color:i.attributeValueColor},children:`"${r}"`})]},`attribute-${e}`))}):null}function ex(e){let{indentation:r,tagKey:i,attributes:a}=e,{theme:o}=Ub();return n(`div`,{children:[t(`span`,{style:{color:o.separatorColor},children:`${r}<?`}),t(`span`,{style:{color:o.tagColor},children:`${i.slice(1)}`}),t($b,{attributes:a}),t(`span`,{style:{color:o.separatorColor},children:`?>`})]})}function tx(e,t){return Array(t*e+1).join(` `)}function nx(e){return typeof e==`string`&&e.includes(`
|
|
340
|
+
`).length,[N]),ze=I(e=>{Pe.current=e,ge(e)},[]);L(()=>{V.current=N},[N]),L(()=>{Se.current=F},[F]),L(()=>{f===`document`&&(Ae.current=!1,ke.current=!1)},[f]);let Be=I(async t=>{if(!e)return;let n=++Ce.current;ce(!0),me(void 0);for(let r=0;r<=60;r++)try{let t=await A.agents.getArtifactContent(e,a);if(Ce.current!==n)return;let r=V.current;r&&r!==t.content&&(re(r),ae(e=>e+1)),V.current=t.content,Se.current=t.generation,Fe.current=t.content,!ke.current&&Te.current===void 0&&!Ee.current&&(Me.current=t.generation,Ne.current=t.content),P(t.content),te(t.generation),me(void 0),ce(!1),T?.(t.content,t.generation);return}catch(e){if(Ce.current!==n||!t||zy(e)!==404||r===60){if(Ce.current!==n)return;me(w(e,j(`agent.failedToLoadArtifact`))),ce(!1);return}await new Promise(e=>setTimeout(e,500))}},[A,T,a,e,j]);L(()=>(Ce.current++,V.current=o,Se.current=void 0,Fe.current=o,Me.current=void 0,Ne.current=o,Pe.current=void 0,ke.current=!1,Ae.current=!1,P(o),te(void 0),re(void 0),me(void 0),ge(void 0),ve(!1),fe(!1),ce(!!e),e&&Be(!0),()=>{Ce.current++}),[o,Be,e]),L(()=>{if(!e||s<=0||Pe.current)return;let t=V.current,n=Ry(t,c);n!==void 0&&n!==t&&(V.current=n,Se.current=void 0,re(t),ae(e=>e+1),P(n),te(void 0),T?.(n)),Be(!1)},[Be,T,c,s,e]);let Ve=I((e,t)=>{let n=V.current;V.current=e,Se.current=t,Ne.current=e,Me.current=t,Te.current=void 0,ze(void 0),je.current?.getMarkdown()!==e&&je.current?.commands.setContent(e,{contentType:`markdown`,emitUpdate:!1}),n!==e&&(re(n),ae(e=>e+1)),P(e),te(t),fe(!1),T?.(e,t)},[T,ze]),He=I(async(t,n,r)=>{if(!e)return!1;V.current=n,Te.current=void 0,P(n),fe(!1),ve(!0);let i,o;try{let s=await A.agents.getArtifactContent(e,a);i=s.content,o=s.generation,Fe.current=s.content;let c=Py(t,n,s.content);if(c.status===`conflict`)return ze({baseContent:t,localContent:n,remoteContent:s.content,remoteGeneration:s.generation,pendingAction:r}),!1;let l=s.generation;if(c.content!==s.content)try{l=(await A.agents.updateArtifactContent(e,a,{content:c.content,generation:s.generation})).generation}catch(e){if(zy(e)===412)return ze({baseContent:s.content,localContent:c.content,remoteContent:s.content,remoteGeneration:s.generation,pendingAction:r}),!1;throw e}return Ve(c.content,l),M({status:`success`,title:j(`agent.artifactConflictRebased`),duration:3e3}),{content:c.content,generation:l}}catch(e){return ze({baseContent:t,localContent:n,remoteContent:i,remoteGeneration:o,pendingAction:r}),M({status:`error`,title:j(`agent.artifactConflictTitle`),description:w(e,j(`agent.failedToLoadArtifact`)),duration:5e3}),!1}finally{ve(!1)}},[Ve,A.agents,a,e,j,M,ze]),H=I(async t=>{if(t.action===`comment`){await h?.(t);return}if(Pe.current){M({status:`warning`,title:j(`agent.artifactConflictTitle`),duration:3e3});return}if(!e||!Se.current){M({status:`warning`,title:j(`agent.artifactEditingUnavailable`),duration:3e3});return}let n=V.current,r=_y(n,t);if(r===void 0){M({status:`error`,title:j(`agent.documentEditApplyFailed`),description:j(`agent.documentEditApplyFailedDescription`),duration:5e3});return}try{let i=await A.agents.updateArtifactContent(e,a,{content:r,generation:Se.current});V.current=r,Se.current=i.generation,Ne.current=r,Me.current=i.generation,re(n),ae(e=>e+1),P(r),te(i.generation),T?.(r,i.generation),await h?.({...t,applied:!0,base_version:i.generation}),Fe.current=r}catch(e){if(zy(e)===412){let e=await He(n,r,t);e&&(await h?.({...t,applied:!0,base_version:e.generation}),Fe.current=e.content);return}M({status:`error`,title:j(`agent.documentEditApplyFailed`),description:w(e,j(`store.errorSavingTextDefault`)),duration:5e3})}},[A,h,T,a,He,e,j,M]),Ue=I(()=>{if(!e)return Promise.resolve(!1);if(De.current)return De.current;let t=(async()=>{Ee.current=!0,ue(!0);try{for(;Te.current!==void 0;){let t=Te.current;Te.current=void 0;let n=Me.current;if(!n)throw Error(j(`agent.artifactEditingUnavailable`));let r=await A.agents.updateArtifactContent(e,a,{content:t,generation:n});Se.current=r.generation,Me.current=r.generation,Ne.current=t,te(r.generation),T?.(V.current,r.generation)}return fe(!1),!0}catch(e){return zy(e)===412?!!await He(Ne.current,V.current):(M({status:`error`,title:j(`agent.documentEditApplyFailed`),description:w(e,j(`store.errorSavingTextDefault`)),duration:5e3}),!1)}finally{Ee.current=!1,ue(!1)}})();return De.current=t,t.finally(()=>{De.current===t&&(De.current=void 0)}),t},[A.agents,T,a,He,e,j,M]);Oe.current=Ue;let Ge=I(async()=>{we.current!==void 0&&(clearTimeout(we.current),we.current=void 0);let t=je.current?.getMarkdown();t!==void 0&&t!==V.current&&(V.current=t,P(t),T?.(t,Se.current),Te.current=t);let n=Pe.current;if(n&&!await He(n.baseContent,V.current))return!1;for(;Te.current!==void 0||De.current;)if(!await Ue())return!1;if(!e||!Se.current)return!1;let r=Fe.current;return Fe.current=V.current,{previous:r,current:V.current}},[T,Ue,He,e]);L(()=>{if(k)return k.current=Ge,()=>{k.current===Ge&&(k.current=null)}},[k,Ge]);let Ke=I(e=>{if(e===V.current||ke.current&&Te.current===void 0&&!Ee.current&&e===Ne.current)return;if(!Ae.current){V.current=e,P(e);return}V.current=e,P(e),E?.(),T?.(e,Se.current);let t=Pe.current;if(t){ze({...t,localContent:e}),fe(!1);return}fe(!0),Te.current=e,we.current!==void 0&&clearTimeout(we.current),we.current=setTimeout(()=>{we.current=void 0,Ue()},400)},[T,E,Ue,ze]),qe=I(e=>{ke.current=e,e&&(Ae.current=!0),(e||Te.current===void 0&&!Ee.current)&&(Me.current=Se.current,Ne.current=V.current)},[]),Je=I(async()=>{let e=Pe.current;if(!e||_e)return;let t=await He(e.baseContent,V.current,e.pendingAction);t&&e.pendingAction&&(await h?.({...e.pendingAction,applied:!0,base_version:t.generation}),Fe.current=t.content)},[_e,h,He]),Ye=I(e=>{let t=Ie.current?.querySelector(`.vertesia-markdown-document-editor-content`);if(!t)return;let n=Math.min(1,e/Math.max(1,Re-1));t.scrollTo({top:n*Math.max(0,t.scrollHeight-t.clientHeight),behavior:`smooth`})},[Re]);return L(()=>()=>{we.current!==void 0&&clearTimeout(we.current);let e=je.current?.getMarkdown();e!==void 0&&e!==V.current&&(V.current=e,Te.current=e),Te.current!==void 0&&Oe.current()},[]),n(`div`,{className:m??`relative h-full min-h-0 overflow-y-auto px-4 py-3`,children:[he?t(`div`,{className:`absolute inset-x-4 top-3 z-30`,role:`alert`,children:t(d,{status:`warning`,title:j(`agent.artifactConflictTitle`),className:`shadow-lg`,children:n(`div`,{className:`space-y-3`,children:[t(`p`,{children:j(`agent.artifactConflictDescription`)}),t(`div`,{className:`flex justify-end`,children:n(r,{variant:`outline`,size:`sm`,disabled:_e,onClick:()=>void Je(),children:[_e?t(_,{size:`sm`}):null,j(`agent.artifactConflictRetry`)]})})]})})}):null,oe&&!N?t(i,{className:`h-full min-h-[200px]`,children:t(_,{size:`lg`})}):pe&&!N?n(i,{className:`h-full min-h-[200px] flex-col gap-3 text-center text-muted`,children:[t(`span`,{children:pe}),t(r,{variant:`outline`,size:`sm`,onClick:()=>void Be(!1),children:j(`agent.retry`)})]}):f===`document`?t(ee,{fallback:t(i,{className:`h-full min-h-[200px]`,children:t(_,{size:`lg`})}),children:t(`div`,{className:`flex h-full min-h-0 flex-col`,children:n(`div`,{ref:Ie,className:`relative min-h-0 flex-1`,children:[t(Iy,{value:N,onChange:Ke,artifactRunId:e,editable:!l&&!!e,externalValueSync:`when-blurred`,onFocusChange:qe,onEditor:e=>{je.current=e},onSendComment:g&&e&&!he&&be?g:void 0,onSendChangesToAgent:v,hasUnsentChanges:y,isSendingChanges:b,sendChangesDisabled:x||!e||!!he,toolbarStatus:S,contentClassName:`pe-5`}),t(By,{regions:Le,totalLines:Re,onNavigate:Ye}),!D&&xe!==`idle`?n(`div`,{className:C(`pointer-events-none absolute bottom-3 end-6 flex items-center gap-1.5 rounded-full`,`border border-mixer-muted/25 bg-background/90 px-2.5 py-1 text-[11px] shadow-sm`,le||de?`text-muted`:`text-success`),children:[le||de?t(_,{size:`sm`}):t(We,{className:`size-3`}),j(le||de?`agent.savingWorkingCopy`:`agent.savedToWorkingCopy`)]}):null]})})}):t(`div`,{className:`vprose prose-sm mx-auto max-w-5xl`,children:t(Sy,{artifactRunId:e,resource:{kind:`agent_artifact`,run_id:e??`pending`,path:a},baseVersion:F,readOnly:l||!e||!!he,allowComments:be&&!!e&&!he,highlightChangesFrom:ne,highlightVersion:ie,onAction:H,children:N})}),oe&&N?t(`div`,{className:`absolute end-3 top-3 rounded-full bg-background/80 p-2 shadow-sm`,children:t(nt,{className:`size-4 animate-pulse text-muted`})}):null]})}function Uy({percent:e}){return t(`div`,{className:`w-full bg-muted rounded-full h-2.5`,children:t(`div`,{className:`bg-primary h-2.5 rounded-full`,style:{width:`${e}%`}})})}function Wy({className:e,properties:r}){return t(b,{className:e,children:t(`tbody`,{children:r.map(e=>n(`tr`,{children:[n(`td`,{className:`w-1/3 font-semibold gap-2`,children:[t(`span`,{children:e.name}),e.description&&t(S,{description:e.description,placement:`top`,children:t(at,{className:`size-3 ms-2 text-muted`})})]}),t(`td`,{className:`w-2/3`,children:e.value??`undefined`})]},e.name))})})}function Gy({content:e,...n}){let r=z(null);return L(()=>{if(!r.current)return;let t=new DOMParser().parseFromString(e,`image/svg+xml`).querySelector(`svg`);if(!t){console.warn(`SvgIcon: No <svg> element found in provided string`),r.current.innerHTML=``;return}Object.entries(n).forEach(([e,n])=>{if(n==null)return;let r=e===`className`?`class`:e;t.setAttribute(r,String(n))}),r.current.innerHTML=``,r.current.appendChild(t)}),t(`span`,{ref:r})}function Ky(e){return n=>t(Gy,{content:e,...n})}function qy(e){return{name:e.getNameSignature(),type:e.getTypeSignature(),description:e.description,extractable:e.extractable}}var Jy;(function(e){e.string=`string`,e.number=`number`,e.integer=`integer`,e.boolean=`boolean`,e.object=`object`,e.any=`any`,e.text=`text`,e.media=`media`,e.document=`document`})(Jy||={});function Yy(e){e=e.trim();let t=!1,n=!1;e.endsWith(`?`)&&(n=!0,e=e.substring(0,e.length-1).trim()),e.endsWith(`[]`)&&(t=!0,e=e.substring(0,e.length-2).trim());let r=Jy[e];if(!r)throw Error(`Unknown type "${e}"`);return{name:r,isArray:t,isNullable:n,isObject:r===Jy.object}}function Xy(){let e=Object.values(Jy),t=[...e];for(let n of e)t.push(`${n}[]`);return e.sort(),t}const Zy=Xy();function Qy({value:e,onChange:i,onCancel:a,onSave:o}){let{t:s}=se(),[c,l]=B(!1);return e?n(`div`,{className:`flex items-center`,children:[t(`div`,{className:`flex-1`,children:t($y,{value:e.name,onChange:t=>{i({...e,name:t})},onCancel:a,onSave:o})}),t(`div`,{className:`px-1 font-semibold`,children:`:`}),t(`div`,{className:`flex-1`,children:t(eb,{value:e.type,onChange:t=>{i({...e,type:t})},onCancel:a,onSave:o})}),n(`div`,{children:[t(r,{variant:`ghost`,size:`xs`,onClick:()=>l(!0),title:s(`widgets.schema.editDescription`),children:t(bt,{className:`size-4`})}),t(tb,{value:e.description,isOpen:c,onClose:t=>{t!==void 0&&typeof t==`string`&&i({...e,description:t},!0),l(!1)}})]})]}):null}function $y({value:e,onChange:n,onCancel:r,onSave:i}){let a=z(null);return L(()=>{a.current?.focus()},[]),t(`input`,{onKeyUp:e=>{switch(e.key){case`Enter`:i?.();break;case`Escape`:r?.()}},ref:a,value:e,onChange:e=>{n(e.target.value)},className:v.INPUT_UNSTYLED,style:{fontSize:`inherit`,width:``,display:`inline`}})}function eb({value:e,onChange:n,onCancel:r,onSave:i}){return t(g,{className:v.INPUT_UNSTYLED,options:Zy,value:e||``,onBlur:()=>{i?.()},onChange:n,onKeyDown:(e,t)=>{t||(e.key===`Enter`?i?.():e.key===`Escape`&&r?.())},popupClass:`schema-type-suggest-popup z-90`})}function tb({value:e,isOpen:r,onClose:i}){let{t:a}=se();return n(f,{isOpen:r,onClose:i,children:[t(h,{children:a(`widgets.schema.editDescription`)}),t(nb,{value:e,onSave:i})]})}function nb({value:i,onSave:a}){let{t:o}=se(),s=z(null),[c,l]=B(i||``);return L(()=>{s.current?.focus()},[]),n(e,{children:[t(p,{className:`h-max`,children:t(`textarea`,{ref:s,className:`dark:bg-muted w-full h-full dark:text-white`,value:c,onChange:e=>l(e.target.value)})}),t(m,{children:t(r,{onClick:()=>a(c),children:o(`store.saveChanges`)})})]})}function rb({value:e}){let{t:r}=se();if(!e)return null;let i=e.extractable===!1;return n(`div`,{className:`w-full flex items-baseline gap-2 min-w-0`,children:[t(`div`,{className:`truncate`,children:e.name||``}),t(`div`,{className:`text-sm text-muted shrink-0`,children:e.type||``}),i&&t(`span`,{className:`shrink-0 text-[10px] uppercase tracking-wide text-attention border border-attention/40 bg-attention/10 rounded px-1.5 py-0.5`,title:r(`widgets.schema.extractFromDocumentHint`),children:r(`widgets.schema.noExtract`)})]})}function ib(e,t,n){if(e.properties){let r=e.properties,i={};for(let e of Object.keys(r)){let a=r[e];e===t?i[n]=a:i[e]=a}e.properties=i}e.required&&=e.required.map(e=>e===t?n:e)}function ab(e,t,n){if(Array.isArray(e.required)){let r=e.required.indexOf(t);n?r<0&&e.required.push(t):r>-1&&e.required.splice(r,1)}else n&&(e.required=[t])}function ob(e,t){let n=t.name===`any`?void 0:t.isNullable?[t.name,`null`]:t.name;if(t.isArray){if(e.type=`array`,e.properties=void 0,!e.items||Array.isArray(e.items))e.items={type:n,properties:t.isObject?{}:void 0};else{let r=e.items;r.type=n,t.isObject&&!r.properties&&(r.properties={})}}else e.type=n,e.items=void 0,t.isObject?e.properties||={}:e.properties=void 0}function sb(e,t){e.properties&&(delete e.properties[t],Array.isArray(e.required)&&(e.required=e.required.filter(e=>e!==t)))}function cb(e,t,n,r=!1){if(e.type!==`object`)throw Error(`Cannot add property to a non-object schema`);e.properties||={};let i={};return ob(i,n),e.properties[t]=i,r&&(Array.isArray(e.required)?fb(e.required,t):e.required=[t]),i}function lb(e){let t=!1,n=!1,r,i=e.type;if(Array.isArray(i))for(let e of i)e===`null`?t=!0:r||=e;else r=i;r||=`any`,r===`array`&&(n=!0,r=ub(e.items));let a=r;switch(e.editor){case`textarea`:a=`text`;break;case`media`:a=`media`;break;case`document`:a=`document`}return{isNullable:t,isArray:n,isObject:r===`object`,name:a}}function ub(e){if(!e)return`any`;let t;return t=db(Array.isArray(e)?e[0].type:e.type),(t===`array`||t===`null`)&&(t=`any`),t}function db(e){return e?Array.isArray(e)?e.find(e=>e!==`null`)||`any`:e:`any`}function fb(e,t){e.includes(t)||e.push(t)}let pb=0;var mb=class e{source;onChange=()=>{};schema;root;constructor(e,t){this.schema=e?typeof e==`string`?JSON.parse(e):e:{title:t,type:`object`,properties:{}},this.schema.properties||(this.schema.properties={}),this.root=new hb(``,this.schema,this),this.root.loadChildren()}get isEmpty(){return!this.root.children||this.root.children.length===0}get children(){return this.root.children??[]}reload(){return this.root=new hb(``,this.schema,this),this.root.loadChildren(),this.onChange?.(this),this}withSource(e,t){return this.source={uri:t,name:e},this}withChangeListener(e){return this.onChange=e,this}replaceSchema(e){this.schema=e||{title:this.schema.title,type:`object`,properties:{}},this.reload()}clone(){let t=new e(this.schema);return t.source=this.source,this.onChange&&t.withChangeListener(this.onChange),t}},hb=class e{schema;loader;parent;name;isRequired=!1;type;children;constructor(e,t,n,r){if(this.schema=t,this.loader=n,this.parent=r,this.name=e,this.type=lb(t),this.parent){let t=this.parent._getPropertiesSchema().required;this.isRequired=t&&Array.isArray(t)?t.includes(e):!1}}get title(){return typeof this.schema.title==`string`?this.schema.title:void 0}set title(e){this.schema.title=e}get description(){return this.schema.description}set description(e){this.schema.description=e}get extractable(){return this.schema[`x-extract`]!==!1}set extractable(e){e?delete this.schema[`x-extract`]:this.schema[`x-extract`]=!1}get isParent(){return this.type.isObject}get isNew(){return!!this.schema.isNew}set isNew(e){e?this.schema.isNew=!0:delete this.schema.isNew}resetIsNew(){let e=this.isNew;return this.isNew=!1,e}getNameSignature(){return`${this.name}${this.isRequired?``:`?`}`}getTypeSignature(){return`${this.type.name}${this.type.isArray?`[]`:``}${this.type.isNullable?`?`:``}`}getSignature(){return`${this.getNameSignature()}: ${this.getTypeSignature()}`}reloadTree(){this.loader.reload()}loadChildren(){this.children=[];let e=this.schema.items?.properties;this.schema.items&&e?this._loadChildren(e,this.children):this.schema.properties&&this._loadChildren(this.schema.properties,this.children)}_loadChildren(t,n){for(let r of Object.keys(t)){let i=t[r],a=new e(r,i,this.loader,this);n.push(a),a.isParent&&a.loadChildren()}}_getPropertiesSchema(){return this.type.isArray&&this.type.isObject?this.schema.items:this.schema}findAvailableChildName(e){let t=this._getPropertiesSchema().properties||{},n;do n=e+ ++pb;while(t[n]);return n}addChild(t,n,r=!1){if(!this.type.isObject)throw Error(`Cannot add child to a non object node`);this.children||=[];let i=cb(this._getPropertiesSchema(),t,n,r),a=new e(t,i,this.loader,this);return this.children.push(a),a}remove(){return this.parent?.type.isObject?(sb(this.parent._getPropertiesSchema(),this.name),this.parent.children&&(this.parent.children=this.parent.children.filter(e=>e.name!==this.name)),!0):!1}update(e){let t=!1;e.name!=null&&this.name!==e.name&&(this.parent&&ib(this.parent._getPropertiesSchema(),this.name,e.name),this.name=e.name,t=!0),e.isRequired!=null&&this.isRequired!==e.isRequired&&(this.parent&&ab(this.parent._getPropertiesSchema(),this.name,e.isRequired),this.isRequired=e.isRequired,t=!0);let n=e.type?.name;n===`any`&&(n=void 0);let r=n!==this.schema.type;return e.type&&(ob(this.schema,e.type),this.type=e.type,this.type.isObject?this.children||=[]:this.children=void 0,t=!0),this.schema.editor&&e.editor===null?(this.schema.editor=void 0,t=!0):e.editor?(this.schema.editor=e.editor,t=!0):r&&(this.schema.editor=void 0,t=!0),e.description!==this.description&&(this.description=e.description,t=!0),e.extractable!=null&&this.extractable!==e.extractable&&(this.extractable=e.extractable,t=!0),t}getUpdateFromNameAndTypeSignature(e,t){let n=e.trim(),r=!0;n.endsWith(`?`)&&(n=n.substring(0,n.length-1).trim(),r=!1);let i=Yy(t),a;return i.name===`text`?(i.name=Jy.string,a=`textarea`):i.name===`media`?(i.name=Jy.any,a=`media`):i.name===`document`?(i.name=Jy.any,a=`document`):a=null,{name:n,type:i,isRequired:r,editor:a}}updateFromNameAndTypeSignature(e,t){return this.update(this.getUpdateFromNameAndTypeSignature(e,t))}updateFromSignature(e){e=e.trim();let t=e.indexOf(`:`);if(t<0)throw Error(`Expecting a name and a type separated by a colon`);let n=e.substring(0,t),r=e.substring(t+1);return this.updateFromNameAndTypeSignature(n,r)}};function gb(e){let[t,n]=B(new mb(e||{type:`object`,properties:{}}).withChangeListener(e=>{n(e.clone())}));return t}const _b=`block text-sm sm:leading-6 rounded-md border-0 py-1.5 px-4`,vb=`${_b} hover:shadow-xs hover:ring-1 hover:ring-inset hover:ring-ring`,yb=`${_b} shadow-xs ring-1 ring-inset ring-ring`;function bb({value:e,onChange:r,onDelete:i,outlineOnHover:a=!1,editOnClick:o=!0,placeholder:s,viewer:c,editor:l,skipClickOutside:u,isEditing:d=!1,readonly:f=!1,onValidate:p}){let{on:m,off:h,isOn:g}=E(d),[_,v]=B();return n(`div`,{className:``,children:[g&&!f?t(Sb,{value:e,onSave:e=>{if(p){let t=p(e);if(t){v(t);return}v(void 0)}r(e)&&h()},onCancel:h,editor:l,skipClickOutside:e=>u?u(e):!1}):t(xb,{value:e,onEdit:m,viewer:c,placeholder:s,outlineOnHover:a,editOnClick:o,onDelete:i,readonly:f}),_&&t(`div`,{className:`text-destructive text-sm`,children:_})]})}function xb({viewer:e,value:i,onEdit:a,editOnClick:o,outlineOnHover:s,placeholder:c,onDelete:l,readonly:u}){let d=()=>{o&&a()},f=e=>{e.key===`Enter`&&a()},p=`invisible group-hover:visible`;return n(`div`,{role:o?`button`:void 0,tabIndex:0,onKeyUp:f,onClick:d,className:k(`flex justify-start items-center group`,s?vb:_b,{"cursor-pointer":o}),children:[t(e,{value:i,placeholder:c}),n(`div`,{className:`ms-auto flex gap-2`,children:[!u&&l&&t(r,{variant:`ghost`,size:`sm`,className:p,onClick:l,children:t(xt,{className:`size-4`})}),u?null:t(r,{variant:`ghost`,size:`sm`,className:p,onClick:a,children:t(_t,{className:`size-4`})})]})]})}function Sb({editor:e,value:n,onSave:r,onCancel:i,skipClickOutside:a}){let[o,s]=B(n),c=z(n),[l,u]=B(null),d=()=>{r(c.current)},f=T(d,a);return t(`div`,{ref:f,children:t(`div`,{className:yb,children:t(`div`,{className:`w-full`,onClick:e=>e.stopPropagation(),children:t(e,{value:o,onChange:(e,t=!1)=>{s(e),c.current=e,t&&(l&&clearTimeout(l),u(setTimeout(()=>{r(e)},500)))},onSave:d,onCancel:i})})})})}function Cb(e){return!!e.target.closest?.(`.schema-type-suggest-popup`)}function wb({schema:e,readonly:r=!1}){let{t:i}=se();return n(`div`,{className:`space-y-1`,children:[n(`div`,{className:`flex items-center gap-2 px-2 py-1 text-xs font-medium text-muted border-b border-border`,children:[t(`div`,{className:`flex-1 min-w-0`,children:i(`widgets.schema.propertyColumn`)}),!r&&t(`div`,{className:`shrink-0 w-28 text-end pe-1`,title:i(`widgets.schema.extractFromDocumentHint`),children:i(`widgets.schema.extractFromDocument`)}),t(`div`,{className:`w-8 shrink-0`})]}),n(`ul`,{className:``,children:[e.children.map(e=>Tb(e,r)),r?null:t(Ab,{parent:e.root})]})]})}function Tb(e,n){return e.isParent?t(Db,{property:e,readonly:n},e.name):t(Eb,{node:e,readonly:n},e.name)}function Eb({node:e,readonly:n}){return t(`li`,{className:`border-b border-border/40 last:border-0`,children:t(kb,{property:e,readonly:n})})}function Db({property:e,readonly:i}){let[a,o]=B(!0),s=a?Ge:Ke;return n(`li`,{className:`border-b border-border/40 last:border-0`,children:[n(`div`,{className:`flex items-center w-full gap-1`,children:[t(`div`,{className:`flex-1 min-w-0`,children:t(kb,{property:e,readonly:i})}),t(r,{variant:`ghost`,size:`icon`,onClick:()=>o(!a),"aria-label":a?`Collapse ${e.name}`:`Expand ${e.name}`,"aria-expanded":a,className:`shrink-0`,children:t(s,{className:`size-4 cn-rtl-flip`})})]}),a&&n(`ul`,{className:`ms-4 border-s border-border border-dashed`,children:[(e.children||[]).map(e=>Tb(e,i)),i?null:t(Ab,{parent:e})]})]})}function Ob(e){if(!e)return`Name is required`;if(!/^[a-zA-Z0-9_]+[?]?$/.test(e))return`Only letters, numbers, underscores or question mark are allowed (a-zA-Z0-9_?)`}function kb({property:e,readonly:r}){let{t:i}=se(),a=O(),o=t=>{try{t.description&&typeof t.description!=`string`&&(t.description=void 0);let n=e.getUpdateFromNameAndTypeSignature(t.name,t.type);e.update({...n,description:t.description,extractable:t.extractable})&&e.reloadTree()}catch(e){return a({status:`error`,title:i(`widgets.schema.invalidPropertyDeclaration`),description:w(e),duration:9e3}),!1}return!0},s=t=>{e.update({extractable:t})&&e.reloadTree()},c=e.resetIsNew(),l=qy(e);return n(`div`,{className:`flex items-center gap-2 w-full min-w-0 py-0.5`,children:[t(`div`,{className:`flex-1 min-w-0`,children:t(bb,{value:l,onChange:o,onDelete:()=>{e.remove(),e.reloadTree()},editor:Qy,viewer:rb,outlineOnHover:!0,isEditing:c,skipClickOutside:Cb,readonly:r,onValidate:e=>Ob(e.name)})}),r?e.extractable===!1?t(`div`,{className:`shrink-0 w-28 flex justify-end pe-1`,children:t(`span`,{className:`text-[10px] uppercase tracking-wide text-attention border border-attention/40 bg-attention/10 rounded px-1.5 py-0.5`,title:i(`widgets.schema.extractFromDocumentHint`),children:i(`widgets.schema.noExtract`)})}):null:t(`div`,{className:`shrink-0 w-28 flex items-center justify-end gap-1.5 pe-1`,children:t(y,{size:`sm`,value:e.extractable,onChange:s,"aria-label":`${i(`widgets.schema.extractFromDocument`)}: ${e.name}`})})]})}function Ab({parent:e}){return n(r,{variant:`ghost`,onClick:()=>{let t=e.findAvailableChildName(`new_property_`),n=e.addChild(t,{isObject:!1,isArray:!1,isNullable:!1,name:Jy.string},!0);n.isNew=!0,e.reloadTree()},children:[t(mt,{className:`size-4`}),`Add property`]})}function jb(e){return e.isFile}function Mb(e){return e.isDirectory}function Nb({onDrop:e,message:i,buttonLabel:a,allowFolders:o=!0,className:s=``}){let{t:c}=se(),l=a??c(`upload.uploadFiles`),[u,d]=B(!1),f=z(null),p=e=>{e.preventDefault(),e.dataTransfer.types.includes(`Files`)&&d(!0)},m=e=>{e.preventDefault(),f.current&&!f.current.contains(e.relatedTarget)&&d(!1)},h=async t=>{if(t.preventDefault(),d(!1),t.dataTransfer.items&&t.dataTransfer.items.length>0){let n=Array.from(t.dataTransfer.items),r=[],i=new Set,a=async e=>{if(jb(e)){let t=await new Promise(t=>{e.file(n=>{Object.defineProperty(n,"webkitRelativePath",{writable:!0,value:e.fullPath.substring(1)}),t(n)})});!t.name.startsWith(`.`)&&t.size>0&&r.push(t);let n=e.fullPath.substring(1).split(`/`).slice(0,-1).join(`/`);n&&i.add(n)}else if(Mb(e)){let t=e.createReader(),n=await new Promise(e=>{t.readEntries(t=>{e(t)})});await Promise.all(n.map(a));let r=e.fullPath.substring(1);r&&i.add(r)}};try{if(await Promise.all(n.map(e=>{let t=e.webkitGetAsEntry?e.webkitGetAsEntry():e;return t?a(t):Promise.resolve()})),r.length>0){let t=new Set(Array.from(i).map(e=>e.split(`/`)[0]).filter(Boolean)).size,n=r.length,a=``;a=t>0?c(`upload.preparingFolder`,{count:t,folderCount:t,fileCount:n}):c(`upload.preparingFiles`,{count:n}),e(r,{count:r.length,message:a})}}catch(n){console.error(`Error processing dropped files:`,n);let r=Array.from(t.dataTransfer.files);r.length>0&&e(r)}}else t.dataTransfer.files&&t.dataTransfer.files.length>0&&e(Array.from(t.dataTransfer.files))},g=t=>{if(t&&t.length>0){let n=Array.from(t);if(n.some(e=>e.webkitRelativePath?.includes(`/`))){let t=new Set(n.map(e=>e.webkitRelativePath.split(`/`)[0]).filter(Boolean)).size,r=n.length,i=c(`upload.preparingFolder`,{count:t,folderCount:t,fileCount:r});e(n,{count:n.length,message:i})}else e(n,{count:n.length,message:c(`upload.preparingFiles`,{count:n.length})})}};return n(`div`,{className:`flex flex-col items-center justify-center py-12 border-2 rounded-lg transition-colors ${u?`border-info bg-info`:`border-dashed border-border`} ${s}`,onDragOver:p,onDragLeave:m,onDrop:h,children:[t(St,{className:`h-12 w-12 mb-3 transition-colors ${u?`text-info`:`text-muted/50`}`}),t(`p`,{className:`text-muted`,children:i}),n(`div`,{className:`flex gap-2 justify-center mt-2`,children:[t(r,{onClick:()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=!0,e.accept=`*`,e?.click(),e.onchange=()=>{g(e.files)}},children:l}),o&&t(r,{onClick:()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=!0,e.accept=`*`,e.webkitdirectory=!0,e?.click(),e.onchange=()=>{g(e.files)}},children:c(`upload.selectFolder`)})]})]})}function Pb({title:e,count:r,icon:i=t(Je,{className:`h-4 w-4 text-success`}),items:a}){let{t:o}=se(),[s,c]=B(!1),l=ie();return n(`div`,{className:`border border-border rounded-md overflow-hidden`,children:[n(`button`,{type:`button`,"aria-expanded":s,"aria-controls":l,className:`w-full flex items-center justify-between p-3 bg-muted/10 cursor-pointer text-start bg-transparent border-0 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,onClick:()=>c(!s),children:[n(`span`,{className:`flex items-center`,children:[t(`span`,{className:`me-2`,children:i}),t(`span`,{className:`font-medium`,children:e}),t(`span`,{className:`ms-2 px-2 py-0.5 bg-muted/20 rounded-full text-xs`,children:r})]}),t(`span`,{className:`text-muted`,"aria-hidden":`true`,children:t(`svg`,{className:`h-5 w-5 transition-transform ${s?`transform rotate-180`:``}`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`,children:t(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 9l-7 7-7-7`})})})]}),s&&t(`div`,{id:l,className:`p-3 border-t border-border max-h-48 overflow-y-auto`,children:a.length>0?t(`ul`,{className:`space-y-1`,children:a.map(e=>t(`li`,{className:`text-sm py-1 px-2 rounded hover:bg-muted/10`,children:e},e))}):t(`div`,{className:`text-sm text-muted py-2`,children:o(`upload.noItems`)})})]})}function Fb({files:e,className:r=``,location:i,collection:a}){let{t:o}=se(),s=e.filter(e=>e.status===`success`),c=e.filter(e=>e.status===`updated`),l=e.filter(e=>e.status===`skipped`),u=e.filter(e=>e.status===`failed`),d=s.length,f=c.length,p=l.length,m=u.length,h=e.length;return n(`div`,{className:`flex flex-col py-2 ${r}`,children:[n(`div`,{className:`flex items-center mb-4`,children:[t(`div`,{className:`size-8 me-4 rounded-full bg-success/10 flex items-center justify-center`,children:t(Je,{className:`size-4 text-success`})}),t(`div`,{children:n(`p`,{className:`text-muted`,children:[o(`upload.filesProcessed`,{count:h}),a?o(`upload.inCollection`,{collection:a}):``,i?o(`upload.inFolder`,{location:i}):``]})})]}),n(`div`,{className:`space-y-3 mt-2`,children:[d>0&&t(Pb,{title:o(`upload.successfullyUploaded`),count:d,icon:t(Je,{className:`h-4 w-4 text-success`}),items:s.map(e=>e.name)}),f>0&&t(Pb,{title:o(`upload.successfullyUpdated`),count:f,icon:t(Je,{className:`h-4 w-4 text-info`}),items:c.map(e=>e.name)}),p>0&&t(Pb,{title:o(`upload.skippedAlreadyExisted`),count:p,icon:t(qe,{className:`h-4 w-4 text-attention`}),items:l.map(e=>e.name)}),m>0&&t(Pb,{title:o(`upload.failedToUpload`),count:m,icon:t(Ye,{className:`h-4 w-4 text-destructive`}),items:u.map(e=>e.name)})]})]})}const Ib=`#text`,Lb=`#comment`,Rb=`#cdata`,zb=`DECLARATION_TAG`,Bb={tagColor:`#d43900`,textColor:`#333`,attributeKeyColor:`#2a7ab0`,attributeValueColor:`#008000`,separatorColor:`#333`,commentColor:`#aaa`,cdataColor:`#1d781d`,fontFamily:`monospace`},Vb={attributeKeyColor:`#FFD700`,attributeValueColor:`#FF4500`,tagColor:`#87CEFA`,textColor:`#00FF00`,separatorColor:`#FFD700`,commentColor:`#BEBEBE`,cdataColor:`#33CC66`,fontFamily:`monospace`},Hb=N({theme:Bb,collapsible:!1,indentSize:2}),Ub=()=>re(Hb);let Wb;function Gb(){return Wb??=import(`fast-xml-parser`).then(({XMLParser:e})=>new e({preserveOrder:!0,ignoreAttributes:!1,attributeNamePrefix:``,allowBooleanAttributes:!0,commentPropName:Lb,cdataPropName:Rb,parseTagValue:!1})).catch(e=>{throw Wb=void 0,e}),Wb}async function Kb(e){try{let t=new DOMParser().parseFromString(e,`application/xml`),n=t.documentElement.localName===`parsererror`?t.documentElement:void 0;if(n)throw Error(n.textContent?.trim()||`Invalid XML!`);let r=(await Gb()).parse(e);if(e.trim().length>0&&r.length===0)throw Error(`Invalid XML!`);return{json:r,valid:!0}}catch(e){return{json:null,valid:!1,errorMessage:`Fail to parse: ${e instanceof Error?e.message:String(e)}`}}}function qb(e){let[t,n]=B(void 0);return L(()=>{let t=!1;return n(void 0),Kb(e).then(e=>{t||n(e)}),()=>{t=!0}},[e]),t}function Jb(e){let{indentation:r,children:i,isInline:a}=e,{theme:o}=Ub();return n(`div`,{style:{color:o.cdataColor},children:[t(`span`,{children:`${r}<![CDATA[`}),i,t(`span`,{children:`${a?``:r}]]>`})]})}function Yb(e){let{collapsible:n,theme:r}=Ub(),{collapsed:i}=e;return n?t(`span`,{style:{position:`relative`},children:t(`span`,{style:{position:`absolute`,right:`0`,border:0,padding:0,background:`none`},children:t(Xb,{fill:r.separatorColor,style:{transform:`rotate(${i?0:90}deg)`,transition:`transform 0.2s`}})})}):null}function Xb({...e}){return t(`svg`,{width:`16px`,height:`16px`,viewBox:`0 0 24 24`,"aria-hidden":`true`,...e,children:t(`path`,{d:`M9 17.898C9 18.972 10.2649 19.546 11.0731 18.8388L17.3838 13.3169C18.1806 12.6197 18.1806 11.3801 17.3838 10.6829L11.0731 5.16108C10.2649 4.45388 9 5.02785 9 6.1018V17.898Z`})})}function Zb(e){let{collapsible:t,initialCollapsedDepth:n}=Ub(),[r,i]=B(()=>xe(n)||!t?!1:e>=n);return L(()=>{i(xe(n)||!t?!1:e>=n)},[n,e,t]),{collapsed:r,buttonProps:t?{onClick:()=>i(e=>!e),role:`button`,style:{cursor:`pointer`}}:{}}}function Qb(e){let{indentation:r,children:i,isInline:a,level:o}=e,{theme:s}=Ub(),{collapsed:c,buttonProps:l}=Zb(o);return n(`div`,{style:{color:s.commentColor},children:[n(`span`,{...l,children:[t(`span`,{children:r}),t(Yb,{collapsed:c}),t(`span`,{children:`<!-- `})]}),!c&&i,c&&`...`,t(`span`,{children:`${a||c?` `:r}-->`})]})}function $b(e){let{attributes:r}=e,{theme:i}=Ub();return r?t(`span`,{children:Object.entries(r).map(([e,r])=>n(`span`,{children:[t(`span`,{style:{color:i.attributeKeyColor},children:` ${e}`}),t(`span`,{style:{color:i.separatorColor},children:`=`}),t(`span`,{style:{color:i.attributeValueColor},children:`"${r}"`})]},`attribute-${e}`))}):null}function ex(e){let{indentation:r,tagKey:i,attributes:a}=e,{theme:o}=Ub();return n(`div`,{children:[t(`span`,{style:{color:o.separatorColor},children:`${r}<?`}),t(`span`,{style:{color:o.tagColor},children:`${i.slice(1)}`}),t($b,{attributes:a}),t(`span`,{style:{color:o.separatorColor},children:`?>`})]})}function tx(e,t){return Array(t*e+1).join(` `)}function nx(e){return typeof e==`string`&&e.includes(`
|
|
341
341
|
`)}function rx(e){return typeof e!=`string`&&e.length===1&&`#text`in e[0]&&!nx(e[0][`#text`])}function ix(e){switch(e){case Ib:case Rb:case Lb:return e;default:return e.startsWith(`?`)?zb:`TAG`}}function ax(e){let t=e[`:@`],n=V(e,`:@`),[[r,i]]=Object.entries(n);return{attributes:t,tagKey:r,subElements:i,type:ix(r)}}function ox(e){return e?Object.keys(e).length>0:!1}function sx(r){let{indentation:i,tagKey:a,attributes:o,children:s,isInline:c,hasChildren:l,level:u}=r,{collapsed:d,buttonProps:f}=Zb(u),{theme:p}=Ub();return n(`div`,{children:[n(`span`,{...f,children:[t(`span`,{children:i}),t(Yb,{collapsed:d}),t(`span`,{style:{color:p.separatorColor},children:`<`}),t(`span`,{style:{color:p.tagColor},children:`${a}`}),!d&&t($b,{attributes:o}),d&&ox(o)&&` ...`,t(`span`,{style:{color:p.separatorColor},children:l?`>`:` />`})]}),l&&n(e,{children:[!d&&s,d&&`...`,t(`span`,{style:{color:p.separatorColor},children:`${c||d?``:i}</`}),t(`span`,{style:{color:p.tagColor},children:`${a}`}),t(`span`,{style:{color:p.separatorColor},children:`>`})]})]})}function cx(e){let{hasSiblings:n,text:r,indentation:i,isText:a}=e,{theme:o}=Ub(),s=a?{color:o.textColor}:void 0;return nx(r)||n?t(`div`,{style:s,children:r.split(`
|
|
342
342
|
`).filter(e=>!!e.trim()).map((e,n)=>t(`div`,{children:`${i}${e.trim()}`},`line-${n}`))}):t(`span`,{style:s,children:r})}function lx(n){let{elements:r,level:i=0,isText:a=!0}=n,{indentSize:o}=Ub();return!Array.isArray(r)||r.length===0?null:t(e,{children:r.map((e,n)=>{let{tagKey:s,attributes:c,subElements:l,type:u}=ax(e),d=r.length>1,f=tx(o,i),p=`${i}-${n}`,m=rx(l);switch(u){case Ib:return t(cx,{text:l,indentation:f,hasSiblings:d,isText:a},p);case Lb:return t(Qb,{isInline:m,indentation:f,level:i,children:t(lx,{elements:l,level:i+1,isText:!1})},p);case Rb:return t(Jb,{indentation:f,isInline:m,children:t(lx,{elements:l,level:i+1,isText:!1})},p);case zb:return t(ex,{indentation:f,tagKey:s,attributes:c},p);default:return t(sx,{indentation:f,tagKey:s,attributes:c,isInline:m,hasChildren:l.length>0,level:i,children:t(lx,{elements:l,level:i+1})},p)}})})}function ux(){return t(`div`,{children:`Invalid XML!`})}function dx(e){let{theme:n,xml:r,collapsible:i=!1,indentSize:a=2,invalidXml:o,initalCollapsedDepth:s,initialCollapsedDepth:c}=e,[l,u]=B(()=>document.documentElement.classList.contains(`dark`));L(()=>{let e=document.documentElement,t=new MutationObserver(()=>{u(e.classList.contains(`dark`))});return t.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},[]);let d=R(()=>({...l?Vb:Bb,...n}),[l,n]),f=qb(r),p=R(()=>({theme:d,collapsible:i,indentSize:a,initialCollapsedDepth:c??s}),[d,i,a,s,c]);return f?f.valid?t(Hb.Provider,{value:p,children:t(`div`,{className:`rxv-container`,style:{whiteSpace:`pre-wrap`,fontFamily:d.fontFamily,overflowWrap:`break-word`},children:t(lx,{elements:f.json})})}):o||t(ux,{}):null}export{Vn as AgentResourceResolverProvider,Jt as ArrayPropertySchema,pa as ArtifactContentRenderer,Hy as ArtifactEditingSurface,J_ as ChartCodeBlockHandler,ia as CodeBlockErrorBoundary,ta as CodeBlockHandlerProvider,U as CodeBlockPlaceholder,N_ as CodeBlockRendererProvider,Sy as CollaborativeMarkdownRenderer,Nb as DropZone,Z_ as ExpandCodeBlockHandler,Tt as FieldSetContextProvider,Mt as Form,Dt as FormContext,At as FormContextProvider,Ut as FormError,Ht as FormHelper,Vt as FormLabel,Pt as GeneratedForm,jt as Input,on as JSONCode,vn as JSONDisplay,Pn as JSONEditor,In as JSONSwitcher,zn as JSONTable,un as JSONView,rn as ManageObjectEntry,nn as ManagedListProperty,$t as ManagedObject,Qt as ManagedObjectBase,en as ManagedObjectProperty,tn as ManagedProperty,an as ManagedScalarEntry,mb as ManagedSchema,iv as MarkdownFigure,ov as MarkdownImage,cv as MarkdownLink,ny as MarkdownRenderer,Y_ as MermaidCodeBlockHandler,V_ as MermaidDiagram,Nn as MonacoEditor,Zt as Node,Uy as Progress,Wy as PropertiesView,Qy as PropertyEditor,$y as PropertyNameEditor,Kt as PropertySchema,rb as PropertyViewer,Lt as ScalarField,Gt as Schema,wb as SchemaEditor,hb as SchemaNode,Gy as SvgIcon,Pb as UploadResultCategory,Fb as UploadSummary,Mn as VEditorApi,dx as XMLViewer,Ry as applyArtifactRefreshChanges,_y as applyMarkdownEditingChange,Yt as computeTitleFromName,Cn as configureMonacoLoader,$_ as createDefaultCodeBlockHandlers,fy as createMarkdownBlockAnchor,Ky as createSvgIcon,Fy as createUnifiedLineDiff,ky as diffTextSegments,Ey as diffWordSegments,vy as formatMarkdownEditingAction,qy as getEditableSchemaProperty,Fn as getJSONEditorValue,Ay as getTextLineChangeRegions,Ly as isArtifactRefreshEvent,Q_ as isExpandLanguage,W_ as isIncompleteJson,Tn as loadMonacoReact,Wn as parseAgentResourceHref,nv as parseUrlScheme,Py as rebaseTextChanges,ln as renderJsonLine,Hn as useAgentResourceResolver,U_ as useArtifactContent,F_ as useCodeBlockComponent,na as useCodeBlockContext,P_ as useCodeBlockRendererRegistry,Et as useFieldSet,kt as useForm,rv as useResolvedUrl,gb as useSchema,Ob as validatePropertyName};
|
|
343
343
|
//# sourceMappingURL=vertesia-ui-widgets.js.map
|