(function(f,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("@xirelogy/xwts"),require("vue")):typeof define=="function"&&define.amd?define(["exports","@xirelogy/xwts","vue"],u):(f=typeof globalThis<"u"?globalThis:f||self,u(f.VanyComponentLibrary={},f.Xwts,f.Vue))})(this,function(f,u,r){"use strict";var pr=Object.defineProperty;var hr=(f,u,r)=>u in f?pr(f,u,{enumerable:!0,configurable:!0,writable:!0,value:r}):f[u]=r;var b=(f,u,r)=>hr(f,typeof u!="symbol"?u+"":u,r);class T{constructor(){b(this,"typeLabel")}using(e){const n=this,o=e??{};return new class extends T{parse(a,s){const c=s??{};return n.parse(a,{...o,_options:c})}format(a,s){const c=s??{};return n.format(a,{...o,_options:c})}}}}function Rt(t){return new class extends T{parse(e,n){return t().parse(e,n)}format(e,n){return t().format(e,n)}}}function Tt(t,...e){const o=[...[t,...e]].reverse();return new class extends T{async parse(a,s){let c=a;for(const l of e)c=await u.xw.asAsyncTarget(l.parse(c,s));return c}format(a,s){let c=a;for(const l of o)c=l.format(c,s);return c}}}class z extends Error{constructor(e){super(typeof e<"u"?u.xw.normalizeString(e):void 0)}}class x extends z{constructor(e){super(e)}}const A=u.xw.i18n.initModule("vany","@xirelogy").init,$t=A("VanyExceededMinCodecError");class _e extends x{constructor(e,n){const o=""+e+u.xw.normalizeString(n??"");super(u.xw.format($t("must not be less than {0}"),o))}}const Nt=A("VanyExceededMaxCodecError");class Ve extends x{constructor(e,n){const o=""+e+u.xw.normalizeString(n??"");super(u.xw.format(Nt("must not be more than {0}"),o))}}let ge=-1;const P=[];function xt(t){let e=-1;for(const n of P)if(++e,n.id==t)return e;return null}class Y{static enterContext(e){++ge;const n=ge;return P.push({id:n,context:e}),new u.XwOneTimeRelease(()=>{const o=xt(n);o!==null&&P.splice(o,1)})}static usingContext(e,n,o){var s;const a=(s=this.currentContext)==null?void 0:s.findMessageHandler(e,n);return a?a():o()}static get currentContext(){const e=P.length;return e<=0?null:P[e-1].context}}const Z=A("VanyInvalidValueCodecError"),we="VanyInvalidValueCodecError";class Dt extends x{constructor(){super(Y.usingContext(we,{},()=>Z("invalid value")))}}const Ut={key:we,handle:(t,e)=>{const n=$.getControlNatureVerb(e),o=$.getControlNaturePassive(e);return t!==void 0?u.xw.format(Z("{2} {1} is invalid"),n,o,t):u.xw.format(Z("value {1} is invalid"),n,o)}},ee=A("VanyRequiredValidationError"),Ce="VanyRequiredValidationError";class be extends z{constructor(){super(Y.usingContext(Ce,{},()=>ee("input is required")))}}const Se={key:Ce,handle:(t,e)=>{const n=$.getControlNatureVerb(e),o=$.getControlNaturePassive(e);return t!==void 0?u.xw.format(ee("{2} must be {1}"),n,o,t):u.xw.format(ee("must be {1}"),n,o)}},D=A("VanyFormCodecMessageContext"),U=new Map;class ${static createInstance(e,n){return{findMessageHandler(o,a){const s=U.get(o);if(!s)return null;let c=e;return(c===""||c==="-")&&(c=void 0),()=>s(c,n,a)}}}static registerHandle(e,n){const o=U.get(e);return U.set(e,n),new u.XwOneTimeRelease(()=>{o?U.set(e,o):U.delete(e)})}static getControlNatureVerb(e){switch(e){case"input":return D("provide");case"select":return D("select");default:return D("provide")}}static getControlNaturePassive(e){switch(e){case"input":return D("provided");case"select":return D("selected");default:return D("provided")}}}function qt(){const t=[Fe,Ut,Se];for(const e of t)U.set(e.key,e.handle)}const q=A("VanyInvalidFormatCodecError"),Be="VanyInvalidFormatCodecError";function Ht(t){return t.formatType?u.xw.format(q("invalid {0} format"),t.formatType):q("invalid format")}class X extends x{constructor(n){const o=n??{};super(Y.usingContext(Be,o,()=>Ht(o)));b(this,"errorData");this.errorData=o}}const Fe={key:Be,handle:(t,e,n)=>{const o=n,a=$.getControlNatureVerb(e),s=$.getControlNaturePassive(e);return t!==void 0?o.formatType!==void 0?u.xw.format(q("{2} must be {1} in correct {3} format"),a,s,t,o.formatType):u.xw.format(q("{2} must be {1} in correct format"),a,s,t):o.formatType!==void 0?u.xw.format(q("must be {1} in correct {2} format"),a,s,o.formatType):u.xw.format(q("must be {1} in correct format"),a,s)}},Pt=A("VanyOverflowCodecError");class te extends x{constructor(){super(Pt("overflow"))}}const Lt=A("vanyMoneyCodec");function ke(t){return t.replace(/,/g,"")}function ne(t){return/^\d+$/.test(t)}function Kt(t,e){switch(e.length){case 0:return t;case 1:return t+parseInt(e,10)*10;case 2:return t+parseInt(e,10);default:return t+parseInt(e.substring(0,2),10)}}function Ot(t){return t.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")}function Ae(t,e){if(typeof t>"u"||t===null||typeof t=="string"&&t.trim()==="")return null;t=Math.round(t);const n=t<0?"-":"",o=Math.floor(Math.abs(t)/100);let s=""+Math.abs(t)%100;for(;s.length<2;)s="0"+s;const c=e?Ot(o):""+o;return n+c+"."+s}function Ee(t,e){return Ae(t,e)??"?"}class Wt extends T{constructor(){super(...arguments);b(this,"typeLabel",Lt("money"))}parse(n,o){const a=(o==null?void 0:o.min)??null,s=(o==null?void 0:o.max)??null,c=(o==null?void 0:o.isGroup)??!1,l=this._onParse(n);if(l===null)return null;if(a!==null&&ls)throw new Ve(Ee(s,c));return l}_onParse(n){if(typeof n>"u"||n===null)return null;let o=(""+n).trim();if(o==="")return null;let a=1;o[0]==="-"&&(a=-1,o=o.substring(1));const s={value:n,formatType:this.typeLabel},c=o.indexOf(".");if(c>=0){const l=ke(o.substring(0,c)),i=o.substring(c+1),h=l!==""?l:"0",p=i!==""?i:"0";if(!ne(h))throw new X(s);if(!ne(p))throw new X(s);if(h.length>13)throw new te;const d=parseInt(h,10)*100;return a*Kt(d,p)}else{const l=ke(o);if(!ne(l))throw new X(s);if(Math.floor(parseFloat(l)*100)>999999999999999)throw new te;return a*parseInt(l,10)*100}}format(n,o){const a=(o==null?void 0:o.isGroup)??!1;return Ae(n,a)}using(n){return super.using(n)}}const jt=new Wt,zt=A("vanyCodecMessages"),re={get ok(){return zt("ok")}};class E extends T{parse(e,n){return u._used(n),e}format(e,n){return u._used(n),e}}const Yt=A("VanyValidationFailedError");class oe extends z{constructor(){super(Yt("validation failed"))}}const H=Symbol();class Xt{constructor(e){b(this,"isInline");this.isInline=e}}function L(t){return new Xt(t)}function Gt(t){const e=r.inject(H,null);return e===null?t:e.isInline}class Qt{static isInline(e){return Gt(e??!1)}}const Me=Symbol();class Jt{constructor(e){b(this,"name");this.name=e}}function Zt(t){return new Jt(t??"")}function en(){const t=r.inject(Me,null);return t===null?"":t.name}class tn{static get name(){return en()}}const ve=Symbol();class nn{constructor(e){b(this,"rowKey");this.rowKey=e}}function rn(t){return new nn(t)}function on(){const t=r.inject(ve,null);if(t!==null)return t.rowKey}class an{static get fn(){return on()}}const sn=r.defineComponent({__name:"VanyExtendedSlot",setup(t){const e=r.useAttrs();function n(a){return Array.isArray(a==null?void 0:a.children)?a.children.map(s=>n(s)):r.cloneVNode(a,e)}const o=()=>{var s;const a=(s=r.useSlots())==null?void 0:s.default();return n(a[0])};return(a,s)=>(r.openBlock(),r.createBlock(o,null,{default:r.withCtx(()=>[r.renderSlot(a.$slots,"default")]),_:3}))}}),Ie=r.defineComponent({__name:"VanyRenderFunctionComponent",props:{fn:{type:Function}},setup(t){const e=t,n=()=>e.fn();return(o,a)=>(r.openBlock(),r.createBlock(n))}}),Re=Symbol();class cn{constructor(e){b(this,"raiseError");this.raiseError=e}}function ln(t){return new cn(t)}function un(t){const e=r.inject(Re,null);return e===null?()=>{}:(n,o)=>{const a=t(n);e.raiseError(a,o)}}class C{static registerHandle(e){this._currentHandle=e}static get name(){if(this._currentHandle===null)throw new Error("No actuator handle is registered: Vany is not configured properly!");return this._currentHandle.name}static render(e){if(this._currentHandle===null)throw new Error("No actuator handle is registered: Vany is not configured properly!");return this._currentHandle.render(e)}static directive(e){if(this._currentHandle===null)throw new Error("No actuator handle is registered: Vany is not configured properly!");return this._currentHandle.directive(e)}static reactive(e){if(this._currentHandle===null)throw new Error("No actuator handle is registered: Vany is not configured properly!");return this._currentHandle.reactive(e)}static registerDefaultService(e,n){var o;(o=this._currentHandle)==null||o.registerService(e,n,!1)}static service(e){if(this._currentHandle===null)throw new Error("No actuator handle is registered: Vany is not configured properly!");return this._currentHandle.service(e)}}b(C,"_currentHandle",null);class S{static acceptAttrs(e){const n={};for(const o in e)n[o]=e[o];return n}static acceptModelValueFromAttrs(e){for(const n in e)if(n==="modelValue")return e[n];return null}static acceptSlot(e){return e===void 0?()=>null:(...n)=>e(...n)}static acceptOptionalSlot(e){if(e!==void 0)return(...n)=>e(...n)}}const Te=r.defineComponent({__name:"VanyApp",emits:["error"],setup(t,{emit:e}){const n=r.useAttrs(),o=r.useSlots(),a=e,s=ln((l,i)=>{a("error",l,i)});r.provide(Re,s);const c=()=>{const l={vanyClass:"app",attrs:S.acceptAttrs(n),slots:o};return C.render(l)};return(l,i)=>(r.openBlock(),r.createBlock(c))}}),$e=Symbol();class dn{constructor(e){b(this,"fwdNotifyKeyword");this.fwdNotifyKeyword=e}}function fn(t){return new dn(t)}function mn(){const t=r.inject($e,null);return t===null?null:t.fwdNotifyKeyword}class Ne{constructor(e){b(this,"_handleFn");this._handleFn=e}call(e){return this._handleFn(e)}handleUsing(e){this._handleFn=e}}class yn extends Ne{constructor(){super(()=>{})}}const xe=r.defineComponent({__name:"VanyAutocomplete",props:{filter:{type:Function},debounce:{},scrollHeight:{},manualTrigger:{type:Boolean}},emits:["selected"],setup(t,{expose:e,emit:n}){const o=t,a=n,s=r.useAttrs(),c=r.useSlots(),l=new yn;(o.manualTrigger??!1)||r.provide($e,fn(l));function i(p){l.call(p)}e({notifyKeyword:i});const h=()=>{const p={vanyClass:"autocomplete",attrs:S.acceptAttrs(s),slots:c,filter:o.filter,notifySelected:(d,m)=>{a("selected",d,m)},fwdNotifyKeyword:l,debounceMs:o.debounce??350,scrollHeight:o.scrollHeight};return C.render(p)};return(p,d)=>(r.openBlock(),r.createBlock(h))}}),De=r.defineComponent({__name:"VanyBreadcrumb",props:{separator:{}},setup(t){const e=t,n=r.useAttrs(),o=r.useSlots(),a=()=>{const s={vanyClass:"breadcrumb",attrs:S.acceptAttrs(n),slots:o,separator:e.separator};return C.render(s)};return(s,c)=>(r.openBlock(),r.createBlock(a))}}),Ue=r.defineComponent({__name:"VanyBreadcrumbItem",setup(t){const e=r.useAttrs(),n=r.useSlots(),o=()=>{const a={vanyClass:"breadcrumb-item",attrs:S.acceptAttrs(e),slots:n};return C.render(a)};return(a,s)=>(r.openBlock(),r.createBlock(o))}}),ae=r.defineComponent({__name:"VanyButton",props:{type:{},light:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},setup(t){const e=t,n=r.useAttrs(),o=r.useSlots(),a=()=>{const s={vanyClass:"button",attrs:S.acceptAttrs(n),slots:o,type:e.type,light:e.light,disabled:e.disabled,loading:e.loading};return C.render(s)};return(s,c)=>(r.openBlock(),r.createBlock(a))}}),qe=r.defineComponent({__name:"VanyCard",props:{dock:{},dockClass:{}},setup(t){const e=t,n=r.useAttrs(),o=r.useSlots(),a=()=>{const s={vanyClass:"card",attrs:S.acceptAttrs(n),slots:o,dock:e.dock,dockClass:e.dockClass};return C.render(s)};return(s,c)=>(r.openBlock(),r.createBlock(a))}}),He=Symbol();class pn{constructor(e){b(this,"renderService");this.renderService=e}}function hn(t){return new pn(t)}function M(){const t=r.inject(He,null);return t===null?null:t.renderService}const Pe=Symbol();function _n(t,e){return e==="rejectEmpty"&&t===""||e==="rejectTrimEmpty"&&t.trim()===""?null:t}function Vn(t,e){return e==="rejectEmpty"&&t.length<1?null:t}function Le(t){return t instanceof Error?t:typeof t=="string"?new Error(t):new oe}function gn(t,e){return t instanceof E?t.parse(e):new oe}function v(t){var N;const e=(N=t.registeredControl)==null?void 0:N.negotiate(Pe);let n=t.codec.format(t.currentValue),o,a=()=>{},s=()=>{},c=()=>{},l=(e==null?void 0:e.validateStringMode)??"rejectEmpty",i=(e==null?void 0:e.validateArrayMode)??"rejectEmpty",h=(e==null?void 0:e.validateTrigger)??t.defaultValidateTrigger,p=t.controlNature;function d(V){return h==="input"&&V==="input"||h==="blur"&&V==="blur"||h==="change"&&V==="change"}async function m(V){if(o!==void 0&&o===V)throw new Dt;let F=await u.xw.asAsyncTarget(t.codec.parse(V));return typeof F=="string"&&(F=u._cast(_n(F,l))),Array.isArray(F)&&(F=u._cast(Vn(F,i))),F}async function y(V){const F=Y.enterContext($.createInstance(e==null?void 0:e.subjectLabel,p));try{const J=await w();return e==null||e.notifyValidated(J,V),J}finally{F.release()}}async function w(){try{const V=await m(n);return t.onUpdateValueFn(V),V!==null}catch(V){return Le(V)}}function B(){u.xw.fork(async()=>{await y(!1)})}e==null||e.registerNotifyingValidator(y),B();const g={onWatch(V){a=V},notifyUpdate(V){n=V;const F=gn(t.codec,V);F instanceof Error||t.onUpdateValueFn(F)}},_={get modelValue(){return g},onFocus(V){t.fwdFocus.handleUsing(V)},onValidated(V){var F;(F=t.registeredControl)==null||F.onValidated(V)},notifyBadModelValue(V){V!==null&&(o=V)},notifyEvent(V,F,J){d(V)&&u.xw.fork(async()=>{await y()}),V==="change"&&u.xw.fork(async()=>{let he=null;try{he=await m(n)}catch(yr){he=Le(yr)}e==null||e.notifyChange(),s(he,n,F)}),V==="input"&&c(J??"",F)}};function k(V){const F=n;n=t.codec.format(V),a(n),o!==void 0&&o!==n&&(o=void 0),F!==n&&B()}return{notifyMounted(V){k(V)},notifyWatch(V){k(V)},notifyBeforeUnmount(){var V;(V=t.registeredControl)==null||V.notifyBeforeUnmount()},onChangeEvent(V){s=V},onInputEvent(V){c=V},export(){return _}}}class I extends Ne{constructor(){super(async()=>!1)}}const Ke=r.defineComponent({__name:"VanyCheck",props:{name:{},modelValue:{default:null},codec:{},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","change"],setup(t,{emit:e}){var p;const n=t,o=e,a=r.useAttrs(),s=r.useSlots(),c=new I;let l=null;typeof n.name=="string"&&(l=((p=M())==null?void 0:p.registerControl(n.name,c))??null);const i=v({currentValue:n.modelValue,onUpdateValueFn:d=>{o("update:modelValue",d)},fwdFocus:c,codec:n.codec??u._cast(new E),registeredControl:l,defaultValidateTrigger:"change",controlNature:"select"});i.onChangeEvent((d,m,y)=>{o("change",d,m,y)}),r.onMounted(()=>i.notifyMounted(n.modelValue)),r.watch(()=>n.modelValue,i.notifyWatch),r.onBeforeUnmount(i.notifyBeforeUnmount);const h=()=>{const d={vanyClass:"check",attrs:S.acceptAttrs(a),slots:s,disabled:n.disabled,_render:i.export()};return C.render(d)};return(d,m)=>(r.openBlock(),r.createBlock(h))}}),Oe=r.defineComponent({__name:"VanyContainer",setup(t){const e=r.useAttrs(),n=r.useSlots(),o=()=>{const a={vanyClass:"container",attrs:S.acceptAttrs(e),slots:n};return C.render(a)};return(a,s)=>(r.openBlock(),r.createBlock(o))}}),We=r.defineComponent({__name:"VanyDateInput",props:{name:{default:null},modelValue:{default:null},codec:{default:null},disabled:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(t,{expose:e,emit:n}){var m;const o=t,a=n,s=r.useAttrs(),c=r.useSlots(),l=new I;let i=null;typeof o.name=="string"&&(i=((m=M())==null?void 0:m.registerControl(o.name,l))??null);const h=v({currentValue:o.modelValue,onUpdateValueFn:y=>{a("update:modelValue",y)},fwdFocus:l,codec:o.codec??u._cast(new E),registeredControl:i,defaultValidateTrigger:"blur",controlNature:"input"});r.onMounted(()=>h.notifyMounted(o.modelValue)),r.watch(()=>o.modelValue,h.notifyWatch),r.onBeforeUnmount(h.notifyBeforeUnmount);async function p(){return l.call()}e({focus:p});const d=()=>{const y={vanyClass:"date-input",attrs:S.acceptAttrs(s),slots:c,name:o.name,disabled:o.disabled,_render:h.export()};return C.render(y)};return(y,w)=>(r.openBlock(),r.createBlock(d))}});class K{constructor(){b(this,"_services",new Map)}registerService(e,n){this._services.set(e,n)}get negotiator(){const e=this;return{negotiate(n){return u._cast(e._services.get(n))??null}}}}function se(t){let e=t.currentValue;const n=new u.XwEventBroker;n.expose().subscribe(a=>{e=a,t.onUpdateValueFn(a)});let o=()=>{};return{get currentValue(){return e},notifyMounted(a){e=a,o(a)},notifyWatch(a){e=a,o(a)},subscribeModelValueUpdated(a){return n.expose().subscribe(a)},export(){return{onWatch(a){o=a},notifyUpdate(a){n.publish(a)}}}}}const G=Symbol();function ce(t,e,n){return{vanyServiceClass:"VanyModalRemoteService",get name(){return n},get currentModelValue(){return t.currentValue},setShowModelValue(o){t.notifyWatch(o)},subscribeModelValueUpdated(o){return t.subscribeModelValueUpdated(o)},subscribeModalEvent(o,a){const s=e.get(o);return typeof s>"u"?null:s.expose().subscribe(a)}}}const le=r.defineComponent({__name:"VanyDialog",props:{modelValue:{type:Boolean,default:!1}},emits:["update:modelValue","show","shown","hide","hidden"],setup(t,{expose:e,emit:n}){const o=A("VanyDialog"),a=t,s=n,c=r.useAttrs(),l=r.useSlots(),i=se({currentValue:a.modelValue,onUpdateValueFn:g=>s("update:modelValue",g)});r.onMounted(()=>i.notifyMounted(a.modelValue)),r.watch(()=>a.modelValue,i.notifyWatch);const h=new Map;function p(g,_){const k=new u.XwEventBroker;k.expose().subscribe(_),h.set(g,k)}p("show",()=>s("show")),p("shown",()=>s("shown")),p("hide",()=>s("hide")),p("hidden",()=>s("hidden"));const d={get modelValue(){return i.export()},notifyEvent(g){var _;(_=h.get(g))==null||_.publish()}},m=new K,y=ce(i,h,o("Dialog"));m.registerService(G,y);const w=m.negotiator;e({serviceNegotiator:w});const B=()=>{const g={vanyClass:"dialog",attrs:S.acceptAttrs(c),modelValue:a.modelValue,slots:l,_render:d};return C.render(g)};return(g,_)=>(r.openBlock(),r.createBlock(B))}}),ie=r.defineComponent({__name:"VanyDiv",props:{inline:{type:Boolean,default:!1}},setup(t){const e=t,n=r.useAttrs(),o=r.useSlots();r.provide(H,L(e.inline));const a=()=>{const s={vanyClass:"div",attrs:S.acceptAttrs(n),slots:o};return C.render(s)};return(s,c)=>(r.openBlock(),r.createBlock(a))}}),je=r.defineComponent({__name:"VanyDrawer",props:{modelValue:{type:Boolean,default:!1},closeButton:{type:Boolean,default:!0},closeOutside:{type:Boolean,default:!0},closeEscape:{type:Boolean,default:!0},modal:{type:Boolean,default:!0},dock:{default:"right"},size:{}},emits:["update:modelValue","show","shown","hide","hidden"],setup(t,{expose:e,emit:n}){const o=A("VanyDrawer"),a=t,s=n,c=r.useAttrs(),l=r.useSlots(),i=se({currentValue:a.modelValue,onUpdateValueFn:g=>s("update:modelValue",g)});r.onMounted(()=>i.notifyMounted(a.modelValue)),r.watch(()=>a.modelValue,i.notifyWatch);const h=new Map;function p(g,_){const k=new u.XwEventBroker;k.expose().subscribe(_),h.set(g,k)}p("show",()=>s("show")),p("shown",()=>s("shown")),p("hide",()=>s("hide")),p("hidden",()=>s("hidden"));const d={get modelValue(){return i.export()},notifyEvent(g){var _;(_=h.get(g))==null||_.publish()}},m=new K,y=ce(i,h,o("Drawer"));m.registerService(G,y);const w=m.negotiator;e({serviceNegotiator:w});const B=()=>{const g={vanyClass:"drawer",attrs:S.acceptAttrs(c),modelValue:a.modelValue,slots:l,closeButton:a.closeButton,closeOutside:a.closeOutside,closeEscape:a.closeEscape,modal:a.modal,dock:a.dock,size:a.size,_render:d};return C.render(g)};return(g,_)=>(r.openBlock(),r.createBlock(B))}}),ue=Symbol();class wn{constructor(e){b(this,"type");this.type=e}}function ze(t){return new wn(t)}function Ye(){const t=r.inject(ue,null);return t===null?null:t.type}const Xe=r.defineComponent({__name:"VanyDropdownMenu",props:{trigger:{default:"hover"},placement:{default:"bottom"}},emits:["selected"],setup(t,{emit:e}){const n=t,o=r.useAttrs(),a=r.useSlots(),s=e,c={notifySelected(i){i!==void 0&&s("selected",i)}};r.provide(ue,ze("dropdown-menu"));const l=()=>{const i={vanyClass:"dropdown-menu",attrs:S.acceptAttrs(o),slots:a,trigger:n.trigger,placement:n.placement,_render:c};return C.render(i)};return(i,h)=>(r.openBlock(),r.createBlock(l))}}),R=u.xw.debugLog.defineLazy("Vany.[VanyFormRunner]"),de=!0;class Cn{constructor(e,n,o,a,s,c,l,i){b(this,"instanceId");b(this,"formName");b(this,"isRequired");b(this,"stringMode");b(this,"arrayMode");b(this,"trigger");b(this,"subjectLabel");b(this,"_fwdFocus");b(this,"_notifyingValidatorFn");b(this,"_onValidateResultFns",[]);b(this,"_lastValidation",!1);b(this,"_isUsable",!0);this.instanceId=e,this.formName=n,this.isRequired=o,this.stringMode=a,this.arrayMode=s,this.trigger=c,this.subjectLabel=l,this._fwdFocus=i??null,this._notifyingValidatorFn=async h=>(this.notifyValidated(!1,h??de),!1)}get isUsable(){return this._isUsable}notifyValidated(e,n){this._lastValidation=e,!(e!==!0&&!n)&&(e===!0?this._forwardNotifyValidated(!0,u.xw.normalizeString(re.ok)):e instanceof Error?this._forwardNotifyValidated(!1,e.message):this.isRequired?this._forwardNotifyValidated(!1,new be):this._forwardNotifyValidated(!0,u.xw.normalizeString(re.ok)))}clearValidate(){this._forwardNotifyValidated(null,"")}_forwardNotifyValidated(e,n){for(const o of this._onValidateResultFns)o(e,n)}evaluateLastValidity(){return!(this._lastValidation===!1&&this.isRequired||this._lastValidation instanceof Error)}async focus(){return this._fwdFocus===null?!1:await this._fwdFocus.call()}subscribeValidationResult(e){this._onValidateResultFns.push(e)}registerNotifyingValidator(e){this._notifyingValidatorFn=e}async validate(e){await this._notifyingValidatorFn(e);const n=this.evaluateLastValidity();return R.r.debug(`[${this.instanceId}] FormField.validate('${this.formName}')`,{lastValidation:this._lastValidation,evaluation:n}),n}destroy(){this._isUsable=!1}}function bn(t){const e=u.xw.random.lowerAlphanumString(8),n=r.ref(!1),o=r.ref(!1),a=new Map;let s=!1;u._used(t.modelValue);function c(m,y,w,B,g,_,k){if((a.get(m)??null)!==null)return R.r.warn(`Duplicate field name: '${m}'`),null;const V=new Cn(e,m,y,w,B,g,_,k);return a.set(m,V),n.value=d(),V}function l(m,y){const w=new K,B={vanyServiceClass:"VanyRegisteredFormItemRemoteService",get subjectLabel(){return m.subjectLabel},get validateStringMode(){return m.stringMode},get validateArrayMode(){return m.arrayMode},get validateTrigger(){return m.trigger},registerNotifyingValidator(g){m.registerNotifyingValidator(g)},notifyChange(){o.value=!0},notifyValidated(g,_){const k=_??de;R.r.debug(`[${e}] ${k?"FG":"BG"}-validation result for '${m.formName}': ${g instanceof Error?g.message:g}`),m.notifyValidated(g,k),n.value=d()}};return w.registerService(Pe,B),{name:m.formName,negotiate(g){return w.negotiator.negotiate(g)},onValidated(g){m.subscribeValidationResult(g)},notifyBeforeUnmount(){y("control-handle")}}}function i(m){m.isUsable&&(m.destroy(),a.delete(m.formName),n.value=d())}function h(){s=!0,r.nextTick(async()=>{s&&(s=!1,await p(!1))})}async function p(m){R.r.debug(`[${e}] validate() triggered, foreground = ${m}`);let y=!0;const w=[];for(const[B,g]of a)u._used(B),await g.validate(m)||(w.push(B),y=!1);return m&&r.nextTick(async()=>{for(const B of w){const g=a.get(B);if(g&&await g.focus())return}}),n.value=y,y}function d(){let m=!0;for(const[y,w]of a)if(u._used(y),!w.evaluateLastValidity()){m=!1;break}return m}return t.getServiceFn({registerFormItem(m,y,w,B,g){let _=null,k=null;const N=V=>{_!==null&&(R.r.debug(`[${e}] Deregistering '${_.formName}' initialized from ${V}`),i(_),_=null)};return{registerControl(V,F){return _!==null||(_=c(V,m,y,w,B,g,F),_===null)?null:(k!==null&&_.subscribeValidationResult(k),R.r.debug(`[${e}] Registered '${_.formName}'`),l(_,N))},onValidated(V){k=V,_==null||_.subscribeValidationResult(V)},notifyRequired(V){if(!_){R.r.warn(`[${e}] notifyRequired() called without registeredField, ignored`);return}R.r.log(`[${e}] Updating '${_.formName}' required`,V);const F=_.isRequired;_.isRequired=V,F!=_.isRequired&&h()},notifyBeforeUnmount(){N("item-handle")}}}}),r.nextTick(async()=>{R.r.log(`[${e}] initial nextTick()`,{modelValue:t.modelValue,fields:a}),n.value=d()}),{isSubmitDisabled:r.computed(()=>!n.value),isDirty:r.computed(()=>o.value),async reset(){R.r.debug(`[${e}] reset()`);for(const[m,y]of a)u._used(m),y.clearValidate();o.value=!1},async autoFocus(){for(const[m,y]of a)if(u._used(m),await y.focus())return!0;return!1},async validate(m){return await p(m??de)}}}const Ge=Symbol();class Sn{constructor(e){b(this,"renderService");this.renderService=e}}function Bn(t){return new Sn(t)}function Fn(){const t=r.inject(Ge,null);return t===null?null:t.renderService}const Qe=r.defineComponent({__name:"VanyForm",props:{modelValue:{default:null},submitButton:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},inline:{type:Boolean,default:!1},virtual:{type:Boolean,default:!1}},setup(t,{expose:e}){const n=t,o=r.useAttrs(),a=r.useSlots();let s=null;const c=bn({getServiceFn:y=>{s=y},modelValue:n.modelValue});r.provide(Ge,Bn(s)),r.provide(H,L(n.inline));const l=r.computed(()=>c.isSubmitDisabled.value);function i(){return c}function h(){return c.reset()}function p(){return c.autoFocus()}function d(y){return c.validate(y)}e({isSubmitDisabled:l,autoFocus:p,reset:h,runner:i,validate:d});const m=()=>{const y={vanyClass:"form",attrs:S.acceptAttrs(o),slots:a,submitButton:n.submitButton,disabled:n.disabled,inline:n.inline,virtual:n.virtual};return C.render(y)};return(y,w)=>(r.openBlock(),r.createBlock(m))}}),kn=A("VanyCurrentlyBusyError");class Je extends Error{constructor(e){super(u.xw.normalizeString(e??kn("Currently busy")))}}function An(t){if(t.length<1)return"";const e=t.toUpperCase(),n=t.toLowerCase();return t==n||t.length>1&&t==e||t[0]==n[0]?t:n}function Ze(t,e){const a=(e??(c=>c))(t).trim().split(" ");let s="";for(const c of a)c.length<1||(s+=" "+An(c));return s.substring(1)}class Q{static async busyWhile(e,n,o){const a=o??(()=>{throw new Je});e.value&&await u.xw.asAsyncFn(a),e.value=!0;try{return await n()}finally{e.value=!1}}static untitleText(e,n){return typeof e=="string"?Ze(e,n):{toString(){return Ze(u.xw.normalizeString(e),n)}}}}const En=r.createTextVNode("dummy");function fe(t){return t===null?null:r.isVNode(t)?t:Array.isArray(t)?fe(t[0]):Array.isArray(t==null?void 0:t.children)?fe(t.children[0]):null}class O{static acceptSlotOrTextAsSlot(e,n){return e||(n?()=>[r.createTextVNode(u.xw.normalizeString(n))]:null)}static acceptSlotOrTextAsFunction(e,n){return e||(n?()=>r.createTextVNode(u.xw.normalizeString(n)):()=>null)}static acceptFunctionOrTextAsFunction(e){return typeof e=="function"?e:()=>r.createTextVNode(u.xw.normalizeString(e))}static acceptFunctionAsSingleVNode(e,n){const o=e();return Array.isArray(o)?r.h(n,{},u._cast(o)):o}static acceptFunctionAsMultipleVNode(e){const n=e();return Array.isArray(n)?n:[n]}static acceptComponent(e){if(typeof e=="string"){const n=r.resolveComponent(e);if(typeof n=="string")throw new Error(`Cannot resolve component: '${n}'`);return n}return e}static acceptSingleVNode(e){return fe(e)}static patchVNodes(e,n){if(r.isVNode(e))return[n(e)];if(e instanceof Array){const o=[];for(const a of e)r.isVNode(a)&&o.push(n(a));return o}else return[]}static isTextVNode(e){return e.type===En.type}static getComponentVNodeType(e){return typeof e.type!="object"?null:e.type.__name??null}static flattenVNodeAsText(e){if(e instanceof Array){let n="";for(const o of e)n+=this.flattenVNodeAsText(o);return n}if(!r.isVNode(e))return"";if(typeof e.children=="string")return e.children;if(e.children instanceof Array){let n="";for(const o of e.children)typeof o=="string"?n+=o:(o instanceof Array||r.isVNode(o))&&(n+=this.flattenVNodeAsText(o));return n}return""}static isComponentVNodeOf(e,n){return(this.getComponentVNodeType(e)??"")==n}}const et=r.defineComponent({__name:"VanyFormItem",props:{label:{},subjectLabel:{},required:{type:Boolean,default:!1},validateStringMode:{default:"rejectEmpty"},validateArrayMode:{default:"rejectEmpty"},validateTrigger:{default:void 0}},setup(t){var l;const e=t,n=r.useAttrs(),o=r.useSlots();r.provide(H,L(!1));const a=(()=>{if(e.subjectLabel)return e.subjectLabel;if(e.label)return Q.untitleText(e.label);if(o.label){const i=o.label();if(i)return Q.untitleText(O.flattenVNodeAsText(i))}})(),s=((l=Fn())==null?void 0:l.registerFormItem(e.required,e.validateStringMode,e.validateArrayMode,e.validateTrigger,a))??null;r.provide(He,hn(s)),r.onBeforeUnmount(()=>{s==null||s.notifyBeforeUnmount()}),r.watch(()=>e.required,i=>{s==null||s.notifyRequired(i)});const c=()=>{const i={vanyClass:"form-item",attrs:S.acceptAttrs(n),slots:o,label:e.label,required:e.required,_render:s};return C.render(i)};return(i,h)=>(r.openBlock(),r.createBlock(c))}}),tt=r.defineComponent({__name:"VanyIcon",props:{colorType:{default:void 0},color:{default:void 0},size:{default:void 0}},setup(t){const e=t,n=r.useAttrs(),o=r.useSlots(),a=()=>{const s={vanyClass:"icon",attrs:S.acceptAttrs(n),slots:o,colorType:e.colorType??null,color:e.color??null,size:e.size??null};return C.render(s)};return(s,c)=>(r.openBlock(),r.createBlock(a))}}),nt=r.defineComponent({__name:"VanyImageInput",props:{name:{default:null},modelValue:{default:null},codec:{default:null},disabled:{type:Boolean,default:!1},deletable:{type:Boolean,default:!0},accept:{default:"image/png,image/jpeg,image/gif"},uploader:{},displayWidth:{},displayHeight:{}},emits:["update:modelValue","change"],setup(t,{expose:e,emit:n}){var m;const o=t,a=n,s=r.useAttrs(),c=r.useSlots(),l=new I;let i=null;typeof o.name=="string"&&(i=((m=M())==null?void 0:m.registerControl(o.name,l))??null);const h=v({currentValue:o.modelValue,onUpdateValueFn:y=>{a("update:modelValue",y)},fwdFocus:l,codec:o.codec??u._cast(new E),registeredControl:i,defaultValidateTrigger:"change",controlNature:"input"});h.onChangeEvent((y,w,B)=>{a("change",y,w,B)}),r.onMounted(()=>h.notifyMounted(o.modelValue)),r.watch(()=>o.modelValue,h.notifyWatch),r.onBeforeUnmount(h.notifyBeforeUnmount);async function p(){return l.call()}e({focus:p});const d=()=>{const y={vanyClass:"image-input",attrs:S.acceptAttrs(s),slots:c,name:o.name,disabled:o.disabled,deletable:o.deletable,accept:o.accept,uploader:o.uploader,displayWidth:o.displayWidth,displayHeight:o.displayHeight,_render:h.export()};return C.render(y)};return(y,w)=>(r.openBlock(),r.createBlock(d))}}),rt=r.defineComponent({__name:"VanyImagesInput",props:{name:{default:null},modelValue:{default:null},codec:{default:null},disabled:{type:Boolean,default:!1},accept:{default:"image/png,image/jpeg,image/gif"},uploader:{},displayWidth:{},displayHeight:{}},emits:["update:modelValue","change"],setup(t,{expose:e,emit:n}){var m;const o=t,a=n,s=r.useAttrs(),c=r.useSlots(),l=new I;let i=null;typeof o.name=="string"&&(i=((m=M())==null?void 0:m.registerControl(o.name,l))??null);const h=v({currentValue:o.modelValue,onUpdateValueFn:y=>{a("update:modelValue",y)},fwdFocus:l,codec:o.codec??u._cast(new E),registeredControl:i,defaultValidateTrigger:"change",controlNature:"input"});h.onChangeEvent((y,w,B)=>{a("change",y,w??[],B)}),r.onMounted(()=>h.notifyMounted(o.modelValue)),r.watch(()=>o.modelValue,h.notifyWatch),r.onBeforeUnmount(h.notifyBeforeUnmount);async function p(){return l.call()}e({focus:p});const d=()=>{const y={vanyClass:"images-input",attrs:S.acceptAttrs(s),slots:c,name:o.name,disabled:o.disabled,accept:o.accept,uploader:o.uploader,displayWidth:o.displayWidth,displayHeight:o.displayHeight,_render:h.export()};return C.render(y)};return(y,w)=>(r.openBlock(),r.createBlock(d))}}),ot=r.defineComponent({__name:"VanyInput",props:{type:{},name:{default:null},modelValue:{default:null},codec:{default:null},password:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","input","change"],setup(t,{expose:e,emit:n}){var y;const o=t,a=n,s=r.useAttrs(),c=r.useSlots(),l=new I;let i=null;typeof o.name=="string"&&(i=((y=M())==null?void 0:y.registerControl(o.name,l))??null);const h=mn(),p=v({currentValue:o.modelValue,onUpdateValueFn:w=>{a("update:modelValue",w)},fwdFocus:l,codec:o.codec??u._cast(new E),registeredControl:i,defaultValidateTrigger:"blur",controlNature:"input"});p.onChangeEvent((w,B,g)=>{a("change",w,B,g)}),p.onInputEvent((w,B)=>{a("input",w,B),h==null||h.call(w)}),r.onMounted(()=>p.notifyMounted(o.modelValue)),r.watch(()=>o.modelValue,p.notifyWatch),r.onBeforeUnmount(p.notifyBeforeUnmount);async function d(){return l.call()}e({focus:d});const m=()=>{const w={vanyClass:"input",attrs:S.acceptAttrs(s),slots:c,name:o.name,password:o.password,disabled:o.disabled,_render:p.export()};return C.render(w)};return(w,B)=>(r.openBlock(),r.createBlock(m))}}),at=Symbol(),st=r.defineComponent({__name:"VanyInputFrame",props:{disabled:{type:Boolean,default:!1}},setup(t,{expose:e}){const n=t,o=r.useAttrs(),a=r.useSlots();let s=()=>{},c=()=>{},l=()=>{};const i={onFocus(y){s=y},onBlur(y){c=y},onValidated(y){l=y}},h=new K,p={vanyServiceClass:"VanyInputFrameRemoteService",notifyFocus(){s()},notifyBlur(){c()},notifyValidated(y,w){l(y,w)}};h.registerService(at,p);const d=h.negotiator;e({serviceNegotiator:d});const m=()=>{const y={vanyClass:"input-frame",attrs:S.acceptAttrs(o),slots:a,disabled:n.disabled,_render:i};return C.render(y)};return(y,w)=>(r.openBlock(),r.createBlock(m))}}),ct=r.defineComponent({__name:"VanyInputGroup",setup(t){const e=r.useAttrs(),n=r.useSlots();r.provide(H,L(!0));const o=()=>{const a={vanyClass:"input-group",attrs:S.acceptAttrs(e),slots:n};return C.render(a)};return(a,s)=>(r.openBlock(),r.createBlock(o))}}),lt=r.defineComponent({__name:"VanyList",props:{listMore:{type:Function}},setup(t){const e=t,n=r.useAttrs(),o=r.useSlots(),a=()=>{const s={vanyClass:"list",attrs:S.acceptAttrs(n),slots:o,listMore:e.listMore??null};return C.render(s)};return(s,c)=>(r.openBlock(),r.createBlock(a))}}),Mn=Symbol();class vn{constructor(e){b(this,"renderService");this.renderService=e}}function In(t){return new vn(t)}const it=r.defineComponent({__name:"VanyMenu",props:{template:{default:"horizontal"},compact:{type:Boolean,default:!1}},emits:["selected"],setup(t,{expose:e,emit:n}){const o=t,a=n,s=r.useAttrs(),c=r.useSlots();let l=async d=>{u._used(d)};const i={onSelect(d){l=d},notifySelected(d){d!==void 0&&a("selected",d)}};r.provide(Mn,In(i)),r.provide(ue,ze("menu"));async function h(d){await l(d)}e({select:h});const p=()=>{const d={vanyClass:"menu",attrs:S.acceptAttrs(s),slots:c,template:o.template,compact:o.compact,_render:i};return C.render(d)};return(d,m)=>(r.openBlock(),r.createBlock(p))}}),ut=r.defineComponent({__name:"VanyMenuDivider",setup(t){const e=r.useAttrs(),n=r.useSlots(),o=()=>{const a={vanyClass:"menu-divider",attrs:S.acceptAttrs(e),slots:n,containerType:Ye()};return C.render(a)};return(a,s)=>(r.openBlock(),r.createBlock(o))}}),dt=r.defineComponent({__name:"VanyMenuItem",props:{menuKey:{},active:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},icon:{default:void 0},label:{default:void 0}},setup(t){const e=t,n=r.useAttrs(),o=r.useSlots(),a=()=>{const s={vanyClass:"menu-item",attrs:S.acceptAttrs(n),slots:o,containerType:Ye(),key:e.menuKey??null,active:e.active,disabled:e.disabled,icon:e.icon??null,label:e.label??null};return C.render(s)};return(s,c)=>(r.openBlock(),r.createBlock(a))}}),ft=r.defineComponent({__name:"VanyOption",props:{value:{},disabled:{type:Boolean,default:!1}},setup(t){const e=t,n=r.useAttrs(),o=r.useSlots(),a=()=>{const s={vanyClass:"option",attrs:S.acceptAttrs(n),slots:o,value:e.value,disabled:e.disabled};return C.render(s)};return(s,c)=>(r.openBlock(),r.createBlock(a))}}),mt=r.defineComponent({__name:"VanyPopup",props:{modelValue:{type:Boolean,default:!1},trigger:{default:"hover"},placement:{default:"bottom"},width:{default:200},popupClass:{}},emits:["update:modelValue","show","shown","hide","hidden"],setup(t,{expose:e,emit:n}){const o=A("VanyPopup"),a=t,s=n,c=r.useAttrs(),l=r.useSlots(),i=se({currentValue:a.modelValue,onUpdateValueFn:g=>s("update:modelValue",g)});r.onMounted(()=>i.notifyMounted(a.modelValue)),r.watch(()=>a.modelValue,i.notifyWatch);const h=new Map;function p(g,_){const k=new u.XwEventBroker;k.expose().subscribe(_),h.set(g,k)}p("show",()=>s("show")),p("shown",()=>s("shown")),p("hide",()=>s("hide")),p("hidden",()=>s("hidden"));const d={get modelValue(){return i.export()},notifyEvent(g){var _;(_=h.get(g))==null||_.publish()}},m=new K,y=ce(i,h,o("Popup"));m.registerService(G,y);const w=m.negotiator;e({serviceNegotiator:w});const B=()=>{const g={vanyClass:"popup",attrs:S.acceptAttrs(c),slots:l,trigger:a.trigger,placement:a.placement,width:a.width,popupClass:a.popupClass,_render:d};return C.render(g)};return(g,_)=>(r.openBlock(),r.createBlock(B))}}),yt=r.defineComponent({__name:"VanyProgress",props:{value:{},barWidth:{default:20},template:{default:"normal"},type:{default:"primary"}},setup(t){const e=t,n=r.useAttrs(),o=r.useSlots(),a=()=>{const s={vanyClass:"progress",attrs:S.acceptAttrs(n),slots:o,value:e.value,barWidth:e.barWidth,template:e.template,type:e.type};return C.render(s)};return(s,c)=>(r.openBlock(),r.createBlock(a))}}),pt=r.defineComponent({__name:"VanyRadio",props:{value:{type:[String,Number,Boolean]},disabled:{type:Boolean,default:!1}},setup(t){const e=t,n=r.useAttrs(),o=r.useSlots(),a=()=>{const s={vanyClass:"radio",attrs:S.acceptAttrs(n),slots:o,value:e.value,disabled:e.disabled};return C.render(s)};return(s,c)=>(r.openBlock(),r.createBlock(a))}}),ht=r.defineComponent({__name:"VanyRadioGroup",props:{modelValue:{default:null},codec:{default:null},name:{default:null},inline:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(t,{emit:e}){var p;const n=t,o=e,a=r.useAttrs(),s=r.useSlots(),c=new I;let l=null;typeof n.name=="string"&&(l=((p=M())==null?void 0:p.registerControl(n.name,c))??null);const i=v({currentValue:n.modelValue,onUpdateValueFn:d=>{o("update:modelValue",d)},fwdFocus:c,codec:n.codec??u._cast(new E),registeredControl:l,defaultValidateTrigger:"change",controlNature:"select"});r.onMounted(()=>i.notifyMounted(n.modelValue)),r.watch(()=>n.modelValue,i.notifyWatch),r.onBeforeUnmount(i.notifyBeforeUnmount),r.provide(H,L(n.inline));const h=()=>{const d={vanyClass:"radio-group",attrs:S.acceptAttrs(a),slots:s,name:n.name??null,inline:n.inline,disabled:n.disabled,_render:i.export()};return C.render(d)};return(d,m)=>(r.openBlock(),r.createBlock(h))}});function Rn(t){let e=async()=>{},n=()=>{};const o={onRefreshOptions(a){e=a},onEnsureSelect(a){n=a}};return{triggerRefreshOptions(){return e(t.manager.source)},triggerEnsureSelect(){n()},export(){return o}}}const _t=r.defineComponent({__name:"VanySelect",props:{name:{default:null},modelValue:{default:null},codec:{default:null},disabled:{type:Boolean,default:!1},placeholder:{},manager:{}},emits:["update:modelValue","change"],setup(t,{expose:e,emit:n}){var g;const o=t,a=n,s=r.useAttrs(),c=r.useSlots(),l=new I;let i=null;typeof o.name=="string"&&(i=((g=M())==null?void 0:g.registerControl(o.name,l))??null);const h=v({currentValue:o.modelValue,onUpdateValueFn:_=>{a("update:modelValue",_)},fwdFocus:l,codec:o.codec??u._cast(new E),registeredControl:i,defaultValidateTrigger:"change",controlNature:"select"});h.onChangeEvent((_,k,N)=>{a("change",_,k,N)}),r.onMounted(()=>h.notifyMounted(o.modelValue)),r.watch(()=>o.modelValue,h.notifyWatch),r.onBeforeUnmount(h.notifyBeforeUnmount);const p=r.ref(),d=o.manager?Rn({manager:o.manager}):null,m=un(_=>({vanyClass:"select",el:p.value,scope:_}));o.manager&&d&&o.manager.autoload&&r.nextTick(async()=>{try{await d.triggerRefreshOptions()}catch(_){m("triggerRefreshOptions",u.XwError.asError(_))}o.manager.autoselect&&r.nextTick(()=>{try{d.triggerEnsureSelect()}catch(_){m("triggerEnsureSelect",u.XwError.asError(_))}})});async function y(){return l.call()}async function w(){await(d==null?void 0:d.triggerRefreshOptions())}e({focus:y,refreshOptions:w});const B=()=>{const _={vanyClass:"select",attrs:S.acceptAttrs(s),slots:c,name:o.name,placeholder:u.xw.normalizeString(o.placeholder??null),disabled:o.disabled,_render:h.export(),_renderManaged:(d==null?void 0:d.export())??null};return C.render(_)};return(_,k)=>(r.openBlock(),r.createBlock(B,{ref_key:"refCtrl",ref:p},null,512))}}),Vt=r.defineComponent({__name:"VanySwitch",props:{name:{},modelValue:{default:null},codec:{},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","change"],setup(t,{emit:e}){var p;const n=t,o=e,a=r.useAttrs(),s=r.useSlots(),c=new I;let l=null;typeof n.name=="string"&&(l=((p=M())==null?void 0:p.registerControl(n.name,c))??null);const i=v({currentValue:n.modelValue,onUpdateValueFn:d=>{o("update:modelValue",d)},fwdFocus:c,codec:n.codec??u._cast(new E),registeredControl:l,defaultValidateTrigger:"change",controlNature:"select"});i.onChangeEvent((d,m,y)=>{o("change",d,m,y)}),r.onMounted(()=>i.notifyMounted(n.modelValue)),r.watch(()=>n.modelValue,i.notifyWatch),r.onBeforeUnmount(i.notifyBeforeUnmount);const h=()=>{const d={vanyClass:"switch",attrs:S.acceptAttrs(a),slots:s,disabled:n.disabled,_render:i.export()};return C.render(d)};return(d,m)=>(r.openBlock(),r.createBlock(h))}}),gt=r.defineComponent({__name:"VanyTable",props:{data:{default:void 0},bordered:{type:Boolean,default:!1},rowKey:{},namePrefix:{}},setup(t){const e=t,n=r.useAttrs(),o=r.useSlots();r.provide(Me,Zt(e.namePrefix)),r.provide(ve,rn(e.rowKey));const a=()=>{const s={vanyClass:"table",attrs:S.acceptAttrs(n),slots:o,data:e.data??[],bordered:e.bordered,rowKey:e.rowKey};return C.render(s)};return(s,c)=>(r.openBlock(),r.createBlock(a))}}),wt=r.defineComponent({__name:"VanyTableColumn",props:{columnKey:{},label:{}},setup(t){const e=t,n=r.useAttrs(),o=r.useSlots(),a=()=>{const s={vanyClass:"table-column",attrs:S.acceptAttrs(n),slots:o,columnKey:e.columnKey,label:e.label};return C.render(s)};return(s,c)=>(r.openBlock(),r.createBlock(a))}}),Ct=r.defineComponent({__name:"VanyTabPane",props:{value:{},label:{},disabled:{type:Boolean,default:!1}},setup(t){const e=t,n=r.useAttrs(),o=r.useSlots(),a=()=>{const s={vanyClass:"tab-pane",attrs:S.acceptAttrs(n),slots:o,value:e.value,label:e.label,disabled:e.disabled};return C.render(s)};return(s,c)=>(r.openBlock(),r.createBlock(a))}}),bt=r.defineComponent({__name:"VanyTabs",setup(t){const e=r.useAttrs(),n=r.useSlots(),o=()=>{const a={vanyClass:"tabs",attrs:S.acceptAttrs(e),slots:n};return C.render(a)};return(a,s)=>(r.openBlock(),r.createBlock(o))}}),St=r.defineComponent({__name:"VanyTag",props:{type:{default:"primary"},light:{type:Boolean,default:!1},closable:{type:Boolean,default:!1}},emits:["click","close"],setup(t,{emit:e}){const n=t,o=r.useAttrs(),a=r.useSlots(),s=e,c={notifyClick(){s("click")},notifyClose(){s("close")}},l=()=>{const i={vanyClass:"tag",attrs:S.acceptAttrs(o),slots:a,type:n.type,light:n.light,closable:n.closable,_render:c};return C.render(i)};return(i,h)=>(r.openBlock(),r.createBlock(l))}}),Bt=r.defineComponent({__name:"VanyTimeInput",props:{name:{default:null},modelValue:{default:null},codec:{default:null},disabled:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(t,{expose:e,emit:n}){var m;const o=t,a=n,s=r.useAttrs(),c=r.useSlots(),l=new I;let i=null;typeof o.name=="string"&&(i=((m=M())==null?void 0:m.registerControl(o.name,l))??null);const h=v({currentValue:o.modelValue,onUpdateValueFn:y=>{a("update:modelValue",y)},fwdFocus:l,codec:o.codec??u._cast(new E),registeredControl:i,defaultValidateTrigger:"blur",controlNature:"input"});r.onMounted(()=>h.notifyMounted(o.modelValue)),r.watch(()=>o.modelValue,h.notifyWatch),r.onBeforeUnmount(h.notifyBeforeUnmount);async function p(){return l.call()}e({focus:p});const d=()=>{const y={vanyClass:"time-input",attrs:S.acceptAttrs(s),slots:c,name:o.name,disabled:o.disabled,_render:h.export()};return C.render(y)};return(y,w)=>(r.openBlock(),r.createBlock(d))}});function Tn(){return C.name}function $n(t,e){const n=t!==void 0,o=e!==void 0;if(n&&o)return Math.max(t,e);if(n&&!o)return t;if(!n&&o)return e}function Nn(t,e,n){const o=e!==void 0?e/t.width:void 0,a=n!==void 0?n/t.height:void 0,s=$n(o,a);if(s===void 0)return{width:t.width,height:t.height};let c=Math.floor(t.width*s),l=Math.floor(t.height*s);return e!==void 0&&c{if(t.width===void 0&&t.height===void 0&&t.imageType===void 0&&t.quality===void 0)return c;const l=await u.xw.loadImage(c),i=Nn(l,e,n),h=e??i.width,p=n??i.height,d=0-Math.floor((i.width-h)/2),m=0-Math.floor((i.height-p)/2),y=document.createElement("canvas");y.width=h,y.height=p;const w=y.getContext("2d");return w?(w.drawImage(l,d,m,i.width,i.height),y.toDataURL(o,a)):""};return async c=>{const l=await u.xw.readFileAsDataUrl(c.file),i=await s(l.data);return await t.uploader(i)}}const Ft=A("VanyModalRunner");class kt{constructor(e,n){b(this,"_service",null);b(this,"_defaultReturn");b(this,"_closure",null);this._defaultReturn=n,r.nextTick(()=>{var o;if(this._service=((o=e())==null?void 0:o.negotiate(G))??null,this._service===null){console.warn("Cannot access to service in VanyModalRunner");return}this._service.subscribeModelValueUpdated(a=>{a||r.nextTick(()=>{this._completeDismissClosure(this._defaultReturn)})})})}get isRunnable(){return!(this._service===null||this._service.currentModelValue||this._closure!==null)}async host(e){const n=new u.XwReleasableCollection;return new Promise((o,a)=>{var s;if(!this._service){a(new Error(u.xw.normalizeString(Ft("Missing service for VanyModalRunner"))));return}if(!this.isRunnable){n.release(),a(new Error(u.xw.normalizeString(u.xw.format(Ft("{0} already running"),this._service.name))));return}e!=null&&e.onBeforeShow&&e.onBeforeShow(),(e!=null&&e.onStartShow||e!=null&&e.onStartShowContent)&&(this._service?n.safePush(this._service.subscribeModalEvent("show",async()=>{e.onStartShow&&await u.xw.asAsyncFn(e.onStartShow),e.onStartShowContent&&r.nextTick(async()=>{await u.xw.asAsyncFn(e.onStartShowContent)})})):r.nextTick(async()=>{e.onStartShow&&await u.xw.asAsyncFn(e.onStartShow),e.onStartShowContent&&r.nextTick(async()=>{await u.xw.asAsyncFn(e.onStartShowContent)})})),e!=null&&e.onAfterShown&&(this._service?n.safePush(this._service.subscribeModalEvent("shown",async()=>{await u.xw.asAsyncFn(e.onAfterShown)})):r.nextTick(async()=>{r.nextTick(async()=>{await u.xw.sleep(100),await u.xw.asAsyncFn(e.onAfterShown)})})),this._closure=c=>{n.release(),o(c)},(s=this._service)==null||s.setShowModelValue(!0)})}_completeDismissClosure(e){const n=this._closure;this._closure=null,n!==null&&n(e)}dismiss(e){var o;(o=this._service)==null||o.setShowModelValue(!1);const n=typeof e<"u"?e:this._defaultReturn;this._completeDismissClosure(n)}}function At(t,e){return new kt(()=>{var n;return(n=t.value)==null?void 0:n.serviceNegotiator},e)}function Dn(t,e){return At(t,e)}function me(t){return typeof t=="function"?t():r.isRef(t)?t.value:t}function Un(t){const e=r.ref(!1);return r.nextTick(()=>{const n=me(t);n==null||n.addEventListener("focusin",()=>{e.value=!0}),n==null||n.addEventListener("focusout",()=>{e.value=!1})}),r.computed(()=>e.value)}function qn(t){const e=r.ref(!1);return r.nextTick(()=>{const n=me(t);n==null||n.addEventListener("mouseenter",()=>{e.value=!0}),n==null||n.addEventListener("mouseout",()=>{e.value=!1})}),r.computed(()=>e.value)}function Hn(t,e){var n;return typeof t!="string"?null:((n=M())==null?void 0:n.registerControl(t,e))??null}function Pn(t){const e=new I,n=t.codec??u._cast(new E);let o=()=>{};const a=l=>{o(l)},s=Hn(t.nameAttr,e),c=v({currentValue:t.currentValue,onUpdateValueFn:a,fwdFocus:e,codec:n,registeredControl:s,defaultValidateTrigger:t.defaultValidateTrigger??"blur",controlNature:t.controlNature??"input"});return{upstream:{notifyBeforeUnmount(){c.notifyBeforeUnmount()},notifyMounted(l){c.notifyMounted(l)},notifyWatch(l){c.notifyWatch(l)},notifyFocus(){return e.call()},onUpdateModelValueEvent(l){o=l},onChangeEvent(l){c.onChangeEvent(l)},onInputEvent(l){c.onInputEvent(l)}},downstream:c.export()}}function Ln(t){const e=r.computed(()=>{var n;return(n=t.value)==null?void 0:n.runner()});return{isSubmitDisabled:r.computed(()=>e.value?e.value.isSubmitDisabled.value:!1),isDirty:r.computed(()=>e.value?e.value.isDirty.value:!1),async reset(){var n;await((n=e.value)==null?void 0:n.reset())},async autoFocus(){var n;return await((n=e.value)==null?void 0:n.autoFocus())??!1},async validate(n){var o;return await((o=e.value)==null?void 0:o.validate(n))??!1}}}function Kn(t,e){const n=r.computed(()=>{var a;return(a=t.value)==null?void 0:a.runner()}),o=r.ref(!1);return{isDisabled:r.computed(()=>n.value?n.value.isSubmitDisabled.value:!0),isDirtyDisabled:r.computed(()=>n.value?!n.value.isDirty.value||n.value.isSubmitDisabled.value:!0),isSubmitting:r.computed(()=>o.value),async notifySubmit(){await Q.busyWhile(o,async()=>{var s;(await((s=n.value)==null?void 0:s.validate())??!1)&&await e()})}}}function ye(t){var e,n;return(n=(e=t.value)==null?void 0:e.serviceNegotiator)==null?void 0:n.negotiate(at)}function On(t){return{notifyFocus(){var e;(e=ye(t))==null||e.notifyFocus()},notifyBlur(){var e;(e=ye(t))==null||e.notifyBlur()},notifyValidated(e,n){var o;(o=ye(t))==null||o.notifyValidated(e,n)}}}function Wn(t){return(e,n)=>{const o=new Map;for(const s of e){const c=t.getModelId(s);c&&o.set(c,s)}const a=[];for(const s of n){const c=t.getFormId(s),l=c?o.get(c):void 0;a.push(t.translate(l??null,s))}return a}}const pe=u.xw.debugLog.defineLazy("Vany.[VanyListRunner]");function jn(t){const e=r.ref([]),n=(t==null?void 0:t.hasNew)??!0,o=(t==null?void 0:t.deep)??2;function a(){const p=t.createEmpty();return p.$id=u.xw.random.lowerAlphanumString(8),p.$meta={isNew:!0,isBlank:!0},p}function s(p){const d={...p};return d.$id=u.xw.random.lowerAlphanumString(8),d.$meta={isNew:!1,isBlank:!1},d}function c(p){for(const[d,m]of e.value.entries())if(m.$id==p.$id)return d}for(const p of t.init)e.value.push(s(p));n&&e.value.push(a());function l(p,d){pe.r.debug("resetItems()",p);const m=[];for(const y of p)m.push(s(y));if((d==null?void 0:d.preserve)??!1)for(const y of e.value)y.$meta.isNew&&m.push(y);else n&&m.push(a());e.value=m}function i(){const p=[];for(const d of e.value)d.$meta.isNew&&d.$meta.isBlank||p.push(d);return p}async function h(p){pe.r.debug("deleteItem()",p);const d=c(p);return d===void 0?!1:(e.value.splice(d,1),!0)}return r.watch(()=>e.value,p=>{u._used(p),r.nextTick(()=>{var d;for(const m of e.value)!m.$meta.isBlank||!t.checker(m)||(pe.r.debug(`[${m.$id}] watched: new blank item now has data`),m.$meta.isBlank=!1,n&&e.value.push(a()),(d=t.watch)==null||d.call(t,e.value))})},{deep:o}),{items:e,resetItems:l,getItems:i,isItemDeletable:p=>!p.$meta.isNew||!p.$meta.isBlank,tableRowKeyFunction:p=>p.$id??"",deleteItem:h}}function zn(t){return new class extends T{async parse(e,n){return await u.xw.asAsyncTarget(t(e,n)),e}format(e,n){return u._used(n),e}}}function Yn(t){return C.reactive({vanyClass:"dark-mode",isDark:t})}class W{}b(W,"template","normal"),b(W,"dock","bottom-right"),b(W,"duration",3e3),b(W,"closable",!0);class Xn{static create(e){const n={vanyClass:"notify",options:e};return C.service(n)}}const Gn=A("VanyPromptService");class j{}b(j,"defaultReturn",null),b(j,"defaultButtonLabel",Gn("Ok"));class Qn{static show(e){const n={vanyClass:"prompt",options:e};return C.service(n)}}const Jn=t=>r.h("unsupported",{vanyClass:t.vanyClass},{default:()=>"UNSUPPORTED-VANY-ITEM"}),Zn=t=>new Error(`Unsupported reactive request ${t.vanyClass}`),er=t=>new Error(`Unsupported service request ${t.vanyClass}`);class Et{constructor(e){b(this,"_name");b(this,"_renderers",new Map);b(this,"_directives",new Map);b(this,"_reactors",new Map);b(this,"_services",new Map);this._name=e}get name(){return this._name}registerRenderer(e,n){this._renderers.set(e,n)}render(e){const n=this._renderers.get(e.vanyClass);return n===void 0?Jn(e):n(e)}registerDirective(e,n){this._directives.set(e,n)}directive(e){const n=this._directives.get(e);if(n!==void 0)return n()}registerReactive(e,n){this._reactors.set(e,n)}reactive(e){const n=this._reactors.get(e.vanyClass);return n===void 0?Zn(e):n(e)}registerService(e,n,o){!(o??!0)&&this._services.get(e)||this._services.set(e,n)}service(e){const n=this._services.get(e.vanyClass);return n===void 0?er(e):n(e)}}class tr{constructor(e){b(this,"_values",new Map);const n=e.split(" ");for(const o of n)o!==""&&this._values.set(o,o)}add(e){e!==""&&this._values.set(e,e)}remove(e){return this._values.delete(e)}toString(){let e="";for(const n of this._values.keys())e+=" "+n;return e.substring(1)}}class nr{constructor(e){b(this,"_values",[]);const n=e.split(";");for(const o of n)o.trim()!==""&&this._values.push(o.trim())}add(e){for(;e.endsWith(";");)e=e.substring(0,e.length-1).trim();e.trim()!==""&&this._values.push(e)}toString(){let e="";for(const n of this._values)e+=n+";";return e}}function rr(t,e){const n={};for(const o in t)e&&o=="class"||(n[o]=t[o]);return n}function Mt(t){const e=[];if(Array.isArray(t))for(const n of t)for(const o of Mt(n))e.push(o);else if(typeof t=="string")for(const n of t.split(" "))e.push(n.trim());else if(typeof t=="object"){for(const n in t)if(t[n])for(const o of n.split(" "))e.push(o.trim())}return e}class or{constructor(e,n){b(this,"values");this.values=rr(e??{},n??!0)}dropAttrs(e){for(const n of e)delete this.values[n]}mergeAttrsClass(e){const n=new tr(this.values.class??"");for(const a of e)n.add(a);const o=n.toString();o.length>0?this.values.class=o:delete this.values.class}mergeAttrsClassSpec(e){this.mergeAttrsClass(Mt(e))}mergeAttrsStyle(e){const n=new nr(this.values.style??"");for(const a of e)n.add(a);const o=n.toString();o.length>0?this.values.style=o:delete this.values.style}}function ar(t){t.component("VanyApp",Te),t.component("VanyAutocomplete",xe),t.component("VanyBreadcrumb",De),t.component("VanyBreadcrumbItem",Ue),t.component("VanyButton",ae),t.component("VanyCard",qe),t.component("VanyCheck",u._cast(Ke)),t.component("VanyContainer",Oe),t.component("VanyDateInput",u._cast(We)),t.component("VanyDialog",le),t.component("VanyDiv",ie),t.component("VanyDrawer",je),t.component("VanyDropdownMenu",Xe),t.component("VanyForm",Qe),t.component("VanyFormItem",et),t.component("VanyIcon",tt),t.component("VanyImageInput",nt),t.component("VanyImagesInput",rt),t.component("VanyInput",u._cast(ot)),t.component("VanyInputFrame",st),t.component("VanyInputGroup",ct),t.component("VanyList",lt),t.component("VanyMenu",it),t.component("VanyMenuDivider",ut),t.component("VanyMenuItem",dt),t.component("VanyOption",ft),t.component("VanyPopup",mt),t.component("VanyProgress",yt),t.component("VanyRadio",pt),t.component("VanyRadioGroup",u._cast(ht)),t.component("VanySelect",u._cast(_t)),t.component("VanySwitch",u._cast(Vt)),t.component("VanyTable",gt),t.component("VanyTableColumn",wt),t.component("VanyTabPane",Ct),t.component("VanyTabs",bt),t.component("VanyTag",St),t.component("VanyTimeInput",u._cast(Bt))}function vt(t,e){const n=C.directive(e);return n?(t.directive(e,n),!0):(console.warn(`Registration of directive '${e}' is not successful. Some dependencies may break!`),!1)}function sr(t){vt(t,"flex"),vt(t,"loading")}function It(t,e){var c,l,i,h;const n=((c=e.modifiers)==null?void 0:c.hor)===!0,o=((l=e.modifiers)==null?void 0:l.ver)===!0,a=((i=e.modifiers)==null?void 0:i.fixed)===!0,s=((h=e.modifiers)==null?void 0:h.spring)===!0;t instanceof HTMLElement&&(n&&t.classList.add("vany-std-flex-hor"),o&&t.classList.add("vany-std-flex-ver"),a&&t.classList.add("vany-std-flex-item-fixed"),s&&t.classList.add("vany-std-flex-item-spring"))}function cr(){return{mounted(t,e){It(t,e)},updated(t,e){It(t,e)}}}function lr(t){t.registerDirective("flex",cr)}function ir(t){lr(t)}const ur=r.defineComponent({__name:"VanyPromptDialogHost",props:{specOptions:{}},setup(t,{expose:e}){const n=t,o=r.useSlots(),a=r.ref(!1),s=r.computed(()=>n.specOptions.buttons??[{type:"primary",value:n.specOptions.defaultReturn??j.defaultReturn,content:j.defaultButtonLabel}]);let c=null,l=()=>{};function i(){l(c)}function h(d){c=d.value,a.value=!1}function p(){return new Promise((d,m)=>{c=null,l=d,a.value=!0,u._used(m)})}return e({run:p}),(d,m)=>(r.openBlock(),r.createBlock(le,{modelValue:a.value,"onUpdate:modelValue":m[0]||(m[0]=y=>a.value=y),onHidden:i},r.createSlots({footer:r.withCtx(()=>[r.createVNode(ie,{inline:""},{default:r.withCtx(()=>[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(s.value,y=>(r.openBlock(),r.createBlock(ae,{type:y.type,light:y.light??!1,onClick:w=>h(y)},{default:r.withCtx(()=>[r.createVNode(Ie,{fn:r.unref(O).acceptFunctionOrTextAsFunction(y.content)},null,8,["fn"])]),_:2},1032,["type","light","onClick"]))),256))]),_:1})]),default:r.withCtx(()=>[r.renderSlot(d.$slots,"default")]),_:2},[r.unref(o).header?{name:"header",fn:r.withCtx(()=>[r.renderSlot(d.$slots,"header")]),key:"0"}:void 0]),1032,["modelValue"]))}}),dr=async t=>{const n=t.options,o={default:O.acceptFunctionOrTextAsFunction(n.content)};n.title&&(o.header=O.acceptFunctionOrTextAsFunction(n.title));const a=r.h(ur,{specOptions:n},o);return r.render(a,document.body),await u.xw.sleep(0),await a.component.exposed.run()};function fr(){C.registerDefaultService("prompt",dr)}const mr={install(t,...e){let n=null;for(const a of e){const s=a.useActuator??null;if(s===null)continue;const c=s.install(t,a.useActuatorOptions??[]);C.registerHandle(c),n=c}const o=t;n instanceof Et&&ir(n),ar(o),sr(o),qt(),fr()}};f.Vany=mr,f.VanyApp=Te,f.VanyAutocomplete=xe,f.VanyBreadcrumb=De,f.VanyBreadcrumbItem=Ue,f.VanyButton=ae,f.VanyCard=qe,f.VanyCheck=Ke,f.VanyCodec=T,f.VanyCodecError=x,f.VanyCommonActuatorHandle=Et,f.VanyContainer=Oe,f.VanyCurrentlyBusyError=Je,f.VanyDateInput=We,f.VanyDialog=le,f.VanyDiv=ie,f.VanyDrawer=je,f.VanyDropdownMenu=Xe,f.VanyDummyCodec=E,f.VanyExceededMaxCodecError=Ve,f.VanyExceededMinCodecError=_e,f.VanyExtendedSlot=sn,f.VanyForm=Qe,f.VanyFormCodecMessageContext=$,f.VanyFormItem=et,f.VanyIcon=tt,f.VanyImageInput=nt,f.VanyImagesInput=rt,f.VanyInlineState=Qt,f.VanyInput=ot,f.VanyInputFrame=st,f.VanyInputGroup=ct,f.VanyInvalidFormatCodecError=X,f.VanyList=lt,f.VanyMenu=it,f.VanyMenuDivider=ut,f.VanyMenuItem=dt,f.VanyModalRunner=kt,f.VanyNamePrefixState=tn,f.VanyNotifyOptionsDefault=W,f.VanyNotifyService=Xn,f.VanyOption=ft,f.VanyOverflowCodecError=te,f.VanyPopup=mt,f.VanyProgress=yt,f.VanyPromptOptionsDefault=j,f.VanyPromptService=Qn,f.VanyRadio=pt,f.VanyRadioGroup=ht,f.VanyRenderAttributes=or,f.VanyRenderFunctionComponent=Ie,f.VanyRenderer=S,f.VanyRequiredValidationError=be,f.VanySelect=_t,f.VanySwitch=Vt,f.VanyTabPane=Ct,f.VanyTable=gt,f.VanyTableColumn=wt,f.VanyTableRowKeyState=an,f.VanyTabs=bt,f.VanyTag=St,f.VanyTimeInput=Bt,f.VanyUi=Q,f.VanyValidationError=z,f.VanyValidationFailedError=oe,f.VanyVue=O,f.chainCodecs=Tt,f.deferCodec=Rt,f.fromVanySpec=me,f.initVanyInvalidFormatCodecErrorFormContext=Fe,f.initVanyRequiredValidationErrorFormContext=Se,f.useVanyActuatorName=Tn,f.useVanyDefaultImageFileProcessor=xn,f.useVanyDialogRunner=Dn,f.useVanyElementFocused=Un,f.useVanyElementHovered=qn,f.useVanyFormControlServiceHost=Pn,f.useVanyFormRunner=Ln,f.useVanyFormRunnerSubmitButton=Kn,f.useVanyInputFrameService=On,f.useVanyListMerger=Wn,f.useVanyListRunner=jn,f.useVanyModalRunner=At,f.useVanyValidateCodec=zn,f.vanyCodecMessages=re,f.vanyMoneyCodec=jt,f.vanyReactDarkMode=Yn,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});