@tempots/beatui 0.78.0 → 0.78.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.cjs.js +1 -1
- package/dist/auth/index.es.js +3 -3
- package/dist/{deep-merge-Cjm-tFVT.js → deep-merge-Bsqkvp9-.js} +2 -2
- package/dist/{deep-merge-BoJqJNah.cjs → deep-merge-cQgRrtGF.cjs} +1 -1
- package/dist/{duration-input-DfdE7_V9.js → duration-input-DcZf0Dyd.js} +2 -2
- package/dist/{duration-input-COTlyMwv.cjs → duration-input-Dt6riwzu.cjs} +1 -1
- package/dist/hls.light.min-Bhrf47iR.cjs +27 -0
- package/dist/{hls.light.min-BHW1Af0w.js → hls.light.min-C6VwviEa.js} +1095 -1087
- package/dist/{index-ByWYsYVI.cjs → index-BGwNJNop.cjs} +19 -19
- package/dist/{index-DKl26ILa.js → index-CCMjK4fD.js} +1 -1
- package/dist/{index-D5kPtj3r.cjs → index-CdVc1Y2V.cjs} +1 -1
- package/dist/{index-BSl-AmDV.js → index-Dbu1ZPpw.js} +1095 -1044
- package/dist/{index-wPyoqxuj.js → index-DiEcd7ZV.js} +2 -6
- package/dist/{index-Ck1DAzZ9.js → index-mPVib4v9.js} +1 -1
- package/dist/index.cjs.js +2 -2
- package/dist/index.es.js +12 -12
- package/dist/index.esm-C6lZ02yY.cjs +1 -0
- package/dist/{index.esm-DPNh6inz.js → index.esm-ChUrm4xR.js} +80 -80
- package/dist/json-schema/index.cjs.js +8 -8
- package/dist/json-schema/index.es.js +3969 -3922
- package/dist/json-structure/index.cjs.js +1 -1
- package/dist/json-structure/index.es.js +3 -3
- package/dist/markdown/index.es.js +1 -1
- package/dist/{modal-CwDATZfz.cjs → modal-D3NQ6ZgO.cjs} +1 -1
- package/dist/{modal-CkcwBTk2.js → modal-oWbT46Rc.js} +1 -1
- package/dist/{notice-CQ1Vx-z1.js → notice-C0Brmeyi.js} +1 -1
- package/dist/{notice-Bs90dF7k.cjs → notice-DYBLXglS.cjs} +1 -1
- package/dist/prosemirror/index.cjs.js +1 -1
- package/dist/prosemirror/index.es.js +1 -1
- package/dist/{use-form-D3EXhCfe.js → use-form-DMiCxK26.js} +2 -2
- package/dist/{use-form-C5eF9ALX.cjs → use-form-pSErMD6z.cjs} +1 -1
- package/dist/{widget-customization-Czt9chmX.cjs → widget-customization-WNWmH_gX.cjs} +1 -1
- package/dist/{widget-customization-BB1gYtwq.js → widget-customization-nxbAoCx5.js} +3 -3
- package/package.json +5 -5
- package/dist/hls.light.min-D3hUMpII.cjs +0 -27
- package/dist/index.esm-DJRz9AE-.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../deep-merge-BoJqJNah.cjs"),l=require("@tempots/dom"),d=require("../use-form-C5eF9ALX.cjs"),P=require("../translations-eUtMHN9s.cjs"),C=require("../duration-input-COTlyMwv.cjs"),Ke=require("../colors-B2yrgHSW.cjs");function le(e){return e==="int64"||e==="int128"||e==="uint64"||e==="uint128"}function q(e){return e==="int8"||e==="int16"||e==="int32"||e==="int64"||e==="int128"||e==="uint8"||e==="uint16"||e==="uint32"||e==="uint64"||e==="uint128"}function U(e){return e==="float"||e==="double"||e==="decimal"}function ce(e){return q(e)||U(e)}function W(e){return e==="date"||e==="datetime"||e==="time"||e==="duration"}function pe(e){return e==="string"||e==="boolean"||e==="null"||ce(e)||W(e)||e==="uuid"||e==="uri"||e==="binary"}function Ze(e){return e==="object"||e==="array"||e==="set"||e==="map"||e==="tuple"||e==="choice"||e==="any"}function D(e){return typeof e=="object"&&e!==null&&"$ref"in e}function de(e){return typeof e=="object"&&e!==null&&!("type"in e)&&!("$ref"in e)&&!("enum"in e)&&!("const"in e)}function fe(e){return typeof e=="object"&&e!==null&&("type"in e||"$ref"in e||"enum"in e||"const"in e)}function M(e){return e.type==="object"&&"properties"in e}function Z(e){return e.type==="array"&&"items"in e}function H(e){return e.type==="set"&&"items"in e}function X(e){return e.type==="map"&&"values"in e}function Y(e){return e.type==="tuple"&&"tuple"in e}function Q(e){return e.type==="choice"&&"choices"in e}function me(e){return"enum"in e&&Array.isArray(e.enum)}function ye(e){return"const"in e}function J(e){return e===void 0?null:typeof e=="string"||Array.isArray(e)?e:(D(e),null)}function ge(e){return e===void 0?!1:e==="null"?!0:Array.isArray(e)?e.includes("null"):!1}function B(e){return typeof e=="string"?e==="null"?[]:[e]:Array.isArray(e)?e.filter(t=>t!=="null"):[]}const V={int8:{min:-128n,max:127n},int16:{min:-32768n,max:32767n},int32:{min:-2147483648n,max:2147483647n},int64:{min:-9223372036854775808n,max:9223372036854775807n},int128:{min:-170141183460469231731687303715884105728n,max:170141183460469231731687303715884105727n},uint8:{min:0n,max:255n},uint16:{min:0n,max:65535n},uint32:{min:0n,max:4294967295n},uint64:{min:0n,max:18446744073709551615n},uint128:{min:0n,max:340282366920938463463374607431768211455n}};function he(e){return e.startsWith("#/")?e.slice(2).split("/"):e.includes("/")?e.split("/"):["definitions",e]}function He(e,t){let r=e;for(const n of t){if(r==null||typeof r!="object")return;r=r[n]}return r}function R(e,t){const r=he(e),n=He(t,r);if(n==null){console.warn(`Failed to resolve $ref: ${e}`);return}if(fe(n))return n;if(de(n)){console.warn(`$ref "${e}" points to a namespace, not a type definition`);return}}function Xe(e,t){return R(e.$ref,t)}class be{schema;visited=new Set;constructor(t){this.schema=t}resolve(t){if(this.visited.has(t)){console.warn(`Circular reference detected: ${t}`);return}this.visited.add(t);try{const r=R(t,this.schema);if(r?.type&&D(r.type)){const n=this.resolve(r.type.$ref);if(n){const{type:s,...a}=r;return{...n,...a}}}return r}finally{this.visited.delete(t)}}resolveDefinition(t){if(t.type&&D(t.type)){const r=this.resolve(t.type.$ref);if(r){const{type:n,...s}=t;return{...r,...s}}}return t}reset(){this.visited.clear()}}function _(e){return new be(e)}class z{schema;definition;path;readOnly;locale;widgetRegistry;isPropertyRequired;suppressLabel;refResolver;constructor(t){this.schema=t.schema,this.definition=t.definition,this.path=t.path,this.readOnly=t.readOnly??!1,this.locale=t.locale,this.widgetRegistry=t.widgetRegistry,this.isPropertyRequired=t.isPropertyRequired??!1,this.suppressLabel=t.suppressLabel??!1,this.refResolver=t.refResolver??_(t.schema)}with(t){return new z({schema:this.schema,definition:t.definition??this.definition,path:t.path??this.path,readOnly:t.readOnly??this.readOnly,locale:t.locale??this.locale,widgetRegistry:t.widgetRegistry??this.widgetRegistry,isPropertyRequired:t.isPropertyRequired??this.isPropertyRequired,suppressLabel:t.suppressLabel??this.suppressLabel,refResolver:this.refResolver})}append(t){return this.with({path:[...this.path,t]})}get isRoot(){return this.path.length===0}get name(){const t=this.path[this.path.length-1];return typeof t=="string"?t:void 0}get widgetName(){return this.path.map(String).join(".")}get resolvedType(){const t=this.definition.type;if(!t)return null;if(D(t)){const r=this.refResolver.resolve(t.$ref);return r?.type?J(r.type):null}return J(t)}get primaryType(){const t=this.resolvedType;return t?typeof t=="string"?t==="null"?null:t:B(t)[0]??null:null}get isNullable(){return ge(this.definition.type)}get isRequired(){return this.isPropertyRequired}get isOptional(){return!this.isPropertyRequired}get isDeprecated(){return this.definition.deprecated===!0}get isAbstract(){return this.definition.abstract===!0}get isPrimitive(){const t=this.primaryType;return t!=null&&pe(t)}get description(){return this.definition.description}get examples(){return this.definition.examples}get defaultValue(){return this.definition.default}get unit(){return this.definition.unit}get currency(){return this.definition.currency}get label(){if(this.locale&&this.definition.altnames){const r=`lang:${this.locale}`,n=this.definition.altnames[r];if(n)return n}if(this.definition.name)return this.definition.name;const t=this.name;return t?h._t(h.gt(t)):""}get altnames(){return this.definition.altnames}get jsonPath(){return this.path.length===0?"":"/"+this.path.map(String).join("/")}resolveRef(t){return this.refResolver.resolve(t)}get hasEnum(){return"enum"in this.definition&&Array.isArray(this.definition.enum)}get enumValues(){if("enum"in this.definition)return this.definition.enum}get hasConst(){return"const"in this.definition}get constValue(){if("const"in this.definition)return this.definition.const}get format(){if("format"in this.definition)return this.definition.format}}function ve(e,t){let r;const n=_(e);if(e.$root){const s=n.resolve(e.$root);s?r=s:(console.warn(`Failed to resolve $root: ${e.$root}`),r=e)}else e.type||e.properties?r=e:r={type:"any"};return new z({schema:e,definition:r,path:[],readOnly:t?.readOnly,locale:t?.locale,widgetRegistry:t?.widgetRegistry,refResolver:n})}function ee(e,t,r){const n=[],s=[];if(!e.$extends)return{merged:e,inheritanceChain:n,errors:s};const a=Array.isArray(e.$extends)?e.$extends:[e.$extends],u=new Set,i=(p,y=0)=>{if(y>100)return s.push({path:p.join(" -> "),message:"Maximum inheritance depth exceeded"}),[];const b=[];for(const m of p){if(u.has(m)){s.push({path:m,message:`Circular inheritance detected: ${m}`});continue}u.add(m),n.push(m);const g=R(m,t);if(!g){s.push({path:m,message:`Failed to resolve base type: ${m}`});continue}if(g.$extends){const f=Array.isArray(g.$extends)?g.$extends:[g.$extends],v=i(f,y+1);b.push(...v)}b.push(g),u.delete(m)}return b},o=i(a);return{merged:Ye(o,e),inheritanceChain:n,errors:s}}function Ye(e,t){if(e.length===0)return t;let r={...e[0]};for(let a=1;a<e.length;a++)r=ie(r,e[a]);r=ie(r,t);const{$extends:n,...s}=r;return s}function ie(e,t){return M(e)&&M(t)?Qe(e,t):{...e,...t}}function Qe(e,t){const r={...e.properties??{},...t.properties??{}},n=se(e.required),s=se(t.required),a=et([...n,...s]),u={...e,...t,type:"object",properties:r};return a.length>0&&(u.required=a),u}function se(e){return e?e.length===0?[]:Array.isArray(e[0])?e.flat():e:[]}function et(e){return[...new Set(e)]}function tt(e){const t=_(e);return{resolve:r=>(t.reset(),ee(r,e))}}function rt(){return l.html.span(l.attr.class("bc-json-structure-deprecated-badge"),l.attr.style("font-size: var(--font-size-xs); color: var(--color-warning-500, #d97706); background: var(--color-warning-100, #fef3c7); padding: 0.125em 0.5em; border-radius: var(--radius-sm); margin-inline-start: 0.5em; font-weight: normal;"),"(deprecated)")}function I(e,t){return!e||!t?e??"":l.html.span(e,rt())}function nt(e){const t=e.examples?.[0]!=null?String(e.examples[0]):void 0;return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated,placeholder:t}}function xe({ctx:e,controller:t}){const r=nt(e);return d.Control(P.TextInput,{...r,controller:h.transformEmptyStringToUndefined(t)})}function it(e){return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated}}function $e({ctx:e,controller:t}){const r=it(e),n=d.Control(d.CheckboxInput,{...r,controller:t});return e.isNullable?d.Control(d.CheckboxInput,{...r,controller:t,after:h.NullableResetAfter(t.signal,t.disabled,s=>t.change(s))}):n}function st(e,t){const r=V[t],n=Te(e,r.min),s=Ie(e,r.max),a=e.examples?.[0]!=null?String(e.examples[0]):void 0;return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated,min:typeof n=="bigint"?Number(n):n,max:typeof s=="bigint"?Number(s):s,step:1,placeholder:a}}function at(e,t){const r=V[t],n=Te(e,r.min),s=Ie(e,r.max),a=e.examples?.[0]!=null?String(e.examples[0]):void 0;return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated,min:typeof n=="number"?BigInt(n):n,max:typeof s=="number"?BigInt(s):s,placeholder:a}}function Te(e,t){const r=e.definition;if(r.minimum!==void 0){const n=typeof r.minimum=="string"?BigInt(r.minimum):r.minimum;return typeof n=="bigint"?n>t?n:t:BigInt(n)>t?n:Number(t)}if(r.exclusiveMinimum!==void 0){const n=typeof r.exclusiveMinimum=="string"?BigInt(r.exclusiveMinimum):r.exclusiveMinimum,s=typeof n=="bigint"?n+1n:n+1;return typeof s=="bigint"?s>t?s:t:BigInt(s)>t?s:Number(t)}return t>=BigInt(Number.MIN_SAFE_INTEGER)&&t<=BigInt(Number.MAX_SAFE_INTEGER)?Number(t):t}function Ie(e,t){const r=e.definition;if(r.maximum!==void 0){const n=typeof r.maximum=="string"?BigInt(r.maximum):r.maximum;return typeof n=="bigint"?n<t?n:t:BigInt(n)<t?n:Number(t)}if(r.exclusiveMaximum!==void 0){const n=typeof r.exclusiveMaximum=="string"?BigInt(r.exclusiveMaximum):r.exclusiveMaximum,s=typeof n=="bigint"?n-1n:n-1;return typeof s=="bigint"?s<t?s:t:BigInt(s)<t?s:Number(t)}return t>=BigInt(Number.MIN_SAFE_INTEGER)&&t<=BigInt(Number.MAX_SAFE_INTEGER)?Number(t):t}function Ce({ctx:e,controller:t,intType:r}){if(le(r)){const s=at(e,r);return e.isNullable?d.Control(C.NullableBigintInput,{...s,controller:t}):d.Control(C.BigintInput,{...s,controller:t})}const n=st(e,r);return e.isNullable?d.Control(h.NullableNumberInput,{...n,controller:t}):d.Control(h.NumberInput,{...n,controller:t})}function ut(e,t){const r=e.definition;let n;r.multipleOf!==void 0?n=r.multipleOf:t==="decimal"&&r.scale!==void 0?n=Math.pow(10,-r.scale):n=void 0;const s=r.minimum!==void 0?typeof r.minimum=="string"?parseFloat(r.minimum):r.minimum:void 0,a=r.maximum!==void 0?typeof r.maximum=="string"?parseFloat(r.maximum):r.maximum:void 0,u=r.exclusiveMinimum!==void 0?typeof r.exclusiveMinimum=="string"?parseFloat(r.exclusiveMinimum):r.exclusiveMinimum:void 0,i=r.exclusiveMaximum!==void 0?typeof r.exclusiveMaximum=="string"?parseFloat(r.exclusiveMaximum):r.exclusiveMaximum:void 0;let o=e.description;if(u!==void 0||i!==void 0){const p=[];u!==void 0&&p.push(`> ${u}`),i!==void 0&&p.push(`< ${i}`);const y=`Valid range: ${p.join(" and ")}`;o=o?`${o} (${y})`:y}const c=e.examples?.[0]!=null?String(e.examples[0]):void 0;return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:o,required:e.isRequired,disabled:e.readOnly||e.isDeprecated,min:s??u,max:a??i,step:n,placeholder:c}}function je({ctx:e,controller:t,floatType:r}){const n=ut(e,r);return e.isNullable?d.Control(h.NullableNumberInput,{...n,controller:t}):d.Control(h.NumberInput,{...n,controller:t})}function ot(e){return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated,placeholder:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}}function we({ctx:e,controller:t}){const r=ot(e);return d.Control(h.UUIDInput,{...r,controller:h.transformEmptyStringToUndefined(t)})}function lt(e){return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated}}function Se({ctx:e,controller:t,temporalType:r}){const n=lt(e);switch(r){case"date":return e.isNullable?d.Control(C.NullablePlainDateInput,{...n,controller:t}):d.Control(C.PlainDateInput,{...n,controller:t});case"datetime":return e.isNullable?d.Control(C.NullablePlainDateTimeInput,{...n,controller:t}):d.Control(C.PlainDateTimeInput,{...n,controller:t});case"time":return e.isNullable?d.Control(C.NullablePlainTimeInput,{...n,controller:t}):d.Control(C.PlainTimeInput,{...n,controller:t});case"duration":return e.isNullable?d.Control(h.NullableDurationInput,{...n,controller:t}):d.Control(C.DurationInput,{...n,controller:t});default:return console.warn(`Unknown temporal type: ${r}`),l.Fragment()}}function ct(e){return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated,placeholder:"https://example.com"}}function De({ctx:e,controller:t}){const r=ct(e);return d.Control(h.UrlInput,{...r,controller:h.transformEmptyStringToUndefined(t)})}function pt(e){return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated}}function Oe({ctx:e,controller:t}){const r=pt(e);return d.Control(C.FileInput,{...r,controller:t})}function dt(e){return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated,placeholder:"Enter JSON value"}}function ft(e){return e.transform(t=>t===void 0?void 0:JSON.stringify(t,null,2),t=>{if(!(t===void 0||t.trim()===""))try{return JSON.parse(t)}catch{return t}})}function K({ctx:e,controller:t}){const r=dt(e);return d.Control(h.TextArea,{...r,controller:ft(t)})}function mt(e){return{label:e.suppressLabel?void 0:e.label,description:e.description,required:e.isRequired}}function yt(e,t){return!t||t.length===0?!1:typeof t[0]=="string"?t.includes(e):Array.isArray(t[0])?t.some(r=>r.includes(e)):!1}function gt(e){if(e.default!==void 0)return e.default;if(e.examples&&e.examples.length>0)return e.examples[0];if(!e.type)return;const t=Array.isArray(e.type)?e.type[0]:e.type;if(!(typeof t=="object"&&"$ref"in t))switch(t){case"string":return"";case"boolean":return!1;case"null":return null;case"object":return{};case"array":case"set":return[];case"map":return{};case"any":return;default:return t==="int8"||t==="int16"||t==="int32"||t==="int64"||t==="uint8"||t==="uint16"||t==="uint32"||t==="uint64"||t==="float"||t==="double"||t==="decimal"?0:void 0}}function ht(e,t="property"){if(!e.has(t))return t;let r=1;for(;e.has(`${t}${r}`);)r++;return`${t}${r}`}function Ae({ctx:e,controller:t}){const r=e.definition;return r.type!=="object"||!("properties"in r)?(console.warn("StructureObjectControl requires an ObjectTypeDefinition"),l.html.div("Invalid object definition")):l.MapSignal(t.signal,n=>{const s=r.properties,a=r.required,u=r.additionalProperties,i=u!==!1,o=typeof u=="object"&&u!==null?u:{type:"any"},c=r.minProperties??0,p=r.maxProperties??1/0,y=Ke.l(s),b=new Set(y.map(([x])=>x)),m=Object.keys(n??{}),g=m.filter(x=>!b.has(x)),f=i&&m.length<p&&!e.readOnly,v=m.length>c&&!e.readOnly,$=y.map(([x,A])=>{const S=x,G=t.field(S),Je=yt(S,a);return T({ctx:e.with({definition:A,isPropertyRequired:Je,suppressLabel:!1}).append(S),controller:G})}),j=g.map(x=>{const A=t.field(x);return l.html.div(l.attr.class("bc-json-structure-additional-property"),l.html.div(l.attr.class("bc-json-structure-additional-property-header"),l.html.strong(`${x}:`),P.Button({variant:"text",size:"xs",onClick:()=>{const S={...l.Value.get(t.signal)??{}};delete S[x],t.change(S)},disabled:!v},"Remove")),l.html.div(l.attr.class("bc-json-structure-additional-property-value"),T({ctx:e.with({definition:o,isPropertyRequired:!1,suppressLabel:!0}).append(x),controller:A})))}),N=f?P.Button({variant:"outline",size:"sm",onClick:()=>{const x=l.Value.get(t.signal)??{},A=new Set(Object.keys(x)),S=ht(A),G=gt(o);t.change({...x,[S]:G})}},"Add Property"):null,O=l.html.div(l.attr.class("bc-json-structure-object-fields"),...$,...j,N),k=l.html.div(l.attr.class("bc-json-structure-object"),O);return!e.suppressLabel&&e.name?d.InputWrapper({...mt(e),content:k}):k})}function bt(e){return{label:e.suppressLabel?void 0:e.label,description:e.description,required:e.isRequired}}function vt(e){if(e.default!==void 0)return e.default;if(e.examples&&e.examples.length>0)return e.examples[0];if(!e.type)return;const t=Array.isArray(e.type)?e.type[0]:e.type;if(!(typeof t=="object"&&"$ref"in t))switch(t){case"string":return"";case"boolean":return!1;case"null":return null;case"object":return{};case"array":case"set":return[];case"map":return{};case"any":return;default:return t==="int8"||t==="int16"||t==="int32"||t==="int64"||t==="int128"||t==="uint8"||t==="uint16"||t==="uint32"||t==="uint64"||t==="uint128"||t==="float"||t==="double"||t==="decimal"?0:void 0}}function Me({ctx:e,controller:t}){const r=e.definition;if(r.type!=="array"||!("items"in r))return console.warn("StructureArrayControl requires an ArrayTypeDefinition"),l.html.div("Invalid array definition");const n=r.items,s=r.minItems??0,a=r.maxItems??1/0,u=l.computedOf(t.signal)(o=>(o?.length??0)<a),i=l.computedOf(t.signal)(o=>(o?.length??0)>s);return h.ListControl({...bt(e),controller:t,createItem:()=>vt(n),showAdd:!0,addDisabled:l.computedOf(u)(o=>!o||e.readOnly),showRemove:!0,removeDisabled:l.computedOf(i)(o=>!o||e.readOnly),element:o=>{const c=o.position.index,p=o.item;return T({ctx:e.with({definition:n,suppressLabel:!0}).append(c),controller:p})}})}function xt(e){return{label:e.suppressLabel?void 0:e.label,description:e.description,required:e.isRequired}}function $t(e){if(e.default!==void 0)return e.default;if(e.examples&&e.examples.length>0)return e.examples[0];if(!e.type)return;const t=Array.isArray(e.type)?e.type[0]:e.type;if(!(typeof t=="object"&&"$ref"in t))switch(t){case"string":return"";case"boolean":return!1;case"null":return null;case"object":return{};case"array":case"set":return[];case"map":return{};case"any":return;default:return t==="int8"||t==="int16"||t==="int32"||t==="int64"||t==="int128"||t==="uint8"||t==="uint16"||t==="uint32"||t==="uint64"||t==="uint128"||t==="float"||t==="double"||t==="decimal"?0:void 0}}function Re({ctx:e,controller:t}){const r=e.definition;if(r.type!=="set"||!("items"in r))return console.warn("StructureSetControl requires a SetTypeDefinition"),l.html.div("Invalid set definition");const n=r.items,s=r.minItems??0,a=r.maxItems??1/0,u=l.computedOf(t.signal)(c=>(c?.length??0)<a),i=l.computedOf(t.signal)(c=>(c?.length??0)>s),o=l.computedOf(t.signal)(c=>{if(!c||c.length===0)return new Set;const p=new Map,y=new Set;for(let b=0;b<c.length;b++){const m=JSON.stringify(c[b]);p.has(m)?(y.add(p.get(m)),y.add(b)):p.set(m,b)}return y});return h.ListControl({...xt(e),controller:t,createItem:()=>$t(n),showAdd:!0,addDisabled:l.computedOf(u)(c=>!c||e.readOnly),showRemove:!0,removeDisabled:l.computedOf(i)(c=>!c||e.readOnly),element:c=>{const p=c.position.index,y=c.item,b=o.map(g=>g.has(p)),m=T({ctx:e.with({definition:n,suppressLabel:!0}).append(p),controller:y});return b.map(g=>g?d.Stack(l.attr.class("bc-stack--gap-1"),m,d.Label(l.attr.class("bc-json-structure-set-error"),"⚠️ Duplicate value - sets must contain unique items")):m)}})}function Tt(e){return{label:e.suppressLabel?void 0:e.label,description:e.description,required:e.isRequired}}function It(e){if(e.default!==void 0)return e.default;if(e.examples&&e.examples.length>0)return e.examples[0];if(!e.type)return;const t=Array.isArray(e.type)?e.type[0]:e.type;if(!(typeof t=="object"&&"$ref"in t))switch(t){case"string":return"";case"boolean":return!1;case"null":return null;case"object":return{};case"array":case"set":return[];case"map":return{};case"any":return;default:return t==="int8"||t==="int16"||t==="int32"||t==="int64"||t==="int128"||t==="uint8"||t==="uint16"||t==="uint32"||t==="uint64"||t==="uint128"||t==="float"||t==="double"||t==="decimal"?0:void 0}}function Ct(e,t="key"){if(!e.has(t))return t;let r=1;for(;e.has(`${t}${r}`);)r++;return`${t}${r}`}function Ne({ctx:e,controller:t}){const r=e.definition;if(r.type!=="map"||!("values"in r))return console.warn("StructureMapControl requires a MapTypeDefinition"),l.html.div("Invalid map definition");const n=r.values,s=r.minProperties??0,a=r.maxProperties??1/0;return l.MapSignal(t.signal,u=>{const i=Object.keys(u??{}),o=i.length,c=o<a&&!e.readOnly,p=o>s&&!e.readOnly,y=i.map(f=>{const v=t.field(f);return l.html.div(l.attr.class("bc-json-structure-map-entry"),l.html.div(l.attr.class("bc-json-structure-map-entry-header"),l.html.strong(l.attr.class("bc-json-structure-map-entry-key"),`${f}:`),P.Button({variant:"text",size:"xs",onClick:()=>{const $={...l.Value.get(t.signal)??{}};delete $[f],t.change($)},disabled:!p},"Remove")),l.html.div(l.attr.class("bc-json-structure-map-entry-value"),T({ctx:e.with({definition:n,suppressLabel:!0}).append(f),controller:v})))}),b=c?P.Button({variant:"outline",size:"sm",onClick:()=>{const f=l.Value.get(t.signal)??{},v=new Set(Object.keys(f)),$=Ct(v),j=It(n);t.change({...f,[$]:j})}},"Add Entry"):null,m=l.html.div(l.attr.class("bc-json-structure-map-entries"),...y,b),g=l.html.div(l.attr.class("bc-json-structure-map"),m);return!e.suppressLabel&&e.name?d.InputWrapper({...Tt(e),content:g}):g})}function jt(e){return{label:e.suppressLabel?void 0:e.label,description:e.description,required:e.isRequired}}function wt(e){if(e.default!==void 0)return e.default;if(e.examples&&e.examples.length>0)return e.examples[0];if(!e.type)return;const t=Array.isArray(e.type)?e.type[0]:e.type;if(!(typeof t=="object"&&"$ref"in t))switch(t){case"string":return"";case"boolean":return!1;case"null":return null;case"object":return{};case"array":case"set":return[];case"map":return{};case"any":return;default:return t==="int8"||t==="int16"||t==="int32"||t==="int64"||t==="int128"||t==="uint8"||t==="uint16"||t==="uint32"||t==="uint64"||t==="uint128"||t==="float"||t==="double"||t==="decimal"?0:void 0}}function ke({ctx:e,controller:t}){const r=e.definition;if(r.type!=="tuple"||!("tuple"in r)||!("properties"in r))return console.warn("StructureTupleControl requires a TupleTypeDefinition"),l.html.div("Invalid tuple definition");const n=r.tuple,s=r.properties,a=t.signal.value;if(!Array.isArray(a)||a.length!==n.length){const i=n.map(o=>{const c=s[o];return c?wt(c):void 0});t.change(i)}const u=jt(e);return l.html.div(l.attr.class("bc-json-structure-tuple"),u.label&&l.html.label(l.attr.class("bc-json-structure-tuple-label"),u.label,u.required&&l.html.span(l.attr.class("bc-required-indicator"),"*")),u.description&&l.html.div(l.attr.class("bc-json-structure-tuple-description"),u.description),l.html.div(l.attr.class("bc-json-structure-tuple-elements"),...n.map((i,o)=>{const c=s[i];if(!c)return console.warn(`Tuple element "${i}" at index ${o} not found in properties`),l.html.div(l.attr.class("bc-json-structure-tuple-element"),l.html.span(`Missing definition for "${i}"`));const p=t.item(o),y=c.name||i;return l.html.div(l.attr.class("bc-json-structure-tuple-element"),l.html.div(l.attr.class("bc-json-structure-tuple-element-header"),l.html.span(l.attr.class("bc-json-structure-tuple-position"),`[${o}]`),l.html.span(l.attr.class("bc-json-structure-tuple-element-name"),y)),l.html.div(l.attr.class("bc-json-structure-tuple-element-control"),T({ctx:e.with({definition:c,suppressLabel:!0}).append(o),controller:p})))})))}function St({options:e,selected:t,onChange:r,disabled:n}){return h.NativeSelect({options:e.map(s=>({type:"value",value:s.value,label:s.label})),value:t,onChange:r,disabled:n})}function Dt({ctx:e,selector:t,inner:r}){const n=d.Stack(l.attr.class("bc-stack--gap-2 bc-stack--align-start"),t,r);return e.isRoot?n:d.InputWrapper({label:e.suppressLabel?void 0:e.label,description:e.description,required:e.isRequired,content:n})}function Ot(e,t,r){if(!e||typeof e!="object")return null;const n=e;if(r&&r in n){const a=n[r];if(typeof a=="string"&&a in t)return a}const s=Object.keys(n);if(s.length===1){const a=s[0];if(a in t)return a}return null}function At(e,t,r){if(!e||typeof e!="object")return;const n=e;if(r&&r in n){const{[r]:s,...a}=n;return a}if(t in n)return n[t]}function ae(e,t,r){return r?e&&typeof e=="object"?{[r]:t,...e}:{[r]:t}:{[t]:e}}function Mt(e){if(e.default!==void 0)return e.default;if(e.examples&&e.examples.length>0)return e.examples[0];const t=Array.isArray(e.type)?e.type[0]:e.type;if(!(!t||typeof t=="object"))switch(t){case"string":return"";case"boolean":return!1;case"null":return null;case"object":return{};case"array":case"set":return[];case"map":return{};default:return}}function qe({ctx:e,controller:t}){const r=e.definition;if(!r.choices||typeof r.choices!="object")return console.warn("StructureChoiceControl requires choices property"),l.html.div(l.attr.class("bc-json-structure-error"),"Invalid choice definition: missing choices");const n=r.choices,s=r.selector,a=Object.keys(n);if(a.length===0)return l.html.div(l.attr.class("bc-json-structure-error"),"Choice type has no variants defined");const u=a.map(f=>{const $=n[f].name||f;return{value:f,label:$}}),i=l.computedOf(t.signal)(f=>Ot(f,n,s)),o=l.Value.get(i)||a[0],c=l.prop(o);t.onDispose(c.dispose);let p=!1;const y=i.on(f=>{!p&&f!==null&&c.set(f)});t.onDispose(y);const m=St({options:u,selected:c,onChange:f=>{p=!0,c.set(f);const v=n[f];if(v){const $=Mt(v),j=ae($,f,s);t.change(j)}},disabled:e.readOnly||e.isDeprecated}),g=l.MapSignal(c,f=>{const v=n[l.Value.get(f)];if(!v)return l.html.div(l.attr.class("bc-json-structure-error"),`Choice variant not found: ${l.Value.get(f)}`);const $=l.computedOf(t.signal)(O=>At(O,l.Value.get(f),s)),j=O=>{const k=ae(O,l.Value.get(f),s);t.change(k)},N=new d.Controller([...t.path,l.Value.get(f)],j,$,t.status,{disabled:t.disabled},void 0);return t.onDispose(()=>N.dispose()),T({ctx:e.with({definition:v,suppressLabel:!0}).append(l.Value.get(f)),controller:N})});return Dt({ctx:e,selector:m,inner:g})}function Rt(e){return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated}}function Fe({ctx:e,controller:t}){const r=Rt(e);return h.NativeSelectControl({...r,options:(e.enumValues??[]).map(n=>({type:"value",value:n,label:String(n)})),controller:t})}function Pe({ctx:e,controller:t}){return l.Fragment(l.WithElement(()=>{l.Value.get(t.signal)!==e.constValue&&t.change(e.constValue)}),h.Group(d.MutedLabel(e.label,": "),d.Label(String(e.constValue))))}function Nt(e){return{label:e.suppressLabel?void 0:e.label,description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated}}function kt(e,t){if(e===null)return t.includes("null")?"null":null;if(e===void 0)return t.includes("string")?"string":t[0]??null;switch(typeof e){case"string":return t.includes("uuid")?"uuid":t.includes("uri")?"uri":t.includes("date")?"date":t.includes("datetime")?"datetime":t.includes("time")?"time":t.includes("duration")?"duration":t.includes("string")?"string":null;case"number":{if(Number.isInteger(e)){if(t.includes("int32"))return"int32";if(t.includes("int64"))return"int64";if(t.includes("uint32"))return"uint32";if(t.includes("uint64"))return"uint64";if(t.includes("int16"))return"int16";if(t.includes("int8"))return"int8";if(t.includes("uint16"))return"uint16";if(t.includes("uint8"))return"uint8"}return t.includes("double")?"double":t.includes("float")?"float":t.includes("decimal")?"decimal":null}case"bigint":return t.includes("int128")?"int128":t.includes("int64")?"int64":t.includes("uint128")?"uint128":t.includes("uint64")?"uint64":null;case"boolean":return t.includes("boolean")?"boolean":null;case"object":return e instanceof File||e instanceof Blob?t.includes("binary")?"binary":null:Array.isArray(e)?t.includes("array")?"array":t.includes("set")?"set":t.includes("tuple")?"tuple":null:t.includes("object")?"object":t.includes("map")?"map":null;default:return null}}function qt(e,t){try{switch(t){case"string":case"uuid":case"uri":case"date":case"datetime":case"time":case"duration":return e==null?{ok:!0,value:void 0}:{ok:!0,value:String(e)};case"int8":case"int16":case"int32":case"uint8":case"uint16":case"uint32":return typeof e=="number"&&Number.isInteger(e)?{ok:!0,value:e}:typeof e=="string"?/^[-+]?\d+$/.test(e.trim())?{ok:!0,value:parseInt(e,10)}:{ok:!1}:typeof e=="boolean"?{ok:!0,value:e?1:0}:{ok:!1};case"int64":case"int128":case"uint64":case"uint128":{if(typeof e=="bigint")return{ok:!0,value:e};if(typeof e=="number"&&Number.isInteger(e))return{ok:!0,value:BigInt(e)};if(typeof e=="string")try{return{ok:!0,value:BigInt(e.trim())}}catch{return{ok:!1}}return{ok:!1}}case"float":case"double":case"decimal":{if(typeof e=="number")return{ok:!0,value:e};if(typeof e=="string"){const r=Number(e);return Number.isFinite(r)?{ok:!0,value:r}:{ok:!1}}return typeof e=="boolean"?{ok:!0,value:e?1:0}:{ok:!1}}case"boolean":{if(typeof e=="boolean")return{ok:!0,value:e};if(typeof e=="string"){const r=e.trim().toLowerCase();return r==="true"||r==="1"||r==="yes"?{ok:!0,value:!0}:r==="false"||r==="0"||r==="no"?{ok:!0,value:!1}:{ok:!1}}return typeof e=="number"?{ok:!0,value:e!==0}:{ok:!1}}case"array":case"set":case"tuple":return Array.isArray(e)?{ok:!0,value:e}:{ok:!1};case"object":case"map":return e!=null&&typeof e=="object"&&!Array.isArray(e)?{ok:!0,value:e}:{ok:!1};case"binary":return e instanceof File||e instanceof Blob?{ok:!0,value:e}:{ok:!1};case"null":return{ok:!0,value:null};case"any":case"choice":return{ok:!0,value:e};default:return{ok:!1}}}catch{return{ok:!1}}}function Ft(e){switch(e){case"null":return null;case"array":case"set":case"tuple":return[];case"object":case"map":return{};case"binary":return;default:return}}function Pt(e){return e.map(t=>({key:t,label:h._t(t),detect:r=>kt(r,[t])===t,convert:r=>qt(r,t),defaultValue:()=>Ft(t)}))}function Vt({options:e,selected:t,onChange:r}){if((e.length<=3?"segmented":"select")==="segmented"){const a=Object.fromEntries(e.map(u=>[u.value,u.label]));return h.SegmentedInput({options:a,value:t,onChange:u=>r(u),size:"sm"})}return h.NativeSelect({options:e.map(a=>({type:"value",value:a.value,label:a.label})),value:t,onChange:r})}function Lt({ctx:e,showSelector:t,selector:r,inner:n}){return e.isRoot?t?d.Stack(l.attr.class("bc-stack--gap-2"),r,n):n:d.InputWrapper({...Nt(e),content:t?d.Stack(l.attr.class("bc-stack--gap-2 bc-stack--align-start"),r,n):n})}function Et({ctx:e,controller:t}){const r=e.definition,n=r.type;let s=[];if(Array.isArray(n))s=n;else return console.warn("StructureUnionControl called with non-array type"),T({ctx:e,controller:t});const a=s.includes("null"),u=B(n),i=a&&u.length>0?u:s,o=Pt(i),c=new h.UnionController(t.path,t.change,t.signal,t.status,{disabled:t.disabled},o);t.onDispose(()=>c.dispose());const p=m=>Vt({options:i.map(g=>({value:g,label:h._t(g)})),selected:c.activeBranch,onChange:m}),y=m=>{c.switchToBranch(m,!1)},b=l.MapSignal(c.activeBranch,m=>{const g=l.Value.get(m),f=c.getBranchController(g),v=e.with({definition:{...r,type:g},suppressLabel:!e.isRoot});return T({ctx:v,controller:f})});return Lt({ctx:e,showSelector:i.length>1,selector:p(y),inner:b})}function T({ctx:e,controller:t}){let r=e;const n=e.definition;if(n.type&&D(n.type)){const i=e.resolveRef(n.type.$ref);if(i){const{type:o,...c}=n,p={...i,...c};r=e.with({definition:p})}}if(r.definition.$extends){const{merged:i}=ee(r.definition,e.schema);r=r.with({definition:i})}const s=r.widgetRegistry;if(s){const i=s.findBestWidget(r);if(i)return i.registration.factory({controller:t,ctx:r})}if(me(r.definition))return Fe({ctx:r,controller:t});if(ye(r.definition))return Pe({ctx:r,controller:t});const a=r.resolvedType;if(Array.isArray(a)&&B(a).length>1)return Et({ctx:r,controller:t});const u=r.primaryType;if(!u)return K({ctx:r,controller:t});if(M(r.definition)){const i=t instanceof d.ObjectController?t:t.object();return Ae({ctx:r,controller:i})}if(Z(r.definition)){const i=t instanceof d.ArrayController?t:t.array();return Me({ctx:r,controller:i})}if(H(r.definition)){const i=t instanceof d.ArrayController?t:t.array();return Re({ctx:r,controller:i})}if(X(r.definition)){const i=t instanceof d.ObjectController?t:t.object();return Ne({ctx:r,controller:i})}if(Y(r.definition)){const i=t instanceof d.ArrayController?t:t.array();return ke({ctx:r,controller:i})}if(Q(r.definition))return qe({ctx:r,controller:t});switch(u){case"string":return xe({ctx:r,controller:t});case"boolean":return $e({ctx:r,controller:t});case"uuid":return we({ctx:r,controller:t});case"uri":return De({ctx:r,controller:t});case"binary":return Oe({ctx:r,controller:t});case"null":return Ut(r);case"any":return K({ctx:r,controller:t});default:return q(u)?Ce({ctx:r,controller:t,intType:u}):U(u)?je({ctx:r,controller:t,floatType:u}):W(u)?Se({ctx:r,controller:t,temporalType:u}):(console.warn(`Unknown type: ${u}`),Wt(r,u))}}function Ve({schema:e,controller:t,widgetRegistry:r,readOnly:n,locale:s}){const a=ve(e,{widgetRegistry:r,readOnly:n,locale:s});return T({ctx:a,controller:t})}function Ut(e){return l.html.div(l.attr.class("bc-json-structure-placeholder"),l.html.span(`[Null: ${e.label}]`),l.html.em("null"))}function Wt(e,t){return l.html.div(l.attr.class("bc-json-structure-unknown"),l.html.span(`Unknown type: ${t}`),l.html.em(`at path: ${e.jsonPath}`))}function te(e,t){return new Bt(e,t)}class Bt{schema;options;constructor(t,r){this.schema=t,this.options=r??{}}validate(t){const r=[];return this.validateValue(t,this.schema,"",r),{isValid:r.length===0,errors:r}}validateAt(t,r){return this.validate(t)}validateValue(t,r,n,s){if(this.options.stopOnFirstError&&s.length>0)return;if(t===null){const c=r.type;if(c==="null"||Array.isArray(c)&&c.includes("null"))return;s.push({path:n,type:"type",expected:c,actual:"null"});return}if("enum"in r&&Array.isArray(r.enum)){r.enum.includes(t)||s.push({path:n,type:"enum",expected:r.enum,actual:t});return}if("const"in r){t!==r.const&&s.push({path:n,type:"const",expected:r.const,actual:t});return}const a=r.type;if(!a)return;const i=(Array.isArray(a)?a:[a]).filter(c=>typeof c=="string");!i.some(c=>this.checkType(t,c,r,n,s))&&i.length>0&&s.push({path:n,type:"type",expected:a,actual:typeof t})}checkType(t,r,n,s,a){switch(r){case"string":return this.validateString(t,n,s,a);case"boolean":return typeof t=="boolean";case"null":return t===null;case"object":return this.validateObject(t,n,s,a);case"array":return this.validateArray(t,n,s,a);case"set":return this.validateSet(t,n,s,a);case"map":return this.validateMap(t,n,s,a);case"tuple":return this.validateTuple(t,n,s,a);case"choice":return this.validateChoice(t,n,s,a);case"any":return!0;default:return q(r)?this.validateInteger(t,r,n,s,a):U(r)?this.validateFloat(t,n,s,a):W(r)?this.validateTemporal(t,r,s,a):r==="uuid"?this.validateUuid(t,s,a):r==="uri"?this.validateUri(t,s,a):r==="binary"?this.validateBinary(t,s,a):!1}}validateString(t,r,n,s){if(typeof t!="string")return!1;const a=r;if(a.minLength!==void 0&&t.length<a.minLength&&s.push({path:n,type:"minLength",expected:a.minLength,actual:t.length}),a.maxLength!==void 0&&t.length>a.maxLength&&s.push({path:n,type:"maxLength",expected:a.maxLength,actual:t.length}),a.pattern!==void 0)try{new RegExp(a.pattern).test(t)||s.push({path:n,type:"pattern",expected:a.pattern,actual:t})}catch{}return!0}validateInteger(t,r,n,s,a){if(typeof t!="number"&&typeof t!="bigint")return!1;if(typeof t=="number"&&!Number.isInteger(t))return a.push({path:s,type:"type",expected:r,actual:"float"}),!1;if(q(r)){const u=V[r],i=typeof t=="bigint"?t:BigInt(Math.round(t));(i<u.min||i>u.max)&&a.push({path:s,type:"integer_bounds",expected:{min:u.min.toString(),max:u.max.toString()},actual:i.toString(),context:{type:r}})}return this.validateNumericConstraints(t,n,s,a),!0}validateFloat(t,r,n,s){return typeof t!="number"?!1:(this.validateNumericConstraints(t,r,n,s),!0)}validateNumericConstraints(t,r,n,s){const a=r,u=typeof t=="bigint"?Number(t):t;if(a.minimum!==void 0){const i=typeof a.minimum=="string"?Number(a.minimum):a.minimum;u<i&&s.push({path:n,type:"minimum",expected:i,actual:u})}if(a.maximum!==void 0){const i=typeof a.maximum=="string"?Number(a.maximum):a.maximum;u>i&&s.push({path:n,type:"maximum",expected:i,actual:u})}if(a.exclusiveMinimum!==void 0){const i=typeof a.exclusiveMinimum=="string"?Number(a.exclusiveMinimum):a.exclusiveMinimum;u<=i&&s.push({path:n,type:"exclusiveMinimum",expected:i,actual:u})}if(a.exclusiveMaximum!==void 0){const i=typeof a.exclusiveMaximum=="string"?Number(a.exclusiveMaximum):a.exclusiveMaximum;u>=i&&s.push({path:n,type:"exclusiveMaximum",expected:i,actual:u})}a.multipleOf!==void 0&&typeof t=="number"&&t%a.multipleOf!==0&&s.push({path:n,type:"multipleOf",expected:a.multipleOf,actual:t})}validateTemporal(t,r,n,s){if(typeof t!="string")return!1;const u={date:/^\d{4}-\d{2}-\d{2}$/,datetime:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})?$/,time:/^\d{2}:\d{2}:\d{2}(\.\d+)?$/,duration:/^P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(\d+H)?(\d+M)?(\d+S)?)?$/}[r];return u&&!u.test(t)?(s.push({path:n,type:"format",expected:r,actual:t}),!1):!0}validateUuid(t,r,n){return typeof t!="string"?!1:/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)?!0:(n.push({path:r,type:"format",expected:"uuid",actual:t}),!1)}validateUri(t,r,n){if(typeof t!="string")return!1;try{return new URL(t),!0}catch{return n.push({path:r,type:"format",expected:"uri",actual:t}),!1}}validateBinary(t,r,n){return t instanceof Uint8Array?!0:typeof t!="string"?!1:/^[A-Za-z0-9+/]*={0,2}$/.test(t)?!0:(n.push({path:r,type:"format",expected:"binary",actual:t}),!1)}validateObject(t,r,n,s){if(typeof t!="object"||t===null||Array.isArray(t))return!1;if(!M(r))return!0;const a=t,u=r.required;if(u){const i=Array.isArray(u[0])?u.flat():u;for(const o of i)o in a||s.push({path:n?`${n}/${o}`:`/${o}`,type:"required",expected:o})}for(const[i,o]of Object.entries(a)){const c=r.properties?.[i];if(c){const p=n?`${n}/${i}`:`/${i}`;this.validateValue(o,c,p,s)}else if(r.additionalProperties===!1)s.push({path:n?`${n}/${i}`:`/${i}`,type:"additionalProperties",actual:i});else if(typeof r.additionalProperties=="object"){const p=n?`${n}/${i}`:`/${i}`;this.validateValue(o,r.additionalProperties,p,s)}}return!0}validateArray(t,r,n,s){if(!Array.isArray(t))return!1;if(!Z(r))return!0;const a=r;a.minItems!==void 0&&t.length<a.minItems&&s.push({path:n,type:"minItems",expected:a.minItems,actual:t.length}),a.maxItems!==void 0&&t.length>a.maxItems&&s.push({path:n,type:"maxItems",expected:a.maxItems,actual:t.length});for(let u=0;u<t.length;u++){const i=`${n}/${u}`;this.validateValue(t[u],r.items,i,s)}return!0}validateSet(t,r,n,s){if(!Array.isArray(t))return!1;if(!H(r))return!0;const a=new Set;for(let u=0;u<t.length;u++){const i=JSON.stringify(t[u]);a.has(i)&&s.push({path:`${n}/${u}`,type:"uniqueItems",actual:t[u]}),a.add(i)}return this.validateArray(t,r,n,s)}validateMap(t,r,n,s){if(typeof t!="object"||t===null||Array.isArray(t))return!1;if(!X(r))return!0;const a=t;for(const[u,i]of Object.entries(a)){const o=`${n}/${u}`;this.validateValue(i,r.values,o,s)}return!0}validateTuple(t,r,n,s){if(!Array.isArray(t))return!1;if(!Y(r))return!0;const a=r.tuple.length;t.length!==a&&s.push({path:n,type:"tuple_length",expected:a,actual:t.length});for(let u=0;u<r.tuple.length;u++){const i=r.tuple[u],o=r.properties?.[i];o&&u<t.length&&this.validateValue(t[u],o,`${n}/${u}`,s)}return!0}validateChoice(t,r,n,s){if(typeof t!="object"||t===null||Array.isArray(t))return!1;if(!Q(r))return!0;const a=t,u=Object.keys(r.choices),i=Object.keys(a).find(c=>u.includes(c));if(!i)return s.push({path:n,type:"choice",expected:u,actual:Object.keys(a)}),!1;const o=r.choices[i];return o&&this.validateValue(a[i],o,`${n}/${i}`,s),!0}}function _t(e,t,r){return te(e,r).validate(t)}function Le(e,t){const r=zt(e,t);return{path:e.path,message:r,code:e.type}}function re(e,t){return e.map(r=>{const n=t?.get(r.path);return Le(r,n)})}function zt(e,t){switch(e.type){case"type":return`Expected ${ue(e.expected)}, got ${Gt(e.actual)}`;case"type_mismatch":return`Value must be of type ${ue(e.expected)}`;case"minLength":return`Must be at least ${e.expected} characters`;case"maxLength":return`Must be no more than ${e.expected} characters`;case"pattern":return Jt(e,t);case"format":return Kt(e);case"minimum":return`Must be at least ${e.expected}`;case"maximum":return`Must be at most ${e.expected}`;case"exclusiveMinimum":return`Must be greater than ${e.expected}`;case"exclusiveMaximum":return`Must be less than ${e.expected}`;case"multipleOf":return`Must be a multiple of ${e.expected}`;case"integer_bounds":return Zt(e);case"minItems":return`Must have at least ${e.expected} items`;case"maxItems":return`Must have no more than ${e.expected} items`;case"uniqueItems":return"All items must be unique";case"contains":return"Must contain at least one matching item";case"minContains":return`Must contain at least ${e.expected} matching items`;case"maxContains":return`Must contain no more than ${e.expected} matching items`;case"required":return"This field is required";case"minProperties":return`Must have at least ${e.expected} properties`;case"maxProperties":return`Must have no more than ${e.expected} properties`;case"additionalProperties":return`Unknown property: ${e.actual}`;case"dependentRequired":return Ht(e);case"enum":return Xt(e);case"const":return`Must be exactly ${JSON.stringify(e.expected)}`;case"ref_not_found":return`Invalid reference: ${e.expected}`;case"circular_ref":return"Circular reference detected";case"invalid":return"Invalid value";default:return e.context?.message??`Validation error: ${e.type}`}}function ue(e){return typeof e=="string"?oe(e):Array.isArray(e)?e.map(oe).join(" or "):String(e)}function Gt(e){return e===null?"null":e===void 0?"undefined":typeof e}function oe(e){return{string:"text",boolean:"true/false",int8:"integer (-128 to 127)",int16:"integer (-32768 to 32767)",int32:"integer",int64:"large integer",int128:"very large integer",uint8:"positive integer (0 to 255)",uint16:"positive integer (0 to 65535)",uint32:"positive integer",uint64:"large positive integer",uint128:"very large positive integer",float:"decimal number",double:"decimal number",decimal:"decimal number",date:"date",datetime:"date and time",time:"time",duration:"duration",uuid:"UUID",uri:"URL",binary:"binary data",object:"object",array:"list",set:"unique list",map:"key-value pairs",tuple:"ordered list",choice:"one of multiple options",any:"any value",null:"empty"}[e]??e}function Jt(e,t){const r=t?.description;if(r&&e.type==="pattern")return`Does not match required format: ${r}`;const n=e.expected;if(n){const a={"^[a-zA-Z]+$":"letters only","^[0-9]+$":"numbers only","^[a-zA-Z0-9]+$":"letters and numbers only","^\\S+$":"no spaces allowed","^[a-z]+$":"lowercase letters only","^[A-Z]+$":"uppercase letters only"}[n];if(a)return`Must be ${a}`}return"Does not match required format"}function Kt(e){const t=e.expected;return{email:"Must be a valid email address","date-time":"Must be a valid date and time",date:"Must be a valid date",time:"Must be a valid time",uri:"Must be a valid URL","uri-reference":"Must be a valid URL or relative path",uuid:"Must be a valid UUID",hostname:"Must be a valid hostname",ipv4:"Must be a valid IPv4 address",ipv6:"Must be a valid IPv6 address",regex:"Must be a valid regular expression","json-pointer":"Must be a valid JSON pointer"}[t]??`Must be a valid ${t}`}function Zt(e){const t=e.context?.type;if(t&&q(t)){const r=V[t];return`Must be between ${r.min} and ${r.max}`}return"Value is out of range for this integer type"}function Ht(e){const t=e.context?.dependent,r=e.context?.required;return t&&r?.length?`When "${t}" is present, "${r.join('", "')}" must also be provided`:"Missing required dependent fields"}function Xt(e){const t=e.expected;return t&&t.length<=5?`Must be one of: ${t.map(n=>JSON.stringify(n)).join(", ")}`:"Invalid value"}function Yt(e){const t=new Map;for(const r of e){const n=t.get(r.path)??[];n.push(r),t.set(r.path,n)}return t}function Qt(e,t){return e.filter(r=>r.path===t)}function er(e,t){return e.some(r=>r.path===t)}function tr(e,t){const r=t===""?"/":`${t}/`;return e.filter(n=>n.path.startsWith(r))}class L{registrations=new Map;parent;constructor(t){this.parent=t??null}register(t,r){this.registrations.set(t,r)}unregister(t){this.registrations.delete(t)}get(t){return this.registrations.get(t)??this.parent?.get(t)}has(t){return this.registrations.has(t)||(this.parent?.has(t)??!1)}names(){const t=this.parent?.names()??[],r=Array.from(this.registrations.keys());return[...new Set([...t,...r])]}getForType(t){const r=[];this.parent&&r.push(...this.parent.getForType(t));for(const n of this.registrations.values())n.supportedTypes?.includes(t)&&r.push(n);return r}getForFormat(t){const r=[];this.parent&&r.push(...this.parent.getForFormat(t));for(const n of this.registrations.values())n.supportedFormats?.includes(t)&&r.push(n);return r}findBestWidget(t){const r=[];for(const s of this.names()){const a=this.get(s);if(!a)continue;const u=this.scoreWidget(a,t);u>0&&r.push({name:s,registration:a,score:u})}if(r.length===0)return null;r.sort((s,a)=>a.score!==s.score?a.score-s.score:(a.registration.priority??0)-(s.registration.priority??0));const n=r[0];return{name:n.name,registration:n.registration}}scoreWidget(t,r){let n=0;if(t.matcher)if(t.matcher(r))n+=100;else return 0;const s=r.primaryType;s&&t.supportedTypes?.includes(s)&&(n+=50);const a=r.format;return a&&t.supportedFormats?.includes(a)&&(n+=30),n+=t.priority??0,n}createChild(){return new L(this)}}let E=null;function F(){return E||(E=new L),E}function rr(e){E=e}function nr(e){return new L(e)}function ir(e,t,r){return{name:`type:${e}`,registration:{factory:t,displayName:r?.displayName??`${e} widget`,description:r?.description,supportedTypes:[e],priority:r?.priority??0,canFallback:r?.canFallback??!1}}}function sr(e,t,r){return{name:`format:${e}`,registration:{factory:t,displayName:r?.displayName??`${e} widget`,description:r?.description,supportedFormats:[e],priority:r?.priority??10,canFallback:r?.canFallback??!1}}}function ar(e,t,r,n){return{name:`type:${e}:format:${t}`,registration:{factory:r,displayName:n?.displayName??`${e}/${t} widget`,description:n?.description,supportedTypes:[e],supportedFormats:[t],priority:n?.priority??20,canFallback:n?.canFallback??!1}}}function ur(e,t,r,n){return{name:e,registration:{factory:r,displayName:n?.displayName??e,description:n?.description,matcher:t,priority:n?.priority??50,canFallback:n?.canFallback??!1}}}function Ee(e,t){if(t){const n=t.findBestWidget(e);if(n)return n}return F().findBestWidget(e)}function or(e){const t=e.definition,r={};if(typeof t=="object"&&"x:ui"in t){const n=t["x:ui"];n.widget&&typeof n.widget=="object"&&(r.options=n.widget),typeof n.priority=="number"&&(r.priority=n.priority)}if(typeof t=="object"&&"widget"in t){const n=t.widget;typeof n=="object"&&n!==null&&(r.options={...r.options??{},...n})}return Object.keys(r).length>0?r:void 0}function ne(e){const t=e.definition;if(typeof t=="object"&&"x:ui"in t){const r=t["x:ui"];if(typeof r.widget=="string")return r.widget}if(typeof t=="object"&&"widget"in t){const r=t.widget;if(r&&typeof r.type=="string")return r.type}}function lr(e){return ne(e)!==void 0}function cr(e,t){const r=ne(e);if(r){if(t){const a=t.get(r);if(a)return{name:r,registration:a}}const s=F().get(r);if(s)return{name:r,registration:s};console.warn(`Widget "${r}" specified in definition but not found in registry`,{path:e.jsonPath})}return Ee(e,t)}function pr(e,t,r){return{...e,...t,...r}}function Ue(e=F()){e.register("string",{factory:({controller:i,ctx:o})=>xe({ctx:o,controller:i}),displayName:"String",description:"Text input for string values",supportedTypes:["string"],priority:0,canFallback:!0}),e.register("boolean",{factory:({controller:i,ctx:o})=>$e({ctx:o,controller:i}),displayName:"Boolean",description:"Checkbox for boolean values",supportedTypes:["boolean"],priority:0,canFallback:!0}),e.register("uuid",{factory:({controller:i,ctx:o})=>we({ctx:o,controller:i}),displayName:"UUID",description:"Input for UUID values",supportedTypes:["uuid"],priority:0,canFallback:!0}),e.register("uri",{factory:({controller:i,ctx:o})=>De({ctx:o,controller:i}),displayName:"URI",description:"Input for URI/URL values",supportedTypes:["uri"],priority:0,canFallback:!0}),e.register("binary",{factory:({controller:i,ctx:o})=>Oe({ctx:o,controller:i}),displayName:"Binary",description:"File upload for binary data",supportedTypes:["binary"],priority:0,canFallback:!0}),e.register("any",{factory:({controller:i,ctx:o})=>K({ctx:o,controller:i}),displayName:"Any",description:"Generic control for any type",supportedTypes:["any"],priority:0,canFallback:!0});const t=["int8","int16","int32","int64","int128","uint8","uint16","uint32","uint64","uint128"],r=({controller:i,ctx:o})=>Ce({ctx:o,controller:i,intType:o.primaryType});for(const i of t)e.register(i,{factory:r,displayName:i.toUpperCase(),description:`Number input for ${i} values`,supportedTypes:[i],priority:0,canFallback:!0});const n=["float","double","decimal"],s=({controller:i,ctx:o})=>je({ctx:o,controller:i,floatType:o.primaryType});for(const i of n)e.register(i,{factory:s,displayName:i.charAt(0).toUpperCase()+i.slice(1),description:`Number input for ${i} values`,supportedTypes:[i],priority:0,canFallback:!0});const a=["date","datetime","time","duration"],u=({controller:i,ctx:o})=>Se({ctx:o,controller:i,temporalType:o.primaryType});for(const i of a)e.register(i,{factory:u,displayName:i.charAt(0).toUpperCase()+i.slice(1),description:`Input for ${i} values`,supportedTypes:[i],priority:0,canFallback:!0});e.register("object",{factory:({controller:i,ctx:o})=>Ae({ctx:o,controller:i}),displayName:"Object",description:"Form for object values",supportedTypes:["object"],priority:0,canFallback:!0}),e.register("array",{factory:({controller:i,ctx:o})=>Me({ctx:o,controller:i}),displayName:"Array",description:"List control for array values",supportedTypes:["array"],priority:0,canFallback:!0}),e.register("set",{factory:({controller:i,ctx:o})=>Re({ctx:o,controller:i}),displayName:"Set",description:"Set control for unique values",supportedTypes:["set"],priority:0,canFallback:!0}),e.register("map",{factory:({controller:i,ctx:o})=>Ne({ctx:o,controller:i}),displayName:"Map",description:"Map control for key-value pairs",supportedTypes:["map"],priority:0,canFallback:!0}),e.register("tuple",{factory:({controller:i,ctx:o})=>ke({ctx:o,controller:i}),displayName:"Tuple",description:"Tuple control for fixed-length arrays",supportedTypes:["tuple"],priority:0,canFallback:!0}),e.register("choice",{factory:({controller:i,ctx:o})=>qe({ctx:o,controller:i}),displayName:"Choice",description:"Choice control for union types",supportedTypes:["choice"],priority:0,canFallback:!0}),e.register("enum",{factory:({controller:i,ctx:o})=>Fe({ctx:o,controller:i}),displayName:"Enum",description:"Dropdown for enumerated values",priority:10,canFallback:!1,matcher:i=>i.hasEnum}),e.register("const",{factory:({controller:i,ctx:o})=>Pe({ctx:o,controller:i}),displayName:"Const",description:"Display for constant values",priority:20,canFallback:!1,matcher:i=>i.hasConst})}function We(e=F()){return e.has("string")&&e.has("object")&&e.has("array")}function dr(e=F()){We(e)||Ue(e)}function Be(e){let t=e;if(e.$root){const r=R(e.$root,e);r&&(t=r)}return w(t,e,new Set)}function w(e,t,r){if(e.type&&D(e.type)){const n=e.type.$ref;if(r.has(n))return;r.add(n);const s=R(n,t);if(s){const a={...s,...e,type:s.type},u=w(a,t,r);return r.delete(n),u}r.delete(n);return}return e.default!==void 0?e.default:Array.isArray(e.examples)&&e.examples.length>0?e.examples[0]:"const"in e&&e.const!==void 0?e.const:"enum"in e&&Array.isArray(e.enum)&&e.enum.length>0?e.enum[0]:Cr(e)?null:fr(e,t,r)}function fr(e,t,r){const n=_e(e);if(M(e))return yr(e,t,r);if(n==="choice"&&"choices"in e)return gr(e,t,r);if(n==="tuple"&&"tuple"in e&&"properties"in e)return hr(e,t,r);if(n==="array")return br(e,t,r);if(n==="set")return vr(e,t,r);if(n==="map")return{};if(n==="string")return xr(e);if(jr(n))return $r(e);if(wr(n))return Tr(e);if(n==="boolean")return!1;if(n==="null")return null;if(Sr(n))return Ir(n);if(n==="uuid"||n==="uri"||n==="uri-reference"||n==="binary"||n==="bytes")return""}function mr(e){if(!e||e.length===0)return new Set;if(Array.isArray(e[0])){const t=e.flat();return new Set(t)}return new Set(e)}function yr(e,t,r){if(!M(e))return{};const n=mr(e.required),s={};for(const[a,u]of Object.entries(e.properties))if(n.has(a))if(u.type&&D(u.type)){const i=u.type.$ref;if(r.has(i))continue;r.add(i);const o=R(i,t);if(o){const c={...o,...u,type:o.type},p=w(c,t,r);p!==void 0&&(s[a]=p)}r.delete(i)}else{const i=w(u,t,r);i!==void 0&&(s[a]=i)}return s}function gr(e,t,r){if(!("choices"in e))return;const n=e.choices,s=Object.keys(n);if(s.length===0)return;const a=s[0],u=n[a];if("selector"in e&&e.selector){const o=e.selector,c=w(u,t,r);return typeof c=="object"&&c!==null?{[o]:a,...c}:{[o]:a}}const i=w(u,t,r);return{[a]:i}}function hr(e,t,r){if(!("tuple"in e)||!("properties"in e))return{};const n=e.tuple,s=e.properties,a=new Set(e.required??n),u={};for(const i of n){if(!a.has(i))continue;const o=s[i];if(o){const c=w(o,t,r);c!==void 0&&(u[i]=c)}}return u}function br(e,t,r){const n=("minItems"in e?e.minItems:0)??0;if(n===0)return[];const s="items"in e?e.items:void 0;if(!s)return Array(n).fill(null);const a=w(s,t,r);return Array(n).fill(a??null)}function vr(e,t,r){const n=("minItems"in e?e.minItems:0)??0;if(n===0)return[];const s="items"in e?e.items:void 0;if(!s)return Array(n).fill(null);const a=w(s,t,r);return Array(n).fill(a??null)}function xr(e){switch("format"in e?e.format:void 0){case"date":return ze();case"date-time":return Ge();case"time":return"00:00:00";case"email":case"uri":case"uri-reference":case"uuid":default:return""}}function $r(e){const t=_e(e),r=t==="int64"||t==="uint64"||t==="int128"||t==="uint128";let n="minimum"in e?e.minimum:void 0,s="maximum"in e?e.maximum:void 0;const a="exclusiveMinimum"in e?e.exclusiveMinimum:void 0,u="exclusiveMaximum"in e?e.exclusiveMaximum:void 0;a!==void 0&&(n=a+1),u!==void 0&&(s=u-1);let i;n!==void 0&&s!==void 0?i=Math.round((n+s)/2):n!==void 0?i=n:s!==void 0?i=0<=s?0:s:i=0;const o="multipleOf"in e?e.multipleOf:void 0;return o!==void 0&&o>0&&(i=Math.round(i/o)*o,n!==void 0&&i<n&&(i=Math.ceil(n/o)*o),s!==void 0&&i>s&&(i=Math.floor(s/o)*o)),r?BigInt(Math.round(i)):Math.round(i)}function Tr(e){let t="minimum"in e?e.minimum:void 0,r="maximum"in e?e.maximum:void 0;const n="exclusiveMinimum"in e?e.exclusiveMinimum:void 0,s="exclusiveMaximum"in e?e.exclusiveMaximum:void 0,a="multipleOf"in e?e.multipleOf:.001;n!==void 0&&(t=n+a),s!==void 0&&(r=s-a);let u;t!==void 0&&r!==void 0?u=(t+r)/2:t!==void 0?u=t:r!==void 0?u=0<=r?0:r:u=0;const i="multipleOf"in e?e.multipleOf:void 0;return i!==void 0&&i>0&&(u=Math.round(u/i)*i,t!==void 0&&u<t&&(u=Math.ceil(t/i)*i),r!==void 0&&u>r&&(u=Math.floor(r/i)*i)),u}function Ir(e){switch(e){case"date":return ze();case"time":return"00:00:00";case"datetime":return Ge();case"duration":return"PT0S";default:return""}}function Cr(e){return Array.isArray(e.type)?e.type.some(t=>typeof t=="string"?t==="null":!1):!1}function _e(e){const t=e.type;if(typeof t=="string")return t;if(Array.isArray(t)){for(const r of t)if(typeof r=="string"&&r!=="null")return r}}function jr(e){return e?["int8","int16","int32","int64","int128","uint8","uint16","uint32","uint64","uint128"].includes(e):!1}function wr(e){return e?["float","double","decimal"].includes(e):!1}function Sr(e){return e?["date","time","datetime","duration"].includes(e):!1}function ze(){return new Date().toISOString().split("T")[0]}function Ge(){return new Date().toISOString()}function Dr(e){if(e.isValid)return d.i.valid;const t=re(e.errors),r=new Map;for(const u of t){const i=r.get(u.path)||[];i.push(u),r.set(u.path,i)}const n=(u,i)=>{if(u.length===0)return{message:i.map(y=>y.message).join("; ")};const[o,...c]=u,p=n(c,i);return{dependencies:{[o]:p}}},s={},a={};for(const[u,i]of r.entries())if(u===""||u==="/")s.message=i.map(o=>o.message).join("; ");else{const o=u.split("/").filter(c=>c!=="");if(o.length===1)a[o[0]]={message:i.map(c=>c.message).join("; ")};else{const[c,...p]=o;a[c]=n(p,i)}}return Object.keys(a).length>0&&(s.dependencies=a),d.i.invalid(s)}function Or({schema:e,initialValue:t,validationMode:r,validateDebounceMs:n,widgetRegistry:s,readOnly:a,locale:u,onChange:i,onValidate:o,applySchemaDefaults:c=!0},p){const y=t!==void 0?l.Value.get(t):void 0,b=Be(e);let m;t===void 0?m=b??{}:c?m=h.deepMergeDefaults(b,y):m=y;const g=te(e),f=r??"onTouched",v=k=>{const x=g.validate(k);if(o&&!x.isValid){const A=re(x.errors);o(A)}return Dr(x)},{controller:$,setStatus:j}=d.useController({initialValue:m,validationMode:f,validateDebounceMs:n,validate:f==="onSubmit"?void 0:v,onChange:i}),N=()=>{$.dispose()},O=l.Fragment(l.OnDispose(N),Ve({schema:e,controller:$,widgetRegistry:s,readOnly:a,locale:u}));return p({Form:O,controller:$,setStatus:j})}exports.DefaultWidgetRegistry=L;exports.INTEGER_BOUNDS=V;exports.JSONStructureForm=Or;exports.RefResolver=be;exports.StructureContext=z;exports.StructureControl=Ve;exports.StructureGenericControl=T;exports.createExtendsResolver=tt;exports.createRefResolver=_;exports.createStructureContext=ve;exports.createValidator=te;exports.createWidgetRegistry=nr;exports.ensureDefaultWidgets=dr;exports.extractStructureDefaults=Be;exports.forFormat=sr;exports.forMatcher=ur;exports.forType=ir;exports.forTypeAndFormat=ar;exports.formatValidationError=Le;exports.formatValidationErrors=re;exports.getChildErrors=tr;exports.getErrorsForPath=Qt;exports.getExplicitWidgetName=ne;exports.getGlobalWidgetRegistry=F;exports.getNonNullTypes=B;exports.getResolvedType=J;exports.getWidgetOptions=or;exports.groupErrorsByPath=Yt;exports.hasConstValue=ye;exports.hasCustomWidget=lr;exports.hasDefaultWidgets=We;exports.hasEnumValue=me;exports.hasErrorsAtPath=er;exports.isArrayTypeDefinition=Z;exports.isBigIntType=le;exports.isChoiceTypeDefinition=Q;exports.isCompoundType=Ze;exports.isFloatType=U;exports.isIntegerType=q;exports.isMapTypeDefinition=X;exports.isNamespace=de;exports.isNullableType=ge;exports.isNumericType=ce;exports.isObjectTypeDefinition=M;exports.isPrimitiveType=pe;exports.isSetTypeDefinition=H;exports.isTemporalType=W;exports.isTupleTypeDefinition=Y;exports.isTypeDefinition=fe;exports.isTypeReference=D;exports.mergeWidgetOptions=pr;exports.parseRefPath=he;exports.registerDefaultWidgets=Ue;exports.resolveExtends=ee;exports.resolveRef=R;exports.resolveTypeReference=Xe;exports.resolveWidget=Ee;exports.resolveWidgetWithOverride=cr;exports.setGlobalWidgetRegistry=rr;exports.validate=_t;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../deep-merge-cQgRrtGF.cjs"),l=require("@tempots/dom"),d=require("../use-form-pSErMD6z.cjs"),P=require("../translations-eUtMHN9s.cjs"),C=require("../duration-input-Dt6riwzu.cjs"),Ke=require("../colors-B2yrgHSW.cjs");function le(e){return e==="int64"||e==="int128"||e==="uint64"||e==="uint128"}function q(e){return e==="int8"||e==="int16"||e==="int32"||e==="int64"||e==="int128"||e==="uint8"||e==="uint16"||e==="uint32"||e==="uint64"||e==="uint128"}function U(e){return e==="float"||e==="double"||e==="decimal"}function ce(e){return q(e)||U(e)}function W(e){return e==="date"||e==="datetime"||e==="time"||e==="duration"}function pe(e){return e==="string"||e==="boolean"||e==="null"||ce(e)||W(e)||e==="uuid"||e==="uri"||e==="binary"}function Ze(e){return e==="object"||e==="array"||e==="set"||e==="map"||e==="tuple"||e==="choice"||e==="any"}function D(e){return typeof e=="object"&&e!==null&&"$ref"in e}function de(e){return typeof e=="object"&&e!==null&&!("type"in e)&&!("$ref"in e)&&!("enum"in e)&&!("const"in e)}function fe(e){return typeof e=="object"&&e!==null&&("type"in e||"$ref"in e||"enum"in e||"const"in e)}function M(e){return e.type==="object"&&"properties"in e}function Z(e){return e.type==="array"&&"items"in e}function H(e){return e.type==="set"&&"items"in e}function X(e){return e.type==="map"&&"values"in e}function Y(e){return e.type==="tuple"&&"tuple"in e}function Q(e){return e.type==="choice"&&"choices"in e}function me(e){return"enum"in e&&Array.isArray(e.enum)}function ye(e){return"const"in e}function J(e){return e===void 0?null:typeof e=="string"||Array.isArray(e)?e:(D(e),null)}function ge(e){return e===void 0?!1:e==="null"?!0:Array.isArray(e)?e.includes("null"):!1}function B(e){return typeof e=="string"?e==="null"?[]:[e]:Array.isArray(e)?e.filter(t=>t!=="null"):[]}const V={int8:{min:-128n,max:127n},int16:{min:-32768n,max:32767n},int32:{min:-2147483648n,max:2147483647n},int64:{min:-9223372036854775808n,max:9223372036854775807n},int128:{min:-170141183460469231731687303715884105728n,max:170141183460469231731687303715884105727n},uint8:{min:0n,max:255n},uint16:{min:0n,max:65535n},uint32:{min:0n,max:4294967295n},uint64:{min:0n,max:18446744073709551615n},uint128:{min:0n,max:340282366920938463463374607431768211455n}};function he(e){return e.startsWith("#/")?e.slice(2).split("/"):e.includes("/")?e.split("/"):["definitions",e]}function He(e,t){let r=e;for(const n of t){if(r==null||typeof r!="object")return;r=r[n]}return r}function R(e,t){const r=he(e),n=He(t,r);if(n==null){console.warn(`Failed to resolve $ref: ${e}`);return}if(fe(n))return n;if(de(n)){console.warn(`$ref "${e}" points to a namespace, not a type definition`);return}}function Xe(e,t){return R(e.$ref,t)}class be{schema;visited=new Set;constructor(t){this.schema=t}resolve(t){if(this.visited.has(t)){console.warn(`Circular reference detected: ${t}`);return}this.visited.add(t);try{const r=R(t,this.schema);if(r?.type&&D(r.type)){const n=this.resolve(r.type.$ref);if(n){const{type:s,...a}=r;return{...n,...a}}}return r}finally{this.visited.delete(t)}}resolveDefinition(t){if(t.type&&D(t.type)){const r=this.resolve(t.type.$ref);if(r){const{type:n,...s}=t;return{...r,...s}}}return t}reset(){this.visited.clear()}}function _(e){return new be(e)}class z{schema;definition;path;readOnly;locale;widgetRegistry;isPropertyRequired;suppressLabel;refResolver;constructor(t){this.schema=t.schema,this.definition=t.definition,this.path=t.path,this.readOnly=t.readOnly??!1,this.locale=t.locale,this.widgetRegistry=t.widgetRegistry,this.isPropertyRequired=t.isPropertyRequired??!1,this.suppressLabel=t.suppressLabel??!1,this.refResolver=t.refResolver??_(t.schema)}with(t){return new z({schema:this.schema,definition:t.definition??this.definition,path:t.path??this.path,readOnly:t.readOnly??this.readOnly,locale:t.locale??this.locale,widgetRegistry:t.widgetRegistry??this.widgetRegistry,isPropertyRequired:t.isPropertyRequired??this.isPropertyRequired,suppressLabel:t.suppressLabel??this.suppressLabel,refResolver:this.refResolver})}append(t){return this.with({path:[...this.path,t]})}get isRoot(){return this.path.length===0}get name(){const t=this.path[this.path.length-1];return typeof t=="string"?t:void 0}get widgetName(){return this.path.map(String).join(".")}get resolvedType(){const t=this.definition.type;if(!t)return null;if(D(t)){const r=this.refResolver.resolve(t.$ref);return r?.type?J(r.type):null}return J(t)}get primaryType(){const t=this.resolvedType;return t?typeof t=="string"?t==="null"?null:t:B(t)[0]??null:null}get isNullable(){return ge(this.definition.type)}get isRequired(){return this.isPropertyRequired}get isOptional(){return!this.isPropertyRequired}get isDeprecated(){return this.definition.deprecated===!0}get isAbstract(){return this.definition.abstract===!0}get isPrimitive(){const t=this.primaryType;return t!=null&&pe(t)}get description(){return this.definition.description}get examples(){return this.definition.examples}get defaultValue(){return this.definition.default}get unit(){return this.definition.unit}get currency(){return this.definition.currency}get label(){if(this.locale&&this.definition.altnames){const r=`lang:${this.locale}`,n=this.definition.altnames[r];if(n)return n}if(this.definition.name)return this.definition.name;const t=this.name;return t?h._t(h.gt(t)):""}get altnames(){return this.definition.altnames}get jsonPath(){return this.path.length===0?"":"/"+this.path.map(String).join("/")}resolveRef(t){return this.refResolver.resolve(t)}get hasEnum(){return"enum"in this.definition&&Array.isArray(this.definition.enum)}get enumValues(){if("enum"in this.definition)return this.definition.enum}get hasConst(){return"const"in this.definition}get constValue(){if("const"in this.definition)return this.definition.const}get format(){if("format"in this.definition)return this.definition.format}}function ve(e,t){let r;const n=_(e);if(e.$root){const s=n.resolve(e.$root);s?r=s:(console.warn(`Failed to resolve $root: ${e.$root}`),r=e)}else e.type||e.properties?r=e:r={type:"any"};return new z({schema:e,definition:r,path:[],readOnly:t?.readOnly,locale:t?.locale,widgetRegistry:t?.widgetRegistry,refResolver:n})}function ee(e,t,r){const n=[],s=[];if(!e.$extends)return{merged:e,inheritanceChain:n,errors:s};const a=Array.isArray(e.$extends)?e.$extends:[e.$extends],u=new Set,i=(p,y=0)=>{if(y>100)return s.push({path:p.join(" -> "),message:"Maximum inheritance depth exceeded"}),[];const b=[];for(const m of p){if(u.has(m)){s.push({path:m,message:`Circular inheritance detected: ${m}`});continue}u.add(m),n.push(m);const g=R(m,t);if(!g){s.push({path:m,message:`Failed to resolve base type: ${m}`});continue}if(g.$extends){const f=Array.isArray(g.$extends)?g.$extends:[g.$extends],v=i(f,y+1);b.push(...v)}b.push(g),u.delete(m)}return b},o=i(a);return{merged:Ye(o,e),inheritanceChain:n,errors:s}}function Ye(e,t){if(e.length===0)return t;let r={...e[0]};for(let a=1;a<e.length;a++)r=ie(r,e[a]);r=ie(r,t);const{$extends:n,...s}=r;return s}function ie(e,t){return M(e)&&M(t)?Qe(e,t):{...e,...t}}function Qe(e,t){const r={...e.properties??{},...t.properties??{}},n=se(e.required),s=se(t.required),a=et([...n,...s]),u={...e,...t,type:"object",properties:r};return a.length>0&&(u.required=a),u}function se(e){return e?e.length===0?[]:Array.isArray(e[0])?e.flat():e:[]}function et(e){return[...new Set(e)]}function tt(e){const t=_(e);return{resolve:r=>(t.reset(),ee(r,e))}}function rt(){return l.html.span(l.attr.class("bc-json-structure-deprecated-badge"),l.attr.style("font-size: var(--font-size-xs); color: var(--color-warning-500, #d97706); background: var(--color-warning-100, #fef3c7); padding: 0.125em 0.5em; border-radius: var(--radius-sm); margin-inline-start: 0.5em; font-weight: normal;"),"(deprecated)")}function I(e,t){return!e||!t?e??"":l.html.span(e,rt())}function nt(e){const t=e.examples?.[0]!=null?String(e.examples[0]):void 0;return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated,placeholder:t}}function xe({ctx:e,controller:t}){const r=nt(e);return d.Control(P.TextInput,{...r,controller:h.transformEmptyStringToUndefined(t)})}function it(e){return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated}}function $e({ctx:e,controller:t}){const r=it(e),n=d.Control(d.CheckboxInput,{...r,controller:t});return e.isNullable?d.Control(d.CheckboxInput,{...r,controller:t,after:h.NullableResetAfter(t.signal,t.disabled,s=>t.change(s))}):n}function st(e,t){const r=V[t],n=Te(e,r.min),s=Ie(e,r.max),a=e.examples?.[0]!=null?String(e.examples[0]):void 0;return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated,min:typeof n=="bigint"?Number(n):n,max:typeof s=="bigint"?Number(s):s,step:1,placeholder:a}}function at(e,t){const r=V[t],n=Te(e,r.min),s=Ie(e,r.max),a=e.examples?.[0]!=null?String(e.examples[0]):void 0;return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated,min:typeof n=="number"?BigInt(n):n,max:typeof s=="number"?BigInt(s):s,placeholder:a}}function Te(e,t){const r=e.definition;if(r.minimum!==void 0){const n=typeof r.minimum=="string"?BigInt(r.minimum):r.minimum;return typeof n=="bigint"?n>t?n:t:BigInt(n)>t?n:Number(t)}if(r.exclusiveMinimum!==void 0){const n=typeof r.exclusiveMinimum=="string"?BigInt(r.exclusiveMinimum):r.exclusiveMinimum,s=typeof n=="bigint"?n+1n:n+1;return typeof s=="bigint"?s>t?s:t:BigInt(s)>t?s:Number(t)}return t>=BigInt(Number.MIN_SAFE_INTEGER)&&t<=BigInt(Number.MAX_SAFE_INTEGER)?Number(t):t}function Ie(e,t){const r=e.definition;if(r.maximum!==void 0){const n=typeof r.maximum=="string"?BigInt(r.maximum):r.maximum;return typeof n=="bigint"?n<t?n:t:BigInt(n)<t?n:Number(t)}if(r.exclusiveMaximum!==void 0){const n=typeof r.exclusiveMaximum=="string"?BigInt(r.exclusiveMaximum):r.exclusiveMaximum,s=typeof n=="bigint"?n-1n:n-1;return typeof s=="bigint"?s<t?s:t:BigInt(s)<t?s:Number(t)}return t>=BigInt(Number.MIN_SAFE_INTEGER)&&t<=BigInt(Number.MAX_SAFE_INTEGER)?Number(t):t}function Ce({ctx:e,controller:t,intType:r}){if(le(r)){const s=at(e,r);return e.isNullable?d.Control(C.NullableBigintInput,{...s,controller:t}):d.Control(C.BigintInput,{...s,controller:t})}const n=st(e,r);return e.isNullable?d.Control(h.NullableNumberInput,{...n,controller:t}):d.Control(h.NumberInput,{...n,controller:t})}function ut(e,t){const r=e.definition;let n;r.multipleOf!==void 0?n=r.multipleOf:t==="decimal"&&r.scale!==void 0?n=Math.pow(10,-r.scale):n=void 0;const s=r.minimum!==void 0?typeof r.minimum=="string"?parseFloat(r.minimum):r.minimum:void 0,a=r.maximum!==void 0?typeof r.maximum=="string"?parseFloat(r.maximum):r.maximum:void 0,u=r.exclusiveMinimum!==void 0?typeof r.exclusiveMinimum=="string"?parseFloat(r.exclusiveMinimum):r.exclusiveMinimum:void 0,i=r.exclusiveMaximum!==void 0?typeof r.exclusiveMaximum=="string"?parseFloat(r.exclusiveMaximum):r.exclusiveMaximum:void 0;let o=e.description;if(u!==void 0||i!==void 0){const p=[];u!==void 0&&p.push(`> ${u}`),i!==void 0&&p.push(`< ${i}`);const y=`Valid range: ${p.join(" and ")}`;o=o?`${o} (${y})`:y}const c=e.examples?.[0]!=null?String(e.examples[0]):void 0;return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:o,required:e.isRequired,disabled:e.readOnly||e.isDeprecated,min:s??u,max:a??i,step:n,placeholder:c}}function je({ctx:e,controller:t,floatType:r}){const n=ut(e,r);return e.isNullable?d.Control(h.NullableNumberInput,{...n,controller:t}):d.Control(h.NumberInput,{...n,controller:t})}function ot(e){return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated,placeholder:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}}function we({ctx:e,controller:t}){const r=ot(e);return d.Control(h.UUIDInput,{...r,controller:h.transformEmptyStringToUndefined(t)})}function lt(e){return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated}}function Se({ctx:e,controller:t,temporalType:r}){const n=lt(e);switch(r){case"date":return e.isNullable?d.Control(C.NullablePlainDateInput,{...n,controller:t}):d.Control(C.PlainDateInput,{...n,controller:t});case"datetime":return e.isNullable?d.Control(C.NullablePlainDateTimeInput,{...n,controller:t}):d.Control(C.PlainDateTimeInput,{...n,controller:t});case"time":return e.isNullable?d.Control(C.NullablePlainTimeInput,{...n,controller:t}):d.Control(C.PlainTimeInput,{...n,controller:t});case"duration":return e.isNullable?d.Control(h.NullableDurationInput,{...n,controller:t}):d.Control(C.DurationInput,{...n,controller:t});default:return console.warn(`Unknown temporal type: ${r}`),l.Fragment()}}function ct(e){return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated,placeholder:"https://example.com"}}function De({ctx:e,controller:t}){const r=ct(e);return d.Control(h.UrlInput,{...r,controller:h.transformEmptyStringToUndefined(t)})}function pt(e){return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated}}function Oe({ctx:e,controller:t}){const r=pt(e);return d.Control(C.FileInput,{...r,controller:t})}function dt(e){return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated,placeholder:"Enter JSON value"}}function ft(e){return e.transform(t=>t===void 0?void 0:JSON.stringify(t,null,2),t=>{if(!(t===void 0||t.trim()===""))try{return JSON.parse(t)}catch{return t}})}function K({ctx:e,controller:t}){const r=dt(e);return d.Control(h.TextArea,{...r,controller:ft(t)})}function mt(e){return{label:e.suppressLabel?void 0:e.label,description:e.description,required:e.isRequired}}function yt(e,t){return!t||t.length===0?!1:typeof t[0]=="string"?t.includes(e):Array.isArray(t[0])?t.some(r=>r.includes(e)):!1}function gt(e){if(e.default!==void 0)return e.default;if(e.examples&&e.examples.length>0)return e.examples[0];if(!e.type)return;const t=Array.isArray(e.type)?e.type[0]:e.type;if(!(typeof t=="object"&&"$ref"in t))switch(t){case"string":return"";case"boolean":return!1;case"null":return null;case"object":return{};case"array":case"set":return[];case"map":return{};case"any":return;default:return t==="int8"||t==="int16"||t==="int32"||t==="int64"||t==="uint8"||t==="uint16"||t==="uint32"||t==="uint64"||t==="float"||t==="double"||t==="decimal"?0:void 0}}function ht(e,t="property"){if(!e.has(t))return t;let r=1;for(;e.has(`${t}${r}`);)r++;return`${t}${r}`}function Ae({ctx:e,controller:t}){const r=e.definition;return r.type!=="object"||!("properties"in r)?(console.warn("StructureObjectControl requires an ObjectTypeDefinition"),l.html.div("Invalid object definition")):l.MapSignal(t.signal,n=>{const s=r.properties,a=r.required,u=r.additionalProperties,i=u!==!1,o=typeof u=="object"&&u!==null?u:{type:"any"},c=r.minProperties??0,p=r.maxProperties??1/0,y=Ke.l(s),b=new Set(y.map(([x])=>x)),m=Object.keys(n??{}),g=m.filter(x=>!b.has(x)),f=i&&m.length<p&&!e.readOnly,v=m.length>c&&!e.readOnly,$=y.map(([x,A])=>{const S=x,G=t.field(S),Je=yt(S,a);return T({ctx:e.with({definition:A,isPropertyRequired:Je,suppressLabel:!1}).append(S),controller:G})}),j=g.map(x=>{const A=t.field(x);return l.html.div(l.attr.class("bc-json-structure-additional-property"),l.html.div(l.attr.class("bc-json-structure-additional-property-header"),l.html.strong(`${x}:`),P.Button({variant:"text",size:"xs",onClick:()=>{const S={...l.Value.get(t.signal)??{}};delete S[x],t.change(S)},disabled:!v},"Remove")),l.html.div(l.attr.class("bc-json-structure-additional-property-value"),T({ctx:e.with({definition:o,isPropertyRequired:!1,suppressLabel:!0}).append(x),controller:A})))}),N=f?P.Button({variant:"outline",size:"sm",onClick:()=>{const x=l.Value.get(t.signal)??{},A=new Set(Object.keys(x)),S=ht(A),G=gt(o);t.change({...x,[S]:G})}},"Add Property"):null,O=l.html.div(l.attr.class("bc-json-structure-object-fields"),...$,...j,N),k=l.html.div(l.attr.class("bc-json-structure-object"),O);return!e.suppressLabel&&e.name?d.InputWrapper({...mt(e),content:k}):k})}function bt(e){return{label:e.suppressLabel?void 0:e.label,description:e.description,required:e.isRequired}}function vt(e){if(e.default!==void 0)return e.default;if(e.examples&&e.examples.length>0)return e.examples[0];if(!e.type)return;const t=Array.isArray(e.type)?e.type[0]:e.type;if(!(typeof t=="object"&&"$ref"in t))switch(t){case"string":return"";case"boolean":return!1;case"null":return null;case"object":return{};case"array":case"set":return[];case"map":return{};case"any":return;default:return t==="int8"||t==="int16"||t==="int32"||t==="int64"||t==="int128"||t==="uint8"||t==="uint16"||t==="uint32"||t==="uint64"||t==="uint128"||t==="float"||t==="double"||t==="decimal"?0:void 0}}function Me({ctx:e,controller:t}){const r=e.definition;if(r.type!=="array"||!("items"in r))return console.warn("StructureArrayControl requires an ArrayTypeDefinition"),l.html.div("Invalid array definition");const n=r.items,s=r.minItems??0,a=r.maxItems??1/0,u=l.computedOf(t.signal)(o=>(o?.length??0)<a),i=l.computedOf(t.signal)(o=>(o?.length??0)>s);return h.ListControl({...bt(e),controller:t,createItem:()=>vt(n),showAdd:!0,addDisabled:l.computedOf(u)(o=>!o||e.readOnly),showRemove:!0,removeDisabled:l.computedOf(i)(o=>!o||e.readOnly),element:o=>{const c=o.position.index,p=o.item;return T({ctx:e.with({definition:n,suppressLabel:!0}).append(c),controller:p})}})}function xt(e){return{label:e.suppressLabel?void 0:e.label,description:e.description,required:e.isRequired}}function $t(e){if(e.default!==void 0)return e.default;if(e.examples&&e.examples.length>0)return e.examples[0];if(!e.type)return;const t=Array.isArray(e.type)?e.type[0]:e.type;if(!(typeof t=="object"&&"$ref"in t))switch(t){case"string":return"";case"boolean":return!1;case"null":return null;case"object":return{};case"array":case"set":return[];case"map":return{};case"any":return;default:return t==="int8"||t==="int16"||t==="int32"||t==="int64"||t==="int128"||t==="uint8"||t==="uint16"||t==="uint32"||t==="uint64"||t==="uint128"||t==="float"||t==="double"||t==="decimal"?0:void 0}}function Re({ctx:e,controller:t}){const r=e.definition;if(r.type!=="set"||!("items"in r))return console.warn("StructureSetControl requires a SetTypeDefinition"),l.html.div("Invalid set definition");const n=r.items,s=r.minItems??0,a=r.maxItems??1/0,u=l.computedOf(t.signal)(c=>(c?.length??0)<a),i=l.computedOf(t.signal)(c=>(c?.length??0)>s),o=l.computedOf(t.signal)(c=>{if(!c||c.length===0)return new Set;const p=new Map,y=new Set;for(let b=0;b<c.length;b++){const m=JSON.stringify(c[b]);p.has(m)?(y.add(p.get(m)),y.add(b)):p.set(m,b)}return y});return h.ListControl({...xt(e),controller:t,createItem:()=>$t(n),showAdd:!0,addDisabled:l.computedOf(u)(c=>!c||e.readOnly),showRemove:!0,removeDisabled:l.computedOf(i)(c=>!c||e.readOnly),element:c=>{const p=c.position.index,y=c.item,b=o.map(g=>g.has(p)),m=T({ctx:e.with({definition:n,suppressLabel:!0}).append(p),controller:y});return b.map(g=>g?d.Stack(l.attr.class("bc-stack--gap-1"),m,d.Label(l.attr.class("bc-json-structure-set-error"),"⚠️ Duplicate value - sets must contain unique items")):m)}})}function Tt(e){return{label:e.suppressLabel?void 0:e.label,description:e.description,required:e.isRequired}}function It(e){if(e.default!==void 0)return e.default;if(e.examples&&e.examples.length>0)return e.examples[0];if(!e.type)return;const t=Array.isArray(e.type)?e.type[0]:e.type;if(!(typeof t=="object"&&"$ref"in t))switch(t){case"string":return"";case"boolean":return!1;case"null":return null;case"object":return{};case"array":case"set":return[];case"map":return{};case"any":return;default:return t==="int8"||t==="int16"||t==="int32"||t==="int64"||t==="int128"||t==="uint8"||t==="uint16"||t==="uint32"||t==="uint64"||t==="uint128"||t==="float"||t==="double"||t==="decimal"?0:void 0}}function Ct(e,t="key"){if(!e.has(t))return t;let r=1;for(;e.has(`${t}${r}`);)r++;return`${t}${r}`}function Ne({ctx:e,controller:t}){const r=e.definition;if(r.type!=="map"||!("values"in r))return console.warn("StructureMapControl requires a MapTypeDefinition"),l.html.div("Invalid map definition");const n=r.values,s=r.minProperties??0,a=r.maxProperties??1/0;return l.MapSignal(t.signal,u=>{const i=Object.keys(u??{}),o=i.length,c=o<a&&!e.readOnly,p=o>s&&!e.readOnly,y=i.map(f=>{const v=t.field(f);return l.html.div(l.attr.class("bc-json-structure-map-entry"),l.html.div(l.attr.class("bc-json-structure-map-entry-header"),l.html.strong(l.attr.class("bc-json-structure-map-entry-key"),`${f}:`),P.Button({variant:"text",size:"xs",onClick:()=>{const $={...l.Value.get(t.signal)??{}};delete $[f],t.change($)},disabled:!p},"Remove")),l.html.div(l.attr.class("bc-json-structure-map-entry-value"),T({ctx:e.with({definition:n,suppressLabel:!0}).append(f),controller:v})))}),b=c?P.Button({variant:"outline",size:"sm",onClick:()=>{const f=l.Value.get(t.signal)??{},v=new Set(Object.keys(f)),$=Ct(v),j=It(n);t.change({...f,[$]:j})}},"Add Entry"):null,m=l.html.div(l.attr.class("bc-json-structure-map-entries"),...y,b),g=l.html.div(l.attr.class("bc-json-structure-map"),m);return!e.suppressLabel&&e.name?d.InputWrapper({...Tt(e),content:g}):g})}function jt(e){return{label:e.suppressLabel?void 0:e.label,description:e.description,required:e.isRequired}}function wt(e){if(e.default!==void 0)return e.default;if(e.examples&&e.examples.length>0)return e.examples[0];if(!e.type)return;const t=Array.isArray(e.type)?e.type[0]:e.type;if(!(typeof t=="object"&&"$ref"in t))switch(t){case"string":return"";case"boolean":return!1;case"null":return null;case"object":return{};case"array":case"set":return[];case"map":return{};case"any":return;default:return t==="int8"||t==="int16"||t==="int32"||t==="int64"||t==="int128"||t==="uint8"||t==="uint16"||t==="uint32"||t==="uint64"||t==="uint128"||t==="float"||t==="double"||t==="decimal"?0:void 0}}function ke({ctx:e,controller:t}){const r=e.definition;if(r.type!=="tuple"||!("tuple"in r)||!("properties"in r))return console.warn("StructureTupleControl requires a TupleTypeDefinition"),l.html.div("Invalid tuple definition");const n=r.tuple,s=r.properties,a=t.signal.value;if(!Array.isArray(a)||a.length!==n.length){const i=n.map(o=>{const c=s[o];return c?wt(c):void 0});t.change(i)}const u=jt(e);return l.html.div(l.attr.class("bc-json-structure-tuple"),u.label&&l.html.label(l.attr.class("bc-json-structure-tuple-label"),u.label,u.required&&l.html.span(l.attr.class("bc-required-indicator"),"*")),u.description&&l.html.div(l.attr.class("bc-json-structure-tuple-description"),u.description),l.html.div(l.attr.class("bc-json-structure-tuple-elements"),...n.map((i,o)=>{const c=s[i];if(!c)return console.warn(`Tuple element "${i}" at index ${o} not found in properties`),l.html.div(l.attr.class("bc-json-structure-tuple-element"),l.html.span(`Missing definition for "${i}"`));const p=t.item(o),y=c.name||i;return l.html.div(l.attr.class("bc-json-structure-tuple-element"),l.html.div(l.attr.class("bc-json-structure-tuple-element-header"),l.html.span(l.attr.class("bc-json-structure-tuple-position"),`[${o}]`),l.html.span(l.attr.class("bc-json-structure-tuple-element-name"),y)),l.html.div(l.attr.class("bc-json-structure-tuple-element-control"),T({ctx:e.with({definition:c,suppressLabel:!0}).append(o),controller:p})))})))}function St({options:e,selected:t,onChange:r,disabled:n}){return h.NativeSelect({options:e.map(s=>({type:"value",value:s.value,label:s.label})),value:t,onChange:r,disabled:n})}function Dt({ctx:e,selector:t,inner:r}){const n=d.Stack(l.attr.class("bc-stack--gap-2 bc-stack--align-start"),t,r);return e.isRoot?n:d.InputWrapper({label:e.suppressLabel?void 0:e.label,description:e.description,required:e.isRequired,content:n})}function Ot(e,t,r){if(!e||typeof e!="object")return null;const n=e;if(r&&r in n){const a=n[r];if(typeof a=="string"&&a in t)return a}const s=Object.keys(n);if(s.length===1){const a=s[0];if(a in t)return a}return null}function At(e,t,r){if(!e||typeof e!="object")return;const n=e;if(r&&r in n){const{[r]:s,...a}=n;return a}if(t in n)return n[t]}function ae(e,t,r){return r?e&&typeof e=="object"?{[r]:t,...e}:{[r]:t}:{[t]:e}}function Mt(e){if(e.default!==void 0)return e.default;if(e.examples&&e.examples.length>0)return e.examples[0];const t=Array.isArray(e.type)?e.type[0]:e.type;if(!(!t||typeof t=="object"))switch(t){case"string":return"";case"boolean":return!1;case"null":return null;case"object":return{};case"array":case"set":return[];case"map":return{};default:return}}function qe({ctx:e,controller:t}){const r=e.definition;if(!r.choices||typeof r.choices!="object")return console.warn("StructureChoiceControl requires choices property"),l.html.div(l.attr.class("bc-json-structure-error"),"Invalid choice definition: missing choices");const n=r.choices,s=r.selector,a=Object.keys(n);if(a.length===0)return l.html.div(l.attr.class("bc-json-structure-error"),"Choice type has no variants defined");const u=a.map(f=>{const $=n[f].name||f;return{value:f,label:$}}),i=l.computedOf(t.signal)(f=>Ot(f,n,s)),o=l.Value.get(i)||a[0],c=l.prop(o);t.onDispose(c.dispose);let p=!1;const y=i.on(f=>{!p&&f!==null&&c.set(f)});t.onDispose(y);const m=St({options:u,selected:c,onChange:f=>{p=!0,c.set(f);const v=n[f];if(v){const $=Mt(v),j=ae($,f,s);t.change(j)}},disabled:e.readOnly||e.isDeprecated}),g=l.MapSignal(c,f=>{const v=n[l.Value.get(f)];if(!v)return l.html.div(l.attr.class("bc-json-structure-error"),`Choice variant not found: ${l.Value.get(f)}`);const $=l.computedOf(t.signal)(O=>At(O,l.Value.get(f),s)),j=O=>{const k=ae(O,l.Value.get(f),s);t.change(k)},N=new d.Controller([...t.path,l.Value.get(f)],j,$,t.status,{disabled:t.disabled},void 0);return t.onDispose(()=>N.dispose()),T({ctx:e.with({definition:v,suppressLabel:!0}).append(l.Value.get(f)),controller:N})});return Dt({ctx:e,selector:m,inner:g})}function Rt(e){return{label:e.suppressLabel?void 0:I(e.label,e.isDeprecated),description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated}}function Fe({ctx:e,controller:t}){const r=Rt(e);return h.NativeSelectControl({...r,options:(e.enumValues??[]).map(n=>({type:"value",value:n,label:String(n)})),controller:t})}function Pe({ctx:e,controller:t}){return l.Fragment(l.WithElement(()=>{l.Value.get(t.signal)!==e.constValue&&t.change(e.constValue)}),h.Group(d.MutedLabel(e.label,": "),d.Label(String(e.constValue))))}function Nt(e){return{label:e.suppressLabel?void 0:e.label,description:e.description,required:e.isRequired,disabled:e.readOnly||e.isDeprecated}}function kt(e,t){if(e===null)return t.includes("null")?"null":null;if(e===void 0)return t.includes("string")?"string":t[0]??null;switch(typeof e){case"string":return t.includes("uuid")?"uuid":t.includes("uri")?"uri":t.includes("date")?"date":t.includes("datetime")?"datetime":t.includes("time")?"time":t.includes("duration")?"duration":t.includes("string")?"string":null;case"number":{if(Number.isInteger(e)){if(t.includes("int32"))return"int32";if(t.includes("int64"))return"int64";if(t.includes("uint32"))return"uint32";if(t.includes("uint64"))return"uint64";if(t.includes("int16"))return"int16";if(t.includes("int8"))return"int8";if(t.includes("uint16"))return"uint16";if(t.includes("uint8"))return"uint8"}return t.includes("double")?"double":t.includes("float")?"float":t.includes("decimal")?"decimal":null}case"bigint":return t.includes("int128")?"int128":t.includes("int64")?"int64":t.includes("uint128")?"uint128":t.includes("uint64")?"uint64":null;case"boolean":return t.includes("boolean")?"boolean":null;case"object":return e instanceof File||e instanceof Blob?t.includes("binary")?"binary":null:Array.isArray(e)?t.includes("array")?"array":t.includes("set")?"set":t.includes("tuple")?"tuple":null:t.includes("object")?"object":t.includes("map")?"map":null;default:return null}}function qt(e,t){try{switch(t){case"string":case"uuid":case"uri":case"date":case"datetime":case"time":case"duration":return e==null?{ok:!0,value:void 0}:{ok:!0,value:String(e)};case"int8":case"int16":case"int32":case"uint8":case"uint16":case"uint32":return typeof e=="number"&&Number.isInteger(e)?{ok:!0,value:e}:typeof e=="string"?/^[-+]?\d+$/.test(e.trim())?{ok:!0,value:parseInt(e,10)}:{ok:!1}:typeof e=="boolean"?{ok:!0,value:e?1:0}:{ok:!1};case"int64":case"int128":case"uint64":case"uint128":{if(typeof e=="bigint")return{ok:!0,value:e};if(typeof e=="number"&&Number.isInteger(e))return{ok:!0,value:BigInt(e)};if(typeof e=="string")try{return{ok:!0,value:BigInt(e.trim())}}catch{return{ok:!1}}return{ok:!1}}case"float":case"double":case"decimal":{if(typeof e=="number")return{ok:!0,value:e};if(typeof e=="string"){const r=Number(e);return Number.isFinite(r)?{ok:!0,value:r}:{ok:!1}}return typeof e=="boolean"?{ok:!0,value:e?1:0}:{ok:!1}}case"boolean":{if(typeof e=="boolean")return{ok:!0,value:e};if(typeof e=="string"){const r=e.trim().toLowerCase();return r==="true"||r==="1"||r==="yes"?{ok:!0,value:!0}:r==="false"||r==="0"||r==="no"?{ok:!0,value:!1}:{ok:!1}}return typeof e=="number"?{ok:!0,value:e!==0}:{ok:!1}}case"array":case"set":case"tuple":return Array.isArray(e)?{ok:!0,value:e}:{ok:!1};case"object":case"map":return e!=null&&typeof e=="object"&&!Array.isArray(e)?{ok:!0,value:e}:{ok:!1};case"binary":return e instanceof File||e instanceof Blob?{ok:!0,value:e}:{ok:!1};case"null":return{ok:!0,value:null};case"any":case"choice":return{ok:!0,value:e};default:return{ok:!1}}}catch{return{ok:!1}}}function Ft(e){switch(e){case"null":return null;case"array":case"set":case"tuple":return[];case"object":case"map":return{};case"binary":return;default:return}}function Pt(e){return e.map(t=>({key:t,label:h._t(t),detect:r=>kt(r,[t])===t,convert:r=>qt(r,t),defaultValue:()=>Ft(t)}))}function Vt({options:e,selected:t,onChange:r}){if((e.length<=3?"segmented":"select")==="segmented"){const a=Object.fromEntries(e.map(u=>[u.value,u.label]));return h.SegmentedInput({options:a,value:t,onChange:u=>r(u),size:"sm"})}return h.NativeSelect({options:e.map(a=>({type:"value",value:a.value,label:a.label})),value:t,onChange:r})}function Lt({ctx:e,showSelector:t,selector:r,inner:n}){return e.isRoot?t?d.Stack(l.attr.class("bc-stack--gap-2"),r,n):n:d.InputWrapper({...Nt(e),content:t?d.Stack(l.attr.class("bc-stack--gap-2 bc-stack--align-start"),r,n):n})}function Et({ctx:e,controller:t}){const r=e.definition,n=r.type;let s=[];if(Array.isArray(n))s=n;else return console.warn("StructureUnionControl called with non-array type"),T({ctx:e,controller:t});const a=s.includes("null"),u=B(n),i=a&&u.length>0?u:s,o=Pt(i),c=new h.UnionController(t.path,t.change,t.signal,t.status,{disabled:t.disabled},o);t.onDispose(()=>c.dispose());const p=m=>Vt({options:i.map(g=>({value:g,label:h._t(g)})),selected:c.activeBranch,onChange:m}),y=m=>{c.switchToBranch(m,!1)},b=l.MapSignal(c.activeBranch,m=>{const g=l.Value.get(m),f=c.getBranchController(g),v=e.with({definition:{...r,type:g},suppressLabel:!e.isRoot});return T({ctx:v,controller:f})});return Lt({ctx:e,showSelector:i.length>1,selector:p(y),inner:b})}function T({ctx:e,controller:t}){let r=e;const n=e.definition;if(n.type&&D(n.type)){const i=e.resolveRef(n.type.$ref);if(i){const{type:o,...c}=n,p={...i,...c};r=e.with({definition:p})}}if(r.definition.$extends){const{merged:i}=ee(r.definition,e.schema);r=r.with({definition:i})}const s=r.widgetRegistry;if(s){const i=s.findBestWidget(r);if(i)return i.registration.factory({controller:t,ctx:r})}if(me(r.definition))return Fe({ctx:r,controller:t});if(ye(r.definition))return Pe({ctx:r,controller:t});const a=r.resolvedType;if(Array.isArray(a)&&B(a).length>1)return Et({ctx:r,controller:t});const u=r.primaryType;if(!u)return K({ctx:r,controller:t});if(M(r.definition)){const i=t instanceof d.ObjectController?t:t.object();return Ae({ctx:r,controller:i})}if(Z(r.definition)){const i=t instanceof d.ArrayController?t:t.array();return Me({ctx:r,controller:i})}if(H(r.definition)){const i=t instanceof d.ArrayController?t:t.array();return Re({ctx:r,controller:i})}if(X(r.definition)){const i=t instanceof d.ObjectController?t:t.object();return Ne({ctx:r,controller:i})}if(Y(r.definition)){const i=t instanceof d.ArrayController?t:t.array();return ke({ctx:r,controller:i})}if(Q(r.definition))return qe({ctx:r,controller:t});switch(u){case"string":return xe({ctx:r,controller:t});case"boolean":return $e({ctx:r,controller:t});case"uuid":return we({ctx:r,controller:t});case"uri":return De({ctx:r,controller:t});case"binary":return Oe({ctx:r,controller:t});case"null":return Ut(r);case"any":return K({ctx:r,controller:t});default:return q(u)?Ce({ctx:r,controller:t,intType:u}):U(u)?je({ctx:r,controller:t,floatType:u}):W(u)?Se({ctx:r,controller:t,temporalType:u}):(console.warn(`Unknown type: ${u}`),Wt(r,u))}}function Ve({schema:e,controller:t,widgetRegistry:r,readOnly:n,locale:s}){const a=ve(e,{widgetRegistry:r,readOnly:n,locale:s});return T({ctx:a,controller:t})}function Ut(e){return l.html.div(l.attr.class("bc-json-structure-placeholder"),l.html.span(`[Null: ${e.label}]`),l.html.em("null"))}function Wt(e,t){return l.html.div(l.attr.class("bc-json-structure-unknown"),l.html.span(`Unknown type: ${t}`),l.html.em(`at path: ${e.jsonPath}`))}function te(e,t){return new Bt(e,t)}class Bt{schema;options;constructor(t,r){this.schema=t,this.options=r??{}}validate(t){const r=[];return this.validateValue(t,this.schema,"",r),{isValid:r.length===0,errors:r}}validateAt(t,r){return this.validate(t)}validateValue(t,r,n,s){if(this.options.stopOnFirstError&&s.length>0)return;if(t===null){const c=r.type;if(c==="null"||Array.isArray(c)&&c.includes("null"))return;s.push({path:n,type:"type",expected:c,actual:"null"});return}if("enum"in r&&Array.isArray(r.enum)){r.enum.includes(t)||s.push({path:n,type:"enum",expected:r.enum,actual:t});return}if("const"in r){t!==r.const&&s.push({path:n,type:"const",expected:r.const,actual:t});return}const a=r.type;if(!a)return;const i=(Array.isArray(a)?a:[a]).filter(c=>typeof c=="string");!i.some(c=>this.checkType(t,c,r,n,s))&&i.length>0&&s.push({path:n,type:"type",expected:a,actual:typeof t})}checkType(t,r,n,s,a){switch(r){case"string":return this.validateString(t,n,s,a);case"boolean":return typeof t=="boolean";case"null":return t===null;case"object":return this.validateObject(t,n,s,a);case"array":return this.validateArray(t,n,s,a);case"set":return this.validateSet(t,n,s,a);case"map":return this.validateMap(t,n,s,a);case"tuple":return this.validateTuple(t,n,s,a);case"choice":return this.validateChoice(t,n,s,a);case"any":return!0;default:return q(r)?this.validateInteger(t,r,n,s,a):U(r)?this.validateFloat(t,n,s,a):W(r)?this.validateTemporal(t,r,s,a):r==="uuid"?this.validateUuid(t,s,a):r==="uri"?this.validateUri(t,s,a):r==="binary"?this.validateBinary(t,s,a):!1}}validateString(t,r,n,s){if(typeof t!="string")return!1;const a=r;if(a.minLength!==void 0&&t.length<a.minLength&&s.push({path:n,type:"minLength",expected:a.minLength,actual:t.length}),a.maxLength!==void 0&&t.length>a.maxLength&&s.push({path:n,type:"maxLength",expected:a.maxLength,actual:t.length}),a.pattern!==void 0)try{new RegExp(a.pattern).test(t)||s.push({path:n,type:"pattern",expected:a.pattern,actual:t})}catch{}return!0}validateInteger(t,r,n,s,a){if(typeof t!="number"&&typeof t!="bigint")return!1;if(typeof t=="number"&&!Number.isInteger(t))return a.push({path:s,type:"type",expected:r,actual:"float"}),!1;if(q(r)){const u=V[r],i=typeof t=="bigint"?t:BigInt(Math.round(t));(i<u.min||i>u.max)&&a.push({path:s,type:"integer_bounds",expected:{min:u.min.toString(),max:u.max.toString()},actual:i.toString(),context:{type:r}})}return this.validateNumericConstraints(t,n,s,a),!0}validateFloat(t,r,n,s){return typeof t!="number"?!1:(this.validateNumericConstraints(t,r,n,s),!0)}validateNumericConstraints(t,r,n,s){const a=r,u=typeof t=="bigint"?Number(t):t;if(a.minimum!==void 0){const i=typeof a.minimum=="string"?Number(a.minimum):a.minimum;u<i&&s.push({path:n,type:"minimum",expected:i,actual:u})}if(a.maximum!==void 0){const i=typeof a.maximum=="string"?Number(a.maximum):a.maximum;u>i&&s.push({path:n,type:"maximum",expected:i,actual:u})}if(a.exclusiveMinimum!==void 0){const i=typeof a.exclusiveMinimum=="string"?Number(a.exclusiveMinimum):a.exclusiveMinimum;u<=i&&s.push({path:n,type:"exclusiveMinimum",expected:i,actual:u})}if(a.exclusiveMaximum!==void 0){const i=typeof a.exclusiveMaximum=="string"?Number(a.exclusiveMaximum):a.exclusiveMaximum;u>=i&&s.push({path:n,type:"exclusiveMaximum",expected:i,actual:u})}a.multipleOf!==void 0&&typeof t=="number"&&t%a.multipleOf!==0&&s.push({path:n,type:"multipleOf",expected:a.multipleOf,actual:t})}validateTemporal(t,r,n,s){if(typeof t!="string")return!1;const u={date:/^\d{4}-\d{2}-\d{2}$/,datetime:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})?$/,time:/^\d{2}:\d{2}:\d{2}(\.\d+)?$/,duration:/^P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(\d+H)?(\d+M)?(\d+S)?)?$/}[r];return u&&!u.test(t)?(s.push({path:n,type:"format",expected:r,actual:t}),!1):!0}validateUuid(t,r,n){return typeof t!="string"?!1:/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)?!0:(n.push({path:r,type:"format",expected:"uuid",actual:t}),!1)}validateUri(t,r,n){if(typeof t!="string")return!1;try{return new URL(t),!0}catch{return n.push({path:r,type:"format",expected:"uri",actual:t}),!1}}validateBinary(t,r,n){return t instanceof Uint8Array?!0:typeof t!="string"?!1:/^[A-Za-z0-9+/]*={0,2}$/.test(t)?!0:(n.push({path:r,type:"format",expected:"binary",actual:t}),!1)}validateObject(t,r,n,s){if(typeof t!="object"||t===null||Array.isArray(t))return!1;if(!M(r))return!0;const a=t,u=r.required;if(u){const i=Array.isArray(u[0])?u.flat():u;for(const o of i)o in a||s.push({path:n?`${n}/${o}`:`/${o}`,type:"required",expected:o})}for(const[i,o]of Object.entries(a)){const c=r.properties?.[i];if(c){const p=n?`${n}/${i}`:`/${i}`;this.validateValue(o,c,p,s)}else if(r.additionalProperties===!1)s.push({path:n?`${n}/${i}`:`/${i}`,type:"additionalProperties",actual:i});else if(typeof r.additionalProperties=="object"){const p=n?`${n}/${i}`:`/${i}`;this.validateValue(o,r.additionalProperties,p,s)}}return!0}validateArray(t,r,n,s){if(!Array.isArray(t))return!1;if(!Z(r))return!0;const a=r;a.minItems!==void 0&&t.length<a.minItems&&s.push({path:n,type:"minItems",expected:a.minItems,actual:t.length}),a.maxItems!==void 0&&t.length>a.maxItems&&s.push({path:n,type:"maxItems",expected:a.maxItems,actual:t.length});for(let u=0;u<t.length;u++){const i=`${n}/${u}`;this.validateValue(t[u],r.items,i,s)}return!0}validateSet(t,r,n,s){if(!Array.isArray(t))return!1;if(!H(r))return!0;const a=new Set;for(let u=0;u<t.length;u++){const i=JSON.stringify(t[u]);a.has(i)&&s.push({path:`${n}/${u}`,type:"uniqueItems",actual:t[u]}),a.add(i)}return this.validateArray(t,r,n,s)}validateMap(t,r,n,s){if(typeof t!="object"||t===null||Array.isArray(t))return!1;if(!X(r))return!0;const a=t;for(const[u,i]of Object.entries(a)){const o=`${n}/${u}`;this.validateValue(i,r.values,o,s)}return!0}validateTuple(t,r,n,s){if(!Array.isArray(t))return!1;if(!Y(r))return!0;const a=r.tuple.length;t.length!==a&&s.push({path:n,type:"tuple_length",expected:a,actual:t.length});for(let u=0;u<r.tuple.length;u++){const i=r.tuple[u],o=r.properties?.[i];o&&u<t.length&&this.validateValue(t[u],o,`${n}/${u}`,s)}return!0}validateChoice(t,r,n,s){if(typeof t!="object"||t===null||Array.isArray(t))return!1;if(!Q(r))return!0;const a=t,u=Object.keys(r.choices),i=Object.keys(a).find(c=>u.includes(c));if(!i)return s.push({path:n,type:"choice",expected:u,actual:Object.keys(a)}),!1;const o=r.choices[i];return o&&this.validateValue(a[i],o,`${n}/${i}`,s),!0}}function _t(e,t,r){return te(e,r).validate(t)}function Le(e,t){const r=zt(e,t);return{path:e.path,message:r,code:e.type}}function re(e,t){return e.map(r=>{const n=t?.get(r.path);return Le(r,n)})}function zt(e,t){switch(e.type){case"type":return`Expected ${ue(e.expected)}, got ${Gt(e.actual)}`;case"type_mismatch":return`Value must be of type ${ue(e.expected)}`;case"minLength":return`Must be at least ${e.expected} characters`;case"maxLength":return`Must be no more than ${e.expected} characters`;case"pattern":return Jt(e,t);case"format":return Kt(e);case"minimum":return`Must be at least ${e.expected}`;case"maximum":return`Must be at most ${e.expected}`;case"exclusiveMinimum":return`Must be greater than ${e.expected}`;case"exclusiveMaximum":return`Must be less than ${e.expected}`;case"multipleOf":return`Must be a multiple of ${e.expected}`;case"integer_bounds":return Zt(e);case"minItems":return`Must have at least ${e.expected} items`;case"maxItems":return`Must have no more than ${e.expected} items`;case"uniqueItems":return"All items must be unique";case"contains":return"Must contain at least one matching item";case"minContains":return`Must contain at least ${e.expected} matching items`;case"maxContains":return`Must contain no more than ${e.expected} matching items`;case"required":return"This field is required";case"minProperties":return`Must have at least ${e.expected} properties`;case"maxProperties":return`Must have no more than ${e.expected} properties`;case"additionalProperties":return`Unknown property: ${e.actual}`;case"dependentRequired":return Ht(e);case"enum":return Xt(e);case"const":return`Must be exactly ${JSON.stringify(e.expected)}`;case"ref_not_found":return`Invalid reference: ${e.expected}`;case"circular_ref":return"Circular reference detected";case"invalid":return"Invalid value";default:return e.context?.message??`Validation error: ${e.type}`}}function ue(e){return typeof e=="string"?oe(e):Array.isArray(e)?e.map(oe).join(" or "):String(e)}function Gt(e){return e===null?"null":e===void 0?"undefined":typeof e}function oe(e){return{string:"text",boolean:"true/false",int8:"integer (-128 to 127)",int16:"integer (-32768 to 32767)",int32:"integer",int64:"large integer",int128:"very large integer",uint8:"positive integer (0 to 255)",uint16:"positive integer (0 to 65535)",uint32:"positive integer",uint64:"large positive integer",uint128:"very large positive integer",float:"decimal number",double:"decimal number",decimal:"decimal number",date:"date",datetime:"date and time",time:"time",duration:"duration",uuid:"UUID",uri:"URL",binary:"binary data",object:"object",array:"list",set:"unique list",map:"key-value pairs",tuple:"ordered list",choice:"one of multiple options",any:"any value",null:"empty"}[e]??e}function Jt(e,t){const r=t?.description;if(r&&e.type==="pattern")return`Does not match required format: ${r}`;const n=e.expected;if(n){const a={"^[a-zA-Z]+$":"letters only","^[0-9]+$":"numbers only","^[a-zA-Z0-9]+$":"letters and numbers only","^\\S+$":"no spaces allowed","^[a-z]+$":"lowercase letters only","^[A-Z]+$":"uppercase letters only"}[n];if(a)return`Must be ${a}`}return"Does not match required format"}function Kt(e){const t=e.expected;return{email:"Must be a valid email address","date-time":"Must be a valid date and time",date:"Must be a valid date",time:"Must be a valid time",uri:"Must be a valid URL","uri-reference":"Must be a valid URL or relative path",uuid:"Must be a valid UUID",hostname:"Must be a valid hostname",ipv4:"Must be a valid IPv4 address",ipv6:"Must be a valid IPv6 address",regex:"Must be a valid regular expression","json-pointer":"Must be a valid JSON pointer"}[t]??`Must be a valid ${t}`}function Zt(e){const t=e.context?.type;if(t&&q(t)){const r=V[t];return`Must be between ${r.min} and ${r.max}`}return"Value is out of range for this integer type"}function Ht(e){const t=e.context?.dependent,r=e.context?.required;return t&&r?.length?`When "${t}" is present, "${r.join('", "')}" must also be provided`:"Missing required dependent fields"}function Xt(e){const t=e.expected;return t&&t.length<=5?`Must be one of: ${t.map(n=>JSON.stringify(n)).join(", ")}`:"Invalid value"}function Yt(e){const t=new Map;for(const r of e){const n=t.get(r.path)??[];n.push(r),t.set(r.path,n)}return t}function Qt(e,t){return e.filter(r=>r.path===t)}function er(e,t){return e.some(r=>r.path===t)}function tr(e,t){const r=t===""?"/":`${t}/`;return e.filter(n=>n.path.startsWith(r))}class L{registrations=new Map;parent;constructor(t){this.parent=t??null}register(t,r){this.registrations.set(t,r)}unregister(t){this.registrations.delete(t)}get(t){return this.registrations.get(t)??this.parent?.get(t)}has(t){return this.registrations.has(t)||(this.parent?.has(t)??!1)}names(){const t=this.parent?.names()??[],r=Array.from(this.registrations.keys());return[...new Set([...t,...r])]}getForType(t){const r=[];this.parent&&r.push(...this.parent.getForType(t));for(const n of this.registrations.values())n.supportedTypes?.includes(t)&&r.push(n);return r}getForFormat(t){const r=[];this.parent&&r.push(...this.parent.getForFormat(t));for(const n of this.registrations.values())n.supportedFormats?.includes(t)&&r.push(n);return r}findBestWidget(t){const r=[];for(const s of this.names()){const a=this.get(s);if(!a)continue;const u=this.scoreWidget(a,t);u>0&&r.push({name:s,registration:a,score:u})}if(r.length===0)return null;r.sort((s,a)=>a.score!==s.score?a.score-s.score:(a.registration.priority??0)-(s.registration.priority??0));const n=r[0];return{name:n.name,registration:n.registration}}scoreWidget(t,r){let n=0;if(t.matcher)if(t.matcher(r))n+=100;else return 0;const s=r.primaryType;s&&t.supportedTypes?.includes(s)&&(n+=50);const a=r.format;return a&&t.supportedFormats?.includes(a)&&(n+=30),n+=t.priority??0,n}createChild(){return new L(this)}}let E=null;function F(){return E||(E=new L),E}function rr(e){E=e}function nr(e){return new L(e)}function ir(e,t,r){return{name:`type:${e}`,registration:{factory:t,displayName:r?.displayName??`${e} widget`,description:r?.description,supportedTypes:[e],priority:r?.priority??0,canFallback:r?.canFallback??!1}}}function sr(e,t,r){return{name:`format:${e}`,registration:{factory:t,displayName:r?.displayName??`${e} widget`,description:r?.description,supportedFormats:[e],priority:r?.priority??10,canFallback:r?.canFallback??!1}}}function ar(e,t,r,n){return{name:`type:${e}:format:${t}`,registration:{factory:r,displayName:n?.displayName??`${e}/${t} widget`,description:n?.description,supportedTypes:[e],supportedFormats:[t],priority:n?.priority??20,canFallback:n?.canFallback??!1}}}function ur(e,t,r,n){return{name:e,registration:{factory:r,displayName:n?.displayName??e,description:n?.description,matcher:t,priority:n?.priority??50,canFallback:n?.canFallback??!1}}}function Ee(e,t){if(t){const n=t.findBestWidget(e);if(n)return n}return F().findBestWidget(e)}function or(e){const t=e.definition,r={};if(typeof t=="object"&&"x:ui"in t){const n=t["x:ui"];n.widget&&typeof n.widget=="object"&&(r.options=n.widget),typeof n.priority=="number"&&(r.priority=n.priority)}if(typeof t=="object"&&"widget"in t){const n=t.widget;typeof n=="object"&&n!==null&&(r.options={...r.options??{},...n})}return Object.keys(r).length>0?r:void 0}function ne(e){const t=e.definition;if(typeof t=="object"&&"x:ui"in t){const r=t["x:ui"];if(typeof r.widget=="string")return r.widget}if(typeof t=="object"&&"widget"in t){const r=t.widget;if(r&&typeof r.type=="string")return r.type}}function lr(e){return ne(e)!==void 0}function cr(e,t){const r=ne(e);if(r){if(t){const a=t.get(r);if(a)return{name:r,registration:a}}const s=F().get(r);if(s)return{name:r,registration:s};console.warn(`Widget "${r}" specified in definition but not found in registry`,{path:e.jsonPath})}return Ee(e,t)}function pr(e,t,r){return{...e,...t,...r}}function Ue(e=F()){e.register("string",{factory:({controller:i,ctx:o})=>xe({ctx:o,controller:i}),displayName:"String",description:"Text input for string values",supportedTypes:["string"],priority:0,canFallback:!0}),e.register("boolean",{factory:({controller:i,ctx:o})=>$e({ctx:o,controller:i}),displayName:"Boolean",description:"Checkbox for boolean values",supportedTypes:["boolean"],priority:0,canFallback:!0}),e.register("uuid",{factory:({controller:i,ctx:o})=>we({ctx:o,controller:i}),displayName:"UUID",description:"Input for UUID values",supportedTypes:["uuid"],priority:0,canFallback:!0}),e.register("uri",{factory:({controller:i,ctx:o})=>De({ctx:o,controller:i}),displayName:"URI",description:"Input for URI/URL values",supportedTypes:["uri"],priority:0,canFallback:!0}),e.register("binary",{factory:({controller:i,ctx:o})=>Oe({ctx:o,controller:i}),displayName:"Binary",description:"File upload for binary data",supportedTypes:["binary"],priority:0,canFallback:!0}),e.register("any",{factory:({controller:i,ctx:o})=>K({ctx:o,controller:i}),displayName:"Any",description:"Generic control for any type",supportedTypes:["any"],priority:0,canFallback:!0});const t=["int8","int16","int32","int64","int128","uint8","uint16","uint32","uint64","uint128"],r=({controller:i,ctx:o})=>Ce({ctx:o,controller:i,intType:o.primaryType});for(const i of t)e.register(i,{factory:r,displayName:i.toUpperCase(),description:`Number input for ${i} values`,supportedTypes:[i],priority:0,canFallback:!0});const n=["float","double","decimal"],s=({controller:i,ctx:o})=>je({ctx:o,controller:i,floatType:o.primaryType});for(const i of n)e.register(i,{factory:s,displayName:i.charAt(0).toUpperCase()+i.slice(1),description:`Number input for ${i} values`,supportedTypes:[i],priority:0,canFallback:!0});const a=["date","datetime","time","duration"],u=({controller:i,ctx:o})=>Se({ctx:o,controller:i,temporalType:o.primaryType});for(const i of a)e.register(i,{factory:u,displayName:i.charAt(0).toUpperCase()+i.slice(1),description:`Input for ${i} values`,supportedTypes:[i],priority:0,canFallback:!0});e.register("object",{factory:({controller:i,ctx:o})=>Ae({ctx:o,controller:i}),displayName:"Object",description:"Form for object values",supportedTypes:["object"],priority:0,canFallback:!0}),e.register("array",{factory:({controller:i,ctx:o})=>Me({ctx:o,controller:i}),displayName:"Array",description:"List control for array values",supportedTypes:["array"],priority:0,canFallback:!0}),e.register("set",{factory:({controller:i,ctx:o})=>Re({ctx:o,controller:i}),displayName:"Set",description:"Set control for unique values",supportedTypes:["set"],priority:0,canFallback:!0}),e.register("map",{factory:({controller:i,ctx:o})=>Ne({ctx:o,controller:i}),displayName:"Map",description:"Map control for key-value pairs",supportedTypes:["map"],priority:0,canFallback:!0}),e.register("tuple",{factory:({controller:i,ctx:o})=>ke({ctx:o,controller:i}),displayName:"Tuple",description:"Tuple control for fixed-length arrays",supportedTypes:["tuple"],priority:0,canFallback:!0}),e.register("choice",{factory:({controller:i,ctx:o})=>qe({ctx:o,controller:i}),displayName:"Choice",description:"Choice control for union types",supportedTypes:["choice"],priority:0,canFallback:!0}),e.register("enum",{factory:({controller:i,ctx:o})=>Fe({ctx:o,controller:i}),displayName:"Enum",description:"Dropdown for enumerated values",priority:10,canFallback:!1,matcher:i=>i.hasEnum}),e.register("const",{factory:({controller:i,ctx:o})=>Pe({ctx:o,controller:i}),displayName:"Const",description:"Display for constant values",priority:20,canFallback:!1,matcher:i=>i.hasConst})}function We(e=F()){return e.has("string")&&e.has("object")&&e.has("array")}function dr(e=F()){We(e)||Ue(e)}function Be(e){let t=e;if(e.$root){const r=R(e.$root,e);r&&(t=r)}return w(t,e,new Set)}function w(e,t,r){if(e.type&&D(e.type)){const n=e.type.$ref;if(r.has(n))return;r.add(n);const s=R(n,t);if(s){const a={...s,...e,type:s.type},u=w(a,t,r);return r.delete(n),u}r.delete(n);return}return e.default!==void 0?e.default:Array.isArray(e.examples)&&e.examples.length>0?e.examples[0]:"const"in e&&e.const!==void 0?e.const:"enum"in e&&Array.isArray(e.enum)&&e.enum.length>0?e.enum[0]:Cr(e)?null:fr(e,t,r)}function fr(e,t,r){const n=_e(e);if(M(e))return yr(e,t,r);if(n==="choice"&&"choices"in e)return gr(e,t,r);if(n==="tuple"&&"tuple"in e&&"properties"in e)return hr(e,t,r);if(n==="array")return br(e,t,r);if(n==="set")return vr(e,t,r);if(n==="map")return{};if(n==="string")return xr(e);if(jr(n))return $r(e);if(wr(n))return Tr(e);if(n==="boolean")return!1;if(n==="null")return null;if(Sr(n))return Ir(n);if(n==="uuid"||n==="uri"||n==="uri-reference"||n==="binary"||n==="bytes")return""}function mr(e){if(!e||e.length===0)return new Set;if(Array.isArray(e[0])){const t=e.flat();return new Set(t)}return new Set(e)}function yr(e,t,r){if(!M(e))return{};const n=mr(e.required),s={};for(const[a,u]of Object.entries(e.properties))if(n.has(a))if(u.type&&D(u.type)){const i=u.type.$ref;if(r.has(i))continue;r.add(i);const o=R(i,t);if(o){const c={...o,...u,type:o.type},p=w(c,t,r);p!==void 0&&(s[a]=p)}r.delete(i)}else{const i=w(u,t,r);i!==void 0&&(s[a]=i)}return s}function gr(e,t,r){if(!("choices"in e))return;const n=e.choices,s=Object.keys(n);if(s.length===0)return;const a=s[0],u=n[a];if("selector"in e&&e.selector){const o=e.selector,c=w(u,t,r);return typeof c=="object"&&c!==null?{[o]:a,...c}:{[o]:a}}const i=w(u,t,r);return{[a]:i}}function hr(e,t,r){if(!("tuple"in e)||!("properties"in e))return{};const n=e.tuple,s=e.properties,a=new Set(e.required??n),u={};for(const i of n){if(!a.has(i))continue;const o=s[i];if(o){const c=w(o,t,r);c!==void 0&&(u[i]=c)}}return u}function br(e,t,r){const n=("minItems"in e?e.minItems:0)??0;if(n===0)return[];const s="items"in e?e.items:void 0;if(!s)return Array(n).fill(null);const a=w(s,t,r);return Array(n).fill(a??null)}function vr(e,t,r){const n=("minItems"in e?e.minItems:0)??0;if(n===0)return[];const s="items"in e?e.items:void 0;if(!s)return Array(n).fill(null);const a=w(s,t,r);return Array(n).fill(a??null)}function xr(e){switch("format"in e?e.format:void 0){case"date":return ze();case"date-time":return Ge();case"time":return"00:00:00";case"email":case"uri":case"uri-reference":case"uuid":default:return""}}function $r(e){const t=_e(e),r=t==="int64"||t==="uint64"||t==="int128"||t==="uint128";let n="minimum"in e?e.minimum:void 0,s="maximum"in e?e.maximum:void 0;const a="exclusiveMinimum"in e?e.exclusiveMinimum:void 0,u="exclusiveMaximum"in e?e.exclusiveMaximum:void 0;a!==void 0&&(n=a+1),u!==void 0&&(s=u-1);let i;n!==void 0&&s!==void 0?i=Math.round((n+s)/2):n!==void 0?i=n:s!==void 0?i=0<=s?0:s:i=0;const o="multipleOf"in e?e.multipleOf:void 0;return o!==void 0&&o>0&&(i=Math.round(i/o)*o,n!==void 0&&i<n&&(i=Math.ceil(n/o)*o),s!==void 0&&i>s&&(i=Math.floor(s/o)*o)),r?BigInt(Math.round(i)):Math.round(i)}function Tr(e){let t="minimum"in e?e.minimum:void 0,r="maximum"in e?e.maximum:void 0;const n="exclusiveMinimum"in e?e.exclusiveMinimum:void 0,s="exclusiveMaximum"in e?e.exclusiveMaximum:void 0,a="multipleOf"in e?e.multipleOf:.001;n!==void 0&&(t=n+a),s!==void 0&&(r=s-a);let u;t!==void 0&&r!==void 0?u=(t+r)/2:t!==void 0?u=t:r!==void 0?u=0<=r?0:r:u=0;const i="multipleOf"in e?e.multipleOf:void 0;return i!==void 0&&i>0&&(u=Math.round(u/i)*i,t!==void 0&&u<t&&(u=Math.ceil(t/i)*i),r!==void 0&&u>r&&(u=Math.floor(r/i)*i)),u}function Ir(e){switch(e){case"date":return ze();case"time":return"00:00:00";case"datetime":return Ge();case"duration":return"PT0S";default:return""}}function Cr(e){return Array.isArray(e.type)?e.type.some(t=>typeof t=="string"?t==="null":!1):!1}function _e(e){const t=e.type;if(typeof t=="string")return t;if(Array.isArray(t)){for(const r of t)if(typeof r=="string"&&r!=="null")return r}}function jr(e){return e?["int8","int16","int32","int64","int128","uint8","uint16","uint32","uint64","uint128"].includes(e):!1}function wr(e){return e?["float","double","decimal"].includes(e):!1}function Sr(e){return e?["date","time","datetime","duration"].includes(e):!1}function ze(){return new Date().toISOString().split("T")[0]}function Ge(){return new Date().toISOString()}function Dr(e){if(e.isValid)return d.i.valid;const t=re(e.errors),r=new Map;for(const u of t){const i=r.get(u.path)||[];i.push(u),r.set(u.path,i)}const n=(u,i)=>{if(u.length===0)return{message:i.map(y=>y.message).join("; ")};const[o,...c]=u,p=n(c,i);return{dependencies:{[o]:p}}},s={},a={};for(const[u,i]of r.entries())if(u===""||u==="/")s.message=i.map(o=>o.message).join("; ");else{const o=u.split("/").filter(c=>c!=="");if(o.length===1)a[o[0]]={message:i.map(c=>c.message).join("; ")};else{const[c,...p]=o;a[c]=n(p,i)}}return Object.keys(a).length>0&&(s.dependencies=a),d.i.invalid(s)}function Or({schema:e,initialValue:t,validationMode:r,validateDebounceMs:n,widgetRegistry:s,readOnly:a,locale:u,onChange:i,onValidate:o,applySchemaDefaults:c=!0},p){const y=t!==void 0?l.Value.get(t):void 0,b=Be(e);let m;t===void 0?m=b??{}:c?m=h.deepMergeDefaults(b,y):m=y;const g=te(e),f=r??"onTouched",v=k=>{const x=g.validate(k);if(o&&!x.isValid){const A=re(x.errors);o(A)}return Dr(x)},{controller:$,setStatus:j}=d.useController({initialValue:m,validationMode:f,validateDebounceMs:n,validate:f==="onSubmit"?void 0:v,onChange:i}),N=()=>{$.dispose()},O=l.Fragment(l.OnDispose(N),Ve({schema:e,controller:$,widgetRegistry:s,readOnly:a,locale:u}));return p({Form:O,controller:$,setStatus:j})}exports.DefaultWidgetRegistry=L;exports.INTEGER_BOUNDS=V;exports.JSONStructureForm=Or;exports.RefResolver=be;exports.StructureContext=z;exports.StructureControl=Ve;exports.StructureGenericControl=T;exports.createExtendsResolver=tt;exports.createRefResolver=_;exports.createStructureContext=ve;exports.createValidator=te;exports.createWidgetRegistry=nr;exports.ensureDefaultWidgets=dr;exports.extractStructureDefaults=Be;exports.forFormat=sr;exports.forMatcher=ur;exports.forType=ir;exports.forTypeAndFormat=ar;exports.formatValidationError=Le;exports.formatValidationErrors=re;exports.getChildErrors=tr;exports.getErrorsForPath=Qt;exports.getExplicitWidgetName=ne;exports.getGlobalWidgetRegistry=F;exports.getNonNullTypes=B;exports.getResolvedType=J;exports.getWidgetOptions=or;exports.groupErrorsByPath=Yt;exports.hasConstValue=ye;exports.hasCustomWidget=lr;exports.hasDefaultWidgets=We;exports.hasEnumValue=me;exports.hasErrorsAtPath=er;exports.isArrayTypeDefinition=Z;exports.isBigIntType=le;exports.isChoiceTypeDefinition=Q;exports.isCompoundType=Ze;exports.isFloatType=U;exports.isIntegerType=q;exports.isMapTypeDefinition=X;exports.isNamespace=de;exports.isNullableType=ge;exports.isNumericType=ce;exports.isObjectTypeDefinition=M;exports.isPrimitiveType=pe;exports.isSetTypeDefinition=H;exports.isTemporalType=W;exports.isTupleTypeDefinition=Y;exports.isTypeDefinition=fe;exports.isTypeReference=D;exports.mergeWidgetOptions=pr;exports.parseRefPath=he;exports.registerDefaultWidgets=Ue;exports.resolveExtends=ee;exports.resolveRef=R;exports.resolveTypeReference=Xe;exports.resolveWidget=Ee;exports.resolveWidgetWithOverride=cr;exports.setGlobalWidgetRegistry=rr;exports.validate=_t;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { _ as J, g as Ke, t as Z, N as Je, b as pe, c as de, U as Ze, e as He, a as Xe, T as Ye, L as fe, f as me, h as Qe, G as et, i as tt, S as nt, j as rt } from "../deep-merge-
|
|
1
|
+
import { _ as J, g as Ke, t as Z, N as Je, b as pe, c as de, U as Ze, e as He, a as Xe, T as Ye, L as fe, f as me, h as Qe, G as et, i as tt, S as nt, j as rt } from "../deep-merge-Bsqkvp9-.js";
|
|
2
2
|
import { html as p, attr as m, Fragment as H, MapSignal as U, Value as I, computedOf as w, prop as it, WithElement as st, OnDispose as at } from "@tempots/dom";
|
|
3
|
-
import { b, a as ne, I as B, S as V, L as ye, d as ut, M as ot, f as re, A as G, g as ct, i as ie } from "../use-form-
|
|
3
|
+
import { b, a as ne, I as B, S as V, L as ye, d as ut, M as ot, f as re, A as G, g as ct, i as ie } from "../use-form-DMiCxK26.js";
|
|
4
4
|
import { T as lt, B as E } from "../translations-BEMKy6-W.js";
|
|
5
|
-
import { N as pt, B as dt, D as ft, a as mt, P as yt, b as gt, c as ht, d as bt, e as vt, F as xt } from "../duration-input-
|
|
5
|
+
import { N as pt, B as dt, D as ft, a as mt, P as yt, b as gt, c as ht, d as bt, e as vt, F as xt } from "../duration-input-DcZf0Dyd.js";
|
|
6
6
|
import { l as $t } from "../colors-DPo9GEJR.js";
|
|
7
7
|
function It(e) {
|
|
8
8
|
return e === "int64" || e === "int128" || e === "uint64" || e === "uint128";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const r=require("@tempots/dom"),w=require("./timer-BJHOsuS6.cjs"),q=require("./use-form-C5eF9ALX.cjs"),O=require("./translations-eUtMHN9s.cjs"),_=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])','[contenteditable="true"]',"audio[controls]","video[controls]","details > summary:first-of-type","details[open]"].join(", ");function P(o){return Array.from(o.querySelectorAll(_)).filter(t=>{const s=t;return s.offsetWidth>0&&s.offsetHeight>0&&!s.hasAttribute("inert")&&window.getComputedStyle(s).visibility!=="hidden"})}function V(o={}){const{active:t=!0,escapeDeactivates:s=!0,onEscape:e,initialFocus:n,returnFocus:a,clickOutsideDeactivates:i=!1,onClickOutside:d}=o;return r.WithElement(p=>{let f=t,h=null,c=[];typeof document<"u"&&(h=document.activeElement);const v=()=>{c=P(p)},b=u=>{if(f){if(s&&u.key==="Escape"){u.preventDefault(),e?.();return}if(u.key==="Tab"){if(v(),c.length===0){u.preventDefault();return}const l=c.indexOf(document.activeElement);u.shiftKey?l<=0&&(u.preventDefault(),c[c.length-1]?.focus()):l>=c.length-1&&(u.preventDefault(),c[0]?.focus())}}},g=u=>{if(!f||!i)return;const l=u.target;p.contains(l)||d?.()},y=()=>{if(!f)return;v();let u=null;typeof n=="function"?u=n():n?u=n:c.length>0&&(u=c[0]),u&&setTimeout(()=>{u?.focus()},50),document.addEventListener("keydown",b,!0),i&&document.addEventListener("click",g,!0)},A=()=>{f=!1,document.removeEventListener("keydown",b,!0),document.removeEventListener("click",g,!0);let u=null;typeof a=="function"?u=a():a?u=a:h&&(u=h),u&&document.body.contains(u)&&setTimeout(()=>{u?.focus()},0)};return setTimeout(()=>y(),0),r.OnDispose(()=>{A()})})}function U(o={}){return{activate:()=>V({...o,active:!0}),deactivate:()=>V({...o,active:!1})}}function B({initialStatus:o="closed",openedAfter:t,closedAfter:s}){const e=r.prop(o),n=()=>{e.set("start-opening")},a=()=>{e.set("start-closing")},i=e.map(l=>l!=="closed"&&l!=="start-closing"&&l!=="closing"),d=l=>{l?n():a()},p=()=>{d(!i.value)},f=[],h=l=>{f.push(e.on(x=>{x==="closed"&&l()}))};let c=()=>{};e.on(l=>{switch(c(),l){case"start-opening":c=w.g(()=>e.set("opening"));break;case"opening":c=t(()=>e.set("opened"));break;case"start-closing":c=w.g(()=>e.set("closing"));break;case"closing":c=s(()=>e.set("closed"));break;case"closed":c=()=>{};break}}),e.onDispose(()=>{f.forEach(l=>l()),c()});const v=e.map(l=>l==="closed"),b=e.map(l=>l==="start-opening"),g=e.map(l=>l==="opening"),y=e.map(l=>l==="opened"),A=e.map(l=>l==="closing"),u=e.map(l=>l==="start-closing");return{status:e,open:n,close:a,toggle:p,setOpen:d,display:i,isClosed:v,isStartOpening:b,isOpening:g,isOpened:y,isClosing:A,isStartClosing:u,dispose:()=>e.dispose(),listenOnClosed:h}}function z({initialStatus:o="closed",duration:t,openDuration:s=t??500,closeDuration:e=t??500}={}){return B({initialStatus:o,openedAfter:n=>w.I(n,s),closedAfter:n=>w.I(n,e)})}function I(o,t){let s=!1,e=null;function n(){s||(s=!0,o.removeEventListener("transitionend",a),o.removeEventListener("animationend",i),e&&(clearTimeout(e),e=null),t())}function a(f){f.target===o&&n()}function i(f){f.target===o&&n()}const d=()=>{if(typeof o.getAnimations>"u"){e=setTimeout(n,16);return}o.addEventListener("transitionend",a),o.addEventListener("animationend",i),o.getAnimations().length===0&&(e=setTimeout(n,1e3))},p=w.g(d);return()=>{s=!0,p(),e&&(clearTimeout(e),e=null),o.removeEventListener("transitionend",a),o.removeEventListener("animationend",i)}}function F({initialStatus:o="closed",element:t}={}){let s=t;return{setElement:e=>{s=e},...B({initialStatus:o,openedAfter:e=>s==null?(e(),()=>{}):I(s,e),closedAfter:e=>s==null?(e(),()=>{}):I(s,e)})}}function R(o){if(o==null)return"";const t=[];return o.fade&&t.push("fade"),o.slide&&t.push(`slide-${o.slide}`),o.scale!=null&&t.push("scale"),t.length>0?t.join(" "):"none"}function H(o){if(o==null)return"";const t=[];return o.scale!=null&&typeof o.scale=="number"&&t.push(`--scale-factor: ${o.scale}`),o.transformOrigin!=null&&t.push(`--transform-origin: ${o.transformOrigin}`),o.duration!=null&&t.push(`--animation-duration: ${o.duration}ms`),o.easing!=null&&t.push(`--animation-easing: ${o.easing}`),t.join("; ")}function M({animation:o,status:t}){const s=r.computedOf(o,t)((n,a)=>{if(n==null)return`bc-animated-toggle bc-animated-toggle--${a}`;const i=a==="start-opening"||a==="opening"||a==="opened";let d;return"enter"in n||"exit"in n?d=i?n.enter:n.exit:d=n,`bc-animated-toggle bc-animated-toggle--${R(d)} bc-animated-toggle--${a}`}),e=r.computedOf(o,t)((n,a)=>{if(n==null)return"";const i=a==="start-opening"||a==="opening"||a==="opened";let d;return"enter"in n||"exit"in n?d=i?n.enter:n.exit:d=n,H(d)});return r.Fragment(r.attr.class(s),r.attr.style(e))}function K({initialStatus:o="closed",animation:t},s){return r.WithElement(e=>{const{setElement:n,dispose:a,...i}=F({initialStatus:o,element:e});return n(e),r.Fragment(M({status:i.status,animation:t}),r.OnDispose(a),s(i))})}function D(o){return{"~standard":{version:1,vendor:"beatui-custom",validate:s=>{const e=o.validate(s);return e.success?{value:e.data}:{issues:e.errors.map(n=>({message:n.message,path:n.path}))}},types:void 0},safeParse:s=>{const e=o.validate(s);return e.success?{success:!0,data:e.data}:{success:!1,error:{errors:e.errors.map(n=>({message:n.message,path:n.path?.map(a=>typeof a=="object"&&"key"in a?a.key.toString():a.toString())||[]}))}}}}}class k{optional(){return new N(this)}default(t){return new G(this,t)}schema(){return D(this)}}class T extends k{minLength;maxLength;pattern;customValidations=[];validate(t){if(typeof t!="string")return{success:!1,errors:[{message:"Expected string"}]};const s=[];this.minLength!==void 0&&t.length<this.minLength&&s.push({message:`Must be at least ${this.minLength} characters`}),this.maxLength!==void 0&&t.length>this.maxLength&&s.push({message:`Must be at most ${this.maxLength} characters`}),this.pattern&&!this.pattern.test(t)&&s.push({message:"Invalid format"});for(const e of this.customValidations){const n=e(t);n&&s.push({message:n})}return s.length>0?{success:!1,errors:s}:{success:!0,data:t}}min(t,s){const e=new T;return e.minLength=t,e.maxLength=this.maxLength,e.pattern=this.pattern,e.customValidations=[...this.customValidations],s&&e.customValidations.push(n=>n.length<t?s:null),e}max(t,s){const e=new T;return e.minLength=this.minLength,e.maxLength=t,e.pattern=this.pattern,e.customValidations=[...this.customValidations],s&&e.customValidations.push(n=>n.length>t?s:null),e}regex(t,s){const e=new T;return e.minLength=this.minLength,e.maxLength=this.maxLength,e.pattern=t,e.customValidations=[...this.customValidations],s&&e.customValidations.push(n=>t.test(n)?null:s),e}email(t="Please enter a valid email address"){const s=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e=new T;return e.minLength=this.minLength,e.maxLength=this.maxLength,e.pattern=this.pattern,e.customValidations=[...this.customValidations,n=>s.test(n)?null:t],e}refine(t){const s=new T;return s.minLength=this.minLength,s.maxLength=this.maxLength,s.pattern=this.pattern,s.customValidations=[...this.customValidations,t],s}}class C extends k{mustBeTrue=!1;trueMessage;validate(t){return typeof t!="boolean"?{success:!1,errors:[{message:"Expected boolean"}]}:this.mustBeTrue&&t!==!0?{success:!1,errors:[{message:this.trueMessage||"Must be true"}]}:{success:!0,data:t}}refine(t,s){const e=new C;e.mustBeTrue=this.mustBeTrue,e.trueMessage=this.trueMessage;const n=e.validate.bind(e);return e.validate=a=>{const i=n(a);return i.success?t(i.data)?i:{success:!1,errors:[{message:s}]}:i},e}literal(t,s){const e=new C;return e.mustBeTrue=!0,e.trueMessage=s,e}}class N extends k{constructor(t){super(),this.inner=t}validate(t){if(t===void 0)return{success:!0,data:void 0};const s=this.inner.validate(t);return s.success?{success:!0,data:s.data}:{success:!1,errors:s.errors}}}class G extends k{constructor(t,s){super(),this.inner=t,this.defaultValue=s}validate(t){return t===void 0?{success:!0,data:this.defaultValue}:this.inner.validate(t)}}class $ extends k{constructor(t){super(),this.shape=t}validate(t){if(typeof t!="object"||t===null||Array.isArray(t))return{success:!1,errors:[{message:"Expected object"}]};const s=t,e={},n=[];for(const[a,i]of Object.entries(this.shape)){const d=i.validate(s[a]);if(d.success)e[a]=d.data;else for(const p of d.errors)n.push({message:p.message,path:[a,...p.path||[]]})}return n.length>0?{success:!1,errors:n}:{success:!0,data:e}}refine(t,s){const e=new $(this.shape),n=e.validate.bind(e);return e.validate=a=>{const i=n(a);if(!i.success)return i;const d=t(i.data);return d?{success:!1,errors:[{message:d,path:s?.path}]}:{success:!0,data:i.data}},e}}const J=()=>new T,Q=()=>new C,X=o=>new $(o);function j(o){return r.WithBrowserCtx(t=>{const s=[],e=()=>s.forEach(a=>a());return o(({effect:a="opaque",mode:i="capturing",onClickOutside:d,onEscape:p,content:f,container:h="body"})=>{h==="body"&&(t=t.makePortal("body"));const c=F();c.listenOnClosed(e);let v=()=>{},b=()=>{};const g=E=>{E.key==="Escape"&&(p?.(),c.close())},y=()=>{d?.(),c.close()},A=E=>{v(),b(),E==="capturing"?(document.addEventListener("keydown",g),v=()=>document.removeEventListener("keydown",g),t.element.addEventListener("mousedown",y),b=()=>t.element.removeEventListener("mousedown",y)):(v=()=>{},b=()=>{})},u=r.Value.on(i,A);s.push(u),s.push(()=>{c.dispose(),v(),b()});const l=()=>{const E=new Set;for(const m of t.element.querySelectorAll(":scope > :not([data-overlay])"))m.hasAttribute("inert")?E.add(m):m.setAttribute("inert","");return s.push(()=>{for(const m of t.element.querySelectorAll(":scope > :not([data-overlay])"))E.has(m)||m.removeAttribute("inert");E.clear()}),document.activeElement?.blur?.(),r.html.div(r.WithElement(m=>c.setElement(m)),r.dataAttr.status(c.status.map(String)),r.dataAttr.overlay("true"),r.attr.class(r.computedOf(a??"opaque",i)((m,L)=>`bc-overlay bc-overlay--effect-${m} bc-overlay--mode-${L}`)),f)},x=r.render(l(),t.element,{disposeWithParent:!0,clear:!1,providers:t.providers});s.push(x),w.g(()=>c.open())},e)})}function W(o,t){const{size:s="md",dismissable:e=!0,showCloseButton:n=!0,onClose:a,overlayEffect:i="opaque",container:d="body",position:p="center"}=o;return j((f,h)=>{let c=()=>{};return t(g=>{c=h;const y=r.prop("capturing");r.Value.on(e,m=>{y.set(m?"capturing":"non-capturing")});const A=r.computedOf(g.header!=null,n)((m,L)=>m||L),u=q.sessionId("modal"),l=`${u}-header`,x=`${u}-body`,E=r.html.div(r.attr.class(r.computedOf(s,p)((m,L)=>`bc-modal bc-modal--size-${m} bc-modal--container-${d} bc-modal--position-${L}`)),r.attr.role("dialog"),r.aria.modal(!0),...g.header?[r.aria.labelledby(l)]:[],r.aria.describedby(x),r.attr.tabindex(-1),r.attr.id(u),r.dataAttr.focusTrap("true"),r.on.mousedown(m=>m.stopPropagation()),V({escapeDeactivates:!1,initialFocus:()=>{const m=document.getElementById(u);if(!m)return null;const L=m.querySelector('[aria-label="Close modal"]');if(L)return L;const S=m.querySelector('button, input, select, textarea, [tabindex]:not([tabindex="-1"])');return S||m}}),r.html.div(r.attr.class("bc-modal__content"),r.When(A,()=>r.html.div(r.attr.class("bc-modal__header"),r.html.div(r.attr.class("bc-modal__title"),...g.header?[r.attr.id(l)]:[],g.header),r.When(n,()=>r.Use(O.BeatUII18n,m=>q.CloseButton({size:"sm",label:m.$.closeModal,onClick:()=>{c(),h()}}))))),r.html.div(r.attr.class("bc-modal__body"),r.attr.id(x),g.body),g.footer&&r.html.div(r.attr.class("bc-modal__footer"),g.footer)));f({mode:y,effect:i??"opaque",container:d,content:E,onClickOutside:()=>{a?.(),h()},onEscape:()=>{a?.(),h()}})},()=>{c(),h()})})}function Y(o,t){const{confirmText:s,cancelText:e,onConfirm:n,onCancel:a,...i}=o;return r.Use(O.BeatUII18n,d=>W({showCloseButton:!1,...i},(p,f)=>{const h=()=>{n?.(),f()},c=()=>{a?.(),f()};return t(b=>{p({body:b,footer:r.Fragment(r.attr.class("bc-modal__actions"),O.Button({variant:"outline",onClick:c},r.coalesce(e,d.$.cancel)),O.Button({color:"primary",variant:"filled",onClick:h},r.coalesce(s,d.$.confirm)))})},f)}))}exports.AnimatedToggle=K;exports.AnimatedToggleClass=M;exports.BooleanValidator=C;exports.ConfirmModal=Y;exports.FocusTrap=V;exports.Modal=W;exports.ObjectValidator=$;exports.Overlay=j;exports.StringValidator=T;exports.boolean=Q;exports.createStandardSchema=D;exports.object=X;exports.string=J;exports.useAnimatedElementToggle=F;exports.useAnimatedToggle=B;exports.useFocusTrap=U;exports.useTimedToggle=z;
|
|
1
|
+
"use strict";const r=require("@tempots/dom"),w=require("./timer-BJHOsuS6.cjs"),q=require("./use-form-pSErMD6z.cjs"),O=require("./translations-eUtMHN9s.cjs"),_=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])','[contenteditable="true"]',"audio[controls]","video[controls]","details > summary:first-of-type","details[open]"].join(", ");function P(o){return Array.from(o.querySelectorAll(_)).filter(t=>{const s=t;return s.offsetWidth>0&&s.offsetHeight>0&&!s.hasAttribute("inert")&&window.getComputedStyle(s).visibility!=="hidden"})}function V(o={}){const{active:t=!0,escapeDeactivates:s=!0,onEscape:e,initialFocus:n,returnFocus:a,clickOutsideDeactivates:i=!1,onClickOutside:d}=o;return r.WithElement(p=>{let f=t,h=null,c=[];typeof document<"u"&&(h=document.activeElement);const v=()=>{c=P(p)},b=u=>{if(f){if(s&&u.key==="Escape"){u.preventDefault(),e?.();return}if(u.key==="Tab"){if(v(),c.length===0){u.preventDefault();return}const l=c.indexOf(document.activeElement);u.shiftKey?l<=0&&(u.preventDefault(),c[c.length-1]?.focus()):l>=c.length-1&&(u.preventDefault(),c[0]?.focus())}}},g=u=>{if(!f||!i)return;const l=u.target;p.contains(l)||d?.()},y=()=>{if(!f)return;v();let u=null;typeof n=="function"?u=n():n?u=n:c.length>0&&(u=c[0]),u&&setTimeout(()=>{u?.focus()},50),document.addEventListener("keydown",b,!0),i&&document.addEventListener("click",g,!0)},A=()=>{f=!1,document.removeEventListener("keydown",b,!0),document.removeEventListener("click",g,!0);let u=null;typeof a=="function"?u=a():a?u=a:h&&(u=h),u&&document.body.contains(u)&&setTimeout(()=>{u?.focus()},0)};return setTimeout(()=>y(),0),r.OnDispose(()=>{A()})})}function U(o={}){return{activate:()=>V({...o,active:!0}),deactivate:()=>V({...o,active:!1})}}function B({initialStatus:o="closed",openedAfter:t,closedAfter:s}){const e=r.prop(o),n=()=>{e.set("start-opening")},a=()=>{e.set("start-closing")},i=e.map(l=>l!=="closed"&&l!=="start-closing"&&l!=="closing"),d=l=>{l?n():a()},p=()=>{d(!i.value)},f=[],h=l=>{f.push(e.on(x=>{x==="closed"&&l()}))};let c=()=>{};e.on(l=>{switch(c(),l){case"start-opening":c=w.g(()=>e.set("opening"));break;case"opening":c=t(()=>e.set("opened"));break;case"start-closing":c=w.g(()=>e.set("closing"));break;case"closing":c=s(()=>e.set("closed"));break;case"closed":c=()=>{};break}}),e.onDispose(()=>{f.forEach(l=>l()),c()});const v=e.map(l=>l==="closed"),b=e.map(l=>l==="start-opening"),g=e.map(l=>l==="opening"),y=e.map(l=>l==="opened"),A=e.map(l=>l==="closing"),u=e.map(l=>l==="start-closing");return{status:e,open:n,close:a,toggle:p,setOpen:d,display:i,isClosed:v,isStartOpening:b,isOpening:g,isOpened:y,isClosing:A,isStartClosing:u,dispose:()=>e.dispose(),listenOnClosed:h}}function z({initialStatus:o="closed",duration:t,openDuration:s=t??500,closeDuration:e=t??500}={}){return B({initialStatus:o,openedAfter:n=>w.I(n,s),closedAfter:n=>w.I(n,e)})}function I(o,t){let s=!1,e=null;function n(){s||(s=!0,o.removeEventListener("transitionend",a),o.removeEventListener("animationend",i),e&&(clearTimeout(e),e=null),t())}function a(f){f.target===o&&n()}function i(f){f.target===o&&n()}const d=()=>{if(typeof o.getAnimations>"u"){e=setTimeout(n,16);return}o.addEventListener("transitionend",a),o.addEventListener("animationend",i),o.getAnimations().length===0&&(e=setTimeout(n,1e3))},p=w.g(d);return()=>{s=!0,p(),e&&(clearTimeout(e),e=null),o.removeEventListener("transitionend",a),o.removeEventListener("animationend",i)}}function F({initialStatus:o="closed",element:t}={}){let s=t;return{setElement:e=>{s=e},...B({initialStatus:o,openedAfter:e=>s==null?(e(),()=>{}):I(s,e),closedAfter:e=>s==null?(e(),()=>{}):I(s,e)})}}function R(o){if(o==null)return"";const t=[];return o.fade&&t.push("fade"),o.slide&&t.push(`slide-${o.slide}`),o.scale!=null&&t.push("scale"),t.length>0?t.join(" "):"none"}function H(o){if(o==null)return"";const t=[];return o.scale!=null&&typeof o.scale=="number"&&t.push(`--scale-factor: ${o.scale}`),o.transformOrigin!=null&&t.push(`--transform-origin: ${o.transformOrigin}`),o.duration!=null&&t.push(`--animation-duration: ${o.duration}ms`),o.easing!=null&&t.push(`--animation-easing: ${o.easing}`),t.join("; ")}function M({animation:o,status:t}){const s=r.computedOf(o,t)((n,a)=>{if(n==null)return`bc-animated-toggle bc-animated-toggle--${a}`;const i=a==="start-opening"||a==="opening"||a==="opened";let d;return"enter"in n||"exit"in n?d=i?n.enter:n.exit:d=n,`bc-animated-toggle bc-animated-toggle--${R(d)} bc-animated-toggle--${a}`}),e=r.computedOf(o,t)((n,a)=>{if(n==null)return"";const i=a==="start-opening"||a==="opening"||a==="opened";let d;return"enter"in n||"exit"in n?d=i?n.enter:n.exit:d=n,H(d)});return r.Fragment(r.attr.class(s),r.attr.style(e))}function K({initialStatus:o="closed",animation:t},s){return r.WithElement(e=>{const{setElement:n,dispose:a,...i}=F({initialStatus:o,element:e});return n(e),r.Fragment(M({status:i.status,animation:t}),r.OnDispose(a),s(i))})}function D(o){return{"~standard":{version:1,vendor:"beatui-custom",validate:s=>{const e=o.validate(s);return e.success?{value:e.data}:{issues:e.errors.map(n=>({message:n.message,path:n.path}))}},types:void 0},safeParse:s=>{const e=o.validate(s);return e.success?{success:!0,data:e.data}:{success:!1,error:{errors:e.errors.map(n=>({message:n.message,path:n.path?.map(a=>typeof a=="object"&&"key"in a?a.key.toString():a.toString())||[]}))}}}}}class k{optional(){return new N(this)}default(t){return new G(this,t)}schema(){return D(this)}}class T extends k{minLength;maxLength;pattern;customValidations=[];validate(t){if(typeof t!="string")return{success:!1,errors:[{message:"Expected string"}]};const s=[];this.minLength!==void 0&&t.length<this.minLength&&s.push({message:`Must be at least ${this.minLength} characters`}),this.maxLength!==void 0&&t.length>this.maxLength&&s.push({message:`Must be at most ${this.maxLength} characters`}),this.pattern&&!this.pattern.test(t)&&s.push({message:"Invalid format"});for(const e of this.customValidations){const n=e(t);n&&s.push({message:n})}return s.length>0?{success:!1,errors:s}:{success:!0,data:t}}min(t,s){const e=new T;return e.minLength=t,e.maxLength=this.maxLength,e.pattern=this.pattern,e.customValidations=[...this.customValidations],s&&e.customValidations.push(n=>n.length<t?s:null),e}max(t,s){const e=new T;return e.minLength=this.minLength,e.maxLength=t,e.pattern=this.pattern,e.customValidations=[...this.customValidations],s&&e.customValidations.push(n=>n.length>t?s:null),e}regex(t,s){const e=new T;return e.minLength=this.minLength,e.maxLength=this.maxLength,e.pattern=t,e.customValidations=[...this.customValidations],s&&e.customValidations.push(n=>t.test(n)?null:s),e}email(t="Please enter a valid email address"){const s=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e=new T;return e.minLength=this.minLength,e.maxLength=this.maxLength,e.pattern=this.pattern,e.customValidations=[...this.customValidations,n=>s.test(n)?null:t],e}refine(t){const s=new T;return s.minLength=this.minLength,s.maxLength=this.maxLength,s.pattern=this.pattern,s.customValidations=[...this.customValidations,t],s}}class C extends k{mustBeTrue=!1;trueMessage;validate(t){return typeof t!="boolean"?{success:!1,errors:[{message:"Expected boolean"}]}:this.mustBeTrue&&t!==!0?{success:!1,errors:[{message:this.trueMessage||"Must be true"}]}:{success:!0,data:t}}refine(t,s){const e=new C;e.mustBeTrue=this.mustBeTrue,e.trueMessage=this.trueMessage;const n=e.validate.bind(e);return e.validate=a=>{const i=n(a);return i.success?t(i.data)?i:{success:!1,errors:[{message:s}]}:i},e}literal(t,s){const e=new C;return e.mustBeTrue=!0,e.trueMessage=s,e}}class N extends k{constructor(t){super(),this.inner=t}validate(t){if(t===void 0)return{success:!0,data:void 0};const s=this.inner.validate(t);return s.success?{success:!0,data:s.data}:{success:!1,errors:s.errors}}}class G extends k{constructor(t,s){super(),this.inner=t,this.defaultValue=s}validate(t){return t===void 0?{success:!0,data:this.defaultValue}:this.inner.validate(t)}}class $ extends k{constructor(t){super(),this.shape=t}validate(t){if(typeof t!="object"||t===null||Array.isArray(t))return{success:!1,errors:[{message:"Expected object"}]};const s=t,e={},n=[];for(const[a,i]of Object.entries(this.shape)){const d=i.validate(s[a]);if(d.success)e[a]=d.data;else for(const p of d.errors)n.push({message:p.message,path:[a,...p.path||[]]})}return n.length>0?{success:!1,errors:n}:{success:!0,data:e}}refine(t,s){const e=new $(this.shape),n=e.validate.bind(e);return e.validate=a=>{const i=n(a);if(!i.success)return i;const d=t(i.data);return d?{success:!1,errors:[{message:d,path:s?.path}]}:{success:!0,data:i.data}},e}}const J=()=>new T,Q=()=>new C,X=o=>new $(o);function j(o){return r.WithBrowserCtx(t=>{const s=[],e=()=>s.forEach(a=>a());return o(({effect:a="opaque",mode:i="capturing",onClickOutside:d,onEscape:p,content:f,container:h="body"})=>{h==="body"&&(t=t.makePortal("body"));const c=F();c.listenOnClosed(e);let v=()=>{},b=()=>{};const g=E=>{E.key==="Escape"&&(p?.(),c.close())},y=()=>{d?.(),c.close()},A=E=>{v(),b(),E==="capturing"?(document.addEventListener("keydown",g),v=()=>document.removeEventListener("keydown",g),t.element.addEventListener("mousedown",y),b=()=>t.element.removeEventListener("mousedown",y)):(v=()=>{},b=()=>{})},u=r.Value.on(i,A);s.push(u),s.push(()=>{c.dispose(),v(),b()});const l=()=>{const E=new Set;for(const m of t.element.querySelectorAll(":scope > :not([data-overlay])"))m.hasAttribute("inert")?E.add(m):m.setAttribute("inert","");return s.push(()=>{for(const m of t.element.querySelectorAll(":scope > :not([data-overlay])"))E.has(m)||m.removeAttribute("inert");E.clear()}),document.activeElement?.blur?.(),r.html.div(r.WithElement(m=>c.setElement(m)),r.dataAttr.status(c.status.map(String)),r.dataAttr.overlay("true"),r.attr.class(r.computedOf(a??"opaque",i)((m,L)=>`bc-overlay bc-overlay--effect-${m} bc-overlay--mode-${L}`)),f)},x=r.render(l(),t.element,{disposeWithParent:!0,clear:!1,providers:t.providers});s.push(x),w.g(()=>c.open())},e)})}function W(o,t){const{size:s="md",dismissable:e=!0,showCloseButton:n=!0,onClose:a,overlayEffect:i="opaque",container:d="body",position:p="center"}=o;return j((f,h)=>{let c=()=>{};return t(g=>{c=h;const y=r.prop("capturing");r.Value.on(e,m=>{y.set(m?"capturing":"non-capturing")});const A=r.computedOf(g.header!=null,n)((m,L)=>m||L),u=q.sessionId("modal"),l=`${u}-header`,x=`${u}-body`,E=r.html.div(r.attr.class(r.computedOf(s,p)((m,L)=>`bc-modal bc-modal--size-${m} bc-modal--container-${d} bc-modal--position-${L}`)),r.attr.role("dialog"),r.aria.modal(!0),...g.header?[r.aria.labelledby(l)]:[],r.aria.describedby(x),r.attr.tabindex(-1),r.attr.id(u),r.dataAttr.focusTrap("true"),r.on.mousedown(m=>m.stopPropagation()),V({escapeDeactivates:!1,initialFocus:()=>{const m=document.getElementById(u);if(!m)return null;const L=m.querySelector('[aria-label="Close modal"]');if(L)return L;const S=m.querySelector('button, input, select, textarea, [tabindex]:not([tabindex="-1"])');return S||m}}),r.html.div(r.attr.class("bc-modal__content"),r.When(A,()=>r.html.div(r.attr.class("bc-modal__header"),r.html.div(r.attr.class("bc-modal__title"),...g.header?[r.attr.id(l)]:[],g.header),r.When(n,()=>r.Use(O.BeatUII18n,m=>q.CloseButton({size:"sm",label:m.$.closeModal,onClick:()=>{c(),h()}}))))),r.html.div(r.attr.class("bc-modal__body"),r.attr.id(x),g.body),g.footer&&r.html.div(r.attr.class("bc-modal__footer"),g.footer)));f({mode:y,effect:i??"opaque",container:d,content:E,onClickOutside:()=>{a?.(),h()},onEscape:()=>{a?.(),h()}})},()=>{c(),h()})})}function Y(o,t){const{confirmText:s,cancelText:e,onConfirm:n,onCancel:a,...i}=o;return r.Use(O.BeatUII18n,d=>W({showCloseButton:!1,...i},(p,f)=>{const h=()=>{n?.(),f()},c=()=>{a?.(),f()};return t(b=>{p({body:b,footer:r.Fragment(r.attr.class("bc-modal__actions"),O.Button({variant:"outline",onClick:c},r.coalesce(e,d.$.cancel)),O.Button({color:"primary",variant:"filled",onClick:h},r.coalesce(s,d.$.confirm)))})},f)}))}exports.AnimatedToggle=K;exports.AnimatedToggleClass=M;exports.BooleanValidator=C;exports.ConfirmModal=Y;exports.FocusTrap=V;exports.Modal=W;exports.ObjectValidator=$;exports.Overlay=j;exports.StringValidator=T;exports.boolean=Q;exports.createStandardSchema=D;exports.object=X;exports.string=J;exports.useAnimatedElementToggle=F;exports.useAnimatedToggle=B;exports.useFocusTrap=U;exports.useTimedToggle=z;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WithElement as S, OnDispose as z, prop as R, computedOf as A, Fragment as M, attr as g, WithBrowserCtx as J, Value as U, render as Q, html as k, dataAttr as B, aria as V, on as X, When as j, Use as H, coalesce as q } from "@tempots/dom";
|
|
2
2
|
import { g as $, I as _ } from "./timer-Rd2sKnvH.js";
|
|
3
|
-
import { s as Y, C as Z } from "./use-form-
|
|
3
|
+
import { s as Y, C as Z } from "./use-form-DMiCxK26.js";
|
|
4
4
|
import { a as K, B as P } from "./translations-BEMKy6-W.js";
|
|
5
5
|
const ee = [
|
|
6
6
|
"a[href]",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { I as j, a as V, b as z, C as O, c as E } from "./translations-BEMKy6-W.js";
|
|
2
2
|
import { Use as x, input as A, attr as n, coalesce as F, on as m, Empty as w, emitValue as v, prop as k, computedOf as C, html as p, aria as M, When as T, Fragment as B, Value as g, Unless as R, Ensure as S } from "@tempots/dom";
|
|
3
|
-
import { C as W } from "./use-form-
|
|
3
|
+
import { C as W } from "./use-form-DMiCxK26.js";
|
|
4
4
|
const L = (t) => {
|
|
5
5
|
const l = {
|
|
6
6
|
name: "email",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const l=require("./translations-eUtMHN9s.cjs"),t=require("@tempots/dom"),C=require("./use-form-
|
|
1
|
+
"use strict";const l=require("./translations-eUtMHN9s.cjs"),t=require("@tempots/dom"),C=require("./use-form-pSErMD6z.cjs"),E=n=>{const r={name:"email",autocomplete:"email",...n},{value:c,before:s,onBlur:a,onChange:p,onInput:i,placeholder:h}=r,d=s??l.InputIcon({icon:"line-md:email",size:n.size,color:"neutral"});return t.Use(l.BeatUII18n,b=>l.InputContainer({...n,before:d,input:t.input.email(l.CommonInputAttributes(r),t.attr.placeholder(t.coalesce(h,b.$.emailPlaceholderText)),t.attr.value(c),t.attr.class("bc-input"),a!=null?t.on.blur(t.emitValue(a)):t.Empty,p!=null?t.on.change(t.emitValue(p)):t.Empty,i!=null?t.on.input(t.emitValue(i)):t.Empty)}))},_=n=>{const{value:r,onBlur:c,onChange:s,onInput:a,before:p,after:i,hasError:h,disabled:d,autocomplete:b,placeholder:I,...f}=n,y={name:"password",disabled:d,...f},u=t.prop(!0),o=t.computedOf(u,b)((e,m)=>e?m??"current-password":"off");return t.Use(l.BeatUII18n,e=>{const m=t.computedOf(e.$.passwordPlaceholderText,u,I)((g,V,v)=>V?"•••••••••••••••":v??g),w=t.html.button(t.attr.type("button"),t.attr.class("bc-input-container__password-toggle"),t.aria.label(e.$.togglePasswordVisibility),t.on.click(()=>u.update(g=>!g)),t.When(u,()=>l.Icon({icon:"line-md:watch"}),()=>l.Icon({icon:"line-md:watch-off"})));return l.InputContainer({before:p,disabled:d,hasError:h,input:t.html.input(l.CommonInputAttributes({...y,autocomplete:o,placeholder:m}),t.When(u,()=>t.Fragment(t.attr.type("password")),()=>t.Fragment(t.attr.type("text"))),t.attr.class("bc-input"),t.attr.value(r),c!=null?t.on.blur(t.emitValue(c)):t.Empty,s!=null?t.on.change(t.emitValue(s)):t.Empty,a!=null?t.on.input(t.emitValue(a)):t.Empty),after:i!=null?t.Fragment(w,i):w})})};function O(n){switch(n){case"success":return"material-symbols:check-circle-outline";case"warning":return"material-symbols:warning-outline";case"danger":return"material-symbols:error-outline";case"info":default:return"material-symbols:info-outline"}}function B(n){switch(n){case"success":return"success";case"warning":return"warning";case"danger":return"danger";case"info":default:return"info"}}function U(n,r,c,s){const a=["bc-notice",`bc-notice--${n}`,`bc-notice--tone-${r}`];return c&&a.push("bc-notice--dismissible"),s&&s.length>0&&a.push(s),a.join(" ")}function P({variant:n="info",tone:r="subtle",role:c,title:s,icon:a,closable:p=!1,onDismiss:i,class:h},...d){const b=t.prop(!0);return t.When(b,()=>{const I=t.Value.map(p,o=>!!o||i!=null),f=t.Value.map(n,o=>o??"info"),y=t.Value.map(r,o=>o??"subtle"),u=t.computedOf(c,f)((o,e)=>o??(e==="danger"?"alert":"status"));return t.Use(l.BeatUII18n,o=>t.html.div(t.attr.class(t.computedOf(f,y,I,h)((e,m,w,g)=>U(e,m,w,g))),t.attr.role(t.Value.map(u,e=>e)),t.Unless(t.Value.map(a,e=>e===!1),()=>t.html.div(t.attr.class("bc-notice__icon"),l.Icon({icon:t.computedOf(a,f)((e,m)=>e===void 0?O(m):String(e)),size:"md",color:t.Value.map(f,B)}))),t.html.div(t.attr.class("bc-notice__body"),t.Ensure(s,e=>t.html.div(t.attr.class("bc-notice__title"),e)),t.html.div(t.attr.class("bc-notice__content"),...d)),t.When(I,()=>C.CloseButton({size:"xs",label:o.$.closeModal,onClick:()=>{b.set(!1),i?.()}}))))})}exports.EmailInput=E;exports.Notice=P;exports.PasswordInput=_;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../index-BGwNJNop.cjs");exports.DEFAULT_FEATURES=r.DEFAULT_FEATURES;exports.ProseMirrorMarkdownInput=r.ProseMirrorMarkdownInput;exports.ProseMirrorToolbar=r.ProseMirrorToolbar;
|
|
@@ -1090,9 +1090,9 @@ function De(...e) {
|
|
|
1090
1090
|
}
|
|
1091
1091
|
const de = (
|
|
1092
1092
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1093
|
-
(e, s) => () => {
|
|
1093
|
+
((e, s) => () => {
|
|
1094
1094
|
e.markTouched(), s?.();
|
|
1095
|
-
}
|
|
1095
|
+
})
|
|
1096
1096
|
), z = (e, s) => (t) => {
|
|
1097
1097
|
e.change(t), s?.(t);
|
|
1098
1098
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const r=require("@tempots/dom"),F=require("./translations-eUtMHN9s.cjs"),P=new Map;function I(e){const s=P.get(e)??0;return P.set(e,s+1),`${e}-${s}`}const n={notAsked:{type:"NotAsked"},loading(e=void 0){return{type:"Loading",previousValue:e}},success(e){return{type:"AsyncSuccess",value:e}},failure(e){return{type:"AsyncFailure",error:e}},isSuccess(e){return e.type==="AsyncSuccess"},isFailure(e){return e.type==="AsyncFailure"},isNotAsked(e){return e.type==="NotAsked"},isLoading(e){return e.type==="Loading"},getOrElse(e,s){return n.isSuccess(e)?e.value:s},getOrElseLazy(e,s){return n.isSuccess(e)?e.value:s()},getOrNull(e){return n.isSuccess(e)?e.value:null},getOrUndefined(e){return n.isSuccess(e)?e.value:void 0},getUnsafe:e=>{if(n.isSuccess(e))return e.value;throw n.isFailure(e)?e.error:new Error("Cannot get value from a not-asked or loading result")},match:(e,{success:s,failure:t,loading:a,notAsked:i=a})=>n.isSuccess(e)?s(e.value):n.isFailure(e)?t(e.error):n.isNotAsked(e)?i():a(e.previousValue),effect:(e,s)=>{switch(e.type){case"AsyncSuccess":s.success?s.success(e.value):s.else?.();break;case"AsyncFailure":s.failure?s.failure(e.error):s.else?.();break;case"Loading":s.loading?s.loading(e.previousValue):s.else?.();break;case"NotAsked":s.notAsked?s.notAsked():s.else?.();break}return e},whenSuccess:(e,s)=>(n.isSuccess(e)&&s(e.value),e),whenFailure:(e,s)=>(n.isFailure(e)&&s(e.error),e),equals:(e,s,t={valueEquals:(a,i)=>a===i,errorEquals:(a,i)=>a===i})=>e.type==="AsyncSuccess"&&s.type==="AsyncSuccess"?t.valueEquals(e.value,s.value):e.type==="AsyncFailure"&&s.type==="AsyncFailure"?t.errorEquals(e.error,s.error):e.type==="Loading"&&s.type==="Loading"?t.valueEquals(e.previousValue,s.previousValue):e.type==="NotAsked"&&s.type==="NotAsked",all:e=>{const s=[];for(const t of e)if(n.isSuccess(t))s.push(t.value);else return t;return n.success(s)},ofPromise:async e=>{try{const s=await e;return n.success(s)}catch(s){return n.failure(s instanceof Error?s:new Error(String(s)))}},map:(e,s)=>{switch(e.type){case"AsyncSuccess":return n.success(s(e.value));case"NotAsked":return n.notAsked;case"AsyncFailure":return n.failure(e.error);case"Loading":return n.loading(e.previousValue!=null?s(e.previousValue):void 0)}},flatMap:(e,s)=>{switch(e.type){case"AsyncSuccess":return s(e.value);case"NotAsked":return n.notAsked;case"AsyncFailure":return n.failure(e.error);case"Loading":return n.loading()}},mapError:(e,s)=>{switch(e.type){case"AsyncSuccess":return n.success(e.value);case"NotAsked":return n.notAsked;case"AsyncFailure":return n.failure(s(e.error));case"Loading":return n.loading(e.previousValue)}},flatMapError:(e,s)=>{switch(e.type){case"AsyncSuccess":return n.success(e.value);case"NotAsked":return n.notAsked;case"AsyncFailure":return s(e.error);case"Loading":return n.loading(e.previousValue)}},toResult:e=>{switch(e.type){case"AsyncSuccess":return{type:"Success",value:e.value};case"AsyncFailure":return{type:"Failure",error:e.error};case"NotAsked":case"Loading":return}},isSettled(e){return e.type==="AsyncSuccess"||e.type==="AsyncFailure"},recover:(e,s)=>{switch(e.type){case"AsyncSuccess":return n.success(e.value);case"NotAsked":return n.notAsked;case"AsyncFailure":return n.success(s(e.error));case"Loading":return n.loading(e.previousValue)}},ap:(e,s)=>n.isSuccess(e)&&n.isSuccess(s)?n.success(e.value(s.value)):n.isFailure(e)?n.failure(e.error):n.isFailure(s)?n.failure(s.error):n.isLoading(e)||n.isLoading(s)?n.loading():n.notAsked,map2:(e,s,t)=>n.isSuccess(e)&&n.isSuccess(s)?n.success(t(e.value,s.value)):n.isFailure(e)?n.failure(e.error):n.isFailure(s)?n.failure(s.error):n.isLoading(e)||n.isLoading(s)?n.loading():n.notAsked,map3:(e,s,t,a)=>n.isSuccess(e)&&n.isSuccess(s)&&n.isSuccess(t)?n.success(a(e.value,s.value,t.value)):n.isFailure(e)?n.failure(e.error):n.isFailure(s)?n.failure(s.error):n.isFailure(t)?n.failure(t.error):n.isLoading(e)||n.isLoading(s)||n.isLoading(t)?n.loading():n.notAsked},E=(e,s)=>e===s||e!==e&&s!==s,h={valid:{type:"valid"},invalid(e){return{type:"invalid",error:e}},isValid(e){return e.type==="valid"},isInvalid(e){return e.type==="invalid"},match:(e,s,t)=>h.isValid(e)?s():t(e.error),toResult:(e,s)=>h.match(e,()=>o.success(s),t=>o.failure(t)),effect:(e,s)=>(e.type==="valid"?s.valid?s.valid():s.else?.():s.invalid?s.invalid(e.error):s.else?.(),e),whenValid:(e,s)=>(h.isValid(e)&&s(),e),whenInvalid:(e,s)=>(h.isInvalid(e)&&s(e.error),e),mapError:(e,s)=>e.type==="invalid"?h.invalid(s(e.error)):e,flatMapError:(e,s)=>e.type==="invalid"?s(e.error):e,combine:(e,s,t)=>h.isValid(e)&&h.isValid(s)?h.valid:h.isInvalid(e)&&h.isInvalid(s)?h.invalid(t(e.error,s.error)):h.isInvalid(e)?e:s,all:e=>{for(const s of e)if(h.isInvalid(s))return s;return h.valid},allErrors:e=>{const s=[];for(const t of e)h.isInvalid(t)&&s.push(t.error);return s.length>0?h.invalid(s):h.valid},equals:(e,s,t=(a,i)=>a===i)=>e.type==="valid"&&s.type==="valid"?!0:e.type==="invalid"&&s.type==="invalid"?t(e.error,s.error):!1,recover:e=>h.valid,getError:e=>{if(h.isInvalid(e))return e.error},getErrorOrElse:(e,s)=>h.isInvalid(e)?e.error:s},o={success(e){return{type:"Success",value:e}},failure(e){return{type:"Failure",error:e}},map:(e,s)=>e.type==="Success"?o.success(s(e.value)):e,flatMap:(e,s)=>e.type==="Success"?s(e.value):e,toAsync(e){return o.match(e,s=>n.success(s),s=>n.failure(s))},toValidation(e){return o.match(e,()=>h.valid,s=>h.invalid(s))},isSuccess(e){return e.type==="Success"},isFailure(e){return e.type==="Failure"},getOrElse(e,s){return o.isSuccess(e)?e.value:s},getOrElseLazy(e,s){return o.isSuccess(e)?e.value:s()},getOrNull(e){return o.isSuccess(e)?e.value:null},getOrUndefined(e){return o.isSuccess(e)?e.value:void 0},getUnsafe:e=>{if(o.isSuccess(e))return e.value;throw e.error},match:(e,s,t)=>o.isSuccess(e)?s(e.value):t(e.error),effect:(e,s)=>(e.type==="Success"?s.success?s.success(e.value):s.else?.():s.failure?s.failure(e.error):s.else?.(),e),whenSuccess:(e,s)=>(o.isSuccess(e)&&s(e.value),e),whenFailure:(e,s)=>(o.isFailure(e)&&s(e.error),e),combine:(e,s,t,a)=>o.match(e,i=>o.match(s,l=>o.success(t(i,l)),l=>o.failure(l)),i=>o.match(s,l=>o.failure(i),l=>o.failure(a(i,l)))),equals:(e,s,t={valueEquals:(a,i)=>a===i,errorEquals:(a,i)=>a===i})=>e.type==="Success"&&s.type==="Success"?t.valueEquals(e.value,s.value):e.type==="Failure"&&s.type==="Failure"?t.errorEquals(e.error,s.error):!1,all:e=>{const s=[];for(const t of e)if(o.isSuccess(t))s.push(t.value);else return t;return o.success(s)},mapError:(e,s)=>e.type==="Failure"?o.failure(s(e.error)):e,flatMapError:(e,s)=>e.type==="Failure"?s(e.error):e,recover:(e,s)=>e.type==="Failure"?{type:"Success",value:s(e.error)}:e,ap:(e,s)=>o.isSuccess(e)&&o.isSuccess(s)?o.success(e.value(s.value)):o.isFailure(e)?o.failure(e.error):o.failure(s.error),map2:(e,s,t)=>o.isSuccess(e)&&o.isSuccess(s)?o.success(t(e.value,s.value)):o.isFailure(e)?o.failure(e.error):o.failure(s.error),map3:(e,s,t,a)=>o.isSuccess(e)&&o.isSuccess(s)&&o.isSuccess(t)?o.success(a(e.value,s.value,t.value)):o.isFailure(e)?o.failure(e.error):o.isFailure(s)?o.failure(s.error):o.failure(t.error),ofPromise:async e=>{try{const s=await e;return o.success(s)}catch(s){return o.failure(s instanceof Error?s:new Error(String(s)))}},swap:e=>o.isSuccess(e)?o.failure(e.value):o.success(e.error),fromNullable:(e,s)=>e==null?o.failure(s):o.success(e),fromNullableLazy:(e,s)=>e==null?o.failure(s()):o.success(e),tryCatch:e=>{try{return o.success(e())}catch(s){return o.failure(s instanceof Error?s:new Error(String(s)))}}};function Z({size:e="sm",icon:s="line-md:close",disabled:t,roundedness:a="full",color:i="base",onClick:l,label:u},...c){return r.Use(F.BeatUII18n,d=>{const m=r.coalesce(u,d.$.closeModal);return F.Button({variant:"text",size:e,roundedness:a,disabled:t,color:i,onClick:l},r.attr.title(m),r.aria.label(m),...c,F.Icon({icon:s,size:e??"sm"}))})}function T(e){return`bc-label bc-label--${e}`}const ee=(...e)=>r.html.span(r.attr.class(T("emphasis")),...e),q=(...e)=>r.html.span(r.attr.class(T("default")),...e),$=(...e)=>r.html.span(r.attr.class(T("muted")),...e),se=(...e)=>r.html.span(r.attr.class(T("danger")),...e),te=e=>{const{value:s,onBlur:t,onChange:a,placeholder:i,disabled:l,id:u,checkedIcon:c,uncheckedIcon:d,iconSize:m="lg"}=e,p=u??I("checkbox"),v=`${p}-label`,b=()=>{if(r.Value.get(l??!1))return;const f=r.Value.get(s);a?.(!f)},k=f=>{r.Value.get(l??!1)||(f.key===" "||f.key==="Enter")&&(f.preventDefault(),b())};return F.InputContainer({baseContainer:!0,growInput:!1,...e,input:r.html.span(r.attr.class("bc-checkbox-input"),r.html.span(r.attr.class("bc-checkbox-input__checkbox"),r.attr.class(r.Value.map(s,f=>f?"bc-checkbox-input__checkbox--checked":"bc-checkbox-input__checkbox--unchecked")),r.attr.class(r.Value.map(l??!1,f=>f?"bc-checkbox-input__checkbox--disabled":"")),r.attr.id(p),r.attr.role("checkbox"),r.attr.tabindex(r.Value.map(l??!1,f=>f?-1:0)),r.aria.checked(s),r.aria.disabled(l),i!=null?r.aria.labelledby(v):r.Empty,r.on.keydown(k),t!=null?r.on.blur(t):r.Empty,F.Icon({icon:r.computedOf(s,c,d)((f,y,S)=>f?y??"akar-icons/check-box-fill":S??"akar-icons/box"),accessibility:"decorative",size:m})),i!=null?r.html.label(r.attr.class("bc-checkbox-input__label"),r.attr.id(v),r.attr.for(p),$(i)):r.Empty)},r.on.click(b))},j=r.html.span(r.attr.class("bc-input-wrapper__required")," *");function re(e){const s=["bc-input-wrapper"];return e!=="vertical"&&s.push(`bc-input-wrapper--${e}`),s.join(" ")}function ae(e,s){const t=["bc-input-wrapper__label-text"];return e?t.push("bc-input-wrapper__label-text--error"):s?t.push("bc-input-wrapper__label-text--disabled"):t.push("bc-input-wrapper__label-text--default"),t.join(" ")}function ie(e,s){if(e==="horizontal-fixed"&&s!=null)return`--input-wrapper-label-width: ${s}`}const M=({fullWidth:e=!1,required:s,label:t,labelChildren:a,context:i,description:l,content:u,error:c,labelFor:d,hasError:m,disabled:p,layout:v,labelWidth:b},...k)=>{const f=m??c!=null,y=p??!1,S=v??"vertical",C=I("input-wrapper"),D=l?`${C}-description`:void 0,O=c!=null?`${C}-error`:void 0,B=r.computedOf(S)(g=>g!=="vertical"),Y=r.computedOf(S,b??void 0)((g,A)=>ie(g,A));return r.html.div(r.attr.class(r.Value.map(S,g=>re(g))),r.attr.class(r.Value.map(e,g=>g?"bc-input-wrapper--full-width":"")),r.attr.style(Y),t!=null||i!=null?r.html.div(r.attr.class("bc-input-wrapper__header"),r.html.div(r.attr.class("bc-input-wrapper__label-section"),r.html.label(r.attr.class("bc-input-wrapper__label"),d!=null?r.attr.for(d):r.Empty,r.html.span(r.attr.class(r.computedOf(f,y)((g,A)=>ae(g??!1,A??!1))),t),t!=null&&s?j:r.Empty),r.When(r.computedOf(B,l)((g,A)=>g&&A!=null),()=>r.html.div(r.attr.class("bc-input-wrapper__description bc-input-wrapper__description--under-label"),r.attr.id(D),l))),i!=null?q(i):r.Empty,a):r.Empty,r.html.div(r.attr.class("bc-input-wrapper__content"),[D,O].filter(Boolean).length>0?r.dataAttr.describedby([D,O].filter(Boolean).join(" ")):r.Empty,s?r.dataAttr.required("true"):r.Empty,r.When(f,()=>r.dataAttr.invalid("true")),u),r.When(r.computedOf(B,l)((g,A)=>!g&&A!=null),()=>r.html.div(r.attr.class("bc-input-wrapper__description"),r.attr.id(D),l)),r.When(f,()=>r.html.div(r.attr.class("bc-input-wrapper__error"),r.attr.id(O),r.aria.live("polite"),r.attr.role("alert"),c)),...k)};function ne(...e){return r.html.div(r.attr.class("bc-stack"),...e)}const H=(e,s)=>()=>{e.markTouched(),s?.()},_=(e,s)=>t=>{e.change(t),s?.(t)};function N(e,s){const{controller:t,onBlur:a,onChange:i,id:l,triggerOn:u,...c}=s;return e({id:l??t.name,disabled:t.disabled,value:t.signal,hasError:t.errorVisible,name:t.name,...c,onInput:u==="input"?_(t,i):void 0,onChange:u!=="input"?_(t,i):void 0,onBlur:H(t,a)})}function le(e,{id:s,labelFor:t,...a},...i){const l=s??a.controller.name??I("control"),u=t??l;return M({...a,hasError:a.controller.errorVisible,error:r.TextNode(a.controller.error.map(c=>c??"")),labelFor:u,content:N(c=>e({...c,id:l}),a)},...i)}function z(e,s){const{toInput:t,fromInput:a,controller:i,...l}=s,u=i.transform(t,a);return N(e,{...l,controller:u})}function ce(e,{id:s,labelFor:t,...a},...i){const l=s??a.controller.name??I("control");return M({...a,labelFor:t??l,content:z(e,{...a,id:l})},...i)}function oe(e){return e.split(".").map(t=>{const a=t.match(/^\[(\d+)\]$/);return a?Number(a[1]):t})}function W(e){return typeof e=="number"?`[${e}]`:`.${e}`}function R(e){if(e.length===0)return"";const[s,...t]=e;return[typeof s=="number"?`[${s}]`:s,...t.map(W)].join("")}const ue={valid:h.valid,invalid(e){return h.invalid({message:e})},invalidFields(e){const s={};for(const[t,a]of Object.entries(e))s[t]=typeof a=="string"?{message:a}:a;return h.invalid({dependencies:s})},fromError(e){return h.invalid(e)}};function V(e){return function(t){if(t.type==="valid")return t;let a=t.error;for(const i of e)if(a=a?.dependencies?.[i],a==null)return h.valid;return h.invalid(a)}}class w{path;change;signal;status;error;hasError;touched;errorVisible;dirty;dependencyErrors;#e={disabled:r.prop(!1),touched:r.prop(!1)};#t;#s=r.prop(void 0);parent;disabled;#r=[];disabledOrHasErrors;constructor(s,t,a,i,l,u=E){this.path=s,this.change=t,this.signal=a,this.status=i,this.#t=u,this.#s.set(a.value),this.error=i.map(c=>c?.type==="invalid"?c.error?.message:void 0),this.hasError=this.error.map(c=>c!=null),this.touched=this.#e.touched,l.validationMode?this.errorVisible=r.computedOf(this.hasError,this.touched,l.validationMode)((c,d,m)=>m==="eager"?!!c:!!c&&!!d):this.errorVisible=r.computedOf(this.hasError,this.touched)((c,d)=>!!c&&!!d),this.dirty=r.computedOf(this.signal,this.#s)((c,d)=>!this.#t(c,d)),this.dependencyErrors=i.map(c=>c?.type==="invalid"?c.error?.dependencies:void 0),this.parent=l,this.disabled=r.computedOf(this.#e.disabled,l.disabled)((c,d)=>c||d),this.disabledOrHasErrors=r.computedOf(this.disabled,this.hasError)((c,d)=>c||d),this.onDispose(()=>{this.#e.disabled.dispose(),this.#e.touched.dispose(),this.disabled.dispose(),this.error.dispose(),this.errorVisible.dispose(),this.dirty.dispose(),this.#s.dispose(),this.dependencyErrors.dispose(),this.disabledOrHasErrors.dispose()})}get name(){return R(this.path)}onDispose=s=>{this.#r.push(s)};dispose=()=>{for(const s of this.#r)try{s()}catch(t){console.error("Error in dispose callback:",t)}this.#r.length=0};setDisabled=s=>{this.#e.disabled.set(s)};disable=()=>this.setDisabled(!0);enable=()=>this.setDisabled(!1);markTouched=()=>{this.#e.touched.set(!0)};resetTouched=()=>{this.#e.touched.set(!1)};markPristine=()=>{this.#s.set(this.signal.value)};reset=()=>{this.change(this.#s.value)};array=(s=E)=>new K(this.path,this.change,this.signal,this.status,this.parent,s);object=(s=E)=>new U(this.path,this.change,this.signal,this.status,this.parent,s);transform=(s,t,a=[],i=E)=>new w([...this.path,...a],l=>this.change(t(l)),this.signal.map(s,i),this.status.map(V(a)),this.parent,i);asyncTransform=(s,t,a,i=[],l=E)=>new w([...this.path,...i],u=>{t(u).then(c=>this.change(c))},this.signal.mapAsync(s,a,void 0,l),this.status.map(V(i)),this.parent,l)}class U extends w{#e=new Map;#t=new Map;#s=new Map;#r=r.prop(!1);touchedDeep=this.#r;#i=new Map;#a=new Map;#l=r.prop(!1);dirtyDeep=this.#l;#o;#u;#c=()=>{let s=!1;for(const t of this.#t.values())if(t){s=!0;break}this.#r.set(this.touched.value||s)};constructor(s,t,a,i,l,u){super(s,t,a.map(d=>d??{},u),i,l,u),this.#o=this.touched.on(()=>{this.#c()}),this.#u=this.dirty.on(()=>{this.#n()});const c=this.signal.on(()=>this.#n());this.onDispose(()=>{for(const d of this.#e.values())d.dispose();this.#e.clear();for(const d of this.#s.values())d();this.#s.clear(),this.#t.clear(),this.#r.dispose();for(const d of this.#a.values())d();this.#a.clear(),this.#i.clear(),this.#l.dispose(),this.#o(),this.#u(),c()})}field=s=>{if(this.#e.has(s))return this.#e.get(s);const t=async u=>{this.change({...this.signal.value,[s]:u})},a=new w([...this.path,s],t,this.signal.map(u=>u[s]),this.status.map(V([s])),{disabled:this.disabled,validationMode:this.parent.validationMode});this.#e.set(s,a);const i=a.touched.on(u=>{this.#t.set(s,u),this.#c()});this.#s.set(s,i);const l=a.dirty.on(u=>{this.#i.set(s,u),this.#n()});return this.#a.set(s,l),a};markAllTouched=()=>{this.markTouched();const s=this.signal.value;for(const t of Object.keys(s))this.field(t).markTouched();for(const t of this.#e.values())t.markTouched()};markAllPristine=()=>{this.markPristine();const s=this.signal.value;for(const t of Object.keys(s))this.field(t).markPristine?.();for(const t of this.#e.values())t.markPristine?.()};#n=()=>{let s=!1;for(const t of this.#i.values())if(t){s=!0;break}this.#l.set(this.dirty.value||s)}}class K extends w{#e=new Array;length;#t=new Map;#s=new Map;#r=r.prop(!1);touchedDeep=this.#r;#i=new Map;#a=new Map;#l=r.prop(!1);dirtyDeep=this.#l;#o;#u;#c=()=>{let s=!1;for(const t of this.#t.values())if(t){s=!0;break}this.#r.set(this.touched.value||s)};constructor(s,t,a,i,l,u){const c=a.map(p=>p??[],u);super(s,t,c,i,l,u);const d=c.on(p=>{const v=this.#e.length-p.length;v>0&&(this.#e.splice(p.length,v).forEach((b,k)=>{const f=p.length+k;b.dispose(),this.#s.get(f)?.(),this.#s.delete(f),this.#t.delete(f),this.#a.get(f)?.(),this.#a.delete(f),this.#i.delete(f)}),this.#c(),this.#n())});this.length=c.map(p=>p.length),this.#o=this.touched.on(()=>{this.#c()}),this.#u=this.dirty.on(()=>{this.#n()});const m=this.signal.on(()=>this.#n());this.onDispose(()=>{for(const p of this.#e)p.dispose();this.length.dispose(),this.#e.length=0,d(),c.dispose();for(const p of this.#s.values())p();this.#s.clear(),this.#t.clear(),this.#r.dispose();for(const p of this.#a.values())p();this.#a.clear(),this.#i.clear(),this.#l.dispose(),this.#o(),this.#u(),m()})}item=s=>{if(this.#e[s])return this.#e[s];const t=async u=>{const c=this.signal.value.slice();c[s]=u,this.change(c)},a=new w([...this.path,s],t,this.signal.map(u=>u[s]),this.status.map(V([s])),{disabled:this.disabled,validationMode:this.parent.validationMode});this.#e[s]=a;const i=a.touched.on(u=>{this.#t.set(s,u),this.#c()});this.#s.set(s,i);const l=a.dirty.on(u=>{this.#i.set(s,u),this.#n()});return this.#a.set(s,l),a};push=(...s)=>{this.change([...this.signal.value,...s])};pop=()=>{this.splice(this.signal.value.length-1,1)};shift=()=>{this.splice(0,1)};unshift=(...s)=>{this.change([...s,...this.signal.value])};removeAt=s=>{this.splice(s,1)};splice=(s,t)=>{const a=this.signal.value.slice();a.splice(s,t),this.change(a)};move=(s,t,a=1)=>{if(a<1||s===t)return;const i=this.signal.value.slice(),l=i.splice(s,a);i.splice(t,0,...l),this.change(i)};markAllTouched=()=>{this.markTouched();const s=this.signal.value.length;for(let t=0;t<s;t++)this.item(t).markTouched()};markAllPristine=()=>{this.markPristine();const s=this.signal.value.length;for(let t=0;t<s;t++)this.item(t).markPristine?.()};#n=()=>{let s=!1;for(const t of this.#i.values())if(t){s=!0;break}this.#l.set(this.dirty.value||s)}}function G(e){function s(t){return typeof t=="number"?t:t.toString()}return e.map(t=>typeof t=="object"&&t.key!=null?s(t.key):s(t))}function J(e){const s=e.filter(i=>i.path==null||i.path.length===0).map(i=>i.message),t=e.filter(i=>i.path!=null&&i.path.length>0).reduce((i,l)=>{const u=G(l.path),c=u.pop();let d=i;for(const m of u)d.dependencies==null&&(d.dependencies={}),d.dependencies[m]==null&&(d.dependencies[m]={}),d=d.dependencies[m];return d.dependencies==null&&(d.dependencies={}),d.dependencies[c]={message:l.message},i},{}),a=s.join(`
|
|
1
|
+
"use strict";const r=require("@tempots/dom"),F=require("./translations-eUtMHN9s.cjs"),P=new Map;function I(e){const s=P.get(e)??0;return P.set(e,s+1),`${e}-${s}`}const n={notAsked:{type:"NotAsked"},loading(e=void 0){return{type:"Loading",previousValue:e}},success(e){return{type:"AsyncSuccess",value:e}},failure(e){return{type:"AsyncFailure",error:e}},isSuccess(e){return e.type==="AsyncSuccess"},isFailure(e){return e.type==="AsyncFailure"},isNotAsked(e){return e.type==="NotAsked"},isLoading(e){return e.type==="Loading"},getOrElse(e,s){return n.isSuccess(e)?e.value:s},getOrElseLazy(e,s){return n.isSuccess(e)?e.value:s()},getOrNull(e){return n.isSuccess(e)?e.value:null},getOrUndefined(e){return n.isSuccess(e)?e.value:void 0},getUnsafe:e=>{if(n.isSuccess(e))return e.value;throw n.isFailure(e)?e.error:new Error("Cannot get value from a not-asked or loading result")},match:(e,{success:s,failure:t,loading:a,notAsked:i=a})=>n.isSuccess(e)?s(e.value):n.isFailure(e)?t(e.error):n.isNotAsked(e)?i():a(e.previousValue),effect:(e,s)=>{switch(e.type){case"AsyncSuccess":s.success?s.success(e.value):s.else?.();break;case"AsyncFailure":s.failure?s.failure(e.error):s.else?.();break;case"Loading":s.loading?s.loading(e.previousValue):s.else?.();break;case"NotAsked":s.notAsked?s.notAsked():s.else?.();break}return e},whenSuccess:(e,s)=>(n.isSuccess(e)&&s(e.value),e),whenFailure:(e,s)=>(n.isFailure(e)&&s(e.error),e),equals:(e,s,t={valueEquals:(a,i)=>a===i,errorEquals:(a,i)=>a===i})=>e.type==="AsyncSuccess"&&s.type==="AsyncSuccess"?t.valueEquals(e.value,s.value):e.type==="AsyncFailure"&&s.type==="AsyncFailure"?t.errorEquals(e.error,s.error):e.type==="Loading"&&s.type==="Loading"?t.valueEquals(e.previousValue,s.previousValue):e.type==="NotAsked"&&s.type==="NotAsked",all:e=>{const s=[];for(const t of e)if(n.isSuccess(t))s.push(t.value);else return t;return n.success(s)},ofPromise:async e=>{try{const s=await e;return n.success(s)}catch(s){return n.failure(s instanceof Error?s:new Error(String(s)))}},map:(e,s)=>{switch(e.type){case"AsyncSuccess":return n.success(s(e.value));case"NotAsked":return n.notAsked;case"AsyncFailure":return n.failure(e.error);case"Loading":return n.loading(e.previousValue!=null?s(e.previousValue):void 0)}},flatMap:(e,s)=>{switch(e.type){case"AsyncSuccess":return s(e.value);case"NotAsked":return n.notAsked;case"AsyncFailure":return n.failure(e.error);case"Loading":return n.loading()}},mapError:(e,s)=>{switch(e.type){case"AsyncSuccess":return n.success(e.value);case"NotAsked":return n.notAsked;case"AsyncFailure":return n.failure(s(e.error));case"Loading":return n.loading(e.previousValue)}},flatMapError:(e,s)=>{switch(e.type){case"AsyncSuccess":return n.success(e.value);case"NotAsked":return n.notAsked;case"AsyncFailure":return s(e.error);case"Loading":return n.loading(e.previousValue)}},toResult:e=>{switch(e.type){case"AsyncSuccess":return{type:"Success",value:e.value};case"AsyncFailure":return{type:"Failure",error:e.error};case"NotAsked":case"Loading":return}},isSettled(e){return e.type==="AsyncSuccess"||e.type==="AsyncFailure"},recover:(e,s)=>{switch(e.type){case"AsyncSuccess":return n.success(e.value);case"NotAsked":return n.notAsked;case"AsyncFailure":return n.success(s(e.error));case"Loading":return n.loading(e.previousValue)}},ap:(e,s)=>n.isSuccess(e)&&n.isSuccess(s)?n.success(e.value(s.value)):n.isFailure(e)?n.failure(e.error):n.isFailure(s)?n.failure(s.error):n.isLoading(e)||n.isLoading(s)?n.loading():n.notAsked,map2:(e,s,t)=>n.isSuccess(e)&&n.isSuccess(s)?n.success(t(e.value,s.value)):n.isFailure(e)?n.failure(e.error):n.isFailure(s)?n.failure(s.error):n.isLoading(e)||n.isLoading(s)?n.loading():n.notAsked,map3:(e,s,t,a)=>n.isSuccess(e)&&n.isSuccess(s)&&n.isSuccess(t)?n.success(a(e.value,s.value,t.value)):n.isFailure(e)?n.failure(e.error):n.isFailure(s)?n.failure(s.error):n.isFailure(t)?n.failure(t.error):n.isLoading(e)||n.isLoading(s)||n.isLoading(t)?n.loading():n.notAsked},E=(e,s)=>e===s||e!==e&&s!==s,h={valid:{type:"valid"},invalid(e){return{type:"invalid",error:e}},isValid(e){return e.type==="valid"},isInvalid(e){return e.type==="invalid"},match:(e,s,t)=>h.isValid(e)?s():t(e.error),toResult:(e,s)=>h.match(e,()=>o.success(s),t=>o.failure(t)),effect:(e,s)=>(e.type==="valid"?s.valid?s.valid():s.else?.():s.invalid?s.invalid(e.error):s.else?.(),e),whenValid:(e,s)=>(h.isValid(e)&&s(),e),whenInvalid:(e,s)=>(h.isInvalid(e)&&s(e.error),e),mapError:(e,s)=>e.type==="invalid"?h.invalid(s(e.error)):e,flatMapError:(e,s)=>e.type==="invalid"?s(e.error):e,combine:(e,s,t)=>h.isValid(e)&&h.isValid(s)?h.valid:h.isInvalid(e)&&h.isInvalid(s)?h.invalid(t(e.error,s.error)):h.isInvalid(e)?e:s,all:e=>{for(const s of e)if(h.isInvalid(s))return s;return h.valid},allErrors:e=>{const s=[];for(const t of e)h.isInvalid(t)&&s.push(t.error);return s.length>0?h.invalid(s):h.valid},equals:(e,s,t=(a,i)=>a===i)=>e.type==="valid"&&s.type==="valid"?!0:e.type==="invalid"&&s.type==="invalid"?t(e.error,s.error):!1,recover:e=>h.valid,getError:e=>{if(h.isInvalid(e))return e.error},getErrorOrElse:(e,s)=>h.isInvalid(e)?e.error:s},o={success(e){return{type:"Success",value:e}},failure(e){return{type:"Failure",error:e}},map:(e,s)=>e.type==="Success"?o.success(s(e.value)):e,flatMap:(e,s)=>e.type==="Success"?s(e.value):e,toAsync(e){return o.match(e,s=>n.success(s),s=>n.failure(s))},toValidation(e){return o.match(e,()=>h.valid,s=>h.invalid(s))},isSuccess(e){return e.type==="Success"},isFailure(e){return e.type==="Failure"},getOrElse(e,s){return o.isSuccess(e)?e.value:s},getOrElseLazy(e,s){return o.isSuccess(e)?e.value:s()},getOrNull(e){return o.isSuccess(e)?e.value:null},getOrUndefined(e){return o.isSuccess(e)?e.value:void 0},getUnsafe:e=>{if(o.isSuccess(e))return e.value;throw e.error},match:(e,s,t)=>o.isSuccess(e)?s(e.value):t(e.error),effect:(e,s)=>(e.type==="Success"?s.success?s.success(e.value):s.else?.():s.failure?s.failure(e.error):s.else?.(),e),whenSuccess:(e,s)=>(o.isSuccess(e)&&s(e.value),e),whenFailure:(e,s)=>(o.isFailure(e)&&s(e.error),e),combine:(e,s,t,a)=>o.match(e,i=>o.match(s,l=>o.success(t(i,l)),l=>o.failure(l)),i=>o.match(s,l=>o.failure(i),l=>o.failure(a(i,l)))),equals:(e,s,t={valueEquals:(a,i)=>a===i,errorEquals:(a,i)=>a===i})=>e.type==="Success"&&s.type==="Success"?t.valueEquals(e.value,s.value):e.type==="Failure"&&s.type==="Failure"?t.errorEquals(e.error,s.error):!1,all:e=>{const s=[];for(const t of e)if(o.isSuccess(t))s.push(t.value);else return t;return o.success(s)},mapError:(e,s)=>e.type==="Failure"?o.failure(s(e.error)):e,flatMapError:(e,s)=>e.type==="Failure"?s(e.error):e,recover:(e,s)=>e.type==="Failure"?{type:"Success",value:s(e.error)}:e,ap:(e,s)=>o.isSuccess(e)&&o.isSuccess(s)?o.success(e.value(s.value)):o.isFailure(e)?o.failure(e.error):o.failure(s.error),map2:(e,s,t)=>o.isSuccess(e)&&o.isSuccess(s)?o.success(t(e.value,s.value)):o.isFailure(e)?o.failure(e.error):o.failure(s.error),map3:(e,s,t,a)=>o.isSuccess(e)&&o.isSuccess(s)&&o.isSuccess(t)?o.success(a(e.value,s.value,t.value)):o.isFailure(e)?o.failure(e.error):o.isFailure(s)?o.failure(s.error):o.failure(t.error),ofPromise:async e=>{try{const s=await e;return o.success(s)}catch(s){return o.failure(s instanceof Error?s:new Error(String(s)))}},swap:e=>o.isSuccess(e)?o.failure(e.value):o.success(e.error),fromNullable:(e,s)=>e==null?o.failure(s):o.success(e),fromNullableLazy:(e,s)=>e==null?o.failure(s()):o.success(e),tryCatch:e=>{try{return o.success(e())}catch(s){return o.failure(s instanceof Error?s:new Error(String(s)))}}};function Z({size:e="sm",icon:s="line-md:close",disabled:t,roundedness:a="full",color:i="base",onClick:l,label:u},...c){return r.Use(F.BeatUII18n,d=>{const m=r.coalesce(u,d.$.closeModal);return F.Button({variant:"text",size:e,roundedness:a,disabled:t,color:i,onClick:l},r.attr.title(m),r.aria.label(m),...c,F.Icon({icon:s,size:e??"sm"}))})}function T(e){return`bc-label bc-label--${e}`}const ee=(...e)=>r.html.span(r.attr.class(T("emphasis")),...e),q=(...e)=>r.html.span(r.attr.class(T("default")),...e),$=(...e)=>r.html.span(r.attr.class(T("muted")),...e),se=(...e)=>r.html.span(r.attr.class(T("danger")),...e),te=e=>{const{value:s,onBlur:t,onChange:a,placeholder:i,disabled:l,id:u,checkedIcon:c,uncheckedIcon:d,iconSize:m="lg"}=e,p=u??I("checkbox"),v=`${p}-label`,b=()=>{if(r.Value.get(l??!1))return;const f=r.Value.get(s);a?.(!f)},k=f=>{r.Value.get(l??!1)||(f.key===" "||f.key==="Enter")&&(f.preventDefault(),b())};return F.InputContainer({baseContainer:!0,growInput:!1,...e,input:r.html.span(r.attr.class("bc-checkbox-input"),r.html.span(r.attr.class("bc-checkbox-input__checkbox"),r.attr.class(r.Value.map(s,f=>f?"bc-checkbox-input__checkbox--checked":"bc-checkbox-input__checkbox--unchecked")),r.attr.class(r.Value.map(l??!1,f=>f?"bc-checkbox-input__checkbox--disabled":"")),r.attr.id(p),r.attr.role("checkbox"),r.attr.tabindex(r.Value.map(l??!1,f=>f?-1:0)),r.aria.checked(s),r.aria.disabled(l),i!=null?r.aria.labelledby(v):r.Empty,r.on.keydown(k),t!=null?r.on.blur(t):r.Empty,F.Icon({icon:r.computedOf(s,c,d)((f,y,S)=>f?y??"akar-icons/check-box-fill":S??"akar-icons/box"),accessibility:"decorative",size:m})),i!=null?r.html.label(r.attr.class("bc-checkbox-input__label"),r.attr.id(v),r.attr.for(p),$(i)):r.Empty)},r.on.click(b))},j=r.html.span(r.attr.class("bc-input-wrapper__required")," *");function re(e){const s=["bc-input-wrapper"];return e!=="vertical"&&s.push(`bc-input-wrapper--${e}`),s.join(" ")}function ae(e,s){const t=["bc-input-wrapper__label-text"];return e?t.push("bc-input-wrapper__label-text--error"):s?t.push("bc-input-wrapper__label-text--disabled"):t.push("bc-input-wrapper__label-text--default"),t.join(" ")}function ie(e,s){if(e==="horizontal-fixed"&&s!=null)return`--input-wrapper-label-width: ${s}`}const M=({fullWidth:e=!1,required:s,label:t,labelChildren:a,context:i,description:l,content:u,error:c,labelFor:d,hasError:m,disabled:p,layout:v,labelWidth:b},...k)=>{const f=m??c!=null,y=p??!1,S=v??"vertical",C=I("input-wrapper"),D=l?`${C}-description`:void 0,O=c!=null?`${C}-error`:void 0,B=r.computedOf(S)(g=>g!=="vertical"),Y=r.computedOf(S,b??void 0)((g,A)=>ie(g,A));return r.html.div(r.attr.class(r.Value.map(S,g=>re(g))),r.attr.class(r.Value.map(e,g=>g?"bc-input-wrapper--full-width":"")),r.attr.style(Y),t!=null||i!=null?r.html.div(r.attr.class("bc-input-wrapper__header"),r.html.div(r.attr.class("bc-input-wrapper__label-section"),r.html.label(r.attr.class("bc-input-wrapper__label"),d!=null?r.attr.for(d):r.Empty,r.html.span(r.attr.class(r.computedOf(f,y)((g,A)=>ae(g??!1,A??!1))),t),t!=null&&s?j:r.Empty),r.When(r.computedOf(B,l)((g,A)=>g&&A!=null),()=>r.html.div(r.attr.class("bc-input-wrapper__description bc-input-wrapper__description--under-label"),r.attr.id(D),l))),i!=null?q(i):r.Empty,a):r.Empty,r.html.div(r.attr.class("bc-input-wrapper__content"),[D,O].filter(Boolean).length>0?r.dataAttr.describedby([D,O].filter(Boolean).join(" ")):r.Empty,s?r.dataAttr.required("true"):r.Empty,r.When(f,()=>r.dataAttr.invalid("true")),u),r.When(r.computedOf(B,l)((g,A)=>!g&&A!=null),()=>r.html.div(r.attr.class("bc-input-wrapper__description"),r.attr.id(D),l)),r.When(f,()=>r.html.div(r.attr.class("bc-input-wrapper__error"),r.attr.id(O),r.aria.live("polite"),r.attr.role("alert"),c)),...k)};function ne(...e){return r.html.div(r.attr.class("bc-stack"),...e)}const H=((e,s)=>()=>{e.markTouched(),s?.()}),_=(e,s)=>t=>{e.change(t),s?.(t)};function N(e,s){const{controller:t,onBlur:a,onChange:i,id:l,triggerOn:u,...c}=s;return e({id:l??t.name,disabled:t.disabled,value:t.signal,hasError:t.errorVisible,name:t.name,...c,onInput:u==="input"?_(t,i):void 0,onChange:u!=="input"?_(t,i):void 0,onBlur:H(t,a)})}function le(e,{id:s,labelFor:t,...a},...i){const l=s??a.controller.name??I("control"),u=t??l;return M({...a,hasError:a.controller.errorVisible,error:r.TextNode(a.controller.error.map(c=>c??"")),labelFor:u,content:N(c=>e({...c,id:l}),a)},...i)}function z(e,s){const{toInput:t,fromInput:a,controller:i,...l}=s,u=i.transform(t,a);return N(e,{...l,controller:u})}function ce(e,{id:s,labelFor:t,...a},...i){const l=s??a.controller.name??I("control");return M({...a,labelFor:t??l,content:z(e,{...a,id:l})},...i)}function oe(e){return e.split(".").map(t=>{const a=t.match(/^\[(\d+)\]$/);return a?Number(a[1]):t})}function W(e){return typeof e=="number"?`[${e}]`:`.${e}`}function R(e){if(e.length===0)return"";const[s,...t]=e;return[typeof s=="number"?`[${s}]`:s,...t.map(W)].join("")}const ue={valid:h.valid,invalid(e){return h.invalid({message:e})},invalidFields(e){const s={};for(const[t,a]of Object.entries(e))s[t]=typeof a=="string"?{message:a}:a;return h.invalid({dependencies:s})},fromError(e){return h.invalid(e)}};function V(e){return function(t){if(t.type==="valid")return t;let a=t.error;for(const i of e)if(a=a?.dependencies?.[i],a==null)return h.valid;return h.invalid(a)}}class w{path;change;signal;status;error;hasError;touched;errorVisible;dirty;dependencyErrors;#e={disabled:r.prop(!1),touched:r.prop(!1)};#t;#s=r.prop(void 0);parent;disabled;#r=[];disabledOrHasErrors;constructor(s,t,a,i,l,u=E){this.path=s,this.change=t,this.signal=a,this.status=i,this.#t=u,this.#s.set(a.value),this.error=i.map(c=>c?.type==="invalid"?c.error?.message:void 0),this.hasError=this.error.map(c=>c!=null),this.touched=this.#e.touched,l.validationMode?this.errorVisible=r.computedOf(this.hasError,this.touched,l.validationMode)((c,d,m)=>m==="eager"?!!c:!!c&&!!d):this.errorVisible=r.computedOf(this.hasError,this.touched)((c,d)=>!!c&&!!d),this.dirty=r.computedOf(this.signal,this.#s)((c,d)=>!this.#t(c,d)),this.dependencyErrors=i.map(c=>c?.type==="invalid"?c.error?.dependencies:void 0),this.parent=l,this.disabled=r.computedOf(this.#e.disabled,l.disabled)((c,d)=>c||d),this.disabledOrHasErrors=r.computedOf(this.disabled,this.hasError)((c,d)=>c||d),this.onDispose(()=>{this.#e.disabled.dispose(),this.#e.touched.dispose(),this.disabled.dispose(),this.error.dispose(),this.errorVisible.dispose(),this.dirty.dispose(),this.#s.dispose(),this.dependencyErrors.dispose(),this.disabledOrHasErrors.dispose()})}get name(){return R(this.path)}onDispose=s=>{this.#r.push(s)};dispose=()=>{for(const s of this.#r)try{s()}catch(t){console.error("Error in dispose callback:",t)}this.#r.length=0};setDisabled=s=>{this.#e.disabled.set(s)};disable=()=>this.setDisabled(!0);enable=()=>this.setDisabled(!1);markTouched=()=>{this.#e.touched.set(!0)};resetTouched=()=>{this.#e.touched.set(!1)};markPristine=()=>{this.#s.set(this.signal.value)};reset=()=>{this.change(this.#s.value)};array=(s=E)=>new K(this.path,this.change,this.signal,this.status,this.parent,s);object=(s=E)=>new U(this.path,this.change,this.signal,this.status,this.parent,s);transform=(s,t,a=[],i=E)=>new w([...this.path,...a],l=>this.change(t(l)),this.signal.map(s,i),this.status.map(V(a)),this.parent,i);asyncTransform=(s,t,a,i=[],l=E)=>new w([...this.path,...i],u=>{t(u).then(c=>this.change(c))},this.signal.mapAsync(s,a,void 0,l),this.status.map(V(i)),this.parent,l)}class U extends w{#e=new Map;#t=new Map;#s=new Map;#r=r.prop(!1);touchedDeep=this.#r;#i=new Map;#a=new Map;#l=r.prop(!1);dirtyDeep=this.#l;#o;#u;#c=()=>{let s=!1;for(const t of this.#t.values())if(t){s=!0;break}this.#r.set(this.touched.value||s)};constructor(s,t,a,i,l,u){super(s,t,a.map(d=>d??{},u),i,l,u),this.#o=this.touched.on(()=>{this.#c()}),this.#u=this.dirty.on(()=>{this.#n()});const c=this.signal.on(()=>this.#n());this.onDispose(()=>{for(const d of this.#e.values())d.dispose();this.#e.clear();for(const d of this.#s.values())d();this.#s.clear(),this.#t.clear(),this.#r.dispose();for(const d of this.#a.values())d();this.#a.clear(),this.#i.clear(),this.#l.dispose(),this.#o(),this.#u(),c()})}field=s=>{if(this.#e.has(s))return this.#e.get(s);const t=async u=>{this.change({...this.signal.value,[s]:u})},a=new w([...this.path,s],t,this.signal.map(u=>u[s]),this.status.map(V([s])),{disabled:this.disabled,validationMode:this.parent.validationMode});this.#e.set(s,a);const i=a.touched.on(u=>{this.#t.set(s,u),this.#c()});this.#s.set(s,i);const l=a.dirty.on(u=>{this.#i.set(s,u),this.#n()});return this.#a.set(s,l),a};markAllTouched=()=>{this.markTouched();const s=this.signal.value;for(const t of Object.keys(s))this.field(t).markTouched();for(const t of this.#e.values())t.markTouched()};markAllPristine=()=>{this.markPristine();const s=this.signal.value;for(const t of Object.keys(s))this.field(t).markPristine?.();for(const t of this.#e.values())t.markPristine?.()};#n=()=>{let s=!1;for(const t of this.#i.values())if(t){s=!0;break}this.#l.set(this.dirty.value||s)}}class K extends w{#e=new Array;length;#t=new Map;#s=new Map;#r=r.prop(!1);touchedDeep=this.#r;#i=new Map;#a=new Map;#l=r.prop(!1);dirtyDeep=this.#l;#o;#u;#c=()=>{let s=!1;for(const t of this.#t.values())if(t){s=!0;break}this.#r.set(this.touched.value||s)};constructor(s,t,a,i,l,u){const c=a.map(p=>p??[],u);super(s,t,c,i,l,u);const d=c.on(p=>{const v=this.#e.length-p.length;v>0&&(this.#e.splice(p.length,v).forEach((b,k)=>{const f=p.length+k;b.dispose(),this.#s.get(f)?.(),this.#s.delete(f),this.#t.delete(f),this.#a.get(f)?.(),this.#a.delete(f),this.#i.delete(f)}),this.#c(),this.#n())});this.length=c.map(p=>p.length),this.#o=this.touched.on(()=>{this.#c()}),this.#u=this.dirty.on(()=>{this.#n()});const m=this.signal.on(()=>this.#n());this.onDispose(()=>{for(const p of this.#e)p.dispose();this.length.dispose(),this.#e.length=0,d(),c.dispose();for(const p of this.#s.values())p();this.#s.clear(),this.#t.clear(),this.#r.dispose();for(const p of this.#a.values())p();this.#a.clear(),this.#i.clear(),this.#l.dispose(),this.#o(),this.#u(),m()})}item=s=>{if(this.#e[s])return this.#e[s];const t=async u=>{const c=this.signal.value.slice();c[s]=u,this.change(c)},a=new w([...this.path,s],t,this.signal.map(u=>u[s]),this.status.map(V([s])),{disabled:this.disabled,validationMode:this.parent.validationMode});this.#e[s]=a;const i=a.touched.on(u=>{this.#t.set(s,u),this.#c()});this.#s.set(s,i);const l=a.dirty.on(u=>{this.#i.set(s,u),this.#n()});return this.#a.set(s,l),a};push=(...s)=>{this.change([...this.signal.value,...s])};pop=()=>{this.splice(this.signal.value.length-1,1)};shift=()=>{this.splice(0,1)};unshift=(...s)=>{this.change([...s,...this.signal.value])};removeAt=s=>{this.splice(s,1)};splice=(s,t)=>{const a=this.signal.value.slice();a.splice(s,t),this.change(a)};move=(s,t,a=1)=>{if(a<1||s===t)return;const i=this.signal.value.slice(),l=i.splice(s,a);i.splice(t,0,...l),this.change(i)};markAllTouched=()=>{this.markTouched();const s=this.signal.value.length;for(let t=0;t<s;t++)this.item(t).markTouched()};markAllPristine=()=>{this.markPristine();const s=this.signal.value.length;for(let t=0;t<s;t++)this.item(t).markPristine?.()};#n=()=>{let s=!1;for(const t of this.#i.values())if(t){s=!0;break}this.#l.set(this.dirty.value||s)}}function G(e){function s(t){return typeof t=="number"?t:t.toString()}return e.map(t=>typeof t=="object"&&t.key!=null?s(t.key):s(t))}function J(e){const s=e.filter(i=>i.path==null||i.path.length===0).map(i=>i.message),t=e.filter(i=>i.path!=null&&i.path.length>0).reduce((i,l)=>{const u=G(l.path),c=u.pop();let d=i;for(const m of u)d.dependencies==null&&(d.dependencies={}),d.dependencies[m]==null&&(d.dependencies[m]={}),d=d.dependencies[m];return d.dependencies==null&&(d.dependencies={}),d.dependencies[c]={message:l.message},i},{}),a=s.join(`
|
|
2
2
|
`);return{...t,message:a!=""?a:void 0}}function Q({initialValue:e,onChange:s,validate:t,equals:a,validationMode:i,validateDebounceMs:l}){const u=r.Value.deriveProp(e),c=r.prop(h.valid),d=r.prop(!1),m=r.prop(i??"onTouched"),p=y=>{c.set(y)};let v;const b=async y=>{if(t!=null){const S=await t(y);p(S)}},k=async y=>{u.set(y),s?.(y);const S=m.value;if(t!=null){if(S==="onSubmit")return;const C=l??0;C>0?(v&&clearTimeout(v),v=setTimeout(()=>{b(y)},C)):await b(y)}},f=new w([],k,u,c,{disabled:d,validationMode:m},a??E);return f.onDispose(()=>{d.dispose(),u.dispose(),c.dispose(),m.dispose(),v&&clearTimeout(v)}),{controller:f,setStatus:p}}function x(e){return r.Fragment(r.attr.disabled(e.disabled),r.attr.name(e.name))}function de(e,{triggerOn:s="change"}={}){return r.Fragment(x(e),r.attr.value(e.signal),(s==="input"?r.on.input:r.on.change)(r.emitValue(e.change)))}function he(e,{triggerOn:s="change"}={}){return r.Fragment(x(e),r.attr.valueAsNumber(e.signal),(s==="input"?r.on.input:r.on.change)(r.emitValueAsNumber(e.change)))}function L(e){return e.issues!=null?h.invalid(J(e.issues)):h.valid}async function pe({task:e,errorMessage:s,errorPath:t=["root"],validation:a}){try{const i=await e();return a!=null?a(i):h.valid}catch(i){const l=s??(i instanceof Error?i.message:"Operation failed");return t.length===1&&t[0]==="root"?h.invalid({message:l}):h.invalid({dependencies:X(t,l)})}}function X(e,s){if(e.length===1)return{[e[0]]:{message:s}};const[t,...a]=e;return{[t]:{dependencies:X(a,s)}}}function fe({initialValue:e={},schema:s,onSubmit:t=async()=>h.valid,validationMode:a,validateDebounceMs:i}){const{controller:l,setStatus:u}=Q({initialValue:e,validationMode:a??"onTouched",validateDebounceMs:i,validate:(a??"onTouched")==="onSubmit"||s==null?void 0:async p=>L(await s["~standard"].validate(p))}),c=r.prop(!1),d=l.object();return d.onDispose(c.dispose),{controller:d,setStatus:u,submit:async p=>{if(c.set(!0),p?.preventDefault(),d.markAllTouched(),s!=null){const b=d.signal.value,k=L(await s["~standard"].validate(b));if(u(k),k.type==="invalid"){c.set(!1);return}}const v=await t(d.signal.value);c.set(!1),v.type==="invalid"&&u(v)},submitting:c}}exports.ArrayController=K;exports.BaseControl=N;exports.BaseMappedControl=z;exports.CheckboxInput=te;exports.CloseButton=Z;exports.Control=le;exports.Controller=w;exports.ControllerValidation=ue;exports.DangerLabel=se;exports.EmphasisLabel=ee;exports.InputWrapper=M;exports.Label=q;exports.MappedControl=ce;exports.MutedLabel=$;exports.O=E;exports.ObjectController=U;exports.RequiredSymbol=j;exports.Stack=ne;exports.connectCommonAttributes=x;exports.connectNumberInput=he;exports.connectStringInput=de;exports.convertStandardSchemaIssues=J;exports.convertStandardSchemaPathToPath=G;exports.i=h;exports.makeMapValidation=V;exports.makeOnBlurHandler=H;exports.makeOnChangeHandler=_;exports.parsePath=oe;exports.pathToString=R;exports.sessionId=I;exports.standardSchemaResultToValidation=L;exports.taskToValidation=pe;exports.useController=Q;exports.useForm=fe;exports.wrapSegment=W;
|