@schemx/vue 0.1.22 → 0.2.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.
@@ -1,4 +1,4 @@
1
- import { SchemxViewGroupSchema, Values } from '../../../../core/src/index.ts';
1
+ import { SchemxViewGroupSchema, Values } from '@schemx/core';
2
2
 
3
3
  /**
4
4
  * FormGroup Props
@@ -1,4 +1,4 @@
1
- import { SchemxViewSchema, Values } from '../../../../core/src/index.ts';
1
+ import { SchemxViewSchema, Values } from '@schemx/core';
2
2
 
3
3
  /**
4
4
  * FormItem 属性。
@@ -1,6 +1,6 @@
1
1
  import { Component, PropType } from 'vue';
2
2
  import { SchemxDictionary } from '../types/dictionary';
3
- import { NamePath } from '../../../core/src/index.ts';
3
+ import { NamePath } from '@schemx/core';
4
4
 
5
5
  /**
6
6
  * WithRemoteOptions 注入给被包装组件的额外 Props
@@ -67,7 +67,7 @@ export declare function WithRemoteOptions(WrappedComponent: Component): import('
67
67
  default: undefined;
68
68
  };
69
69
  }>> & Readonly<{}>, {
70
- dict: SchemxDictionary<import('../../../core/src/index.ts').Values, any>;
70
+ dict: SchemxDictionary<import('@schemx/core').Values, any>;
71
71
  fieldName: string;
72
72
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
73
73
  export default WithRemoteOptions;
@@ -1,5 +1,5 @@
1
1
  import { SchemxFormProps } from '../types';
2
- import { Values } from '../../../core/src/index.ts';
2
+ import { Values } from '@schemx/core';
3
3
 
4
4
  /** FormContext 注入 key */
5
5
  export declare const FORM_CONTEXT_KEY: unique symbol;
@@ -1,6 +1,6 @@
1
1
  import { Ref } from 'vue';
2
2
  import { SchemxDictionary } from '../types/dictionary';
3
- import { NamePath, Values } from '../../../core/src/index.ts';
3
+ import { NamePath, Values } from '@schemx/core';
4
4
 
5
5
  export type { SchemxDictionary, SchemxWithDictionary } from '../types/dictionary';
6
6
  /**
@@ -1,4 +1,4 @@
1
- import { CreateEffectReturn, EffectCallback } from '../../../core/src/index.ts';
1
+ import { CreateEffectReturn, EffectCallback } from '@schemx/core';
2
2
 
3
3
  /**
4
4
  * 创建 Signal effect 并在组件卸载时自动取消。
@@ -1,5 +1,5 @@
1
1
  import { FieldInstance } from '../types/field';
2
- import { NamePath, Values } from '../../../core/src/index.ts';
2
+ import { NamePath, Values } from '@schemx/core';
3
3
 
4
4
  /**
5
5
  * 获取单个字段的控制能力
@@ -1,4 +1,4 @@
1
- import { CreateFormOptions, NamePath, SchemxInstance, Values } from '../../../core/src/index.ts';
1
+ import { CreateFormOptions, NamePath, SchemxInstance, Values } from '@schemx/core';
2
2
 
3
3
  /** SchemxInstance 在 Vue provide/inject 中的注入 key */
4
4
  export declare const SCHEMX_INSTANCE_KEY: unique symbol;
@@ -1,5 +1,5 @@
1
1
  import { ShallowRef } from 'vue';
2
- import { SchemxInstance, SchemxViewSchema, Values } from '../../../core/src/index.ts';
2
+ import { SchemxInstance, SchemxViewSchema, Values } from '@schemx/core';
3
3
 
4
4
  export declare function useViewSchemas<T extends Values = Values>(form: SchemxInstance<T>): ShallowRef<readonly SchemxViewSchema<T>[]>;
5
5
  export default useViewSchemas;
@@ -1,4 +1,4 @@
1
- import { NamePath, Values, CreateWatchOptions, WatchAllCallback, WatchFieldCallback, WatchFieldsCallback } from '../../../core/src/index.ts';
1
+ import { NamePath, Values, CreateWatchOptions, WatchAllCallback, WatchFieldCallback, WatchFieldsCallback } from '@schemx/core';
2
2
 
3
3
  /**
4
4
  * 监听所有字段变化
package/dist/index.cjs CHANGED
@@ -1,7 +1,2 @@
1
- "use strict";var e=Object.defineProperty,t=(t,r,n)=>((t,r,n)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n)(t,"symbol"!=typeof r?r+"":r,n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("vue");function n(e,t){for(var r=0;r<t.length;r++){const n=t[r];if("string"!=typeof n&&!Array.isArray(n))for(const t in n)if("default"!==t&&!(t in e)){const r=Object.getOwnPropertyDescriptor(n,t);r&&Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function o(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}),r}var a,l={exports:{}};
2
- /*!
3
- Copyright (c) 2018 Jed Watson.
4
- Licensed under the MIT License (MIT), see
5
- http://jedwatson.github.io/classnames
6
- */a=l,function(){var e={}.hasOwnProperty;function t(){for(var e="",t=0;t<arguments.length;t++){var i=arguments[t];i&&(e=n(e,r(i)))}return e}function r(r){if("string"==typeof r||"number"==typeof r)return r;if("object"!=typeof r)return"";if(Array.isArray(r))return t.apply(null,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var i="";for(var s in r)e.call(r,s)&&r[s]&&(i=n(i,s));return i}function n(e,t){return t?e?e+" "+t:e+t:e}a.exports?(t.default=t,a.exports=t):window.classNames=t}();const c=s(l.exports);var u=Symbol.for("preact-signals");function d(){if(y>1)y--;else{var e,t=!1;for(!function(){var e=b;for(b=void 0;void 0!==e;)e.S.v===e.v&&(e.S.i=e.i),e=e.o}();void 0!==p;){var r=p;for(p=void 0,v++;void 0!==r;){var n=r.u;if(r.u=void 0,r.f&=-3,!(8&r.f)&&x(r))try{r.c()}catch(i){t||(e=i,t=!0)}r=n}}if(v=0,y--,t)throw e}}var f=void 0;function h(e){var t=f;f=void 0;try{return e()}finally{f=t}}var p=void 0,y=0,v=0,g=0,m=0,b=void 0,w=0;function S(e){if(void 0!==f){var t=e.n;if(void 0===t||t.t!==f)return t={i:0,S:e,p:f.s,n:void 0,t:f,e:void 0,x:void 0,r:t},void 0!==f.s&&(f.s.n=t),f.s=t,e.n=t,32&f.f&&e.S(t),t;if(-1===t.i)return t.i=0,void 0!==t.n&&(t.n.p=t.p,void 0!==t.p&&(t.p.n=t.n),t.p=f.s,t.n=void 0,f.s.n=t,f.s=t),t}}function F(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function x(e){for(var t=e.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function _(e){for(var t=e.s;void 0!==t;t=t.n){var r=t.S.n;if(void 0!==r&&(t.r=r),t.S.n=t,t.i=-1,void 0===t.n){e.s=t;break}}}function k(e){for(var t=e.s,r=void 0;void 0!==t;){var n=t.p;-1===t.i?(t.S.U(t),void 0!==n&&(n.n=t.n),void 0!==t.n&&(t.n.p=n)):r=t,t.S.n=t.r,void 0!==t.r&&(t.r=void 0),t=n}e.s=r}function A(e,t){F.call(this,void 0,t),this.x=e,this.s=void 0,this.g=w-1,this.f=4}function O(e){var t=e.m;if(e.m=void 0,"function"==typeof t){y++;var r=f;f=void 0;try{t()}catch(n){throw e.f&=-2,e.f|=8,j(e),n}finally{f=r,d()}}}function j(e){for(var t=e.s;void 0!==t;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,O(e)}function P(e){if(f!==this)throw new Error("Out-of-order effect");k(this),f=e,this.f&=-2,8&this.f&&j(this),d()}function V(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=null==t?void 0:t.name}function R(e,t){var r=new V(e,t);try{r.c()}catch(i){throw r.d(),i}var n=r.d.bind(r);return n[Symbol.dispose]=n,n}function C(e,t){return new F(e,t)}F.prototype.brand=u,F.prototype.h=function(){return!0},F.prototype.S=function(e){var t=this,r=this.t;r!==e&&void 0===e.e&&(e.x=r,this.t=e,void 0!==r?r.e=e:h(function(){var e;null==(e=t.W)||e.call(t)}))},F.prototype.U=function(e){var t=this;if(void 0!==this.t){var r=e.e,n=e.x;void 0!==r&&(r.x=n,e.e=void 0),void 0!==n&&(n.e=r,e.x=void 0),e===this.t&&(this.t=n,void 0===n&&h(function(){var e;null==(e=t.Z)||e.call(t)}))}},F.prototype.subscribe=function(e){var t=this;return R(function(){var r=t.value;h(function(){return e(r)})},{name:"sub"})},F.prototype.valueOf=function(){return this.value},F.prototype.toString=function(){return this.value+""},F.prototype.toJSON=function(){return this.value},F.prototype.peek=function(){var e=this;return h(function(){return e.value})},Object.defineProperty(F.prototype,"value",{get:function(){var e=S(this);return void 0!==e&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(v>100)throw new Error("Cycle detected");r=this,0!==y&&0===v&&r.l!==m&&(r.l=m,b={S:r,v:r.v,i:r.i,o:b}),this.v=e,this.i++,w++,y++;try{for(var t=this.t;void 0!==t;t=t.x)t.t.N()}finally{d()}}var r}}),A.prototype=new F,A.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===w)return!0;if(this.g=w,this.f|=1,this.i>0&&!x(this))return this.f&=-2,!0;var e=f;try{_(this),f=this;var t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(r){this.v=r,this.f|=16,this.i++}return f=e,k(this),this.f&=-2,!0},A.prototype.S=function(e){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}F.prototype.S.call(this,e)},A.prototype.U=function(e){if(void 0!==this.t&&(F.prototype.U.call(this,e),void 0===this.t)){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}},A.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;void 0!==e;e=e.x)e.t.N()}},Object.defineProperty(A.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=S(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),V.prototype.c=function(){var e=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();"function"==typeof t&&(this.m=t)}finally{e()}},V.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,O(this),_(this),y++;var e=f;return f=this,P.bind(this,e)},V.prototype.N=function(){2&this.f||(this.f|=2,this.u=p,p=this)},V.prototype.d=function(){this.f|=8,1&this.f||j(this)},V.prototype.dispose=function(){this.d()};const E="object"==typeof globalThis&&globalThis||"object"==typeof window&&window||"object"==typeof self&&self||"object"==typeof global&&global||function(){return this}();function T(e,t,{signal:r,edges:n}={}){let i,s=null;const o=null!=n&&n.includes("leading"),a=null==n||n.includes("trailing"),l=()=>{null!==s&&(e.apply(i,s),i=void 0,s=null)};let c=null;const u=()=>{null!=c&&clearTimeout(c),c=setTimeout(()=>{c=null,a&&l(),d()},t)},d=()=>{null!==c&&(clearTimeout(c),c=null),i=void 0,s=null},f=function(...e){if(null==r?void 0:r.aborted)return;i=this,s=e;const t=null==c;u(),o&&t&&l()};return f.schedule=u,f.cancel=d,f.flush=()=>{l()},null==r||r.addEventListener("abort",d,{once:!0}),f}function I(){}function M(e){return void 0!==E.Buffer&&E.Buffer.isBuffer(e)}function B(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function D(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const N="[object RegExp]",$="[object String]",W="[object Number]",U="[object Boolean]",z="[object Arguments]",q="[object Symbol]",K="[object Date]",L="[object Map]",G="[object Set]",Z="[object Array]",H="[object ArrayBuffer]",X="[object Object]",J="[object DataView]",Q="[object Uint8Array]",Y="[object Uint8ClampedArray]",ee="[object Uint16Array]",te="[object Uint32Array]",re="[object Int8Array]",ne="[object Int16Array]",ie="[object Int32Array]",se="[object Float32Array]",oe="[object Float64Array]";function ae(e,t,r,n=new Map,i=void 0){const s=null==i?void 0:i(e,t,r,n);if(void 0!==s)return s;if(null==(o=e)||"object"!=typeof o&&"function"!=typeof o)return e;var o,a;if(n.has(e))return n.get(e);if(Array.isArray(e)){const t=new Array(e.length);n.set(e,t);for(let s=0;s<e.length;s++)t[s]=ae(e[s],s,r,n,i);return Object.hasOwn(e,"index")&&(t.index=e.index),Object.hasOwn(e,"input")&&(t.input=e.input),t}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){const t=new RegExp(e.source,e.flags);return t.lastIndex=e.lastIndex,t}if(e instanceof Map){const t=new Map;n.set(e,t);for(const[s,o]of e)t.set(s,ae(o,s,r,n,i));return t}if(e instanceof Set){const t=new Set;n.set(e,t);for(const s of e)t.add(ae(s,void 0,r,n,i));return t}if(M(e))return e.subarray();if(a=e,ArrayBuffer.isView(a)&&!(a instanceof DataView)){const t=new(Object.getPrototypeOf(e).constructor)(e.length);n.set(e,t);for(let s=0;s<e.length;s++)t[s]=ae(e[s],s,r,n,i);return t}if(e instanceof ArrayBuffer||"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){const t=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return n.set(e,t),le(t,e,r,n,i),t}if("undefined"!=typeof File&&e instanceof File){const t=new File([e],e.name,{type:e.type});return n.set(e,t),le(t,e,r,n,i),t}if("undefined"!=typeof Blob&&e instanceof Blob){const t=new Blob([e],{type:e.type});return n.set(e,t),le(t,e,r,n,i),t}if(e instanceof Error){const t=structuredClone(e);return n.set(e,t),t.message=e.message,t.name=e.name,t.stack=e.stack,t.cause=e.cause,t.constructor=e.constructor,le(t,e,r,n,i),t}if(e instanceof Boolean){const t=new Boolean(e.valueOf());return n.set(e,t),le(t,e,r,n,i),t}if(e instanceof Number){const t=new Number(e.valueOf());return n.set(e,t),le(t,e,r,n,i),t}if(e instanceof String){const t=new String(e.valueOf());return n.set(e,t),le(t,e,r,n,i),t}if("object"==typeof e&&function(e){switch(D(e)){case z:case Z:case H:case J:case U:case K:case se:case oe:case re:case ne:case ie:case L:case W:case X:case N:case G:case $:case q:case Q:case Y:case ee:case te:return!0;default:return!1}}(e)){const t=Object.create(Object.getPrototypeOf(e));return n.set(e,t),le(t,e,r,n,i),t}return e}function le(e,t,r=e,n,i){const s=[...Object.keys(t),...B(t)];for(let o=0;o<s.length;o++){const a=s[o],l=Object.getOwnPropertyDescriptor(e,a);(null==l||l.writable)&&(e[a]=ae(t[a],a,r,n,i))}}function ce(e){return ae(e,void 0,e,new Map,void 0)}function ue(e){if(!e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&"[object Object]"===Object.prototype.toString.call(e)}function de(e){return"__proto__"===e}function fe(e,t){const r={};for(let n=0;n<t.length;n++){const i=t[n];Object.hasOwn(e,i)&&(r[i]=e[i])}return r}function he(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function pe(e,t,r,n,i,s,o){const a=o(e,t,r,n,i,s);if(void 0!==a)return a;if(typeof e==typeof t)switch(typeof e){case"bigint":case"string":case"boolean":case"symbol":case"undefined":case"function":return e===t;case"number":return e===t||Object.is(e,t);case"object":return ye(e,t,s,o)}return ye(e,t,s,o)}function ye(e,t,r,n){if(Object.is(e,t))return!0;let i=D(e),s=D(t);if("[object Arguments]"===i&&(i=X),"[object Arguments]"===s&&(s=X),i!==s)return!1;switch(i){case $:return e.toString()===t.toString();case W:return he(e.valueOf(),t.valueOf());case U:case K:case q:return Object.is(e.valueOf(),t.valueOf());case N:return e.source===t.source&&e.flags===t.flags;case"[object Function]":return e===t}const o=(r=r??new Map).get(e),a=r.get(t);if(null!=o&&null!=a)return o===t;r.set(e,t),r.set(t,e);try{switch(i){case L:if(e.size!==t.size)return!1;for(const[i,s]of e.entries())if(!t.has(i)||!pe(s,t.get(i),i,e,t,r,n))return!1;return!0;case G:{if(e.size!==t.size)return!1;const i=Array.from(e.values()),s=Array.from(t.values());for(let o=0;o<i.length;o++){const a=i[o],l=s.findIndex(i=>pe(a,i,void 0,e,t,r,n));if(-1===l)return!1;s.splice(l,1)}return!0}case Z:case Q:case Y:case ee:case te:case"[object BigUint64Array]":case re:case ne:case ie:case"[object BigInt64Array]":case se:case oe:if(M(e)!==M(t))return!1;if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!pe(e[i],t[i],i,e,t,r,n))return!1;return!0;case H:return e.byteLength===t.byteLength&&ye(new Uint8Array(e),new Uint8Array(t),r,n);case J:return e.byteLength===t.byteLength&&e.byteOffset===t.byteOffset&&ye(new Uint8Array(e),new Uint8Array(t),r,n);case"[object Error]":return e.name===t.name&&e.message===t.message;case X:{if(!(ye(e.constructor,t.constructor,r,n)||ue(e)&&ue(t)))return!1;const i=[...Object.keys(e),...B(e)],s=[...Object.keys(t),...B(t)];if(i.length!==s.length)return!1;for(let o=0;o<i.length;o++){const s=i[o],a=e[s];if(!Object.hasOwn(t,s))return!1;if(!pe(a,t[s],s,e,t,r,n))return!1}return!0}default:return!1}}finally{r.delete(e),r.delete(t)}}function ve(e,t){return function(e,t,r){return pe(e,t,void 0,void 0,void 0,void 0,r)}(e,t,I)}function ge(e){const{value:t,initialValue:r,touched:n,pending:i}=e||{},s=C(void 0===t?void 0:ce(t)),o=C(void 0===r?void 0:ce(r)),a=C(n??!1),l=C(i??!1),c=C([]);return{value:s,initialValue:o,touched:a,pending:l,pendingMessage:c,setValue:e=>{s.value=e},setInitialValue:e=>{o.value=e},setTouched:e=>{a.value=e},setPending:(e,t)=>{l.value=e,e?t&&(c.value=Array.isArray(t)?t:[t]):c.value=[]},reset:(e=o.peek())=>{s.value=ce(e),a.value=!1,l.value=!1},peek:()=>({value:s.peek(),initialValue:o.peek(),touched:a.peek(),pending:l.peek(),pendingMessage:c.peek()})}}class me{constructor(e={}){t(this,"records",new Map),t(this,"version",C(0)),t(this,"normalizeKey"),this.normalizeKey=e.normalizeKey??we}getKey(e){return this.normalizeKey(e)}get(e){const t=this.records.get(this.getKey(e));if(t)return t.value;this.version.value}peek(e){var t;return null==(t=this.records.get(this.getKey(e)))?void 0:t.value}set(e,t){const r=this.getKey(e),n=this.records.has(r);return this.records.set(r,{key:e,value:t}),n||this.version.value++,this}has(e){return this.records.has(this.getKey(e))}delete(e){const t=this.getKey(e),r=this.records.get(t);return!!r&&(this.records.delete(t),be(r.value),this.version.value++,!0)}clear(){if(0!==this.records.size){for(const e of this.records.values())be(e.value);this.records.clear(),this.version.value++}}keys(){return this.version.value,Array.from(this.records.values(),e=>e.key).values()}values(){return this.version.value,Array.from(this.records.values(),e=>e.value).values()}entries(){return this.version.value,Array.from(this.records.values(),e=>[e.key,e.value]).values()}}function be(e){e.value.value=void 0,e.initialValue.value=void 0,e.touched.value=!1,e.pending.value=!1}function we(e){return Array.isArray(e)?e.map(e=>String(e)).join("."):String(e)}function Se(e,t={}){if(!t.once)return R(e);const r={};return r.current=R(()=>{var t;e(),null==(t=r.current)||t.call(r)}),()=>{var e;return null==(e=r.current)?void 0:e.call(r)}}function Fe(e){!function(e){if(y>0)return e();m=++g,y++;try{return e()}finally{d()}}(e)}class xe{constructor(){t(this,"signals",new Map),t(this,"version",C(0))}get(e){const t=this.signals.get(e);if(t)return t.value;this.version.value}set(e,t){const r=this.signals.get(e);return r?r.value=t:(this.signals.set(e,C(t)),this.version.value++),this}peek(e){var t;return null==(t=this.signals.get(e))?void 0:t.peek()}has(e){return this.signals.has(e)}delete(e){const t=this.signals.get(e);return!!t&&(this.signals.delete(e),Fe(()=>{t.value=void 0,this.version.value++}),!0)}clear(){if(0===this.signals.size)return;const e=[...this.signals.values()];this.signals.clear(),Fe(()=>{for(const t of e)t.value=void 0;this.version.value++})}keys(){return this.version.value,this.signals.keys()}values(){return this.version.value,Array.from(this.signals.values(),e=>e.value).values()}entries(){return this.version.value,Array.from(this.signals.entries(),([e,t])=>[e,t.value]).values()}}function _e(e,t){return new A(e,t)}function ke(e){return!Ae(e)&&!Oe(e)}function Ae(e){return"group"===e.componentType}function Oe(e){return"dependency"===e.componentType}function je(e){return"group"===e.componentType}const Pe=e=>Object.hasOwn(e,"componentType")&&"string"==typeof e.componentType;function Ve(e){const t=[];return(e=>Object.hasOwn(e,"name")&&[null,void 0,""].every(t=>t!==e.name))(e)||t.push("name"),Pe(e)||t.push("componentType"),t}function Re(e){const t=[];return Pe(e)||t.push("componentType"),Object.hasOwn(e,"children")&&Array.isArray(e.children)||t.push("children"),t}function Ce(e){const t=[];return Pe(e)||t.push("componentType"),Object.hasOwn(e,"to")&&Array.isArray(e.to)&&0!==e.to.length||t.push("to"),"function"!=typeof e.renderer&&t.push("renderer"),t}function Ee(e,t,r){const n="name"in t&&t.name||t.componentType||"unknown";return`[schemx] schemas[${e}] (${String(n)}) 缺少必填项: ${r.join(", ")},已被过滤`}function Te(e){const t=[],r=[];let n=!1;for(let i=0;i<e.length;i++){const s=e[i];let o=[];if(Ae(s)){if(o=Re(s),o.length>0){r.push(Ee(i,s,o)),n=!0;continue}const e=Te(s.children);e===s.children?t.push(s):(t.push({...s,children:e}),n=!0)}else if(Oe(s)){if(o=Ce(s),o.length>0){r.push(Ee(i,s,o)),n=!0;continue}t.push(s)}else if(ke(s)){if(o=Ve(s),o.length>0){r.push(Ee(i,s,o)),n=!0;continue}t.push(s)}else n=!0}return r.length&&console.warn(r.join("\n")),n?t:e}function Ie(e){if(null==e)return"";if("string"==typeof e)return e;if(Array.isArray(e))return e.map(Ie).join(",");const t=String(e);return"0"===t&&Object.is(Number(e),-0)?"-0":t}function Me(e){var t;return"string"==typeof e||"symbol"==typeof e?e:Object.is(null==(t=null==e?void 0:e.valueOf)?void 0:t.call(e),-0)?"-0":String(e)}function Be(e){if(Array.isArray(e))return e.map(Me);if("symbol"==typeof e)return[e];const t=[],r=(e=Ie(e)).length;if(0===r)return t;let n=0,i="",s="",o=!1;for(46===e.charCodeAt(0)&&(t.push(""),n++);n<r;){const a=e[n];s?"\\"===a&&n+1<r?(n++,i+=e[n]):a===s?s="":i+=a:o?'"'===a||"'"===a?s=a:"]"===a?(o=!1,t.push(i),i=""):i+=a:"["===a?(o=!0,i&&(t.push(i),i="")):"."===a?i&&(t.push(i),i=""):i+=a,n++}return i&&t.push(i),t}function De(e,t,r){if(null==e)return r;switch(typeof t){case"string":{if(de(t))return r;const n=e[t];return void 0===n?function(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e.includes(".")||e.includes("[")||e.includes("]")}}(t)?De(e,Be(t),r):r:n}case"number":case"symbol":{"number"==typeof t&&(t=Me(t));const n=e[t];return void 0===n?r:n}default:{if(Array.isArray(t))return function(e,t,r){if(0===t.length)return r;let n=e;for(let i=0;i<t.length;i++){if(null==n)return r;if(de(t[i]))return r;n=n[t[i]]}return void 0===n?r:n}(e,t,r);if(de(t=Object.is(null==t?void 0:t.valueOf(),-0)?"-0":String(t)))return r;const n=e[t];return void 0===n?r:n}}}function Ne(e){return null!==e&&("object"==typeof e||"function"==typeof e)}const $e=/^(?:0|[1-9]\d*)$/;function We(e,t=Number.MAX_SAFE_INTEGER){switch(typeof e){case"number":return Number.isInteger(e)&&e>=0&&e<t;case"symbol":return!1;case"string":return $e.test(e)}}const Ue=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ze=/^\w*$/;function qe(e,t){return!Array.isArray(e)&&(!("number"!=typeof e&&"boolean"!=typeof e&&null!=e&&!function(e){return"symbol"==typeof e||e instanceof Symbol}(e))||("string"==typeof e&&(ze.test(e)||!Ue.test(e))||null!=t&&Object.hasOwn(t,e)))}const Ke=(e,t,r)=>{const n=e[t];Object.hasOwn(e,t)&&he(n,r)&&(void 0!==r||t in e)||(e[t]=r)};function Le(e,t,r){return function(e,t,r,n){if(null==e&&!Ne(e))return e;let i;i=qe(t,e)?[t]:Array.isArray(t)?t:Be(t);const s=r(De(e,i));let o=e;for(let a=0;a<i.length&&null!=o;a++){const t=Me(i[a]);if(de(t))continue;let r;if(a===i.length-1)r=s;else{const s=o[t],l=null==n?void 0:n(s,t,e);r=void 0!==l?l:Ne(s)?s:We(i[a+1])?[]:{}}Ke(o,t,r),o=o[t]}return e}(e,t,()=>r,()=>{})}function Ge(e,t){return""===t||Array.isArray(t)&&0===t.length?e:De(e,Xe(t))}function Ze(e,t,r){null!=e&&Le(e,Xe(t),r)}function He(e,t=""){const r=[];for(const n of Object.keys(e)){const i=t?`${t}.${n}`:n,s=e[n];Array.isArray(s)?s.forEach((e,t)=>{const n=`${i}[${t}]`;null!==e&&"object"==typeof e?r.push(...He(e,n)):r.push(n)}):null!==s&&"object"==typeof s?r.push(...He(s,i)):r.push(i)}return r}const Xe=e=>Array.isArray(e)?e.map(e=>"number"==typeof e?e:String(e)):e;function Je(e){let t=null;return(...r)=>t||(t=e(...r).finally(()=>{t=null}),t)}function Qe(e,t){const r={};for(const n of Object.keys(e))ve(e[n],t[n])||(r[n]=e[n]);return r}const Ye={required:!1,readonly:!1,disabled:!1,visible:!0,labelIcon:"",labelAlign:"left",labelPosition:"left",labelWidth:"auto",validationTrigger:"blur",colon:!0},et=Object.keys(Ye);class tt{constructor(){t(this,"rules",new Map),t(this,"errors",new xe)}register(e,t,r){const n=Array.isArray(t)?t:[t],i=this.rules.get(e);i?(i.schemas.push(...n),r&&(i.defaultMessage=r)):this.rules.set(e,{schemas:n,defaultMessage:r})}unregister(e){this.rules.delete(e),this.errors.delete(e)}getFieldError(e){return this.errors.get(e)}setFieldError(e,t){this.errors.set(e,t)}async validateField(e,t){const r=Array.isArray(e)?e:[e];this.reset(r);let n=!0;for(const i of r){(await this.validateSingleRule(i,t)).ok||(n=!1)}return this.buildResult(n,t)}async validate(e){let t=!0;this.reset();for(const r of this.rules.keys()){(await this.validateSingleRule(r,e)).ok||(t=!1)}return this.buildResult(t,e)}reset(e){Fe(e?()=>{for(const t of e)this.errors.set(t,[])}:()=>{for(const e of this.rules.keys())this.errors.set(e,[]);for(const e of[...this.errors.keys()])this.rules.has(e)||this.errors.delete(e)})}buildResult(e,t){return e?{ok:!0,values:t}:{ok:!1,error:{errors:Array.from(this.errors.keys()).map(e=>({field:e,message:this.errors.peek(e)||[]})),values:t}}}failResult(e,t,r){return this.errors.set(e,t),{ok:!1,error:{errors:[{field:e,message:t}],values:r}}}async validateSingleRule(e,t){const r=this.rules.get(e);if(!r||0===r.schemas.length)return this.errors.delete(e),{ok:!0,values:t};const n=Ge(t,e),i=[];null==n&&r.defaultMessage&&i.push(r.defaultMessage);for(const o of r.schemas)try{const e=await o["~standard"].validate(n);e.issues&&i.push(...e.issues.map(e=>e.message))}catch(s){console.warn(`[Validator] 校验字段 "${e}" 时发生错误:`,s),i.push("校验失败")}return i.length>0?this.failResult(e,i,t):(this.errors.delete(e),{ok:!0,values:t})}}function rt(){return new tt}function nt(e){return ot(t=>{if(null==t||""===t){const t=(null==e?void 0:e.label)??"";return at(t?`请输入${t}`:"此项为必填项")}return lt(t)})}function it(e){return ot(t=>{if(null==t||""===t||Array.isArray(t)&&0===t.length){const t=(null==e?void 0:e.label)??"";return at(t?`请选择${t}`:"此项为必选项")}return lt(t)})}function st(e){return ot(t=>{if(null==t||Array.isArray(t)&&0===t.length){const t=(null==e?void 0:e.label)??"";return at(t?`请上传${t}`:"此项为必传项")}return lt(t)})}const ot=e=>({"~standard":{version:1,vendor:"schemx",validate:e}}),at=e=>({issues:[{message:e}]}),lt=e=>({value:e});class ct{constructor(e){t(this,"renderers"),t(this,"defaultType"),this.renderers=new Map,this.defaultType=e}register(e,t,r){this.renderers.has(e)&&!1===(null==r?void 0:r.override)?console.warn(`[RendererRegistryType] RendererRegistry "${e}" already exists, skipping registration`):this.renderers.set(e,t)}registerAll(e){Object.entries(e).forEach(([e,t])=>{this.renderers.set(e,t)})}getRenderer(e){let t=this.renderers.get(e);return t||(console.warn(`[RendererRegistryType] RendererRegistry "${e}" not found, falling back to default "${this.defaultType}"`),this.defaultType&&(t=this.renderers.get(this.defaultType))),t}hasRenderer(e){return this.renderers.has(e)}unregister(e){const t=e===this.defaultType,r=this.renderers.delete(e);if(t&&r){const e=this.renderers.keys().next().value;e&&(console.warn("[RendererRegistryType] Default renderer was removed, Please reset the default renderer."),this.defaultType=e)}return r}getTypes(){return Array.from(this.renderers.keys())}setDefault(e){this.renderers.has(e)?this.defaultType=e:console.warn(`[RendererRegistryType] Cannot set default to "${e}": renderer not registered`)}getDefault(){return this.defaultType}clear(){this.renderers.clear()}size(){return this.renderers.size}}function ut(e){return new ct(e)}class dt{constructor(){t(this,"validators"),this.validators=new Map}register(e,t,r){this.validators.has(e)&&!1===(null==r?void 0:r.override)?console.warn(`[ValidatorsRegistryType] Validators "${e}" 已存在,跳过注册`):this.validators.set(e,t)}registerAll(e){Object.entries(e).forEach(([e,t])=>{this.validators.set(e,t)})}get(e){return this.validators.get(e)}resolveValidatorsBySchema(e){const t=(null==e?void 0:e.rules)??[],r=Array.isArray(t)?t:[t],n=[];for(const i of r)if("string"==typeof i)if(this.validators.has(i)){const t=this.validators.get(i);t&&n.push("function"==typeof t?t(e):t)}else console.warn(`[schemx] 未找到名为 "${i}" 的校验规则`);else i&&n.push(i);return n}has(e){return this.validators.has(e)}unregister(e){return this.validators.delete(e)}getNames(){return Array.from(this.validators.keys())}clear(){this.validators.clear()}size(){return this.validators.size}}function ft(){return new dt}var ht={},pt=function(e,t){return(pt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};function yt(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}pt(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var vt=function(){return vt=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},vt.apply(this,arguments)};function gt(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}function mt(e,t,r,n){var i,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,r,o):i(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}function bt(e,t){return function(r,n){t(r,n,e)}}function wt(e,t,r,n,i,s){function o(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var a,l=n.kind,c="getter"===l?"get":"setter"===l?"set":"value",u=!t&&e?n.static?e:e.prototype:null,d=t||(u?Object.getOwnPropertyDescriptor(u,n.name):{}),f=!1,h=r.length-1;h>=0;h--){var p={};for(var y in n)p[y]="access"===y?{}:n[y];for(var y in n.access)p.access[y]=n.access[y];p.addInitializer=function(e){if(f)throw new TypeError("Cannot add initializers after decoration has completed");s.push(o(e||null))};var v=(0,r[h])("accessor"===l?{get:d.get,set:d.set}:d[c],p);if("accessor"===l){if(void 0===v)continue;if(null===v||"object"!=typeof v)throw new TypeError("Object expected");(a=o(v.get))&&(d.get=a),(a=o(v.set))&&(d.set=a),(a=o(v.init))&&i.unshift(a)}else(a=o(v))&&("field"===l?i.unshift(a):d[c]=a)}u&&Object.defineProperty(u,n.name,d),f=!0}function St(e,t,r){for(var n=arguments.length>2,i=0;i<t.length;i++)r=n?t[i].call(e,r):t[i].call(e);return n?r:void 0}function Ft(e){return"symbol"==typeof e?e:"".concat(e)}function xt(e,t,r){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function _t(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function kt(e,t,r,n){return new(r||(r=Promise))(function(i,s){function o(e){try{l(n.next(e))}catch(t){s(t)}}function a(e){try{l(n.throw(e))}catch(t){s(t)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((n=n.apply(e,t||[])).next())})}function At(e,t){var r,n,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(l){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(l){a=[6,l],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}var Ot=Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]};function jt(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||Ot(t,e,r)}function Pt(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Vt(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,s=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(a){i={error:a}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o}function Rt(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Vt(arguments[t]));return e}function Ct(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),i=0;for(t=0;t<r;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,i++)n[i]=s[o];return n}function Et(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}function Tt(e){return this instanceof Tt?(this.v=e,this):new Tt(e)}function It(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),s=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",function(e){return function(t){return Promise.resolve(t).then(e,c)}}),n[Symbol.asyncIterator]=function(){return this},n;function o(e,t){i[e]&&(n[e]=function(t){return new Promise(function(r,n){s.push([e,t,r,n])>1||a(e,t)})},t&&(n[e]=t(n[e])))}function a(e,t){try{(r=i[e](t)).value instanceof Tt?Promise.resolve(r.value.v).then(l,c):u(s[0][2],r)}catch(n){u(s[0][3],n)}var r}function l(e){a("next",e)}function c(e){a("throw",e)}function u(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function Mt(e){var t,r;return t={},n("next"),n("throw",function(e){throw e}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,i){t[n]=e[n]?function(t){return(r=!r)?{value:Tt(e[n](t)),done:!1}:i?i(t):t}:i}}function Bt(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=Pt(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,i){(function(e,t,r,n){Promise.resolve(n).then(function(t){e({value:t,done:r})},t)})(n,i,(t=e[r](t)).done,t.value)})}}}function Dt(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var Nt=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},$t=function(e){return($t=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t})(e)};function Wt(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=$t(e),n=0;n<r.length;n++)"default"!==r[n]&&Ot(t,e,r[n]);return Nt(t,e),t}function Ut(e){return e&&e.__esModule?e:{default:e}}function zt(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function qt(e,t,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,r):i?i.value=r:t.set(e,r),r}function Kt(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function Lt(e,t,r){if(null!=t){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object expected.");var n,i;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=t[Symbol.asyncDispose]}if(void 0===n){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=t[Symbol.dispose],r&&(i=n)}if("function"!=typeof n)throw new TypeError("Object not disposable.");i&&(n=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:n,async:r})}else r&&e.stack.push({async:!0});return t}var Gt="function"==typeof SuppressedError?SuppressedError:function(e,t,r){var n=new Error(r);return n.name="SuppressedError",n.error=e,n.suppressed=t,n};function Zt(e){function t(t){e.error=e.hasError?new Gt(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}var r,n=0;return function i(){for(;r=e.stack.pop();)try{if(!r.async&&1===n)return n=0,e.stack.push(r),Promise.resolve().then(i);if(r.dispose){var s=r.dispose.call(r.value);if(r.async)return n|=2,Promise.resolve(s).then(i,function(e){return t(e),i()})}else n|=1}catch(o){t(o)}if(1===n)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}()}function Ht(e,t){return"string"==typeof e&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,r,n,i,s){return r?t?".jsx":".js":!n||i&&s?n+i+"."+s.toLowerCase()+"js":e}):e}const Xt={__extends:yt,__assign:vt,__rest:gt,__decorate:mt,__param:bt,__esDecorate:wt,__runInitializers:St,__propKey:Ft,__setFunctionName:xt,__metadata:_t,__awaiter:kt,__generator:At,__createBinding:Ot,__exportStar:jt,__values:Pt,__read:Vt,__spread:Rt,__spreadArrays:Ct,__spreadArray:Et,__await:Tt,__asyncGenerator:It,__asyncDelegator:Mt,__asyncValues:Bt,__makeTemplateObject:Dt,__importStar:Wt,__importDefault:Ut,__classPrivateFieldGet:zt,__classPrivateFieldSet:qt,__classPrivateFieldIn:Kt,__addDisposableResource:Lt,__disposeResources:Zt,__rewriteRelativeImportExtension:Ht},Jt=o(Object.freeze(Object.defineProperty({__proto__:null,__addDisposableResource:Lt,get __assign(){return vt},__asyncDelegator:Mt,__asyncGenerator:It,__asyncValues:Bt,__await:Tt,__awaiter:kt,__classPrivateFieldGet:zt,__classPrivateFieldIn:Kt,__classPrivateFieldSet:qt,__createBinding:Ot,__decorate:mt,__disposeResources:Zt,__esDecorate:wt,__exportStar:jt,__extends:yt,__generator:At,__importDefault:Ut,__importStar:Wt,__makeTemplateObject:Dt,__metadata:_t,__param:bt,__propKey:Ft,__read:Vt,__rest:gt,__rewriteRelativeImportExtension:Ht,__runInitializers:St,__setFunctionName:xt,__spread:Rt,__spreadArray:Et,__spreadArrays:Ct,__values:Pt,default:Xt},Symbol.toStringTag,{value:"Module"})));var Qt={},Yt={},er={};Object.defineProperty(er,"__esModule",{value:!0}),er.AsyncStack=void 0;const tr=Symbol("Global");class rr{static getCurrent(){return this.current}static set(e){this.current=e}static fork(){const e=rr.getCurrent(),t=new rr(e);return t.start(),t}constructor(e){e!==tr&&(this.origin=e)}start(){rr.set(this)}yield(){rr.set(this.origin)}}er.AsyncStack=rr,rr.Global=new rr(tr),rr.current=rr.Global,rr.NO_DATA=Symbol("NO_DATA");var nr={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.runInStack=e.withContext=e.createAsyncResolver=void 0,e.callWithContext=r;const t=er;function r(r,n){const i=t.AsyncStack.fork(),s=n.map(t=>"function"==typeof t?(0,e.createAsyncResolver)(i,t):t),o=r.call(this,...s);return i.yield(),o}e.createAsyncResolver=(e,t,r=!0)=>{let n=!1;return function(...i){if(r&&n)return;n=!0,e.yield();return t.call(this,...i)}};e.withContext=(e,t=!0)=>{if(void 0!==e)return function(...t){return r.call(this,e,t)}};e.runInStack=(e,r)=>{const n=t.AsyncStack.getCurrent();e.start();try{const e=r();return n.start(),e}catch(i){throw n.start(),i}}}(nr),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.PromiseWithContext=e.OriginalPromise=void 0;const t=er,r=nr;e.OriginalPromise=Promise;class n extends e.OriginalPromise{constructor(e){super((n,i)=>{const s=t.AsyncStack.fork(),o=(0,r.createAsyncResolver)(s,n),a=(0,r.createAsyncResolver)(s,i);e(o,a),s.yield()})}then(...e){return r.callWithContext.call(this,super.then,e)}catch(...e){return r.callWithContext.call(this,super.catch,e)}finally(...e){return r.callWithContext.call(this,super.finally,e)}}e.PromiseWithContext=n,Object.getOwnPropertyNames(Promise).forEach(t=>{"function"==typeof Promise[t]&&(n[t]=e.OriginalPromise[t].bind(n))})}(Yt);var ir={};Object.defineProperty(ir,"__esModule",{value:!0}),ir.addEventListenerWithContext=ir.dispatchWithContext=void 0;const sr=er,or=nr,ar=EventTarget.prototype.addEventListener,lr=EventTarget.prototype.dispatchEvent,cr=new WeakMap;ir.dispatchWithContext=function(e){const t=sr.AsyncStack.getCurrent();return cr.set(e,t),lr.call(this,e)};ir.addEventListenerWithContext=function(e,t,r){return ar.call(this,e,function(e){const r=cr.get(e)||sr.AsyncStack.Global;return(0,or.runInStack)(r,()=>t.call(this,e))},r)},Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.Polyfill=void 0;const ur=Yt,dr=ir,fr=nr,hr=void 0!==i&&i||"undefined"!=typeof window&&window;class pr{static ensureEnabled(){pr.enabled||(pr.enabled=!0,hr.Promise=ur.PromiseWithContext,hr.setTimeout=(0,fr.withContext)(hr.setTimeout),hr.setInterval=(0,fr.withContext)(hr.setInterval),hr.setImmediate=(0,fr.withContext)(hr.setImmediate),EventTarget.prototype.addEventListener=dr.addEventListenerWithContext,EventTarget.prototype.dispatchEvent=dr.dispatchWithContext)}}Qt.Polyfill=pr,pr.originalSetTimeout=setTimeout,pr.OriginalPromise=ur.OriginalPromise,pr.enabled=!1;var yr,vr,gr={},mr={},br={};function wr(){if(yr)return br;yr=1,Object.defineProperty(br,"__esModule",{value:!0}),br.runInFork=void 0;return br.runInFork=e=>{let t,r;if(new Promise(n=>{try{t=e(),n(t)}catch(i){r=i}}),r)throw r;return t},br}function Sr(){if(vr)return mr;vr=1,Object.defineProperty(mr,"__esModule",{value:!0}),mr.AsyncVariable=void 0;const e=er,t=wr();let r=class r{constructor(){this.data=new WeakMap}static registerVariable(e,t){r.variableByStack.has(t)||r.variableByStack.set(t,new Set),r.variableByStack.get(t).add(e)}getBox(e){if(!e)return;const t=this.data.get(e);if(t)return t;if(r.stopWalkAt.has(e))return;const n=this.getBox(e.origin);return n&&this.setBox(e,n),n}setBox(e,t){r.registerVariable(this,e),this.data.set(e,t)}set(e,t){this.setBox(e,{value:t})}get(){var t;const r=e.AsyncStack.getCurrent();return null===(t=this.getBox(r))||void 0===t?void 0:t.value}run(r,n){return(0,t.runInFork)(()=>{const t=e.AsyncStack.getCurrent();return this.set(t,r),n()})}wrap(e,t){return(...r)=>this.run(e,()=>t(...r))}};return mr.AsyncVariable=r,r.stopWalkAt=new WeakSet,r.variableByStack=new WeakMap,mr}var Fr,xr,_r={};function kr(){if(xr)return gr;xr=1,Object.defineProperty(gr,"__esModule",{value:!0}),gr.AsyncContext=void 0;const e=Sr(),t=function(){if(Fr)return _r;Fr=1,Object.defineProperty(_r,"__esModule",{value:!0}),_r.AsyncSnapshot=void 0;const e=er,t=Sr(),r=wr();return _r.AsyncSnapshot=class n{capture(){let r=e.AsyncStack.getCurrent();for(;r;){const e=t.AsyncVariable.variableByStack.get(r);null==e||e.forEach(e=>{if(!this.dataByVariable.has(e)){const t=e.get();this.dataByVariable.set(e,t)}}),r=r.origin}}constructor(){this.dataByVariable=new Map,this.capture()}static create(){return new n}run(n){return(0,r.runInFork)(()=>{const r=e.AsyncStack.getCurrent();return t.AsyncVariable.stopWalkAt.add(r),this.dataByVariable.forEach((e,t)=>{t.set(r,e)}),n()})}wrap(e){return(...t)=>this.run(()=>e(...t))}static wrap(e){return(0,r.runInFork)(()=>n.create().wrap(e))}},_r}();class r{}return gr.AsyncContext=r,r.Variable=e.AsyncVariable,r.Snapshot=t.AsyncSnapshot,gr}!function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Jt;Qt.Polyfill.ensureEnabled(),t.__exportStar(kr(),e)}(ht);const Ar=n({__proto__:null},[ht]),Or=Symbol("schemx.async-context"),{AsyncContext:jr}=Ar;function Pr(e,t){const r=arguments.length>=2,n=new jr.Variable;return{name:e,useContext:()=>{const i=n.get();if(void 0!==i)return i;if(r)return t;throw new Vr({name:e})},tryUseContext:()=>{const e=n.get();return void 0!==e?e:r?t:void 0},Provider:(e,t)=>n.run(e,t),[Or]:!0}}class Vr extends Error{constructor(e){super(`[schemx] Context "${e.name}" has not been provided.`),this.name="ContextNotProvidedError"}}const Rr=Pr("SchemxContext");function Cr(){const e=Rr.tryUseContext();if("runtime"===(null==e?void 0:e.type))return e.value}function Er(e){const{schema:t,parentKey:r=""}=e,n=t.key??(r?`field:${r}/${t.name}`:`field:${t.name}`),i=function(e){const{defaultProps:t,instance:r}=function(){const e=Rr.tryUseContext();if("runtime"!==(null==e?void 0:e.type))throw new Error("[schemx] Form runtime context has not been provided.");return e.value}(),{componentProps:n,visible:i,readonly:s,disabled:o,required:a,rules:l,validationTrigger:c,dependencies:u,...d}=e,f=i??Ye.visible,h=s??t.readonly??Ye.readonly,p=o??t.disabled??Ye.disabled,y=h?"right":(null==n?void 0:n.align)??d.contentAlign,v=c??t.validationTrigger??Ye.validationTrigger,g=function(e){var t;const r=(null==(t=e.componentProps)?void 0:t.placeholder)??e.placeholder;if(null==r)return["input","text","textarea"].includes(e.componentType)?`请输入${e.label||e.name}`:`请选择${e.label||e.name}`;return r}(e),m=(Array.isArray(l)?l:[l]).filter(Boolean),b=a??(m.length>0||Ye.required),w={...d??{},key:d.key,name:d.name,label:d.label,componentType:d.componentType,visible:f,readonly:h,disabled:p,required:b,placeholder:g,labelIcon:d.labelIcon||Ye.labelIcon,labelAlign:d.labelAlign||Ye.labelAlign,labelPosition:d.labelPosition||Ye.labelPosition,labelWidth:d.labelWidth||Ye.labelWidth,colon:d.colon??Ye.colon,rules:l,validationTrigger:Nr(v)};Object.hasOwn(e,"initialValue")&&(w.initialValue=d.initialValue);h&&(w.contentAlign="right",w.labelPosition="left");return w.componentProps={...n,align:y,readonly:h,disabled:p,placeholder:g,formItemProps:w,formInstance:r},w}(t);return{type:"field",key:n,name:t.name,componentType:t.componentType,staticSchema:i,dynamicProps:Mr(t.dependencies),validation:Br(i)}}function Tr(e){const{schema:t,index:r,parentKey:n=""}=e,i=function(e,t,r){return e??(r?`group:${r}/${t}`:`group:${t}`)}(t.key,r,n),{children:s,...o}=t;return{type:"group",key:i,staticSchema:{...o,key:i},children:[]}}function Ir(e){const{schema:t,parentKey:r=""}=e,n=[...t.to],i=n.map(Dr).join(",");return{type:"dependency",key:t.key??(r?`dependency:${r}/${i}`:`dependency:${i}`),triggerFields:n,renderer:(e,r)=>{const n=e.getValues();return t.renderer(n,e,{abortSignal:r})}}}function Mr(e){return e?{source:"dependencies",triggerFields:e.triggerFields,dependencies:e}:null}function Br(e){const t=function(e){if(null==e)return null;if(Array.isArray(e))return e.length>0?e:null;return e}(e.rules);return t?{trigger:e.validationTrigger,rules:t}:null}function Dr(e){return Array.isArray(e)?e.join("."):String(e)}function Nr(e){const t={onBlur:"blur",onChange:"change",onSubmit:"submit",blur:"blur",change:"change",submit:"submit"};return(Array.isArray(e)?e:[e]).map(e=>t[e]??"submit")}function $r(e){return"dependency"===e.type}function Wr(e={}){const t={defaultProps:e.defaultProps??{},formInstance:e.formInstance??{}},r={version:0,entries:new WeakMap};function n(e,r=""){return Cr()?i(e,r):(n={defaultProps:t.defaultProps,instance:t.formInstance},s=()=>i(e,r),Rr.Provider({type:"runtime",value:n},s));var n,s}function i(e,t=""){const i=[],s=Te([...e]);for(let o=0;o<s.length;o++){const e=s[o];let a;const l=r.entries.get(e);l&&l.version===r.version?i.push(l.descriptor):(Ae(e)?(a=Tr({schema:e,index:o,parentKey:t}),e.children.length>0&&(a.children=n(e.children,a.key))):a=Oe(e)?Ir({schema:e,parentKey:t}):Er({schema:e,parentKey:t}),r.entries.set(e,{version:r.version,descriptor:a}),i.push(a))}return i}return{cache:r,getCacheVersion:function(){return r.version},toDescriptors:n,invalidate:function(){r.version++},getVersion:function(){return r.version}}}function Ur(e=[]){const t=C(e);return{signal:t,get value(){return t.value},peek:()=>t.peek(),set:e=>{t.value=e},update:e=>{t.value=e(t.peek())},subscribe:e=>{let r=!0;const n=t.subscribe(t=>{r?r=!1:e(t)});return()=>{n()}}}}function zr(e){if(!e||Array.isArray(e))return!1;const t=e;return"function"==typeof t.peek&&"function"==typeof t.set&&"function"==typeof t.update&&"function"==typeof t.subscribe}function qr(e){const t=e.scope.child();let r=0,n=null;const i=(e,n)=>t.disposed||n.signal.aborted||e!==r,s=async(t,r)=>{var n,s,o,a;try{const o=await e.run(r.signal);return i(t,r)||(null==(n=e.onSuccess)||n.call(e,o),null==(s=e.onSettled)||s.call(e)),o}catch(l){const n=function(e){return e instanceof Error?e:new Error(String(e))}(l);if(i(t,r)){if(e.throwOnError)throw n;return}if(null==(o=e.onError)||o.call(e,n),null==(a=e.onSettled)||a.call(e),e.throwOnError)throw n}},o=()=>{r+=1,null==n||n.abort(),t.dispose()};return e.scope.add(o),{run:async()=>{var i;if(t.disposed)return;const o=++r;return null==n||n.abort(),n=new AbortController,null==(i=e.onStart)||i.call(e,n),await e.scheduler.track(s(o,n))},dispose:o}}const Kr=["componentProps","placeholder","required","readonly","disabled","visible","rules"];function Lr(e){const{context:t,descriptor:r,runtimeState:n,scope:i}=e,{formApi:s,scheduler:o}=t,a=r.dynamicProps,l=null==a?void 0:a.dependencies,c=null==a?void 0:a.triggerFields;if(null==l||null==c||0===c.length)return;const u=qr({scope:i,scheduler:o,run:()=>async function(e,t){const r=t.getValues(),[n]=await Promise.all([Zr(e,r,t),Gr(e,r,t)]);return n}(l,s),onSuccess:e=>{!function(e,t,r){e.dynamicOverrides.value=t;const n=e.diagnostics.peek();e.diagnostics.value={...n,lastUpdatedBy:"dependencies",version:n.version+1,triggerFields:r.triggerFields,overriddenKeys:Object.keys(t),error:r.error??null}}(n,e,{triggerFields:c})},onError:e=>{console.error("[schemx] dependencies 执行错误:",e)}}),d=Se(()=>{s.getValues([...c]),u.run()});i.add(()=>{d()})}async function Gr(e,t,r){if(e.trigger)try{await e.trigger(t,r)}catch(n){console.error("[schemx] trigger 执行错误:",n)}}async function Zr(e,t,r){const n=await Promise.all(Kr.filter(t=>null!=e[t]).map(async n=>{const i=e[n],s=await async function(e,t,r,n){try{return await t(r,e)??n}catch(i){return console.error("[schemx] 解析动态属性时发生错误:",i),n}}(r,i,t,void 0);return[n,s]}));return Object.fromEntries(n)}const Hr=new WeakMap;function Xr(e){var t;const{context:r,node:n,descriptor:i}=e,{formApi:s,scheduler:o,compile:a,commitChildren:l}=r,c=e.scope??n.scope.child();let u=a.getCacheVersion();const d=r.nodeResources;Hr.set(n,d),null==(t=d.dependencyEffects.get(n.id))||t.dispose();const f={loading:C(!1),error:C(null),version:C(0),abortController:C(null),run:async()=>{},dispose:()=>{}};d.dependencyResourceScopes.set(n.id,c);const h=qr({scope:c,scheduler:o,run:async e=>{const t=d.descriptors.get(n.id);return t&&$r(t)?await Promise.resolve(t.renderer(s,e)):[]},onStart:e=>{f.version.value+=1,f.abortController.value=e,f.loading.value=!0,f.error.value=null},onSuccess:e=>{const t=a.getCacheVersion();t!==u&&(a.invalidate(),u=t);const r=a.toDescriptors(e,"");l(n,r)},onError:e=>{f.error.value=e},onSettled:()=>{f.loading.value=!1}});return f.run=async()=>{if(c.disposed)return;const e=d.descriptors.get(n.id);e&&$r(e)&&await h.run()},f.dispose=()=>{f.version.value+=1,h.dispose(),c.dispose()},c.add(()=>{var e;null==(e=f.abortController.value)||e.abort(),f.abortController.value=null,d.dependencyEffects.get(n.id)===f&&d.dependencyEffects.delete(n.id),d.dependencyResourceScopes.get(n.id)===c&&d.dependencyResourceScopes.delete(n.id)}),function(e,t,r,n,i,s){let o=!0;const a=Se(()=>{t.getValues([...e]),o||i.schedule({id:s,priority:"normal",scope:n,run:r,onError:e=>{console.error("DependencyEffectState trigger run error:",e)}}),o=!1});n.add(a)}(i.triggerFields,s,()=>f.run(),c,o,`dependency:${n.id}:trigger`),d.dependencyEffects.set(n.id,f),f.run().catch(e=>{console.error("DependencyEffectState initial run error:",e)}),f}class Jr{constructor(){t(this,"fields",new Map)}register(e){const t=e.name;this.fields.set(t,{name:e.name,node:e.node})}unregister(e,t){const r=e,n=this.fields.get(r);t&&(null==n?void 0:n.node)!==t||this.fields.delete(r)}get(e){const t=e;return this.fields.get(t)}list(){return Array.from(this.fields.values())}}function Qr(e){const{context:t,name:r,effectiveSchema:n,scope:i}=e,s=t.scheduler,o=C(!1);let a=0;const l=e=>{const{visible:n,readonly:i,disabled:s,label:a,rules:l}=e;if(!n||i||s||!function(e){return Array.isArray(e)?e.length>0:Boolean(e)}(l))return t.instance.unregisterRules(r),t.instance.setFieldError(r,[]),void(o.value=!1);const c=l??[];t.instance.registerRules(r,c,`${a}为必填项`),o.value=!0};i.add(()=>{a+=1,t.instance.unregisterRules(r),t.instance.setFieldError(r,[]),o.value=!1});const c=Se(()=>{(e=>{const t=++a;s.schedule({id:`validation:${String(r)}`,priority:"post",scope:i,run:()=>{i.disposed||t!==a||l(e)}})})((()=>{const e=n.value;return{visible:e.visible,readonly:e.readonly,disabled:e.disabled,label:e.label,rules:e.rules}})())});i.add(c);return{registered:o,dispose:()=>{i.dispose()}}}function Yr(e){const t=new Set;e&&t.add(e);const r=(e,...r)=>{for(const n of Array.from(t))e(n,...r)};return{on:e=>(t.add(e),()=>{t.delete(e)}),emitMount:e=>{r((e,t)=>{var r,n;null==(r=e.mount)||r.call(e,t),null==(n=e.mounted)||n.call(e,t)},e)},emitBeforeMount:e=>{r((e,t)=>{var r;null==(r=e.beforeMount)||r.call(e,t)},e)},emitUpdate:(e,t)=>{r((e,t,r)=>{var n;null==(n=e.update)||n.call(e,t,r)},e,t)},emitBeforeUpdate:(e,t)=>{r((e,t,r)=>{var n;null==(n=e.beforeUpdate)||n.call(e,t,r)},e,t)},emitUpdated:(e,t)=>{r((e,t,r)=>{var n;null==(n=e.updated)||n.call(e,t,r)},e,t)},emitBeforeUnmount:e=>{r((e,t)=>{var r;null==(r=e.beforeUnmount)||r.call(e,t)},e)},emitUnmount:e=>{r((e,t)=>{var r,n;null==(r=e.unmount)||r.call(e,t),null==(n=e.unmounted)||n.call(e,t)},e)},clear:()=>{t.clear()}}}const en=Yr;function tn(){let e=!1;const t=[],r=[];return{get disposed(){return e},add:r=>{if(e)return on(r),rn();const n={cleanup:r,disposed:!1};t.push(n);return{get disposed(){return n.disposed},dispose:()=>{n.disposed||(n.disposed=!0,sn(t,n),on(n.cleanup))}}},child:()=>{const e=tn();return r.push(e),e.add(()=>{sn(r,e)}),e},dispose:()=>{if(!e){e=!0;for(const e of r.slice().reverse())e.dispose();r.length=0;for(const e of t.slice().reverse())e.disposed||(e.disposed=!0,on(e.cleanup));t.length=0}}}}const rn=()=>({disposed:!0,dispose:nn}),nn=()=>{},sn=(e,t)=>{const r=e.indexOf(t);r>=0&&e.splice(r,1)},on=e=>{try{e()}catch(t){!function(e){console.error("[Scope] Cleanup error:",e)}(t)}};function an(e){switch(e.type){case"root":case"group":case"dependency":return e.childNodes;case"field":return[]}}function ln(e){const t=e.nodeResources;let r=1;const n={resources:t,nodes:t.nodes,createRoot:function(){const e=(r={scope:tn()},{id:0,key:"schemx:root",type:"root",parent:null,scope:r.scope,mounted:C(!1),disposed:C(!1),childNodes:[]});var r;return cn(t,e),o(e),e},create:function(e,t){const r=i({type:e.type,key:e.key,scope:t.scope.child()});r.parent=t,"field"!==r.type&&o(r);return r},createNode:i,getNode:function(e){return t.nodes.get(e)},traverse:function(e){const t=[],r=e=>{t.push(e);for(const t of an(e))r(t)};return r(e),t},insertChild:function(e,t,r=an(e).length){t.parent&&s(t.parent,t);const n=[...an(e).filter(e=>e!==t)],i=Math.max(0,Math.min(r,n.length));n.splice(i,0,t),t.parent=e,a(e,n)},replaceChildren:function(e,t){const r=an(e),n=Array.from(new Set(t)),i=new Set(n);for(const s of r)i.has(s)||(s.parent=null);for(const o of n)o.parent&&o.parent!==e&&s(o.parent,o),o.parent=e;a(e,n)},removeChild:function(e,t){s(e,t)},removeSubtree:function e(r){for(const t of an(r))e(t);"field"!==r.type&&a(r,[]);r.parent&&s(r.parent,r);r.parent=null,r.disposed.value=!0,r.scope.dispose(),function(e,t){e.nodes.delete(t),e.descriptors.delete(t),e.fieldStates.delete(t),e.viewStates.delete(t),e.childrenStates.delete(t),e.dependencyEffects.delete(t),e.fieldResourceScopes.delete(t),e.fieldDynamicPropScopes.delete(t),e.dependencyResourceScopes.delete(t)}(t,r.id)}};return n;function i(e){const n=r++,i=e.scope??tn(),s={id:n,key:e.key,scope:i};let a={};var l,c;return a="field"===e.type?{id:(l=s).id,key:l.key,type:"field",parent:l.parent??null,scope:l.scope??(null==(c=l.parent)?void 0:c.scope.child())??tn(),mounted:C(!1),disposed:C(!1)}:"group"===e.type?function(e){var t;return{id:e.id,key:e.key,type:"group",parent:e.parent??null,scope:e.scope??(null==(t=e.parent)?void 0:t.scope.child())??tn(),mounted:C(!1),disposed:C(!1),childNodes:[]}}(s):function(e){var t;return{id:e.id,key:e.key,type:"dependency",parent:e.parent??null,scope:e.scope??(null==(t=e.parent)?void 0:t.scope.child())??tn(),mounted:C(!1),disposed:C(!1),childNodes:[]}}(s),cn(t,a),"field"!==a.type&&o(a),a}function s(e,t){a(e,an(e).filter(e=>e!==t)),t.parent===e&&(t.parent=null)}function o(e){let r=t.childrenStates.get(e.id);return r||(r={children:C(an(e))},t.childrenStates.set(e.id,r)),r}function a(e,t){!function(e,t){switch(e.type){case"root":case"group":case"dependency":return void(e.childNodes=t);case"field":;}}(e,t),o(e).children.value=t}}function cn(e,t){e.nodes.set(t.id,t)}function un(e,t){return _e(()=>{const r=[];for(const n of e.value){const e=dn(n,t);null!=e&&(Array.isArray(e)?r.push(...e):r.push(e))}return r})}function dn(e,t=(e=>null==(e=Cr())?void 0:e.nodeResources)()){if(e.disposed.value)return null;if(!t)return null;const r=t.viewStates.get(e.id);return"field"===e.type||"group"===e.type?fn(r)?r.view.value??null:null:"dependency"===e.type?fn(r)?r.view.value??[]:[]:null}function fn(e){return null!=e&&"view"in e}function hn(e,t){var r;return{runtimeNodeId:e??0,runtimeNodeType:"field",hasRuntimeState:!0,hasDependencyEffect:!1,lastUpdatedBy:null==t?void 0:t.lastUpdatedBy,overriddenKeys:null==t?void 0:t.overriddenKeys,error:(null==(r=null==t?void 0:t.error)?void 0:r.message)??null}}function pn(e,t,r,n){return{runtimeNodeId:e??0,runtimeNodeType:t,hasRuntimeState:r,hasDependencyEffect:n}}function yn(e){return e?e.length>1e3?e.slice(0,1e3):e:""}function vn(e,t=0){if(t>10)return{};const r={};for(const n of Object.keys(e)){if(!gn(n))continue;const i=e[n];null===i||"object"!=typeof i||Array.isArray(i)?r[n]=i:r[n]=vn(i,t+1)}return r}function gn(e){return!!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)||/^[a-zA-Z0-9_-]+$/.test(e)}function mn(e,t){const r=function(e,t){return{viewSchemas:un(e,t)}}(wn(e,t).children,t);return t.viewStates.set(e.id,r),r}function bn(e,t,r){if("field"===e.type&&"field"===t.type)return function(e,t,r){const n=r.fieldStates.get(e.id);if(!n)throw new Error(`[schemx] fieldState is required for node "${e.key}"`);const i=(s=n.viewSchema,o=e.key,a=e.id,l=n.diagnostics,{view:_e(()=>{const e=s.value,t=null==l?void 0:l.value;return{...e,key:o??"",placeholder:yn(e.placeholder??""),componentProps:vn(e.componentProps??{}),debug:hn(a,t)}})});var s,o,a,l;return r.viewStates.set(e.id,i),i}(e,0,r);if("group"===e.type&&"group"===t.type)return function(e,t,r){const n=(i=t.staticSchema,s=un(wn(e,r).children,r),o=e.key,a=e.id,{view:_e(()=>({...i,key:o??"",children:s.value,debug:pn(a,"group",!1,!1)}))});var i,s,o,a;return r.viewStates.set(e.id,n),n}(e,t,r);if("dependency"===e.type&&"dependency"===t.type)return function(e,t,r){const n=(i=un(wn(e,r).children,r),{view:_e(()=>i.value)});var i;return r.viewStates.set(e.id,n),n}(e,0,r);throw new Error(`[schemx] Cannot create viewState for node "${e.key}" with descriptor "${t.type}".`)}function wn(e,t){const r=t.childrenStates.get(e.id);if(!r)throw new Error(`[schemx] childrenState is required for node "${e.key}"`);return r}function Sn(e){const t=e.nodeResources,r=e.lifecycleBus;return{mount:function(n,s){t.descriptors.set(n.id,s),r.emitBeforeMount(n),function(r,n){if("field"===r.type&&"field"===n.type)return void i(r,n);if("group"===r.type&&"group"===n.type)return void o(r,n);"dependency"===r.type&&"dependency"===n.type&&function(r,n){bn(r,n,t),Xr({context:e,node:r,descriptor:n,scope:r.scope.child()})}(r,n)}(n,s),n.mounted.value=!0,r.emitMount(n)},update:function(n,a,l){if(n.type!==l.type)throw new Error(`unexpected descriptor type: node ${n.type} cannot update with ${l.type}`);const c={...n};r.emitBeforeUpdate(n,c),t.descriptors.set(n.id,l),function(r,n,a){if("field"===r.type&&"field"===a.type)return void function(r,n,o){const a=t.fieldStates.get(r.id);if(!a)return void i(r,n);o&&o.name!==n.name&&e.fieldRegistry.unregister(o.name,r);(function(e,t){e.staticSchema.value=t.staticSchema,e.name.value=t.name;const r=e.diagnostics.peek();e.diagnostics.value={...r,lastUpdatedBy:"static-schema",version:r.version+1,triggerFields:[],overriddenKeys:[],error:null}})(a,n),function(e,t,r){bn(e,t,r)}(r,n,t),e.fieldRegistry.register({name:n.name,node:r}),s(r,n,a)}(r,a,"field"===(null==n?void 0:n.type)?n:void 0);if("group"===r.type&&"group"===a.type)return void o(r,a);"dependency"===r.type&&"dependency"===a.type&&function(r,n,i){var s;if(bn(r,n,t),i&&function(e,t){if(e.length!==t.length)return!1;return e.every((e,r)=>function(e,t){if(void 0===t)return!1;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,r)=>e===t[r]);return e===t}(e,t[r]))}(i.triggerFields,n.triggerFields)&&t.dependencyEffects.has(r.id))return;null==(s=t.dependencyResourceScopes.get(r.id))||s.dispose(),Xr({context:e,node:r,descriptor:n,scope:r.scope.child()})}(r,a,"dependency"===(null==n?void 0:n.type)?n:void 0)}(n,a,l),r.emitUpdate(n,c),r.emitUpdated(n,c)},unmount:n,unmountSubtree:function e(t){if(t.disposed.value)return;for(const r of an(t))e(r);n(t)}};function n(n){"root"!==n.type&&(r.emitBeforeUnmount(n),function(r){var n,i,s;const o=t.descriptors.get(r.id);(function(e,t){t.viewStates.delete(e.id)})(r,t),"field"===r.type&&"field"===(null==o?void 0:o.type)?(e.fieldRegistry.unregister(o.name,r),null==(n=t.fieldResourceScopes.get(r.id))||n.dispose(),null==(i=t.fieldDynamicPropScopes.get(r.id))||i.dispose()):"dependency"===r.type&&(null==(s=t.dependencyResourceScopes.get(r.id))||s.dispose())}(n),r.emitUnmount(n))}function i(r,n){const i=function(e){const{key:t,descriptor:r}=e,n=C(r.staticSchema,{name:`field:${String(r.name)}:staticSchema`}),i=C({},{name:`field:${String(r.name)}:dynamicOverrides`}),s=C({lastUpdatedBy:"static-schema",version:0,triggerFields:[],overriddenKeys:[],error:null},{name:`field:${String(r.name)}:diagnostics`}),o=C(r.name,{name:`field:${String(r.name)}:name`}),a=_e(()=>{const e=n.value,r=i.value;return{key:t,name:o.value,componentType:e.componentType,label:e.label||"",visible:r.visible??e.visible??!0,disabled:r.disabled??e.disabled??!1,readonly:r.readonly??e.readonly??!1,required:r.required??e.required??!1,placeholder:r.placeholder??e.placeholder??"",componentProps:r.componentProps??e.componentProps??{},rules:r.rules??e.rules??[],validationTrigger:e.validationTrigger}}),l=_e(()=>{const e=a.value;return{...n.value,visible:e.visible,disabled:e.disabled,readonly:e.readonly,required:e.required,label:e.label,placeholder:e.placeholder,componentProps:e.componentProps,rules:e.rules}});return{name:o,staticSchema:n,dynamicOverrides:i,effectiveSchema:a,viewSchema:l,diagnostics:s}}({nodeId:r.id,key:r.key,descriptor:n});!function(t){if(!Object.hasOwn(t.staticSchema,"initialValue"))return;if(void 0!==e.instance.getFieldValue(t.name))return;e.instance.setFieldValue(t.name,t.staticSchema.initialValue)}(n),t.fieldStates.set(r.id,i),bn(r,n,t),e.fieldRegistry.register({name:n.name,node:r}),s(r,n,i)}function s(r,n,i){var s,o;null==(s=t.fieldResourceScopes.get(r.id))||s.dispose(),null==(o=t.fieldDynamicPropScopes.get(r.id))||o.dispose();const a=r.scope.child(),l=r.scope.child();t.fieldResourceScopes.set(r.id,a),t.fieldDynamicPropScopes.set(r.id,l),a.add(()=>{t.fieldResourceScopes.get(r.id)===a&&t.fieldResourceScopes.delete(r.id)}),l.add(()=>{t.fieldDynamicPropScopes.get(r.id)===l&&t.fieldDynamicPropScopes.delete(r.id)}),Qr({context:e,name:n.name,effectiveSchema:i.effectiveSchema,scope:a}),Lr({context:e,descriptor:n,runtimeState:i,scope:l})}function o(e,r){bn(e,r,t)}}function Fn(e,t,r){const n=function(e){const t=new Map;for(const r of e)t.set(r.key,r);return t}(e),i=function(e){const t=new Map;for(const r of e)t.set(r.key,r);return t}(t),s=[],o=[],a=[],l=[];for(const c of t){const e=n.get(c.key);if(!e||!xn(e,c)){s.push({descriptor:c}),l.push({descriptor:c});continue}const t=r.get(e.id);t!==c&&o.push({node:e,previousDescriptor:t,nextDescriptor:c}),l.push({descriptor:c,node:e})}for(const c of e){const e=i.get(c.key);e&&xn(c,e)||a.push({node:c})}return{creates:s,updates:o,removes:a,nextChildrenOrder:l}}function xn(e,t){return e.type===t.type}function _n(e){const t=function(e){if(function(e){return"nodeManager"in e&&"lifecycle"in e}(e))return e;const t=ln(e),r=Sn(e);return{nodeManager:t,lifecycle:r,getCurrentDescriptors:()=>e.nodeResources.descriptors}}(e);return{createRoot:function(){const e=t.nodeManager.createRoot;if(!e)throw new Error("[schemx] Reconciler nodeManager cannot create root node.");return e()},reconcileChildren:function e(r,n){const i=function(e,t,r){const n=new Map;for(const{descriptor:s}of t.creates){const t=r.nodeManager.createNode({type:s.type,key:s.key,scope:e.scope.child()});n.set(s.key,t)}const i=t.nextChildrenOrder.map(e=>{if(e.node)return e.node;const t=n.get(e.descriptor.key);if(!t)throw new Error(`[schemx] Missing created runtime node for descriptor "${e.descriptor.key}".`);return t});for(const{node:s,previousDescriptor:o,nextDescriptor:a}of t.updates)r.lifecycle.update(s,o,a);for(const{descriptor:s}of t.creates){const e=n.get(s.key);if(!e)throw new Error(`[schemx] Missing mounted runtime node for descriptor "${s.key}".`);r.lifecycle.mount(e,s)}r.nodeManager.replaceChildren(e,i);for(const{node:s}of t.removes)r.lifecycle.unmountSubtree(s),r.nodeManager.removeSubtree(s);return i}(r,Fn(an(r),n,t.getCurrentDescriptors()),t);for(const[t,s]of i.entries()){const r=n[t];"group"===(null==r?void 0:r.type)&&"group"===s.type&&e(s,r.children)}},updateNode:function(e,r){const n=t.getCurrentDescriptors().get(e.id);n!==r&&t.lifecycle.update(e,n,r)},removeNode:function(e){t.lifecycle.unmountSubtree(e),t.nodeManager.removeSubtree(e)}}}const kn=["sync","pre","normal","post"];const An=e=>null!==e&&"object"==typeof e&&"then"in e&&"function"==typeof e.then;class On{constructor(e={}){t(this,"fieldSignals",function(e={}){return new me(e)}()),t(this,"initialValues");const r=e.initialValues??{};this.initialValues=ce(r);const n=He(r);for(const t of n){const e=Ge(r,t);this.fieldSignals.set(t,ge({value:e,initialValue:e}))}}getOrCreateFieldSignal(e){const t=Ge(this.initialValues,e);let r=this.fieldSignals.peek(e);return r||(r=ge({value:t,initialValue:t}),this.fieldSignals.set(e,r)),r}getFieldValue(e){const t=this.fieldSignals.get(e);return null==t?void 0:t.value.value}setFieldValue(e,t){const r=this.getOrCreateFieldSignal(e);r.setValue(t),r.setTouched(!ve(t,r.initialValue.peek()))}getFieldsValue(e){const t={},r=e??this.fieldSignals.keys();for(const n of r)Ze(t,n,this.getFieldValue(n));return t}setFieldsValue(e){const t=He(e);Fe(()=>{for(const r of t)this.setFieldValue(r,Ge(e,r))})}getFieldSnapshot(e){const t=this.fieldSignals.peek(e);return null==t?void 0:t.value.peek()}getFieldsSnapshot(e){const t={},r=e??this.fieldSignals.keys();for(const n of r)Ze(t,n,this.getFieldSnapshot(n));return t}getInitialValue(e){const t=this.fieldSignals.peek(e);return t?t.initialValue.peek():Ge(this.initialValues,e)}getInitialValues(e){if(void 0===e)return ce(this.initialValues);const t={};for(const r of e)Ze(t,r,Ge(this.initialValues,r));return t}setInitialValue(e,t){Ze(this.initialValues,e,t);const r=this.getOrCreateFieldSignal(e);r.setInitialValue(t),r.setTouched(!ve(r.value.peek(),r.initialValue.peek()))}setInitialValues(e){const t=He(e);t.length&&Fe(()=>{for(const r of t){const t=Ge(e,r);Ze(this.initialValues,r,t);const n=this.getOrCreateFieldSignal(r);n.setInitialValue(t),n.setTouched(!ve(n.value.peek(),n.initialValue.peek()))}})}isFieldTouched(e){var t;return(null==(t=this.fieldSignals.get(e))?void 0:t.touched.value)??!1}isFieldsTouched(e){const t=e??[...this.fieldSignals.keys()];return void 0===e?t.some(e=>this.isFieldTouched(e)):t.every(e=>this.isFieldTouched(e))}getTouchedFields(){const e=[];for(const[t,r]of this.fieldSignals.entries())r.touched.value&&e.push(t);return e}setFieldTouched(e,t){this.getOrCreateFieldSignal(e).setTouched(t)}setFieldsTouched(e,t=!0){Fe(()=>{for(const r of e)this.setFieldTouched(r,t)})}isFieldPending(e){var t;return(null==(t=this.fieldSignals.get(e))?void 0:t.pending.value)??!1}isFieldsPending(e){return(e??[...this.fieldSignals.keys()]).every(e=>this.isFieldPending(e))}getPendingFields(){const e=[];for(const[t,r]of this.fieldSignals.entries())r.pending.value&&e.push({field:t,message:r.pendingMessage.peek()});return e}setFieldPending(e,t,r){this.getOrCreateFieldSignal(e).setPending(t,r)}setFieldsPending(e,t=!0,r){Fe(()=>{for(const n of e)this.setFieldPending(n,t,r)})}resetField(e){this.getOrCreateFieldSignal(e).reset()}resetFields(e){Fe(()=>{for(const t of e)this.getOrCreateFieldSignal(t).reset()})}reset(e){const t=ce(e??this.initialValues),r=He(t),n=new Set(r);Fe(()=>{for(const e of this.fieldSignals.keys())n.has(e)||this.fieldSignals.delete(e);for(const e of r){const r=Ge(t,e);Ze(this.initialValues,e,r);const n=this.fieldSignals.peek(e);n?(n.setInitialValue(r),n.reset(r)):this.fieldSignals.set(e,ge({value:r,initialValue:r}))}})}destroy(){this.fieldSignals.clear()}}function jn(e,t,r){let n=!1;const i=e.scope.add(()=>{n=!0}),s=function(e,t,r=16,n={}){let i=!1;const s=e=>{t(e),n.once&&l()},o=T(s,r,{edges:n.edges}),a=Se(()=>{const t=e();if(!i&&n.immediate)return i=!0,void s(t);i=!0,o(t)}),l=()=>{a(),o.cancel()};return l}(()=>{if(n)return[];const r=t.viewStates.get(e.id);return null!=(i=r)&&"viewSchemas"in i?r.viewSchemas.value:[];var i},e=>{try{r(e)}catch(t){console.error("[subscribeViewSchemas] onChange error:",t)}},16,{immediate:!0,edges:["leading","trailing"]});return()=>{s(),i.dispose(),n=!1}}class Pn{constructor(e={}){var r,n;t(this,"context"),t(this,"callbacks"),t(this,"store"),t(this,"rendererRegistry"),t(this,"validatorRegistry"),t(this,"validator"),t(this,"root"),t(this,"scheduler"),t(this,"reconciler"),t(this,"fieldRegistry"),t(this,"nodeResources"),t(this,"scope",tn()),t(this,"schemas"),t(this,"compile"),t(this,"disposed",!1),t(this,"lifecycleBus"),t(this,"getFormInstance",()=>({setFieldValue:this.store.setFieldValue.bind(this.store),setFieldsValue:this.store.setFieldsValue.bind(this.store),getFieldValue:this.store.getFieldValue.bind(this.store),getFieldsValue:this.store.getFieldsValue.bind(this.store),getFieldSnapshot:this.store.getFieldSnapshot.bind(this.store),getFieldsSnapshot:this.store.getFieldsSnapshot.bind(this.store),getInitialValue:this.store.getInitialValue.bind(this.store),getInitialValues:this.store.getInitialValues.bind(this.store),setInitialValues:this.store.setInitialValues.bind(this.store),isFieldTouched:this.store.isFieldTouched.bind(this.store),setFieldTouched:this.store.setFieldTouched.bind(this.store),getTouchedFields:this.store.getTouchedFields.bind(this.store),setFieldPending:this.store.setFieldPending.bind(this.store),isFieldPending:this.store.isFieldPending.bind(this.store),getPendingFields:this.store.getPendingFields.bind(this.store),validateField:this.validateField.bind(this),validate:this.validate.bind(this),getFieldError:this.validator.getFieldError.bind(this.validator),setFieldError:this.validator.setFieldError.bind(this.validator),resetFields:this.store.resetFields.bind(this.store),reset:this.reset.bind(this),submit:this.submit.bind(this),registerRules:this.register.bind(this),unregisterRules:this.validator.unregister.bind(this.validator),effect:this.effect.bind(this),batch:this.batch.bind(this),setSchemas:this.setSchemas.bind(this),updateSchemas:this.updateSchemas.bind(this),updateFieldSchema:this.updateFieldSchema.bind(this),updateDefaultProps:this.updateDefaultProps.bind(this),getViewSchemas:this.getViewSchemas.bind(this),subscribeViewSchemas:this.subscribeViewSchemas.bind(this),waitForDependencies:this.waitForIdle.bind(this),getRenderer:this.rendererRegistry.getRenderer.bind(this.rendererRegistry),registerRenderer:this.rendererRegistry.register.bind(this.rendererRegistry),hasRenderer:this.rendererRegistry.hasRenderer.bind(this.rendererRegistry),getValidator:this.validatorRegistry.get.bind(this.validatorRegistry),registerValidator:this.validatorRegistry.register.bind(this.validatorRegistry),hasValidator:this.validatorRegistry.has.bind(this.validatorRegistry),destroy:this.destroy.bind(this)})),t(this,"getFormApi",()=>({setValue:this.store.setFieldValue.bind(this.store),setValues:this.store.setFieldsValue.bind(this.store),getValue:this.store.getFieldValue.bind(this.store),getValues:this.store.getFieldsValue.bind(this.store),getSnapshots:this.store.getFieldsSnapshot.bind(this.store),setPending:this.store.setFieldPending.bind(this.store),isPending:this.store.isFieldPending.bind(this.store),setTouched:this.store.setFieldTouched.bind(this.store),isTouched:this.store.isFieldTouched.bind(this.store),getError:this.validator.getFieldError.bind(this.validator),setError:this.validator.setFieldError.bind(this.validator),resetFields:this.store.resetFields.bind(this.store),reset:this.reset.bind(this),validateField:this.validateField.bind(this),validate:this.validate.bind(this)})),t(this,"validate",Je(async()=>{const e=this.store.getPendingFields();if(e.length>0){const t=`存在正在操作中的字段: ${e.map(e=>e.field).join(", ")},请等待完成后再提交`;return console.warn(`[schemx] ${t}`),{ok:!1,error:{errors:e.map(({field:e,message:t})=>{const r=t.length?t:["字段正在处理中,请稍后重试"];return this.validator.setFieldError(e,r),{field:e,message:r}}),values:this.store.getFieldsSnapshot()}}}return await this.validator.validate(this.store.getFieldsValue())})),t(this,"submit",Je(async()=>{var e,t,r,n;if(!(await this.waitForIdle()))return;const i=await this.validate();i.ok?await(null==(t=(e=this.callbacks).onFinish)?void 0:t.call(e,i.values)):null==(n=(r=this.callbacks).onFinishFailed)||n.call(r,i.error)})),t(this,"commitChildren",(e,t)=>{this.reconciler.reconcileChildren(e,t)});const{schemas:i,initialValues:s={},modelValue:o,rendererRegistry:a,defaultRendererType:l,validatorRegistry:c,...u}=e;this.callbacks={onValuesChange:e.onValuesChange,onFinish:e.onFinish,onFinishFailed:e.onFinishFailed,onFieldsChange:e.onFieldsChange},this.rendererRegistry=a??ut(l),this.validatorRegistry=c??ft(),this.validator=rt(),this.store=function(e={}){return new On(e)}({initialValues:{...s,...o??{}}}),this.validatorRegistry.registerAll({required:nt,selectRequired:it,uploadRequired:st}),this.lifecycleBus=Yr(),this.scheduler=function(){const e=new Map(kn.map(e=>[e,new Map])),t=new Set;let r=0,n=!1,i=null;const s=async()=>{if(!n)return i||(i=o().finally(()=>{i=null,d()}),i)},o=async()=>{for(var e,t;!n;){const i=a();if(0===i.length)return;for(const s of i)if(!n&&!(null==(e=s.scope)?void 0:e.disposed))try{const e=s.run();An(e)&&await l(e)}catch(r){null==(t=s.onError)||t.call(s,r)}}},a=()=>{const t=[];for(const r of kn){const n=e.get(r);n&&(t.push(...n.values()),n.clear())}return t},l=async e=>{r+=1;try{return await e}finally{r-=1,d()}},c=()=>!i&&0===r&&!u(),u=()=>Array.from(e.values()).some(e=>e.size>0),d=()=>{if(!c())return;const e=Array.from(t);t.clear(),e.forEach(e=>e(!0))};return{schedule:t=>{var r,i;n||(null==(r=t.scope)?void 0:r.disposed)||(null==(i=e.get(t.priority))||i.set(t.id,t),queueMicrotask(()=>{s()}))},flush:s,whenIdle:(e=1e4)=>c()?Promise.resolve(!0):new Promise(r=>{const n=globalThis.setTimeout(()=>{t.delete(r),r(!1)},e);t.add(e=>{globalThis.clearTimeout(n),r(e)})}),track:l,dispose:()=>{n=!0,e.forEach(e=>e.clear()),d()}}}(),this.fieldRegistry=new Jr,this.nodeResources={nodes:new Map,descriptors:new Map,fieldStates:new Map,viewStates:new Map,childrenStates:new Map,dependencyEffects:new Map,fieldResourceScopes:new Map,fieldDynamicPropScopes:new Map,dependencyResourceScopes:new Map};const d=fe(u,et);this.compile=Wr({defaultProps:d,formInstance:this.getFormInstance()}),this.context={defaultProps:d,instance:this.getFormInstance(),formApi:this.getFormApi(),compile:this.compile,scheduler:this.scheduler,lifecycleBus:this.lifecycleBus,fieldRegistry:this.fieldRegistry,nodeResources:this.nodeResources,commitChildren:this.commitChildren},this.reconciler=_n(this.context),this.root=this.reconciler.createRoot();if(!this.nodeResources.childrenStates.get(this.root.id))throw new Error("[schemx] root childrenState is required");mn(this.root,this.nodeResources),e.lifecycleHooks&&this.lifecycleBus.on(e.lifecycleHooks),this.schemas=zr(i)?i:Ur(i??[]),this.applySchemas(this.schemas.peek());const f=this.schemas.subscribe(e=>{this.applySchemas(e)});if(this.scope.add(f),(null==(r=this.callbacks)?void 0:r.onValuesChange)||(null==(n=this.callbacks)?void 0:n.onFieldsChange)){let e=this.store.getFieldsSnapshot();const t=Se(()=>{var t,r,n,i;const s=this.store.getFieldsValue(),o=this.store.getFieldsSnapshot(),a=Qe(o,e),l=He(a);l.length>0&&(null==(r=(t=this.callbacks).onValuesChange)||r.call(t,a,o),null==(i=(n=this.callbacks).onFieldsChange)||i.call(n,l,He(s))),e=o});this.scope.add(t)}}register(e,t,r){var n;const i=[],s=null==(n=this.fieldRegistry.get(e))?void 0:n.node,o=s?this.nodeResources.descriptors.get(s.id):void 0,a="field"===(null==o?void 0:o.type)?o.staticSchema:void 0;this.validator.unregister(e);const l={...a,rules:t};i.push(...this.validatorRegistry.resolveValidatorsBySchema(l)),i.length>0&&this.validator.register(e,i,r)}async validateField(e){return await this.validator.validateField(e,this.store.getFieldsValue())}reset(){this.store.reset(),this.validator.reset()}effect(e){const t=Se(e),r=this.scope.add(t);return()=>{r.dispose()}}batch(e){Fe(e)}setSchemas(e){this.disposed||this.schemas.set(e)}updateSchemas(e){this.disposed||this.schemas.update(e)}updateFieldSchema(e,t){var r;if(this.disposed)return;const n=this.fieldRegistry.get(e);if(!n)return;const i=n.node,s=this.nodeResources.descriptors.get(i.id);if("field"!==(null==s?void 0:s.type))return;const o={...s.staticSchema,...t,componentProps:t.componentProps?{...s.staticSchema.componentProps,...t.componentProps}:s.staticSchema.componentProps,key:s.key,name:s.name,componentType:s.staticSchema.componentType,dependencies:null==(r=s.dynamicProps)?void 0:r.dependencies},[a]=this.compile.toDescriptors([o]);"field"===a.type&&this.reconciler.updateNode(i,a)}updateDefaultProps(e){this.disposed||(Object.assign(this.context.defaultProps,fe(e,et)),this.compile.invalidate(),this.applySchemas(this.schemas.peek()))}applySchemas(e){if(this.disposed)return;const t=this.compile.toDescriptors(e);this.commitChildren(this.root,t)}destroy(){this.disposed||(this.disposed=!0,this.scope.dispose(),this.reconciler.removeNode(this.root),this.scheduler.dispose(),this.store.destroy())}getViewSchemas(){const e=this.nodeResources.viewStates.get(this.root.id);return e&&"viewSchemas"in e?e.viewSchemas.value:[]}subscribeViewSchemas(e){return jn(this.root,this.nodeResources,e)}waitForIdle(e=1e4){return this.scheduler.whenIdle(e)}}function Vn(e={}){return new Pn(e).getFormInstance()}function Rn(e,t){return{getValue:()=>e.getFieldValue(t),setValue:r=>{e.setFieldValue(t,r)},getInitialValue:()=>e.getInitialValue(t),setInitialValue:r=>{const n={};Ze(n,t,r),e.setInitialValues(n)},getValues:()=>e.getFieldsValue(),getSnapshot:()=>e.getFieldsSnapshot(),validate:()=>e.validateField(t),getError:()=>e.getFieldError(t),setError:r=>{e.setFieldError(t,r)},clearError:()=>{e.setFieldError(t,[])},registerRules:(r,n)=>{e.registerRules(t,r,n)},unregisterRules:()=>{e.unregisterRules(t)},isTouched:()=>e.isFieldTouched(t)??!1,reset:()=>{e.resetFields([t])},setPending:(r,n)=>{e.setFieldPending(t,r,n)},isPending:()=>e.isFieldPending(t)??!1,effect:t=>e.effect(t)}}function Cn(e){let t,r=!1;const n=Se(()=>{null==t||t(),t=void 0;const r=e();"function"==typeof r&&(t=r)});return()=>{r||(r=!0,n(),null==t||t(),t=void 0)}}const En=(e,t,r,n)=>{let i=e.getFieldSnapshot(t),s=!0;return e.effect(()=>{const o=e.getFieldValue(t),a=e.getFieldsSnapshot();if(s)return s=!1,n.immediate&&r({value:o,prevValue:void 0},a),void(i=o);n.inequality&&ve(o,i)||(r({value:o,prevValue:i},a),i=o)})},Tn=(e,t,r,n)=>{let i=e.getFieldsSnapshot(t),s=!0;return e.effect(()=>{const o=e.getFieldsValue(t),a=e.getFieldsSnapshot();if(s)return s=!1,n.immediate&&r({changedPaths:t,changedValues:o,prevValues:{}},a),void(i={...o});if(n.inequality&&ve(o,i))return;const l=Qe(o,i),c=He(l);r({changedPaths:c,changedValues:l,prevValues:i},a),i={...o}})},In=(e,t,r)=>{let n=!0,i=e.getFieldsSnapshot();return e.effect(()=>{const s=e.getFieldsSnapshot();if(n)return n=!1,r.immediate&&t({changedPaths:[],changedValues:s,prevValues:{}},s),void(i={...s});if(r.inequality&&ve(s,i))return;const o=Qe(s,i),a=He(o);t({changedPaths:a,changedValues:o,prevValues:i},s),i={...s}})};function Mn(e,t,r,n){return"function"==typeof t?In(e,t,r||{}):"string"==typeof t||"number"==typeof t?En(e,t,r,n||{}):Tn(e,t,r,n||{})}const Bn=ut("input"),Dn=ft(),Nn=Symbol("SCHEMX_INSTANCE");function $n(e={}){const{...t}=e,n={...t,rendererRegistry:t.rendererRegistry??Bn,validatorRegistry:t.validatorRegistry??Dn},i=r.computed(()=>Vn(n));return r.provide(Nn,i.value),r.onUnmounted(()=>{i.value.destroy()}),i.value}function Wn(){const e=r.inject(Nn);if(!e)throw new Error("useFormContext must be used within a Form");return e}const Un=Symbol("schemx:field"),zn=new WeakMap;const qn=e=>{const t=Wn(),n=e;let i=zn.get(t);i||(i=new Map,zn.set(t,i));const s=i.get(n);let o;if(s)s.refCount++,o=s;else{const{result:s,dispose:a}=function(e,t){const n=Rn(e,t),i=r.shallowRef(n.getValue()),s=r.shallowRef(n.getError()),o=r.shallowRef(n.isPending()),a=n.effect(()=>{i.value=n.getValue(),s.value=n.getError(),o.value=n.isPending()}),l=r.computed(()=>s.value),c=r.computed(()=>(i.value,n.isTouched())),u=r.computed(()=>o.value);return{result:{value:i,error:l,dirty:c,pending:u,...n,getValue:()=>i.value},dispose:a}}(t,e);o={refCount:1,result:s,dispose:a},i.set(n,o)}return r.onUnmounted(()=>{--o.refCount<=0&&(o.dispose(),i.delete(n))}),o.result};function Kn(e,t,n){const i=Mn(Wn(),e,t,n);return r.onUnmounted(i),i}function Ln(e,t,r){return Kn(e,t,r)}function Gn(e){return e instanceof Error?e:new Error(String(e))}const Zn=(e,t)=>{var n;const i=Wn(),s=r.ref([]),o=r.ref(!1),a=r.ref(void 0);let l=0;const c=async()=>{try{const t=i.getFieldsValue();if("function"==typeof e.shouldFetch&&!e.shouldFetch(t))return s.value=[],void(o.value=!1);o.value=!0,a.value=void 0;const r=++l,n=await(async t=>{const r=e.retryCount??0,n=e.retryInterval??1e3;let s=new Error("Unknown error");for(let a=0;a<=r;a++)try{return await e.api(t,i)}catch(o){s=Gn(o),a<r&&await new Promise(e=>setTimeout(e,n))}throw s})(t);if(r!==l)return;const c=await(async t=>"function"==typeof(null==e?void 0:e.formatter)?await e.formatter(t,i):t)(n);if(r!==l)return;s.value=c,a.value=void 0,"function"==typeof e.onSuccess&&e.onSuccess(c,i),o.value=!1}catch(t){const r=Gn(t);a.value=r,s.value=[],o.value=!1,"function"==typeof e.onError&&e.onError(r,i)}};(null==(n=e.dependsOn)?void 0:n.length)&&Ln(e.dependsOn,(r,n)=>{"function"==typeof e.onDepsChange&&e.onDepsChange(n,i),e.resetOnDepsChange&&t&&i.setFieldValue(t,void 0),c()});const u=e.immediate??!0;return r.onMounted(()=>{u&&c()}),{list:s,loading:o,error:a,loadDict:c,refresh:()=>c(),mutate:e=>{s.value=e}}},Hn=Symbol("FormContext");function Xn(){const e=r.inject(Hn);if(!e)throw new Error("useConfigContext must be used within a Form");return e}function Jn(e){const t=r.shallowRef({});return r.watchEffect(()=>{const r=e();((e,t)=>{const r=Object.keys(e),n=Object.keys(t);return r.length===n.length&&r.every(r=>e[r]===t[r])})(t.value,r)||(t.value=r)}),t}function Qn(e){return void 0!==e&&(!Array.isArray(e)||0!==e.length)}function Yn(e,t){if(!t)return!1;return(Array.isArray(t)?t:[t]).some(t=>function(e){return{onBlur:"blur",onChange:"change",onSubmit:"submit",blur:"blur",change:"change",submit:"submit"}[e]??"submit"}(t)===e)}const ei=e=>/[A-Z]/.test(e),ti=e=>e.includes("-"),ri=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase(),ni=e=>e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),ii=(e,t)=>{if(e[t])return e[t];const r=ei(t)?ri(t):ti(t)?ni(t):void 0;return r&&e[r]?e[r]:void 0},si=(e,t)=>{const r={},n=(i=String(e),(ti(i)?ni(i):i)+":");var i;const s=(e=>ei(e)?ri(e):e)(String(e))+":";for(const[o,a]of Object.entries(t))o.startsWith(n)?r[o.slice(n.length)]=a:o.startsWith(s)&&s!==n&&(r[o.slice(s.length)]=a);return r},oi=r.defineComponent((e,{slots:t})=>{const n=r.ref(Boolean(e.schema.defaultCollapsed)),i=()=>{e.schema.collapsible&&(n.value=!n.value)};return()=>{const s=e.schema,o=Boolean(s.collapsible);return r.createVNode("div",{class:c("schemx-group",{"schemx-group--collapsed":n.value},s.class),"data-key":s.key},[s.label&&r.createVNode("div",{role:o?"button":void 0,tabindex:o?0:void 0,class:c("schemx-group__header",{"schemx-group__header--clickable":o}),onClick:i,onKeydown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),i())}},[r.createVNode("span",{class:"schemx-group__title"},[s.label]),o&&r.createVNode("span",{class:c("schemx-group__arrow",{"schemx-group__arrow--down":!n.value})},null)]),!n.value&&r.createVNode("div",{class:"schemx-group__body"},[s.children.map(e=>r.createVNode(ai,{key:e.key,schema:e},t))])])}},{name:"SchemxGroup",props:{schema:{type:Object,required:!0}}}),ai=r.defineComponent((e,{slots:t})=>{const n=r.toRef(e,"schema");if(li(n.value))return()=>r.h(oi,{schema:n.value},t);const i=Wn(),s=Xn(),o=()=>n.value,a=qn(o().name);!function(e){r.provide(Un,e)}(a);const l=r.computed(()=>{return e=o().validationTrigger,t=s.validationTrigger,r="onChange",Qn(e)?e:Qn(t)?t:r;var e,t,r}),u=r.computed(()=>{const e=o().visible&&!o().readonly&&!o().disabled,t=o().rules,r=Array.isArray(t)?(null==t?void 0:t.length)>0:!!o().rules;return e&&r}),d=e=>{var t,r;a.setValue(e),null==(r=null==(t=o().componentProps)?void 0:t.onChange)||r.call(t,e),u.value&&Yn("change",l.value)&&a.validate()},f=()=>{u.value&&Yn("blur",l.value)&&a.validate()},h=Jn(()=>({...o().componentProps,value:a.getValue(),onChange:d,onBlur:f,"onUpdate:value":e=>a.setValue(e)})),p=()=>{const e=ii(t,`${o().name}Label`);if(e)return e(o());const n=o().labelAlign||s.labelAlign,i=o().labelWidth||s.labelWidth,a=o().colon??s.colon;return r.createVNode("label",{class:"schemx-item__label",style:{width:i,textAlign:n}},[!o().required||o().disabled||o().readonly?null:r.createVNode("span",{class:"schemx-item__required"},[r.createTextVNode("*")]),r.createVNode("span",{class:"schemx-item__label-text"},[o().label,a?":":""])])},y=()=>{const e=i.getRenderer(o().componentType);if(!e)throw new Error(`[schemx] Can not find component renderer of "${o().componentType}".`);const n=si(ci(o().name),t),s=r.h(e,h.value,n),a=ii(t,`${o().name}Content`);return a?a({...o(),columnElement:s}):r.createVNode("div",{class:"schemx-item__control"},[s])},v=()=>{const e=ii(t,`${o().name}Error`);return e?e({...o(),errors:a.error.value}):Array.isArray(a.error.value)&&0!==a.error.value.length?r.createVNode("div",{class:"schemx-item__error"},[a.error.value[0]]):null};return()=>{if(!o().visible)return null;const e=ii(t,ci(o().name));if(e)return e(o());const n=o().labelPosition||s.labelPosition;return r.createVNode("div",{class:c("schemx-item-wrapper")},[r.createVNode("div",{class:c("schemx-item",`schemx-item--label-${n}`,o().class,{"is-readonly":o().readonly,"is-disabled":o().disabled}),style:{...o().style??{}}},[p(),r.createVNode("div",{class:"schemx-item__content"},[y(),v()])])])}},{name:"SchemxItem",props:{schema:{type:Object,required:!0}}}),li=e=>"group"===e.componentType,ci=e=>Array.isArray(e)?e.map(e=>String(e)).join("."):String(e);function ui(e){return!(!e||"group"===e.componentType||"visible"in e&&!1===e.visible)}function di(e,t,r){for(let n=t+r;n>=0&&n<e.length;n+=r)if(ui(e[n]))return e[n]}const fi=r.defineComponent({name:"SchemxForm",__name:"form",props:{class:{default:""},style:{default:()=>({})},required:{type:Boolean},readonly:{type:Boolean},disabled:{type:Boolean},visible:{type:Boolean},labelIcon:{},labelAlign:{},labelPosition:{},labelWidth:{},contentAlign:{},validationTrigger:{},colon:{type:Boolean},modelValue:{default:()=>({})},initialValues:{default:()=>({})},schemas:{default:()=>[]},form:{default:void 0},rendererRegistry:{default:void 0},defaultRendererType:{},validatorRegistry:{default:void 0},onFinish:{type:Function,default:void 0},onFinishFailed:{type:Function,default:void 0},onValuesChange:{type:Function,default:void 0},onFieldsChange:{type:Function,default:void 0}},emits:["update:modelValue"],setup(e,{expose:t,emit:n}){const i=e,s=n;(e=>{r.provide(Hn,e)})(function(e,t){const r={...e};for(let n=0;n<t.length;n++)delete r[t[n]];return r}(i,["form","modelValue","rendererRegistry","defaultRendererType","validatorRegistry","onFinish","onFinishFailed","onValuesChange","onFieldsChange"]));const o=i.form?i.form:$n({schemas:i.schemas,initialValues:i.initialValues,rendererRegistry:i.rendererRegistry,defaultRendererType:i.defaultRendererType,validatorRegistry:i.validatorRegistry,readonly:i.readonly,disabled:i.disabled,onFinish:async e=>{var t;null==(t=i.onFinish)||t.call(i,e)},onFinishFailed:async e=>{var t;null==(t=i.onFinishFailed)||t.call(i,e)},onValuesChange:(e,t)=>{var r;s("update:modelValue",t),null==(r=i.onValuesChange)||r.call(i,e,t)},onFieldsChange:(e,t)=>{var r;null==(r=i.onFieldsChange)||r.call(i,e,t)}});r.watch(()=>i.schemas,e=>{o.setSchemas(e)},{deep:!1,immediate:!!i.form});const a=function(e){const t=r.shallowRef(e.getViewSchemas()),n=e.subscribeViewSchemas(e=>{t.value=e});return r.onScopeDispose(n),t}(o),l=e=>{const{isFirst:t,isLast:r}=function(e,t){const r=e.findIndex(e=>e.key===t);return-1===r?{found:!1,isFirst:!1,isLast:!1}:ui(e[r])?{found:!0,isFirst:!di(e,r,-1),isLast:!di(e,r,1)}:{found:!0,isFirst:!1,isLast:!1}}(a.value,e.key);return{"schemx-item-wrapper--first":t,"schemx-item-wrapper--last":r}};return r.watchEffect(()=>{o.updateDefaultProps(i)}),t({...o}),(e,t)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["schemx",i.class])},[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(r.unref(a),t=>(r.openBlock(),r.createBlock(r.unref(ai),{key:t.key,schema:t,class:r.normalizeClass(l(t))},r.createSlots({_:2},[r.renderList(e.$slots,(t,n)=>({name:n,fn:r.withCtx(t=>[r.renderSlot(e.$slots,n,r.mergeProps({ref_for:!0},t??{}))])}))]),1032,["schema","class"]))),128))],2))}});const hi=(pi=fi,yi={install(e,t){e.component("SchemxForm",fi)},FormItem:ai},Object.assign(pi,yi));var pi,yi;exports.ContextNotProvidedError=Vr,exports.FormGroup=oi,exports.FormItem=ai,exports.WithRemoteOptions=function(e){return r.defineComponent({name:`WithRemoteOptions(${e.name||"Anonymous"})`,inheritAttrs:!1,props:{dict:{type:Object,default:void 0},fieldName:{type:[String,Array],default:void 0}},setup(t,{attrs:n,slots:i}){const s=t.dict?Zn(t.dict,t.fieldName):null,o=r.computed(()=>({...n,dict:t.dict,options:t.dict?null==s?void 0:s.list.value:n.options,loading:t.dict?null==s?void 0:s.loading.value:n.loading}));return()=>r.h(e,o.value,i)}})},exports.collectObjectPathsByLeaf=He,exports.createContext=Pr,exports.createEffect=Cn,exports.createField=Rn,exports.createForm=Vn,exports.createLifecycle=en,exports.createLifecycleBus=Yr,exports.createRendererRegistry=ut,exports.createSchemas=Ur,exports.createValidator=rt,exports.createValidatorsRegistry=ft,exports.createWatch=Mn,exports.createWatchAll=In,exports.createWatchField=En,exports.createWatchFields=Tn,exports.default=hi,exports.getByPath=Ge,exports.isBaseResolvedSchema=function(e){return!je(e)&&!function(e){return"dependency"===e.componentType}(e)},exports.isBaseSchema=ke,exports.isContext=function(e){return Boolean(e&&"object"==typeof e&&Or in e&&!0===e[Or])},exports.isDependencySchema=Oe,exports.isGroupResolvedSchema=je,exports.isGroupSchema=Ae,exports.isSchemxSchemas=zr,exports.rendererRegistry=Bn,exports.schemxForm=hi,exports.setByPath=Ze,exports.useConfigContext=Xn,exports.useDictionary=Zn,exports.useEffect=function(e){const t=Cn(e);return r.onUnmounted(t),t},exports.useField=qn,exports.useFieldContext=function(){const e=r.inject(Un);if(!e)throw new Error("[schemx] useFieldContext() must be used inside a FormItem tree");return e},exports.useForm=$n,exports.useFormContext=Wn,exports.useWatch=Kn,exports.useWatchAll=function(e,t){return Kn(e,t)},exports.useWatchField=function(e,t,r){return Kn(e,t,r)},exports.useWatchFields=Ln,exports.validatorRegistry=Dn;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),t=require("classnames"),r=require("@schemx/core"),n=require("es-toolkit"),o=r.createRendererRegistry("input"),s=r.createValidatorsRegistry(),a=Symbol("SCHEMX_INSTANCE");function l(t={}){const{...n}=t,l={...n,rendererRegistry:n.rendererRegistry??o,validatorRegistry:n.validatorRegistry??s},i=e.computed(()=>r.createForm(l));return e.provide(a,i.value),e.onUnmounted(()=>{i.value.destroy()}),i.value}function i(){const t=e.inject(a);if(!t)throw new Error("useFormContext must be used within a Form");return t}const u=Symbol("schemx:field"),c=new WeakMap;const d=t=>{const n=i(),o=t;let s=c.get(n);s||(s=new Map,c.set(n,s));const a=s.get(o);let l;if(a)a.refCount++,l=a;else{const{result:a,dispose:i}=function(t,n){const o=r.createField(t,n),s=e.shallowRef(o.getValue()),a=e.shallowRef(o.getError()),l=e.shallowRef(o.isPending()),i=o.effect(()=>{s.value=o.getValue(),a.value=o.getError(),l.value=o.isPending()}),u=e.computed(()=>a.value),c=e.computed(()=>(s.value,o.isTouched())),d=e.computed(()=>l.value);return{result:{value:s,error:u,dirty:c,pending:d,...o,getValue:()=>s.value},dispose:i}}(n,t);l={refCount:1,result:a,dispose:i},s.set(o,l)}return e.onUnmounted(()=>{--l.refCount<=0&&(l.dispose(),s.delete(o))}),l.result};function m(t,n,o){const s=i(),a=r.createWatch(s,t,n,o);return e.onUnmounted(a),a}function p(e,t,r){return m(e,t,r)}function f(e){return e instanceof Error?e:new Error(String(e))}const h=(t,r)=>{var n;const o=i(),s=e.ref([]),a=e.ref(!1),l=e.ref(void 0);let u=0;const c=async()=>{try{const e=o.getFieldsValue();if("function"==typeof t.shouldFetch&&!t.shouldFetch(e))return s.value=[],void(a.value=!1);a.value=!0,l.value=void 0;const r=++u,n=await(async e=>{const r=t.retryCount??0,n=t.retryInterval??1e3;let s=new Error("Unknown error");for(let l=0;l<=r;l++)try{return await t.api(e,o)}catch(a){s=f(a),l<r&&await new Promise(e=>setTimeout(e,n))}throw s})(e);if(r!==u)return;const i=await(async e=>"function"==typeof(null==t?void 0:t.formatter)?await t.formatter(e,o):e)(n);if(r!==u)return;s.value=i,l.value=void 0,"function"==typeof t.onSuccess&&t.onSuccess(i,o),a.value=!1}catch(e){const r=f(e);l.value=r,s.value=[],a.value=!1,"function"==typeof t.onError&&t.onError(r,o)}};(null==(n=t.dependsOn)?void 0:n.length)&&p(t.dependsOn,(e,n)=>{"function"==typeof t.onDepsChange&&t.onDepsChange(n,o),t.resetOnDepsChange&&r&&o.setFieldValue(r,void 0),c()});const d=t.immediate??!0;return e.onMounted(()=>{d&&c()}),{list:s,loading:a,error:l,loadDict:c,refresh:()=>c(),mutate:e=>{s.value=e}}},v=Symbol("FormContext");function y(){const t=e.inject(v);if(!t)throw new Error("useConfigContext must be used within a Form");return t}function g(t){const r=e.shallowRef({});return e.watchEffect(()=>{const e=t();((e,t)=>{const r=Object.keys(e),n=Object.keys(t);return r.length===n.length&&r.every(r=>e[r]===t[r])})(r.value,e)||(r.value=e)}),r}function b(e){return void 0!==e&&(!Array.isArray(e)||0!==e.length)}function x(e,t){if(!t)return!1;return(Array.isArray(t)?t:[t]).some(t=>function(e){return{onBlur:"blur",onChange:"change",onSubmit:"submit",blur:"blur",change:"change",submit:"submit"}[e]??"submit"}(t)===e)}const F=e=>/[A-Z]/.test(e),w=e=>e.includes("-"),C=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase(),V=e=>e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),_=(e,t)=>{if(e[t])return e[t];const r=F(t)?C(t):w(t)?V(t):void 0;return r&&e[r]?e[r]:void 0},R=(e,t)=>{const r={},n=(o=String(e),(w(o)?V(o):o)+":");var o;const s=(e=>F(e)?C(e):e)(String(e))+":";for(const[a,l]of Object.entries(t))a.startsWith(n)?r[a.slice(n.length)]=l:a.startsWith(s)&&s!==n&&(r[a.slice(s.length)]=l);return r},S=e.defineComponent((r,{slots:n})=>{const o=e.ref(Boolean(r.schema.defaultCollapsed)),s=()=>{r.schema.collapsible&&(o.value=!o.value)};return()=>{const a=r.schema,l=Boolean(a.collapsible);return e.createVNode("div",{class:t("schemx-group",{"schemx-group--collapsed":o.value},a.class),"data-key":a.key},[a.label&&e.createVNode("div",{role:l?"button":void 0,tabindex:l?0:void 0,class:t("schemx-group__header",{"schemx-group__header--clickable":l}),onClick:s,onKeydown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),s())}},[e.createVNode("span",{class:"schemx-group__title"},[a.label]),l&&e.createVNode("span",{class:t("schemx-group__arrow",{"schemx-group__arrow--down":!o.value})},null)]),!o.value&&e.createVNode("div",{class:"schemx-group__body"},[a.children.map(t=>e.createVNode(k,{key:t.key,schema:t},n))])])}},{name:"SchemxGroup",props:{schema:{type:Object,required:!0}}}),k=e.defineComponent((r,{slots:n})=>{const o=e.toRef(r,"schema");if(E(o.value))return()=>e.h(S,{schema:o.value},n);const s=i(),a=y(),l=()=>o.value,c=d(l().name);!function(t){e.provide(u,t)}(c);const m=e.computed(()=>{return e=l().validationTrigger,t=a.validationTrigger,r="onChange",b(e)?e:b(t)?t:r;var e,t,r}),p=e.computed(()=>{const e=l().visible&&!l().readonly&&!l().disabled,t=l().rules,r=Array.isArray(t)?(null==t?void 0:t.length)>0:!!l().rules;return e&&r}),f=e=>{var t,r;c.setValue(e),null==(r=null==(t=l().componentProps)?void 0:t.onChange)||r.call(t,e),p.value&&x("change",m.value)&&c.validate()},h=()=>{p.value&&x("blur",m.value)&&c.validate()},v=g(()=>({...l().componentProps,value:c.getValue(),onChange:f,onBlur:h,"onUpdate:value":e=>c.setValue(e)})),F=()=>{const t=_(n,`${l().name}Label`);if(t)return t(l());const r=l().labelAlign||a.labelAlign,o=l().labelWidth||a.labelWidth,s=l().colon??a.colon;return e.createVNode("label",{class:"schemx-item__label",style:{width:o,textAlign:r}},[!l().required||l().disabled||l().readonly?null:e.createVNode("span",{class:"schemx-item__required"},[e.createTextVNode("*")]),e.createVNode("span",{class:"schemx-item__label-text"},[l().label,s?":":""])])},w=()=>{const t=s.getRenderer(l().componentType);if(!t)throw new Error(`[schemx] Can not find component renderer of "${l().componentType}".`);const r=R(A(l().name),n),o=e.h(t,v.value,r),a=_(n,`${l().name}Content`);return a?a({...l(),columnElement:o}):e.createVNode("div",{class:"schemx-item__control"},[o])},C=()=>{const t=_(n,`${l().name}Error`);return t?t({...l(),errors:c.error.value}):Array.isArray(c.error.value)&&0!==c.error.value.length?e.createVNode("div",{class:"schemx-item__error"},[c.error.value[0]]):null};return()=>{if(!l().visible)return null;const r=_(n,A(l().name));if(r)return r(l());const o=l().labelPosition||a.labelPosition;return e.createVNode("div",{class:t("schemx-item-wrapper")},[e.createVNode("div",{class:t("schemx-item",`schemx-item--label-${o}`,l().class,{"is-readonly":l().readonly,"is-disabled":l().disabled}),style:{...l().style??{}}},[F(),e.createVNode("div",{class:"schemx-item__content"},[w(),C()])])])}},{name:"SchemxItem",props:{schema:{type:Object,required:!0}}}),E=e=>"group"===e.componentType,A=e=>Array.isArray(e)?e.map(e=>String(e)).join("."):String(e);function N(e){return!(!e||"group"===e.componentType||"visible"in e&&!1===e.visible)}function O(e,t,r){for(let n=t+r;n>=0&&n<e.length;n+=r)if(N(e[n]))return e[n]}const T=e.defineComponent({name:"SchemxForm",__name:"form",props:{class:{default:""},style:{default:()=>({})},required:{type:Boolean},readonly:{type:Boolean},disabled:{type:Boolean},visible:{type:Boolean},labelIcon:{},labelAlign:{},labelPosition:{},labelWidth:{},contentAlign:{},validationTrigger:{},colon:{type:Boolean},modelValue:{default:()=>({})},initialValues:{default:()=>({})},schemas:{default:()=>[]},form:{default:void 0},rendererRegistry:{default:void 0},defaultRendererType:{},validatorRegistry:{default:void 0},onFinish:{type:Function,default:void 0},onFinishFailed:{type:Function,default:void 0},onValuesChange:{type:Function,default:void 0},onFieldsChange:{type:Function,default:void 0}},emits:["update:modelValue"],setup(t,{expose:r,emit:o}){const s=t,a=o;(t=>{e.provide(v,t)})(n.omit(s,["form","modelValue","rendererRegistry","defaultRendererType","validatorRegistry","onFinish","onFinishFailed","onValuesChange","onFieldsChange"]));const i=s.form?s.form:l({schemas:s.schemas,initialValues:s.initialValues,rendererRegistry:s.rendererRegistry,defaultRendererType:s.defaultRendererType,validatorRegistry:s.validatorRegistry,readonly:s.readonly,disabled:s.disabled,onFinish:async e=>{var t;null==(t=s.onFinish)||t.call(s,e)},onFinishFailed:async e=>{var t;null==(t=s.onFinishFailed)||t.call(s,e)},onValuesChange:(e,t)=>{var r;a("update:modelValue",t),null==(r=s.onValuesChange)||r.call(s,e,t)},onFieldsChange:(e,t)=>{var r;null==(r=s.onFieldsChange)||r.call(s,e,t)}});e.watch(()=>s.schemas,e=>{i.setSchemas(e)},{deep:!1,immediate:!!s.form});const u=function(t){const r=e.shallowRef(t.getViewSchemas()),n=t.subscribeViewSchemas(e=>{r.value=e});return e.onScopeDispose(n),r}(i),c=e=>{const{isFirst:t,isLast:r}=function(e,t){const r=e.findIndex(e=>e.key===t);return-1===r?{found:!1,isFirst:!1,isLast:!1}:N(e[r])?{found:!0,isFirst:!O(e,r,-1),isLast:!O(e,r,1)}:{found:!0,isFirst:!1,isLast:!1}}(u.value,e.key);return{"schemx-item-wrapper--first":t,"schemx-item-wrapper--last":r}};return e.watchEffect(()=>{i.updateDefaultProps(s)}),r({...i}),(t,r)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["schemx",s.class])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(u),r=>(e.openBlock(),e.createBlock(e.unref(k),{key:r.key,schema:r,class:e.normalizeClass(c(r))},e.createSlots({_:2},[e.renderList(t.$slots,(r,n)=>({name:n,fn:e.withCtx(r=>[e.renderSlot(t.$slots,n,e.mergeProps({ref_for:!0},r??{}))])}))]),1032,["schema","class"]))),128))],2))}});const j=(B=T,P={install(e,t){e.component("SchemxForm",T)},FormItem:k},Object.assign(B,P));var B,P;exports.FormGroup=S,exports.FormItem=k,exports.WithRemoteOptions=function(t){return e.defineComponent({name:`WithRemoteOptions(${t.name||"Anonymous"})`,inheritAttrs:!1,props:{dict:{type:Object,default:void 0},fieldName:{type:[String,Array],default:void 0}},setup(r,{attrs:n,slots:o}){const s=r.dict?h(r.dict,r.fieldName):null,a=e.computed(()=>({...n,dict:r.dict,options:r.dict?null==s?void 0:s.list.value:n.options,loading:r.dict?null==s?void 0:s.loading.value:n.loading}));return()=>e.h(t,a.value,o)}})},exports.default=j,exports.rendererRegistry=o,exports.schemxForm=j,exports.useConfigContext=y,exports.useDictionary=h,exports.useEffect=function(t){const n=r.createEffect(t);return e.onUnmounted(n),n},exports.useField=d,exports.useFieldContext=function(){const t=e.inject(u);if(!t)throw new Error("[schemx] useFieldContext() must be used inside a FormItem tree");return t},exports.useForm=l,exports.useFormContext=i,exports.useWatch=m,exports.useWatchAll=function(e,t){return m(e,t)},exports.useWatchField=function(e,t,r){return m(e,t,r)},exports.useWatchFields=p,exports.validatorRegistry=s,Object.keys(r).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})});
7
2
  //# sourceMappingURL=index.cjs.map