@structured-field/widget-editor 1.1.0 → 1.1.1
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/structured-widget-editor.esm.js +10 -7
- package/dist/structured-widget-editor.esm.js.map +1 -1
- package/dist/structured-widget-editor.iife.js +1 -1
- package/dist/structured-widget-editor.js +1 -1
- package/dist/structured-widget-editor.js.map +1 -1
- package/package.json +1 -1
- package/src/editors/ArrayEditor.vue +1 -1
|
@@ -22,5 +22,5 @@ let ee,te;class ne{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,
|
|
|
22
22
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
23
23
|
* @license MIT
|
|
24
24
|
**/
|
|
25
|
-
let wr;const Ar="undefined"!=typeof window&&window.trustedTypes;if(Ar)try{wr=Ar.createPolicy("vue",{createHTML:e=>e})}catch(e){}const Vr=wr?e=>wr.createHTML(e):e=>e,Or="undefined"!=typeof document?document:null,Pr=Or&&Or.createElement("template"),jr={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,s)=>{const r="svg"===t?Or.createElementNS("http://www.w3.org/2000/svg",e):"mathml"===t?Or.createElementNS("http://www.w3.org/1998/Math/MathML",e):n?Or.createElement(e,{is:n}):Or.createElement(e);return"select"===e&&s&&null!=s.multiple&&r.setAttribute("multiple",s.multiple),r},createText:e=>Or.createTextNode(e),createComment:e=>Or.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>Or.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,s,r,o){const i=n?n.previousSibling:t.lastChild;if(r&&(r===o||r.nextSibling))for(;t.insertBefore(r.cloneNode(!0),n),r!==o&&(r=r.nextSibling););else{Pr.innerHTML=Vr("svg"===s?`<svg>${e}</svg>`:"mathml"===s?`<math>${e}</math>`:e);const r=Pr.content;if("svg"===s||"mathml"===s){const e=r.firstChild;for(;e.firstChild;)r.appendChild(e.firstChild);r.removeChild(e)}t.insertBefore(r,n)}return[i?i.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},Ir=Symbol("_vtc");const $r=Symbol("_vod"),Dr=Symbol("_vsh"),Rr={name:"show",beforeMount(e,{value:t},{transition:n}){e[$r]="none"===e.style.display?"":e.style.display,n&&t?n.beforeEnter(e):Tr(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:s}){!t!=!n&&(s?t?(s.beforeEnter(e),Tr(e,!0),s.enter(e)):s.leave(e,()=>{Tr(e,!1)}):Tr(e,t))},beforeUnmount(e,{value:t}){Tr(e,t)}};function Tr(e,t){e.style.display=t?e[$r]:"none",e[Dr]=!t}const Fr=Symbol(""),Mr=/(?:^|;)\s*display\s*:/;const Nr=/\s*!important$/;function Ur(e,t,n){if(p(n))n.forEach(n=>Ur(e,t,n));else if(null==n&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const s=function(e,t){const n=qr[t];if(n)return n;let s=O(t);if("filter"!==s&&s in e)return qr[t]=s;s=I(s);for(let n=0;n<Lr.length;n++){const r=Lr[n]+s;if(r in e)return qr[t]=r}return t}(e,t);Nr.test(n)?e.setProperty(j(s),n.replace(Nr,""),"important"):e[s]=n}}const Lr=["Webkit","Moz","ms"],qr={};const zr="http://www.w3.org/1999/xlink";function Wr(e,t,n,s,r,o=K(t)){s&&t.startsWith("xlink:")?null==n?e.removeAttributeNS(zr,t.slice(6,t.length)):e.setAttributeNS(zr,t,n):null==n||o&&!Z(n)?e.removeAttribute(t):e.setAttribute(t,o?"":_(n)?String(n):n)}function Br(e,t,n,s,r){if("innerHTML"===t||"textContent"===t)return void(null!=n&&(e[t]="innerHTML"===t?Vr(n):n));const o=e.tagName;if("value"===t&&"PROGRESS"!==o&&!o.includes("-")){const s="OPTION"===o?e.getAttribute("value")||"":e.value,r=null==n?"checkbox"===e.type?"on":"":String(n);return s===r&&"_value"in e||(e.value=r),null==n&&e.removeAttribute(t),void(e._value=n)}let i=!1;if(""===n||null==n){const s=typeof e[t];"boolean"===s?n=Z(n):null==n&&"string"===s?(n="",i=!0):"number"===s&&(n=0,i=!0)}try{e[t]=n}catch(e){}i&&e.removeAttribute(r||t)}function Hr(e,t,n,s){e.addEventListener(t,n,s)}const Kr=Symbol("_vei");function Zr(e,t,n,s,r=null){const o=e[Kr]||(e[Kr]={}),i=o[t];if(s&&i)i.value=s;else{const[n,l]=function(e){let t;if(Qr.test(e)){let n;for(t={};n=e.match(Qr);)e=e.slice(0,e.length-n[0].length),t[n[0].toLowerCase()]=!0}const n=":"===e[2]?e.slice(3):j(e.slice(2));return[n,t]}(t);if(s){const i=o[t]=function(e,t){const n=e=>{if(e._vts){if(e._vts<=n.attached)return}else e._vts=Date.now();jt(function(e,t){if(p(t)){const n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(e=>t=>!t._stopped&&e&&e(t))}return t}(e,n.value),t,5,[e])};return n.value=e,n.attached=Xr(),n}(s,r);Hr(e,n,i,l)}else i&&(!function(e,t,n,s){e.removeEventListener(t,n,s)}(e,n,i,l),o[t]=void 0)}}const Qr=/(?:Once|Passive|Capture)$/;let Jr=0;const Gr=Promise.resolve(),Xr=()=>Jr||(Gr.then(()=>Jr=0),Jr=Date.now());const Yr=e=>111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123;const eo={};const to="undefined"!=typeof HTMLElement?HTMLElement:class{};class no extends to{constructor(e,t={},n=vo){super(),this._def=e,this._props=t,this._createApp=n,this._isVueCE=!0,this._instance=null,this._app=null,this._nonce=this._def.nonce,this._connected=!1,this._resolved=!1,this._patching=!1,this._dirty=!1,this._numberProps=null,this._styleChildren=new WeakSet,this._styleAnchors=new WeakMap,this._ob=null,this.shadowRoot&&n!==vo?this._root=this.shadowRoot:!1!==e.shadowRoot?(this.attachShadow(c({},e.shadowRootOptions,{mode:"open"})),this._root=this.shadowRoot):this._root=this}connectedCallback(){if(!this.isConnected)return;this.shadowRoot||this._resolved||this._parseSlots(),this._connected=!0;let e=this;for(;e=e&&(e.assignedSlot||e.parentNode||e.host);)if(e instanceof no){this._parent=e;break}this._instance||(this._resolved?this._mount(this._def):e&&e._pendingResolve?this._pendingResolve=e._pendingResolve.then(()=>{this._pendingResolve=void 0,this._resolveDef()}):this._resolveDef())}_setParent(e=this._parent){e&&(this._instance.parent=e._instance,this._inheritParentContext(e))}_inheritParentContext(e=this._parent){e&&this._app&&Object.setPrototypeOf(this._app._context.provides,e._instance.provides)}disconnectedCallback(){this._connected=!1,Ut(()=>{this._connected||(this._ob&&(this._ob.disconnect(),this._ob=null),this._app&&this._app.unmount(),this._instance&&(this._instance.ce=void 0),this._app=this._instance=null,this._teleportTargets&&(this._teleportTargets.clear(),this._teleportTargets=void 0))})}_processMutations(e){for(const t of e)this._setAttr(t.attributeName)}_resolveDef(){if(this._pendingResolve)return;for(let e=0;e<this.attributes.length;e++)this._setAttr(this.attributes[e].name);this._ob=new MutationObserver(this._processMutations.bind(this)),this._ob.observe(this,{attributes:!0});const e=(e,t=!1)=>{this._resolved=!0,this._pendingResolve=void 0;const{props:n,styles:s}=e;let r;if(n&&!p(n))for(const e in n){const t=n[e];(t===Number||t&&t.type===Number)&&(e in this._props&&(this._props[e]=M(this._props[e])),(r||(r=Object.create(null)))[O(e)]=!0)}this._numberProps=r,this._resolveProps(e),this.shadowRoot&&this._applyStyles(s),this._mount(e)},t=this._def.__asyncLoader;t?this._pendingResolve=t().then(t=>{t.configureApp=this._def.configureApp,e(this._def=t,!0)}):e(this._def)}_mount(e){this._app=this._createApp(e),this._inheritParentContext(),e.configureApp&&e.configureApp(this._app),this._app._ceVNode=this._createVNode(),this._app.mount(this._root);const t=this._instance&&this._instance.exposed;if(t)for(const e in t)d(this,e)||Object.defineProperty(this,e,{get:()=>St(t[e])})}_resolveProps(e){const{props:t}=e,n=p(t)?t:Object.keys(t||{});for(const e of Object.keys(this))"_"!==e[0]&&n.includes(e)&&this._setProp(e,this[e]);for(const e of n.map(O))Object.defineProperty(this,e,{get(){return this._getProp(e)},set(t){this._setProp(e,t,!0,!this._patching)}})}_setAttr(e){if(e.startsWith("data-v-"))return;const t=this.hasAttribute(e);let n=t?this.getAttribute(e):eo;const s=O(e);t&&this._numberProps&&this._numberProps[s]&&(n=M(n)),this._setProp(s,n,!1,!0)}_getProp(e){return this._props[e]}_setProp(e,t,n=!0,s=!1){if(t!==this._props[e]&&(this._dirty=!0,t===eo?delete this._props[e]:(this._props[e]=t,"key"===e&&this._app&&(this._app._ceVNode.key=t)),s&&this._instance&&this._update(),n)){const n=this._ob;n&&(this._processMutations(n.takeRecords()),n.disconnect()),!0===t?this.setAttribute(j(e),""):"string"==typeof t||"number"==typeof t?this.setAttribute(j(e),t+""):t||this.removeAttribute(j(e)),n&&n.observe(this,{attributes:!0})}}_update(){const e=this._createVNode();this._app&&(e.appContext=this._app._context),go(e,this._root)}_createVNode(){const e={};this.shadowRoot||(e.onVnodeMounted=e.onVnodeUpdated=this._renderSlots.bind(this));const t=er(this._def,c(e,this._props));return this._instance||(t.ce=e=>{this._instance=e,e.ce=this,e.isCE=!0;const t=(e,t)=>{this.dispatchEvent(new CustomEvent(e,C(t[0])?c({detail:t},t[0]):{detail:t}))};e.emit=(e,...n)=>{t(e,n),j(e)!==e&&t(j(e),n)},this._setParent()}),t}_applyStyles(e,t,n){if(!e)return;if(t){if(t===this._def||this._styleChildren.has(t))return;this._styleChildren.add(t)}const s=this._nonce,r=this.shadowRoot,o=n?this._getStyleAnchor(n)||this._getStyleAnchor(this._def):this._getRootStyleInsertionAnchor(r);let i=null;for(let l=e.length-1;l>=0;l--){const a=document.createElement("style");s&&a.setAttribute("nonce",s),a.textContent=e[l],r.insertBefore(a,i||o),i=a,0===l&&(n||this._styleAnchors.set(this._def,a),t&&this._styleAnchors.set(t,a))}}_getStyleAnchor(e){if(!e)return null;const t=this._styleAnchors.get(e);return t&&t.parentNode===this.shadowRoot?t:(t&&this._styleAnchors.delete(e),null)}_getRootStyleInsertionAnchor(e){for(let t=0;t<e.childNodes.length;t++){const n=e.childNodes[t];if(!(n instanceof HTMLStyleElement))return n}return null}_parseSlots(){const e=this._slots={};let t;for(;t=this.firstChild;){const n=1===t.nodeType&&t.getAttribute("slot")||"default";(e[n]||(e[n]=[])).push(t),this.removeChild(t)}}_renderSlots(){const e=this._getSlots(),t=this._instance.type.__scopeId;for(let n=0;n<e.length;n++){const s=e[n],r=s.getAttribute("name")||"default",o=this._slots[r],i=s.parentNode;if(o)for(const e of o){if(t&&1===e.nodeType){const n=t+"-s",s=document.createTreeWalker(e,1);let r;for(e.setAttribute(n,"");r=s.nextNode();)r.setAttribute(n,"")}i.insertBefore(e,s)}else for(;s.firstChild;)i.insertBefore(s.firstChild,s);i.removeChild(s)}}_getSlots(){const e=[this];this._teleportTargets&&e.push(...this._teleportTargets);const t=new Set;for(const n of e){const e=n.querySelectorAll("slot");for(let n=0;n<e.length;n++)t.add(e[n])}return Array.from(t)}_injectChildStyle(e,t){this._applyStyles(e.styles,e,t)}_beginPatch(){this._patching=!0,this._dirty=!1}_endPatch(){this._patching=!1,this._dirty&&this._instance&&this._update()}_hasShadowRoot(){return!1!==this._def.shadowRoot}_removeChildStyle(e){}}const so=e=>{const t=e.props["onUpdate:modelValue"]||!1;return p(t)?e=>R(t,e):t};function ro(e){e.target.composing=!0}function oo(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const io=Symbol("_assign");function lo(e,t,n){return t&&(e=e.trim()),n&&(e=F(e)),e}const ao={created(e,{modifiers:{lazy:t,trim:n,number:s}},r){e[io]=so(r);const o=s||r.props&&"number"===r.props.type;Hr(e,t?"change":"input",t=>{t.target.composing||e[io](lo(e.value,n,o))}),(n||o)&&Hr(e,"change",()=>{e.value=lo(e.value,n,o)}),t||(Hr(e,"compositionstart",ro),Hr(e,"compositionend",oo),Hr(e,"change",oo))},mounted(e,{value:t}){e.value=null==t?"":t},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:s,trim:r,number:o}},i){if(e[io]=so(i),e.composing)return;const l=null==t?"":t;if((!o&&"number"!==e.type||/^0\d/.test(e.value)?e.value:F(e.value))!==l){if(document.activeElement===e&&"range"!==e.type){if(s&&t===n)return;if(r&&e.value.trim()===l)return}e.value=l}}},co=["ctrl","shift","alt","meta"],uo={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&0!==e.button,middle:e=>"button"in e&&1!==e.button,right:e=>"button"in e&&2!==e.button,exact:(e,t)=>co.some(n=>e[`${n}Key`]&&!t.includes(n))},ho=(e,t)=>{if(!e)return e;const n=e._withMods||(e._withMods={}),s=t.join(".");return n[s]||(n[s]=(n,...s)=>{for(let e=0;e<t.length;e++){const s=uo[t[e]];if(s&&s(n,t))return}return e(n,...s)})},po=c({patchProp:(e,t,n,s,r,o)=>{const i="svg"===r;"class"===t?function(e,t,n){const s=e[Ir];s&&(t=(t?[t,...s]:[...s]).join(" ")),null==t?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}(e,s,i):"style"===t?function(e,t,n){const s=e.style,r=y(n);let o=!1;if(n&&!r){if(t)if(y(t))for(const e of t.split(";")){const t=e.slice(0,e.indexOf(":")).trim();null==n[t]&&Ur(s,t,"")}else for(const e in t)null==n[e]&&Ur(s,e,"");for(const e in n)"display"===e&&(o=!0),Ur(s,e,n[e])}else if(r){if(t!==n){const e=s[Fr];e&&(n+=";"+e),s.cssText=n,o=Mr.test(n)}}else t&&e.removeAttribute("style");$r in e&&(e[$r]=o?s.display:"",e[Dr]&&(s.display="none"))}(e,n,s):l(t)?a(t)||Zr(e,t,0,s,o):("."===t[0]?(t=t.slice(1),1):"^"===t[0]?(t=t.slice(1),0):function(e,t,n,s){if(s)return"innerHTML"===t||"textContent"===t||!!(t in e&&Yr(t)&&v(n));if("spellcheck"===t||"draggable"===t||"translate"===t||"autocorrect"===t)return!1;if("sandbox"===t&&"IFRAME"===e.tagName)return!1;if("form"===t)return!1;if("list"===t&&"INPUT"===e.tagName)return!1;if("type"===t&&"TEXTAREA"===e.tagName)return!1;if("width"===t||"height"===t){const t=e.tagName;if("IMG"===t||"VIDEO"===t||"CANVAS"===t||"SOURCE"===t)return!1}if(Yr(t)&&y(n))return!1;return t in e}(e,t,s,i))?(Br(e,t,s),e.tagName.includes("-")||"value"!==t&&"checked"!==t&&"selected"!==t||Wr(e,t,s,i,0,"value"!==t)):e._isVueCE&&(function(e,t){const n=e._def.props;if(!n)return!1;const s=O(t);return Array.isArray(n)?n.some(e=>O(e)===s):Object.keys(n).some(e=>O(e)===s)}(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!y(s)))?Br(e,O(t),s,0,t):("true-value"===t?e._trueValue=s:"false-value"===t&&(e._falseValue=s),Wr(e,t,s,i))}},jr);let fo;function mo(){return fo||(fo=Os(po))}const go=(...e)=>{mo().render(...e)},vo=(...e)=>{const t=mo().createApp(...e),{mount:n}=t;return t.mount=e=>{const s=function(e){if(y(e)){return document.querySelector(e)}return e}(e);if(!s)return;const r=t._component;v(r)||r.render||r.template||(r.template=s.innerHTML),1===s.nodeType&&(s.textContent="");const o=n(s,!1,function(e){if(e instanceof SVGElement)return"svg";if("function"==typeof MathMLElement&&e instanceof MathMLElement)return"mathml"}(s));return s instanceof Element&&(s.removeAttribute("v-cloak"),s.setAttribute("data-v-app","")),o},t};const yo=["value","placeholder"],_o=["value","placeholder"],bo={key:2,class:"errorlist"};t.render=function(e,t,n,s,r,o){return zs(),Ks("div",{class:H(["sf-field",{errors:o.fieldErrors.length}])},[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),o.isLong?(zs(),Ks("textarea",{key:0,class:"sf-input sf-textarea",rows:"3",value:n.modelValue,placeholder:n.schema.placeholder||"",onInput:t[0]||(t[0]=t=>e.$emit("update:modelValue",t.target.value))},null,40,yo)):(zs(),Ks("input",{key:1,type:"text",class:"sf-input",value:null!=n.modelValue?String(n.modelValue):"",placeholder:n.schema.placeholder||"",onInput:t[1]||(t[1]=t=>e.$emit("update:modelValue",t.target.value))},null,40,_o)),o.fieldErrors.length?(zs(),Ks("ul",bo,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},t.__file="src/editors/StringEditor.vue";var So={name:"NumberEditor",props:{schema:{type:Object,required:!0},modelValue:{default:0},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},isRequired(){if(this.path.length<2||!this.form)return!1;const e=this.path.slice(0,-1),t=this.path[this.path.length-1],n=this.form.getSchemaAtPath(e);return n&&Array.isArray(n.required)&&n.required.includes(t)},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",onInput(e){const t=e.target.value;""===t?this.$emit("update:modelValue",0):this.$emit("update:modelValue","integer"===this.schema.type?parseInt(t,10):parseFloat(t))}}};const xo=["step","min","max","value"],ko={key:0,class:"errorlist"};So.render=function(e,t,n,s,r,o){return zs(),Ks("div",{class:H(["sf-field",{errors:o.fieldErrors.length}])},[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),Ys("input",{type:"number",class:"sf-input",step:"integer"===n.schema.type?"1":"any",min:null!=n.schema.minimum?String(n.schema.minimum):void 0,max:null!=n.schema.maximum?String(n.schema.maximum):void 0,value:null!=n.modelValue?n.modelValue:"",onInput:t[0]||(t[0]=(...e)=>o.onInput&&o.onInput(...e))},null,40,xo),o.fieldErrors.length?(zs(),Ks("ul",ko,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},So.__file="src/editors/NumberEditor.vue";var Co={name:"BooleanEditor",props:{schema:{type:Object,required:!0},modelValue:{default:!1},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):""}};const Eo={class:"sf-checkbox-label"},wo=["checked"],Ao={key:0,class:"errorlist"};Co.render=function(e,t,n,s,r,o){return zs(),Ks("div",{class:H(["sf-field sf-field-boolean",{errors:o.fieldErrors.length}])},[Ys("label",Eo,[Ys("input",{type:"checkbox",class:"sf-checkbox",checked:!!n.modelValue,onChange:t[0]||(t[0]=t=>e.$emit("update:modelValue",t.target.checked))},null,40,wo),nr(" "+G(o.title),1)]),o.fieldErrors.length?(zs(),Ks("ul",Ao,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},Co.__file="src/editors/BooleanEditor.vue";var Vo={name:"SelectEditor",props:{schema:{type:Object,required:!0},modelValue:{default:""},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},isRequired(){if(this.path.length<2||!this.form)return!1;const e=this.path.slice(0,-1),t=this.path[this.path.length-1],n=this.form.getSchemaAtPath(e);return n&&Array.isArray(n.required)&&n.required.includes(t)},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):""}};const Oo=["value"],Po=["value"],jo={key:0,class:"errorlist"};Vo.render=function(e,t,n,s,r,o){return zs(),Ks("div",{class:H(["sf-field",{errors:o.fieldErrors.length}])},[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),Ys("select",{class:"sf-input sf-select",value:null!=n.modelValue?String(n.modelValue):"",onChange:t[0]||(t[0]=t=>e.$emit("update:modelValue",t.target.value))},[(zs(!0),Ks(Fs,null,Tn(n.schema.enum||[],e=>(zs(),Ks("option",{key:e,value:String(e)},G(e),9,Po))),128))],40,Oo),o.fieldErrors.length?(zs(),Ks("ul",jo,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},Vo.__file="src/editors/SelectEditor.vue";var Io={name:"HiddenEditor",props:{schema:{type:Object,required:!0},modelValue:{default:null},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],computed:{resolvedValue(){return"const"in this.schema?this.schema.const:this.schema.enum&&1===this.schema.enum.length?this.schema.enum[0]:this.modelValue}},mounted(){this.resolvedValue!==this.modelValue&&this.$emit("update:modelValue",this.resolvedValue)},methods:{getValue(){return this.resolvedValue}}};const $o={style:{display:"none"}};Io.render=function(e,t,n,s,r,o){return zs(),Ks("div",$o)},Io.__file="src/editors/HiddenEditor.vue";var Do={name:"SfIcon",props:{name:{type:String,required:!0},size:{type:[Number,String],default:14}}};const Ro=["width","height"],To={key:4,points:"6 9 12 15 18 9"},Fo={key:5,points:"18 15 12 9 6 15"};Do.render=function(e,t,n,s,r,o){return zs(),Ks("svg",{class:"sf-icon",width:n.size,height:n.size,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"},["plus"===n.name?(zs(),Ks(Fs,{key:0},[t[0]||(t[0]=Ys("line",{x1:"12",y1:"5",x2:"12",y2:"19"},null,-1)),t[1]||(t[1]=Ys("line",{x1:"5",y1:"12",x2:"19",y2:"12"},null,-1))],64)):"times"===n.name?(zs(),Ks(Fs,{key:1},[t[2]||(t[2]=Ys("line",{x1:"6",y1:"6",x2:"18",y2:"18"},null,-1)),t[3]||(t[3]=Ys("line",{x1:"6",y1:"18",x2:"18",y2:"6"},null,-1))],64)):"arrow-up"===n.name?(zs(),Ks(Fs,{key:2},[t[4]||(t[4]=Ys("line",{x1:"12",y1:"19",x2:"12",y2:"5"},null,-1)),t[5]||(t[5]=Ys("polyline",{points:"5 12 12 5 19 12"},null,-1))],64)):"arrow-down"===n.name?(zs(),Ks(Fs,{key:3},[t[6]||(t[6]=Ys("line",{x1:"12",y1:"5",x2:"12",y2:"19"},null,-1)),t[7]||(t[7]=Ys("polyline",{points:"19 12 12 19 5 12"},null,-1))],64)):"chevron-down"===n.name?(zs(),Ks("polyline",To)):"chevron-up"===n.name?(zs(),Ks("polyline",Fo)):"grip"===n.name?(zs(),Ks(Fs,{key:6},[t[8]||(t[8]=sr('<circle cx="9" cy="7" r="1" fill="currentColor" stroke="none"></circle><circle cx="15" cy="7" r="1" fill="currentColor" stroke="none"></circle><circle cx="9" cy="12" r="1" fill="currentColor" stroke="none"></circle><circle cx="15" cy="12" r="1" fill="currentColor" stroke="none"></circle><circle cx="9" cy="17" r="1" fill="currentColor" stroke="none"></circle><circle cx="15" cy="17" r="1" fill="currentColor" stroke="none"></circle>',6))],64)):rr("v-if",!0)],8,Ro)},Do.__file="src/editors/SfIcon.vue";var Mo={name:"ObjectEditor",beforeCreate(){this.$options.components||(this.$options.components={}),this.$options.components.SchemaEditor=Di,this.$options.components.SfIcon=Do},props:{schema:{type:Object,required:!0},modelValue:{default:()=>({})},path:{type:Array,default:()=>[]},form:{type:Object,required:!0}},emits:["update:modelValue"],data:()=>({collapsed:!1}),computed:{isRoot(){return 0===this.path.length},title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},summary(){const e=this.modelValue||{},t=[];for(const n of Object.keys(this.schema.properties||{})){if(t.length>=3)break;const s=e[n];null!=s&&""!==s&&"object"!=typeof s&&t.push(String(s))}return t.join(" · ")}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",collapse(){this.collapsed=!0},expand(){this.collapsed=!1},onChildChange(e,t){const n={...this.modelValue||{},[e]:t};this.$emit("update:modelValue",n)}}};const No={key:0,class:"sf-object sf-object-root"},Uo={class:"sf-object-fields"},Lo={class:"sf-object-title"},qo=["aria-label"],zo={class:"sf-object-title-text"},Wo={key:0,class:"sf-object-summary"},Bo={class:"sf-object-fields"};function Ho(e){if(null===e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(Ho);const t={};for(const n of Object.keys(e))t[n]=Ho(e[n]);return t}function Ko(e){if("default"in e)return Ho(e.default);if("object"===e.type){const t={};for(const[n,s]of Object.entries(e.properties||{}))"default"in s?t[n]=Ho(s.default):"string"===s.type?t[n]="":"integer"===s.type||"number"===s.type?t[n]=0:"boolean"===s.type?t[n]=!1:"array"===s.type&&(t[n]=[]);return t}return"array"===e.type?[]:"string"===e.type?"":"integer"===e.type||"number"===e.type?0:"boolean"!==e.type&&("relation"===e.type&&e.multiple?[]:null)}Mo.render=function(e,t,n,s,r,o){const i=In("SchemaEditor"),l=In("SfIcon");return o.isRoot?(zs(),Ks("div",No,[Ys("div",Uo,[(zs(!0),Ks(Fs,null,Tn(n.schema.properties||{},(e,t)=>(zs(),Zs(i,{key:t,schema:n.form.resolveSchema(e),"model-value":(n.modelValue||{})[t],path:[...n.path,t],form:n.form,"onUpdate:modelValue":e=>o.onChildChange(t,e)},null,8,["schema","model-value","path","form","onUpdate:modelValue"]))),128))])])):(zs(),Ks("fieldset",{key:1,class:H(["sf-object",{"sf-object-collapsed":r.collapsed}])},[Ys("legend",Lo,[Ys("button",{type:"button",class:"sf-collapse-btn","aria-label":r.collapsed?"Expand":"Collapse",onClick:t[0]||(t[0]=e=>r.collapsed=!r.collapsed)},[er(l,{name:r.collapsed?"chevron-down":"chevron-up",size:12},null,8,["name"])],8,qo),Ys("span",zo,G(o.title),1),r.collapsed&&o.summary?(zs(),Ks("span",Wo,G(o.summary),1)):rr("v-if",!0)]),Jt(Ys("div",Bo,[(zs(!0),Ks(Fs,null,Tn(n.schema.properties||{},(e,t)=>(zs(),Zs(i,{key:t,schema:n.form.resolveSchema(e),"model-value":(n.modelValue||{})[t],path:[...n.path,t],form:n.form,"onUpdate:modelValue":e=>o.onChildChange(t,e)},null,8,["schema","model-value","path","form","onUpdate:modelValue"]))),128))],512),[[Rr,!r.collapsed]])],2))},Mo.__file="src/editors/ObjectEditor.vue";let Zo=0;var Qo={name:"ArrayEditor",beforeCreate(){this.$options.components||(this.$options.components={}),this.$options.components.SchemaEditor=Di,this.$options.components.SfIcon=Do},props:{schema:{type:Object,required:!0},modelValue:{default:()=>[]},path:{type:Array,default:()=>[]},form:{type:Object,required:!0}},emits:["update:modelValue"],data(){return{items:(Array.isArray(this.modelValue)?this.modelValue:[]).map(e=>({_key:Zo++,value:e})),dragSourceIndex:null,dragOverIndex:null,allCollapsed:!1}},computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},itemSchema(){return this.form.resolveSchema(this.schema.items||{})},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",addItem(){const e=Ko(this.itemSchema);this.items.push({_key:Zo++,value:e}),this.emitValue()},removeItem(e){this.items.splice(e,1),this.emitValue()},moveItem(e,t){const n=e+t;if(n<0||n>=this.items.length)return;const s=this.items[e];this.items.splice(e,1,this.items[n]),this.items.splice(n,1,s),this.emitValue()},onItemChange(e,t){this.items[e].value=t,this.emitValue()},onDragStart(e,t){this.dragSourceIndex=e,t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",String(e))},onDragOver(e){null!==this.dragSourceIndex&&e!==this.dragSourceIndex&&(this.dragOverIndex=e)},onDragLeave(e){this.dragOverIndex===e&&(this.dragOverIndex=null)},onDrop(e){if(null===this.dragSourceIndex||this.dragSourceIndex===e)return;const t=this.items.splice(this.dragSourceIndex,1)[0];this.items.splice(e,0,t),this.dragSourceIndex=null,this.dragOverIndex=null,this.emitValue()},onDragEnd(){this.dragSourceIndex=null,this.dragOverIndex=null},toggleCollapseAll(){this.allCollapsed=!this.allCollapsed;const e=this.$refs.itemEditors;if(!e)return;const t=Array.isArray(e)?e:[e];this.allCollapsed?t.forEach(e=>e?.collapseAll?.()):t.forEach(e=>e?.expandAll?.())},emitValue(){this.$emit("update:modelValue",this.items.map(e=>e.value))}}};const Jo={class:"sf-array-header"},Go={class:"sf-label"},Xo={class:"sf-array-count"},Yo=["title"],ei={class:"sf-array-items"},ti=["onDragstart","onDragover","onDragleave","onDrop"],ni={class:"sf-array-item-header"},si={class:"sf-array-item-left"},ri={class:"sf-drag-handle",title:"Drag to reorder"},oi={class:"sf-array-item-index"},ii={class:"sf-array-item-actions"},li=["onClick"],ai=["onClick"],ci=["onClick"],ui=["onDrop"],hi={key:0,class:"errorlist"};Qo.render=function(e,t,n,s,r,o){const i=In("SfIcon"),l=In("SchemaEditor");return zs(),Ks("div",{class:H(["sf-array",{errors:o.fieldErrors.length}])},[Ys("div",Jo,[Ys("span",Go,G(o.title),1),Ys("span",Xo,G(r.items.length),1),Ys("button",{type:"button",class:"sf-btn sf-btn-add",onClick:t[0]||(t[0]=e=>o.addItem())},[er(i,{name:"plus"}),t[4]||(t[4]=nr(" Add ",-1))]),r.items.length?(zs(),Ks("span",{key:0,class:"sf-array-collapse-toggle",title:r.allCollapsed?"Expand all":"Collapse all",onClick:t[1]||(t[1]=(...e)=>o.toggleCollapseAll&&o.toggleCollapseAll(...e))},[er(i,{name:r.allCollapsed?"chevron-down":"chevron-up"},null,8,["name"])],8,Yo)):rr("v-if",!0)]),Ys("div",ei,[(zs(!0),Ks(Fs,null,Tn(r.items,(e,s)=>(zs(),Ks("div",{key:e._key,class:H(["sf-array-item",{"sf-drag-over":r.dragOverIndex===s,"sf-dragging":r.dragSourceIndex===s}]),draggable:"true",onDragstart:e=>o.onDragStart(s,e),onDragover:ho(e=>o.onDragOver(s),["prevent"]),onDragleave:e=>o.onDragLeave(s),onDrop:ho(e=>o.onDrop(s),["prevent"]),onDragend:t[3]||(t[3]=(...e)=>o.onDragEnd&&o.onDragEnd(...e))},[Ys("div",ni,[Ys("div",si,[Ys("span",ri,[er(i,{name:"grip"})]),Ys("span",oi,"#"+G(s+1),1)]),Ys("div",ii,[s>0?(zs(),Ks("button",{key:0,type:"button",class:"sf-btn sf-btn-sm",onClick:e=>o.moveItem(s,-1)},[er(i,{name:"arrow-up"})],8,li)):rr("v-if",!0),Ys("button",{type:"button",class:"sf-btn sf-btn-sm",onClick:e=>o.moveItem(s,1)},[er(i,{name:"arrow-down"})],8,ai),Ys("button",{type:"button",class:"sf-btn sf-btn-sm sf-btn-danger",onClick:e=>o.removeItem(s)},[er(i,{name:"times"})],8,ci)])]),Ys("div",{class:"sf-array-item-body",onDragover:t[2]||(t[2]=ho(()=>{},["prevent"])),onDrop:ho(e=>o.onDrop(s),["prevent"])},[er(l,{ref_for:!0,ref:"itemEditors",schema:o.itemSchema,"model-value":e.value,path:[...n.path,String(s)],form:n.form,"onUpdate:modelValue":e=>o.onItemChange(s,e)},null,8,["schema","model-value","path","form","onUpdate:modelValue"])],40,ui)],42,ti))),128))]),o.fieldErrors.length?(zs(),Ks("ul",hi,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},Qo.__file="src/editors/ArrayEditor.vue";var di={name:"NullableEditor",beforeCreate(){this.$options.components||(this.$options.components={}),this.$options.components.SchemaEditor=Di,this.$options.components.SfIcon=Do},props:{schema:{type:Object,required:!0},modelValue:{default:null},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],data(){return{isNull:null===this.modelValue||void 0===this.modelValue}},computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},isRequired(){if(this.path.length<2||!this.form)return!1;const e=this.path.slice(0,-1),t=this.path[this.path.length-1],n=this.form.getSchemaAtPath(e);return n&&Array.isArray(n.required)&&n.required.includes(t)},innerSchema(){const e={...this.schema};return delete e._nullable,e},toggleClass(){return this.isNull?"sf-btn sf-btn-sm sf-btn-add":"sf-btn sf-btn-sm sf-btn-danger"},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},watch:{modelValue(e){this.isNull=null==e}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",toggle(){this.isNull?(this.isNull=!1,this.$emit("update:modelValue",Ko(this.innerSchema))):(this.isNull=!0,this.$emit("update:modelValue",null))}}};const pi={class:"sf-nullable-header"},fi={class:"sf-nullable-body"},mi={key:0,class:"errorlist"};di.render=function(e,t,n,s,r,o){const i=In("SfIcon"),l=In("SchemaEditor");return zs(),Ks("div",{class:H(["sf-nullable",{errors:o.fieldErrors.length}])},[Ys("div",pi,[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),Ys("button",{type:"button",class:H(o.toggleClass),onClick:t[0]||(t[0]=(...e)=>o.toggle&&o.toggle(...e))},[r.isNull?(zs(),Ks(Fs,{key:0},[er(i,{name:"plus"}),t[2]||(t[2]=nr(" Add ",-1))],64)):(zs(),Ks(Fs,{key:1},[er(i,{name:"times"}),t[3]||(t[3]=nr(" Remove ",-1))],64))],2)]),Ys("div",fi,[r.isNull?rr("v-if",!0):(zs(),Zs(l,{key:0,schema:o.innerSchema,"model-value":n.modelValue,path:n.path,form:n.form,"onUpdate:modelValue":t[1]||(t[1]=t=>e.$emit("update:modelValue",t))},null,8,["schema","model-value","path","form"]))]),o.fieldErrors.length?(zs(),Ks("ul",mi,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},di.__file="src/editors/NullableEditor.vue";var gi={name:"UnionEditor",beforeCreate(){this.$options.components||(this.$options.components={}),this.$options.components.SchemaEditor=Di},props:{schema:{type:Object,required:!0},modelValue:{default:null},path:{type:Array,default:()=>[]},form:{type:Object,required:!0}},emits:["update:modelValue"],data(){const e=this.schema.discriminator.propertyName,t=this.schema.discriminator.mapping;return{discriminatorProp:e,mapping:t,currentType:this.modelValue?this.modelValue[e]:Object.keys(t)[0]}},computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},typeKeys(){return Object.keys(this.mapping)},currentSchema(){const e=this.mapping[this.currentType];return this.form.resolveSchema({$ref:e})},innerValue(){if(this.modelValue&&this.modelValue[this.discriminatorProp]===this.currentType)return this.modelValue;const e=Ko(this.currentSchema);return e[this.discriminatorProp]=this.currentType,e}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",onTypeChange(e){this.currentType=e.target.value;const t=Ko(this.currentSchema);t[this.discriminatorProp]=this.currentType,this.$emit("update:modelValue",t)},onInnerChange(e){e&&(e[this.discriminatorProp]=this.currentType),this.$emit("update:modelValue",e)}}};const vi={class:"sf-union"},yi={class:"sf-field"},_i={class:"sf-label"},bi=["value"],Si=["value"],xi={class:"sf-union-body"};gi.render=function(e,t,n,s,r,o){const i=In("SchemaEditor");return zs(),Ks("div",vi,[Ys("div",yi,[Ys("label",_i,G(o.title),1),Ys("select",{class:"sf-input sf-select",value:r.currentType,onChange:t[0]||(t[0]=(...e)=>o.onTypeChange&&o.onTypeChange(...e))},[(zs(!0),Ks(Fs,null,Tn(o.typeKeys,e=>(zs(),Ks("option",{key:e,value:e},G(o.humanize(e)),9,Si))),128))],40,bi)]),Ys("div",xi,[(zs(),Zs(i,{key:r.currentType,schema:o.currentSchema,"model-value":o.innerValue,path:n.path,form:n.form,"onUpdate:modelValue":o.onInnerChange},null,8,["schema","model-value","path","form","onUpdate:modelValue"]))])])},gi.__file="src/editors/UnionEditor.vue";var ki={name:"RelationEditor",components:{SfIcon:Do},props:{schema:{type:Object,required:!0},modelValue:{default:null},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],data(){const e=!!this.schema.multiple,t=this.modelValue;let n;return n=e?Array.isArray(t)?[...t]:[]:t?[t]:[],{isMultiple:e,allowClear:this.schema.options?.select2?.allowClear??!0,placeholder:this.schema.options?.select2?.placeholder||"Search...",searchUrl:this.schema.options?.select2?.ajax?.url||"",selected:n,dropdownVisible:!1,searchResults:[],currentPage:1,hasMore:!1,loading:!1,highlightIndex:-1,searchQuery:""}},computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},isRequired(){if(this.path.length<2||!this.form)return!1;const e=this.path.slice(0,-1),t=this.path[this.path.length-1],n=this.form.getSchemaAtPath(e);return n&&Array.isArray(n.required)&&n.required.includes(t)},showSearch(){return!(!this.isMultiple&&this.selected.length>0)},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]},filteredResults(){const e=new Set(this.selected.map(e=>this.itemKey(e)));return this.searchResults.filter(t=>!e.has(this.itemKey(t)))}},created(){this._doSearch=function(e,t){let n;return function(...s){clearTimeout(n),n=setTimeout(()=>e.apply(this,s),t)}}(e=>this.fetchResults(e,1),300),this._onDocClick=e=>{this.$refs.root&&!this.$refs.root.contains(e.target)&&this.closeDropdown()}},mounted(){document.addEventListener("click",this._onDocClick)},beforeUnmount(){document.removeEventListener("click",this._onDocClick)},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",getDisplayName(e){if(!e)return"";for(const t of["__str__","name","title","label"])if(e[t])return String(e[t]);return`#${e.id||"?"}`},itemKey:e=>`${e.id}-${e.model||""}`,onSearchInput(){this._doSearch(this.searchQuery)},openDropdown(){this.dropdownVisible||(this.dropdownVisible=!0,this.fetchResults(this.searchQuery,1))},closeDropdown(){this.dropdownVisible=!1,this.highlightIndex=-1},async fetchResults(e,t){if(this.searchUrl){this.loading=!0,this.currentPage=t;try{const n=new URL(this.searchUrl,window.location.origin);n.searchParams.set("_q",e||""),n.searchParams.set("page",String(t));const s=await fetch(n,{credentials:"same-origin"});if(!s.ok)return;const r=await s.json();this.searchResults=1===t?r.items||[]:this.searchResults.concat(r.items||[]),this.hasMore=r.more}finally{this.loading=!1}}},handleKeyDown(e){this.filteredResults.length&&("ArrowDown"===e.key?(e.preventDefault(),this.highlightIndex=Math.min(this.highlightIndex+1,this.filteredResults.length-1)):"ArrowUp"===e.key?(e.preventDefault(),this.highlightIndex=Math.max(this.highlightIndex-1,0)):"Enter"===e.key?(e.preventDefault(),this.highlightIndex>=0&&this.highlightIndex<this.filteredResults.length&&this.selectItem(this.filteredResults[this.highlightIndex])):"Escape"===e.key&&this.closeDropdown())},selectItem(e){this.isMultiple?this.selected.push(e):this.selected=[e],this.searchQuery="",this.highlightIndex=-1,this.closeDropdown(),this.emitValue()},removeItem(e){this.selected=this.selected.filter(t=>!(t.id===e.id&&(t.model||"")===(e.model||""))),this.emitValue()},emitValue(){this.isMultiple?this.$emit("update:modelValue",[...this.selected]):this.$emit("update:modelValue",this.selected[0]||null)}}};const Ci={class:"sf-relation-wrapper"},Ei={key:0,class:"sf-relation-selected"},wi={class:"sf-relation-tag-text"},Ai=["onClick"],Vi={class:"sf-relation-search"},Oi=["placeholder"],Pi={class:"sf-relation-dropdown"},ji={key:0,class:"sf-relation-dropdown-empty"},Ii=["onClick"],$i={key:0,class:"errorlist"};ki.render=function(e,t,n,s,r,o){const i=In("SfIcon");return zs(),Ks("div",{class:H(["sf-field sf-relation",{errors:o.fieldErrors.length}]),ref:"root"},[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),Ys("div",Ci,[rr(" Selected items "),r.selected.length?(zs(),Ks("div",Ei,[(zs(!0),Ks(Fs,null,Tn(r.selected,e=>(zs(),Ks("div",{key:o.itemKey(e),class:"sf-relation-tag"},[Ys("span",wi,G(o.getDisplayName(e)),1),r.isMultiple||r.allowClear?(zs(),Ks("button",{key:0,type:"button",class:"sf-relation-tag-remove",onClick:ho(t=>o.removeItem(e),["stop"])},[er(i,{name:"times"})],8,Ai)):rr("v-if",!0)]))),128))])):rr("v-if",!0),rr(" Search box "),Jt(Ys("div",Vi,[Jt(Ys("input",{ref:"searchInput",type:"text",class:"sf-input sf-relation-input",placeholder:r.placeholder,autocomplete:"off","onUpdate:modelValue":t[0]||(t[0]=e=>r.searchQuery=e),onInput:t[1]||(t[1]=(...e)=>o.onSearchInput&&o.onSearchInput(...e)),onFocus:t[2]||(t[2]=(...e)=>o.openDropdown&&o.openDropdown(...e)),onKeydown:t[3]||(t[3]=(...e)=>o.handleKeyDown&&o.handleKeyDown(...e))},null,40,Oi),[[ao,r.searchQuery]]),rr(" Dropdown "),Jt(Ys("div",Pi,[0!==o.filteredResults.length||r.loading?rr("v-if",!0):(zs(),Ks("div",ji," No results found ")),(zs(!0),Ks(Fs,null,Tn(o.filteredResults,(e,t)=>(zs(),Ks("div",{key:o.itemKey(e),class:H(["sf-relation-dropdown-item",{highlighted:t===r.highlightIndex}]),onClick:t=>o.selectItem(e)},G(o.getDisplayName(e)),11,Ii))),128)),r.hasMore?(zs(),Ks("div",{key:1,class:"sf-relation-dropdown-more",onClick:t[4]||(t[4]=e=>o.fetchResults(r.searchQuery,r.currentPage+1))}," Load more... ")):rr("v-if",!0)],512),[[Rr,r.dropdownVisible]])],512),[[Rr,o.showSearch]])]),o.fieldErrors.length?(zs(),Ks("ul",$i,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},ki.__file="src/editors/RelationEditor.vue";var Di={name:"SchemaEditor",components:{StringEditor:t,NumberEditor:So,BooleanEditor:Co,SelectEditor:Vo,HiddenEditor:Io,ObjectEditor:Mo,ArrayEditor:Qo,NullableEditor:di,UnionEditor:gi,RelationEditor:ki},props:{schema:{type:Object,required:!0},modelValue:{default:void 0},path:{type:Array,default:()=>[]},form:{type:Object,required:!0}},emits:["update:modelValue"],methods:{collapseAll(){const e=this.$refs.editor;e?.collapse&&e.collapse(),e?.collapseAll&&e.collapseAll()},expandAll(){const e=this.$refs.editor;e?.expand&&e.expand(),e?.expandAll&&e.expandAll()}},computed:{editorComponent(){const e=this.schema;return this.path.length>12?"StringEditor":"relation"===e.type?"RelationEditor":e.oneOf&&e.discriminator?"UnionEditor":"const"in e||e.enum&&1===e.enum.length&&"string"===e.type?"HiddenEditor":e._nullable?"NullableEditor":"object"===e.type&&e.properties?"ObjectEditor":"array"===e.type?"ArrayEditor":e.enum?"SelectEditor":"boolean"===e.type?"BooleanEditor":"number"===e.type||"integer"===e.type?"NumberEditor":"StringEditor"}}};Di.render=function(e,t,n,s,r,o){return zs(),Zs((i=o.editorComponent,y(i)?Dn(jn,i,!1)||i:i||$n),{ref:"editor",schema:n.schema,"model-value":n.modelValue,path:n.path,form:n.form,"onUpdate:modelValue":t[0]||(t[0]=t=>e.$emit("update:modelValue",t))},null,8,["schema","model-value","path","form"]);var i},Di.__file="src/editors/SchemaEditor.vue";var Ri={name:"SchemaForm",components:{SchemaEditor:Di},props:{schema:{type:[Object,String],default:()=>({})},initialData:{default:void 0},errors:{type:Object,default:()=>({})}},emits:["change"],expose:["getValue"],data(){const e="string"==typeof this.schema?JSON.parse(this.schema):this.schema;return{rootSchema:e,defs:e.$defs||e.definitions||{},currentValue:null!=this.initialData?Ho(this.initialData):void 0}},computed:{resolvedSchema(){return this.resolveSchema(this.rootSchema)},formApi(){return{resolveSchema:e=>this.resolveSchema(e),getSchemaAtPath:e=>this.getSchemaAtPath(e),getErrorsForPath:e=>this.getErrorsForPath(e)}}},watch:{schema:{handler(e){const t="string"==typeof e?JSON.parse(e):e;this.rootSchema=t,this.defs=t.$defs||t.definitions||{}},deep:!0},initialData:{handler(e){this.currentValue=null!=e?Ho(e):void 0},deep:!0}},methods:{resolveSchema(e){if(!e)return{type:"string"};if(e.$ref){const t=e.$ref.replace(/^#\/\$defs\//,"").replace(/^#\/definitions\//,""),n=this.defs[t];if(!n)return{type:"string",title:t};const{$ref:s,...r}=e;return{...this.resolveSchema(n),...r}}if(e.anyOf){const t=e.anyOf.filter(e=>"null"!==e.type);if(e.anyOf.some(e=>"null"===e.type)&&1===t.length){const n=this.resolveSchema(t[0]);return{...n,_nullable:!0,title:e.title||n.title,default:"default"in e?e.default:null}}if(t.length>=1)return this.resolveSchema(t[0])}if(e.oneOf&&e.discriminator)return e;if(e.oneOf){const t=e.oneOf.filter(e=>"null"!==e.type);if(e.oneOf.some(e=>"null"===e.type)&&1===t.length){const n=this.resolveSchema(t[0]);return{...n,_nullable:!0,title:e.title||n.title,default:"default"in e?e.default:null}}if(t.length>=1)return this.resolveSchema(t[0])}return e},getSchemaAtPath(e){let t=this.resolveSchema(this.rootSchema);for(const n of e){if(!t)return null;if(t.properties&&t.properties[n])t=this.resolveSchema(t.properties[n]);else{if(!t.items)return null;t=this.resolveSchema(t.items)}}return t},onValueChange(e){this.currentValue=e,this.$emit("change",e)},getErrorsForPath(e){if(!this.errors||"object"!=typeof this.errors)return[];const t=e.join(".");return this.errors[t]||[]},getValue(){return this.currentValue}}};const Ti={class:"structured-field-editor"};Ri.render=function(e,t,n,s,r,o){const i=In("SchemaEditor");return zs(),Ks("div",Ti,[o.resolvedSchema?(zs(),Zs(i,{key:0,schema:o.resolvedSchema,"model-value":r.currentValue,path:[],form:o.formApi,"onUpdate:modelValue":o.onValueChange},null,8,["schema","model-value","form","onUpdate:modelValue"])):rr("v-if",!0)])},Ri.__file="src/SchemaForm.vue";const Fi=function(e,t,n){let s=function(e,t){return v(e)?(()=>c({name:e.name},t,{setup:e}))():e}(e,t);C(s)&&(s=c({},s,t));class r extends no{constructor(e){super(s,e,n)}}return r.def=s,r}({...Ri,shadowRoot:!1});return e.ArrayEditor=Qo,e.BooleanEditor=Co,e.HiddenEditor=Io,e.NullableEditor=di,e.NumberEditor=So,e.ObjectEditor=Mo,e.RelationEditor=ki,e.SchemaEditor=Di,e.SchemaForm=Ri,e.SchemaFormElement=Fi,e.SelectEditor=Vo,e.StringEditor=t,e.UnionEditor=gi,e.registerCustomElement=function(e="schema-form"){customElements.get(e)||customElements.define(e,Fi)},e}({});
|
|
25
|
+
let wr;const Ar="undefined"!=typeof window&&window.trustedTypes;if(Ar)try{wr=Ar.createPolicy("vue",{createHTML:e=>e})}catch(e){}const Vr=wr?e=>wr.createHTML(e):e=>e,Or="undefined"!=typeof document?document:null,Pr=Or&&Or.createElement("template"),jr={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,s)=>{const r="svg"===t?Or.createElementNS("http://www.w3.org/2000/svg",e):"mathml"===t?Or.createElementNS("http://www.w3.org/1998/Math/MathML",e):n?Or.createElement(e,{is:n}):Or.createElement(e);return"select"===e&&s&&null!=s.multiple&&r.setAttribute("multiple",s.multiple),r},createText:e=>Or.createTextNode(e),createComment:e=>Or.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>Or.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,s,r,o){const i=n?n.previousSibling:t.lastChild;if(r&&(r===o||r.nextSibling))for(;t.insertBefore(r.cloneNode(!0),n),r!==o&&(r=r.nextSibling););else{Pr.innerHTML=Vr("svg"===s?`<svg>${e}</svg>`:"mathml"===s?`<math>${e}</math>`:e);const r=Pr.content;if("svg"===s||"mathml"===s){const e=r.firstChild;for(;e.firstChild;)r.appendChild(e.firstChild);r.removeChild(e)}t.insertBefore(r,n)}return[i?i.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},Ir=Symbol("_vtc");const $r=Symbol("_vod"),Dr=Symbol("_vsh"),Rr={name:"show",beforeMount(e,{value:t},{transition:n}){e[$r]="none"===e.style.display?"":e.style.display,n&&t?n.beforeEnter(e):Tr(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:s}){!t!=!n&&(s?t?(s.beforeEnter(e),Tr(e,!0),s.enter(e)):s.leave(e,()=>{Tr(e,!1)}):Tr(e,t))},beforeUnmount(e,{value:t}){Tr(e,t)}};function Tr(e,t){e.style.display=t?e[$r]:"none",e[Dr]=!t}const Fr=Symbol(""),Mr=/(?:^|;)\s*display\s*:/;const Nr=/\s*!important$/;function Ur(e,t,n){if(p(n))n.forEach(n=>Ur(e,t,n));else if(null==n&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const s=function(e,t){const n=qr[t];if(n)return n;let s=O(t);if("filter"!==s&&s in e)return qr[t]=s;s=I(s);for(let n=0;n<Lr.length;n++){const r=Lr[n]+s;if(r in e)return qr[t]=r}return t}(e,t);Nr.test(n)?e.setProperty(j(s),n.replace(Nr,""),"important"):e[s]=n}}const Lr=["Webkit","Moz","ms"],qr={};const zr="http://www.w3.org/1999/xlink";function Wr(e,t,n,s,r,o=K(t)){s&&t.startsWith("xlink:")?null==n?e.removeAttributeNS(zr,t.slice(6,t.length)):e.setAttributeNS(zr,t,n):null==n||o&&!Z(n)?e.removeAttribute(t):e.setAttribute(t,o?"":_(n)?String(n):n)}function Br(e,t,n,s,r){if("innerHTML"===t||"textContent"===t)return void(null!=n&&(e[t]="innerHTML"===t?Vr(n):n));const o=e.tagName;if("value"===t&&"PROGRESS"!==o&&!o.includes("-")){const s="OPTION"===o?e.getAttribute("value")||"":e.value,r=null==n?"checkbox"===e.type?"on":"":String(n);return s===r&&"_value"in e||(e.value=r),null==n&&e.removeAttribute(t),void(e._value=n)}let i=!1;if(""===n||null==n){const s=typeof e[t];"boolean"===s?n=Z(n):null==n&&"string"===s?(n="",i=!0):"number"===s&&(n=0,i=!0)}try{e[t]=n}catch(e){}i&&e.removeAttribute(r||t)}function Hr(e,t,n,s){e.addEventListener(t,n,s)}const Kr=Symbol("_vei");function Zr(e,t,n,s,r=null){const o=e[Kr]||(e[Kr]={}),i=o[t];if(s&&i)i.value=s;else{const[n,l]=function(e){let t;if(Qr.test(e)){let n;for(t={};n=e.match(Qr);)e=e.slice(0,e.length-n[0].length),t[n[0].toLowerCase()]=!0}const n=":"===e[2]?e.slice(3):j(e.slice(2));return[n,t]}(t);if(s){const i=o[t]=function(e,t){const n=e=>{if(e._vts){if(e._vts<=n.attached)return}else e._vts=Date.now();jt(function(e,t){if(p(t)){const n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(e=>t=>!t._stopped&&e&&e(t))}return t}(e,n.value),t,5,[e])};return n.value=e,n.attached=Xr(),n}(s,r);Hr(e,n,i,l)}else i&&(!function(e,t,n,s){e.removeEventListener(t,n,s)}(e,n,i,l),o[t]=void 0)}}const Qr=/(?:Once|Passive|Capture)$/;let Jr=0;const Gr=Promise.resolve(),Xr=()=>Jr||(Gr.then(()=>Jr=0),Jr=Date.now());const Yr=e=>111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123;const eo={};const to="undefined"!=typeof HTMLElement?HTMLElement:class{};class no extends to{constructor(e,t={},n=vo){super(),this._def=e,this._props=t,this._createApp=n,this._isVueCE=!0,this._instance=null,this._app=null,this._nonce=this._def.nonce,this._connected=!1,this._resolved=!1,this._patching=!1,this._dirty=!1,this._numberProps=null,this._styleChildren=new WeakSet,this._styleAnchors=new WeakMap,this._ob=null,this.shadowRoot&&n!==vo?this._root=this.shadowRoot:!1!==e.shadowRoot?(this.attachShadow(c({},e.shadowRootOptions,{mode:"open"})),this._root=this.shadowRoot):this._root=this}connectedCallback(){if(!this.isConnected)return;this.shadowRoot||this._resolved||this._parseSlots(),this._connected=!0;let e=this;for(;e=e&&(e.assignedSlot||e.parentNode||e.host);)if(e instanceof no){this._parent=e;break}this._instance||(this._resolved?this._mount(this._def):e&&e._pendingResolve?this._pendingResolve=e._pendingResolve.then(()=>{this._pendingResolve=void 0,this._resolveDef()}):this._resolveDef())}_setParent(e=this._parent){e&&(this._instance.parent=e._instance,this._inheritParentContext(e))}_inheritParentContext(e=this._parent){e&&this._app&&Object.setPrototypeOf(this._app._context.provides,e._instance.provides)}disconnectedCallback(){this._connected=!1,Ut(()=>{this._connected||(this._ob&&(this._ob.disconnect(),this._ob=null),this._app&&this._app.unmount(),this._instance&&(this._instance.ce=void 0),this._app=this._instance=null,this._teleportTargets&&(this._teleportTargets.clear(),this._teleportTargets=void 0))})}_processMutations(e){for(const t of e)this._setAttr(t.attributeName)}_resolveDef(){if(this._pendingResolve)return;for(let e=0;e<this.attributes.length;e++)this._setAttr(this.attributes[e].name);this._ob=new MutationObserver(this._processMutations.bind(this)),this._ob.observe(this,{attributes:!0});const e=(e,t=!1)=>{this._resolved=!0,this._pendingResolve=void 0;const{props:n,styles:s}=e;let r;if(n&&!p(n))for(const e in n){const t=n[e];(t===Number||t&&t.type===Number)&&(e in this._props&&(this._props[e]=M(this._props[e])),(r||(r=Object.create(null)))[O(e)]=!0)}this._numberProps=r,this._resolveProps(e),this.shadowRoot&&this._applyStyles(s),this._mount(e)},t=this._def.__asyncLoader;t?this._pendingResolve=t().then(t=>{t.configureApp=this._def.configureApp,e(this._def=t,!0)}):e(this._def)}_mount(e){this._app=this._createApp(e),this._inheritParentContext(),e.configureApp&&e.configureApp(this._app),this._app._ceVNode=this._createVNode(),this._app.mount(this._root);const t=this._instance&&this._instance.exposed;if(t)for(const e in t)d(this,e)||Object.defineProperty(this,e,{get:()=>St(t[e])})}_resolveProps(e){const{props:t}=e,n=p(t)?t:Object.keys(t||{});for(const e of Object.keys(this))"_"!==e[0]&&n.includes(e)&&this._setProp(e,this[e]);for(const e of n.map(O))Object.defineProperty(this,e,{get(){return this._getProp(e)},set(t){this._setProp(e,t,!0,!this._patching)}})}_setAttr(e){if(e.startsWith("data-v-"))return;const t=this.hasAttribute(e);let n=t?this.getAttribute(e):eo;const s=O(e);t&&this._numberProps&&this._numberProps[s]&&(n=M(n)),this._setProp(s,n,!1,!0)}_getProp(e){return this._props[e]}_setProp(e,t,n=!0,s=!1){if(t!==this._props[e]&&(this._dirty=!0,t===eo?delete this._props[e]:(this._props[e]=t,"key"===e&&this._app&&(this._app._ceVNode.key=t)),s&&this._instance&&this._update(),n)){const n=this._ob;n&&(this._processMutations(n.takeRecords()),n.disconnect()),!0===t?this.setAttribute(j(e),""):"string"==typeof t||"number"==typeof t?this.setAttribute(j(e),t+""):t||this.removeAttribute(j(e)),n&&n.observe(this,{attributes:!0})}}_update(){const e=this._createVNode();this._app&&(e.appContext=this._app._context),go(e,this._root)}_createVNode(){const e={};this.shadowRoot||(e.onVnodeMounted=e.onVnodeUpdated=this._renderSlots.bind(this));const t=er(this._def,c(e,this._props));return this._instance||(t.ce=e=>{this._instance=e,e.ce=this,e.isCE=!0;const t=(e,t)=>{this.dispatchEvent(new CustomEvent(e,C(t[0])?c({detail:t},t[0]):{detail:t}))};e.emit=(e,...n)=>{t(e,n),j(e)!==e&&t(j(e),n)},this._setParent()}),t}_applyStyles(e,t,n){if(!e)return;if(t){if(t===this._def||this._styleChildren.has(t))return;this._styleChildren.add(t)}const s=this._nonce,r=this.shadowRoot,o=n?this._getStyleAnchor(n)||this._getStyleAnchor(this._def):this._getRootStyleInsertionAnchor(r);let i=null;for(let l=e.length-1;l>=0;l--){const a=document.createElement("style");s&&a.setAttribute("nonce",s),a.textContent=e[l],r.insertBefore(a,i||o),i=a,0===l&&(n||this._styleAnchors.set(this._def,a),t&&this._styleAnchors.set(t,a))}}_getStyleAnchor(e){if(!e)return null;const t=this._styleAnchors.get(e);return t&&t.parentNode===this.shadowRoot?t:(t&&this._styleAnchors.delete(e),null)}_getRootStyleInsertionAnchor(e){for(let t=0;t<e.childNodes.length;t++){const n=e.childNodes[t];if(!(n instanceof HTMLStyleElement))return n}return null}_parseSlots(){const e=this._slots={};let t;for(;t=this.firstChild;){const n=1===t.nodeType&&t.getAttribute("slot")||"default";(e[n]||(e[n]=[])).push(t),this.removeChild(t)}}_renderSlots(){const e=this._getSlots(),t=this._instance.type.__scopeId;for(let n=0;n<e.length;n++){const s=e[n],r=s.getAttribute("name")||"default",o=this._slots[r],i=s.parentNode;if(o)for(const e of o){if(t&&1===e.nodeType){const n=t+"-s",s=document.createTreeWalker(e,1);let r;for(e.setAttribute(n,"");r=s.nextNode();)r.setAttribute(n,"")}i.insertBefore(e,s)}else for(;s.firstChild;)i.insertBefore(s.firstChild,s);i.removeChild(s)}}_getSlots(){const e=[this];this._teleportTargets&&e.push(...this._teleportTargets);const t=new Set;for(const n of e){const e=n.querySelectorAll("slot");for(let n=0;n<e.length;n++)t.add(e[n])}return Array.from(t)}_injectChildStyle(e,t){this._applyStyles(e.styles,e,t)}_beginPatch(){this._patching=!0,this._dirty=!1}_endPatch(){this._patching=!1,this._dirty&&this._instance&&this._update()}_hasShadowRoot(){return!1!==this._def.shadowRoot}_removeChildStyle(e){}}const so=e=>{const t=e.props["onUpdate:modelValue"]||!1;return p(t)?e=>R(t,e):t};function ro(e){e.target.composing=!0}function oo(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const io=Symbol("_assign");function lo(e,t,n){return t&&(e=e.trim()),n&&(e=F(e)),e}const ao={created(e,{modifiers:{lazy:t,trim:n,number:s}},r){e[io]=so(r);const o=s||r.props&&"number"===r.props.type;Hr(e,t?"change":"input",t=>{t.target.composing||e[io](lo(e.value,n,o))}),(n||o)&&Hr(e,"change",()=>{e.value=lo(e.value,n,o)}),t||(Hr(e,"compositionstart",ro),Hr(e,"compositionend",oo),Hr(e,"change",oo))},mounted(e,{value:t}){e.value=null==t?"":t},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:s,trim:r,number:o}},i){if(e[io]=so(i),e.composing)return;const l=null==t?"":t;if((!o&&"number"!==e.type||/^0\d/.test(e.value)?e.value:F(e.value))!==l){if(document.activeElement===e&&"range"!==e.type){if(s&&t===n)return;if(r&&e.value.trim()===l)return}e.value=l}}},co=["ctrl","shift","alt","meta"],uo={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&0!==e.button,middle:e=>"button"in e&&1!==e.button,right:e=>"button"in e&&2!==e.button,exact:(e,t)=>co.some(n=>e[`${n}Key`]&&!t.includes(n))},ho=(e,t)=>{if(!e)return e;const n=e._withMods||(e._withMods={}),s=t.join(".");return n[s]||(n[s]=(n,...s)=>{for(let e=0;e<t.length;e++){const s=uo[t[e]];if(s&&s(n,t))return}return e(n,...s)})},po=c({patchProp:(e,t,n,s,r,o)=>{const i="svg"===r;"class"===t?function(e,t,n){const s=e[Ir];s&&(t=(t?[t,...s]:[...s]).join(" ")),null==t?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}(e,s,i):"style"===t?function(e,t,n){const s=e.style,r=y(n);let o=!1;if(n&&!r){if(t)if(y(t))for(const e of t.split(";")){const t=e.slice(0,e.indexOf(":")).trim();null==n[t]&&Ur(s,t,"")}else for(const e in t)null==n[e]&&Ur(s,e,"");for(const e in n)"display"===e&&(o=!0),Ur(s,e,n[e])}else if(r){if(t!==n){const e=s[Fr];e&&(n+=";"+e),s.cssText=n,o=Mr.test(n)}}else t&&e.removeAttribute("style");$r in e&&(e[$r]=o?s.display:"",e[Dr]&&(s.display="none"))}(e,n,s):l(t)?a(t)||Zr(e,t,0,s,o):("."===t[0]?(t=t.slice(1),1):"^"===t[0]?(t=t.slice(1),0):function(e,t,n,s){if(s)return"innerHTML"===t||"textContent"===t||!!(t in e&&Yr(t)&&v(n));if("spellcheck"===t||"draggable"===t||"translate"===t||"autocorrect"===t)return!1;if("sandbox"===t&&"IFRAME"===e.tagName)return!1;if("form"===t)return!1;if("list"===t&&"INPUT"===e.tagName)return!1;if("type"===t&&"TEXTAREA"===e.tagName)return!1;if("width"===t||"height"===t){const t=e.tagName;if("IMG"===t||"VIDEO"===t||"CANVAS"===t||"SOURCE"===t)return!1}if(Yr(t)&&y(n))return!1;return t in e}(e,t,s,i))?(Br(e,t,s),e.tagName.includes("-")||"value"!==t&&"checked"!==t&&"selected"!==t||Wr(e,t,s,i,0,"value"!==t)):e._isVueCE&&(function(e,t){const n=e._def.props;if(!n)return!1;const s=O(t);return Array.isArray(n)?n.some(e=>O(e)===s):Object.keys(n).some(e=>O(e)===s)}(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!y(s)))?Br(e,O(t),s,0,t):("true-value"===t?e._trueValue=s:"false-value"===t&&(e._falseValue=s),Wr(e,t,s,i))}},jr);let fo;function mo(){return fo||(fo=Os(po))}const go=(...e)=>{mo().render(...e)},vo=(...e)=>{const t=mo().createApp(...e),{mount:n}=t;return t.mount=e=>{const s=function(e){if(y(e)){return document.querySelector(e)}return e}(e);if(!s)return;const r=t._component;v(r)||r.render||r.template||(r.template=s.innerHTML),1===s.nodeType&&(s.textContent="");const o=n(s,!1,function(e){if(e instanceof SVGElement)return"svg";if("function"==typeof MathMLElement&&e instanceof MathMLElement)return"mathml"}(s));return s instanceof Element&&(s.removeAttribute("v-cloak"),s.setAttribute("data-v-app","")),o},t};const yo=["value","placeholder"],_o=["value","placeholder"],bo={key:2,class:"errorlist"};t.render=function(e,t,n,s,r,o){return zs(),Ks("div",{class:H(["sf-field",{errors:o.fieldErrors.length}])},[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),o.isLong?(zs(),Ks("textarea",{key:0,class:"sf-input sf-textarea",rows:"3",value:n.modelValue,placeholder:n.schema.placeholder||"",onInput:t[0]||(t[0]=t=>e.$emit("update:modelValue",t.target.value))},null,40,yo)):(zs(),Ks("input",{key:1,type:"text",class:"sf-input",value:null!=n.modelValue?String(n.modelValue):"",placeholder:n.schema.placeholder||"",onInput:t[1]||(t[1]=t=>e.$emit("update:modelValue",t.target.value))},null,40,_o)),o.fieldErrors.length?(zs(),Ks("ul",bo,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},t.__file="src/editors/StringEditor.vue";var So={name:"NumberEditor",props:{schema:{type:Object,required:!0},modelValue:{default:0},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},isRequired(){if(this.path.length<2||!this.form)return!1;const e=this.path.slice(0,-1),t=this.path[this.path.length-1],n=this.form.getSchemaAtPath(e);return n&&Array.isArray(n.required)&&n.required.includes(t)},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",onInput(e){const t=e.target.value;""===t?this.$emit("update:modelValue",0):this.$emit("update:modelValue","integer"===this.schema.type?parseInt(t,10):parseFloat(t))}}};const xo=["step","min","max","value"],ko={key:0,class:"errorlist"};So.render=function(e,t,n,s,r,o){return zs(),Ks("div",{class:H(["sf-field",{errors:o.fieldErrors.length}])},[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),Ys("input",{type:"number",class:"sf-input",step:"integer"===n.schema.type?"1":"any",min:null!=n.schema.minimum?String(n.schema.minimum):void 0,max:null!=n.schema.maximum?String(n.schema.maximum):void 0,value:null!=n.modelValue?n.modelValue:"",onInput:t[0]||(t[0]=(...e)=>o.onInput&&o.onInput(...e))},null,40,xo),o.fieldErrors.length?(zs(),Ks("ul",ko,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},So.__file="src/editors/NumberEditor.vue";var Co={name:"BooleanEditor",props:{schema:{type:Object,required:!0},modelValue:{default:!1},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):""}};const Eo={class:"sf-checkbox-label"},wo=["checked"],Ao={key:0,class:"errorlist"};Co.render=function(e,t,n,s,r,o){return zs(),Ks("div",{class:H(["sf-field sf-field-boolean",{errors:o.fieldErrors.length}])},[Ys("label",Eo,[Ys("input",{type:"checkbox",class:"sf-checkbox",checked:!!n.modelValue,onChange:t[0]||(t[0]=t=>e.$emit("update:modelValue",t.target.checked))},null,40,wo),nr(" "+G(o.title),1)]),o.fieldErrors.length?(zs(),Ks("ul",Ao,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},Co.__file="src/editors/BooleanEditor.vue";var Vo={name:"SelectEditor",props:{schema:{type:Object,required:!0},modelValue:{default:""},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},isRequired(){if(this.path.length<2||!this.form)return!1;const e=this.path.slice(0,-1),t=this.path[this.path.length-1],n=this.form.getSchemaAtPath(e);return n&&Array.isArray(n.required)&&n.required.includes(t)},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):""}};const Oo=["value"],Po=["value"],jo={key:0,class:"errorlist"};Vo.render=function(e,t,n,s,r,o){return zs(),Ks("div",{class:H(["sf-field",{errors:o.fieldErrors.length}])},[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),Ys("select",{class:"sf-input sf-select",value:null!=n.modelValue?String(n.modelValue):"",onChange:t[0]||(t[0]=t=>e.$emit("update:modelValue",t.target.value))},[(zs(!0),Ks(Fs,null,Tn(n.schema.enum||[],e=>(zs(),Ks("option",{key:e,value:String(e)},G(e),9,Po))),128))],40,Oo),o.fieldErrors.length?(zs(),Ks("ul",jo,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},Vo.__file="src/editors/SelectEditor.vue";var Io={name:"HiddenEditor",props:{schema:{type:Object,required:!0},modelValue:{default:null},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],computed:{resolvedValue(){return"const"in this.schema?this.schema.const:this.schema.enum&&1===this.schema.enum.length?this.schema.enum[0]:this.modelValue}},mounted(){this.resolvedValue!==this.modelValue&&this.$emit("update:modelValue",this.resolvedValue)},methods:{getValue(){return this.resolvedValue}}};const $o={style:{display:"none"}};Io.render=function(e,t,n,s,r,o){return zs(),Ks("div",$o)},Io.__file="src/editors/HiddenEditor.vue";var Do={name:"SfIcon",props:{name:{type:String,required:!0},size:{type:[Number,String],default:14}}};const Ro=["width","height"],To={key:4,points:"6 9 12 15 18 9"},Fo={key:5,points:"18 15 12 9 6 15"};Do.render=function(e,t,n,s,r,o){return zs(),Ks("svg",{class:"sf-icon",width:n.size,height:n.size,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"},["plus"===n.name?(zs(),Ks(Fs,{key:0},[t[0]||(t[0]=Ys("line",{x1:"12",y1:"5",x2:"12",y2:"19"},null,-1)),t[1]||(t[1]=Ys("line",{x1:"5",y1:"12",x2:"19",y2:"12"},null,-1))],64)):"times"===n.name?(zs(),Ks(Fs,{key:1},[t[2]||(t[2]=Ys("line",{x1:"6",y1:"6",x2:"18",y2:"18"},null,-1)),t[3]||(t[3]=Ys("line",{x1:"6",y1:"18",x2:"18",y2:"6"},null,-1))],64)):"arrow-up"===n.name?(zs(),Ks(Fs,{key:2},[t[4]||(t[4]=Ys("line",{x1:"12",y1:"19",x2:"12",y2:"5"},null,-1)),t[5]||(t[5]=Ys("polyline",{points:"5 12 12 5 19 12"},null,-1))],64)):"arrow-down"===n.name?(zs(),Ks(Fs,{key:3},[t[6]||(t[6]=Ys("line",{x1:"12",y1:"5",x2:"12",y2:"19"},null,-1)),t[7]||(t[7]=Ys("polyline",{points:"19 12 12 19 5 12"},null,-1))],64)):"chevron-down"===n.name?(zs(),Ks("polyline",To)):"chevron-up"===n.name?(zs(),Ks("polyline",Fo)):"grip"===n.name?(zs(),Ks(Fs,{key:6},[t[8]||(t[8]=sr('<circle cx="9" cy="7" r="1" fill="currentColor" stroke="none"></circle><circle cx="15" cy="7" r="1" fill="currentColor" stroke="none"></circle><circle cx="9" cy="12" r="1" fill="currentColor" stroke="none"></circle><circle cx="15" cy="12" r="1" fill="currentColor" stroke="none"></circle><circle cx="9" cy="17" r="1" fill="currentColor" stroke="none"></circle><circle cx="15" cy="17" r="1" fill="currentColor" stroke="none"></circle>',6))],64)):rr("v-if",!0)],8,Ro)},Do.__file="src/editors/SfIcon.vue";var Mo={name:"ObjectEditor",beforeCreate(){this.$options.components||(this.$options.components={}),this.$options.components.SchemaEditor=Di,this.$options.components.SfIcon=Do},props:{schema:{type:Object,required:!0},modelValue:{default:()=>({})},path:{type:Array,default:()=>[]},form:{type:Object,required:!0}},emits:["update:modelValue"],data:()=>({collapsed:!1}),computed:{isRoot(){return 0===this.path.length},title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},summary(){const e=this.modelValue||{},t=[];for(const n of Object.keys(this.schema.properties||{})){if(t.length>=3)break;const s=e[n];null!=s&&""!==s&&"object"!=typeof s&&t.push(String(s))}return t.join(" · ")}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",collapse(){this.collapsed=!0},expand(){this.collapsed=!1},onChildChange(e,t){const n={...this.modelValue||{},[e]:t};this.$emit("update:modelValue",n)}}};const No={key:0,class:"sf-object sf-object-root"},Uo={class:"sf-object-fields"},Lo={class:"sf-object-title"},qo=["aria-label"],zo={class:"sf-object-title-text"},Wo={key:0,class:"sf-object-summary"},Bo={class:"sf-object-fields"};function Ho(e){if(null===e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(Ho);const t={};for(const n of Object.keys(e))t[n]=Ho(e[n]);return t}function Ko(e){if("default"in e)return Ho(e.default);if("object"===e.type){const t={};for(const[n,s]of Object.entries(e.properties||{}))"default"in s?t[n]=Ho(s.default):"string"===s.type?t[n]="":"integer"===s.type||"number"===s.type?t[n]=0:"boolean"===s.type?t[n]=!1:"array"===s.type&&(t[n]=[]);return t}return"array"===e.type?[]:"string"===e.type?"":"integer"===e.type||"number"===e.type?0:"boolean"!==e.type&&("relation"===e.type&&e.multiple?[]:null)}Mo.render=function(e,t,n,s,r,o){const i=In("SchemaEditor"),l=In("SfIcon");return o.isRoot?(zs(),Ks("div",No,[Ys("div",Uo,[(zs(!0),Ks(Fs,null,Tn(n.schema.properties||{},(e,t)=>(zs(),Zs(i,{key:t,schema:n.form.resolveSchema(e),"model-value":(n.modelValue||{})[t],path:[...n.path,t],form:n.form,"onUpdate:modelValue":e=>o.onChildChange(t,e)},null,8,["schema","model-value","path","form","onUpdate:modelValue"]))),128))])])):(zs(),Ks("fieldset",{key:1,class:H(["sf-object",{"sf-object-collapsed":r.collapsed}])},[Ys("legend",Lo,[Ys("button",{type:"button",class:"sf-collapse-btn","aria-label":r.collapsed?"Expand":"Collapse",onClick:t[0]||(t[0]=e=>r.collapsed=!r.collapsed)},[er(l,{name:r.collapsed?"chevron-down":"chevron-up",size:12},null,8,["name"])],8,qo),Ys("span",zo,G(o.title),1),r.collapsed&&o.summary?(zs(),Ks("span",Wo,G(o.summary),1)):rr("v-if",!0)]),Jt(Ys("div",Bo,[(zs(!0),Ks(Fs,null,Tn(n.schema.properties||{},(e,t)=>(zs(),Zs(i,{key:t,schema:n.form.resolveSchema(e),"model-value":(n.modelValue||{})[t],path:[...n.path,t],form:n.form,"onUpdate:modelValue":e=>o.onChildChange(t,e)},null,8,["schema","model-value","path","form","onUpdate:modelValue"]))),128))],512),[[Rr,!r.collapsed]])],2))},Mo.__file="src/editors/ObjectEditor.vue";let Zo=0;var Qo={name:"ArrayEditor",beforeCreate(){this.$options.components||(this.$options.components={}),this.$options.components.SchemaEditor=Di,this.$options.components.SfIcon=Do},props:{schema:{type:Object,required:!0},modelValue:{default:()=>[]},path:{type:Array,default:()=>[]},form:{type:Object,required:!0}},emits:["update:modelValue"],data(){return{items:(Array.isArray(this.modelValue)?this.modelValue:[]).map(e=>({_key:Zo++,value:e})),dragSourceIndex:null,dragOverIndex:null,allCollapsed:!1}},computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},itemSchema(){return this.form.resolveSchema(this.schema.items||{})},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",addItem(){const e=Ko(this.itemSchema);this.items.push({_key:Zo++,value:e}),this.emitValue()},removeItem(e){this.items.splice(e,1),this.emitValue()},moveItem(e,t){const n=e+t;if(n<0||n>=this.items.length)return;const s=this.items[e];this.items.splice(e,1,this.items[n]),this.items.splice(n,1,s),this.emitValue()},onItemChange(e,t){this.items[e].value=t,this.emitValue()},onDragStart(e,t){this.dragSourceIndex=e,t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",String(e))},onDragOver(e){null!==this.dragSourceIndex&&e!==this.dragSourceIndex&&(this.dragOverIndex=e)},onDragLeave(e){this.dragOverIndex===e&&(this.dragOverIndex=null)},onDrop(e){if(null===this.dragSourceIndex||this.dragSourceIndex===e)return;const t=this.items.splice(this.dragSourceIndex,1)[0];this.items.splice(e,0,t),this.dragSourceIndex=null,this.dragOverIndex=null,this.emitValue()},onDragEnd(){this.dragSourceIndex=null,this.dragOverIndex=null},toggleCollapseAll(){this.allCollapsed=!this.allCollapsed;const e=this.$refs.itemEditors;if(!e)return;const t=Array.isArray(e)?e:[e];this.allCollapsed?t.forEach(e=>e?.collapseAll?.()):t.forEach(e=>e?.expandAll?.())},emitValue(){this.$emit("update:modelValue",this.items.map(e=>e.value))}}};const Jo={class:"sf-array-header"},Go={class:"sf-label"},Xo={class:"sf-array-count"},Yo=["title"],ei={class:"sf-array-items"},ti=["onDragstart","onDragover","onDragleave","onDrop"],ni={class:"sf-array-item-header"},si={class:"sf-array-item-left"},ri={class:"sf-drag-handle",title:"Drag to reorder"},oi={class:"sf-array-item-index"},ii={class:"sf-array-item-actions"},li=["onClick"],ai=["onClick"],ci=["onClick"],ui=["onDrop"],hi={key:0,class:"errorlist"};Qo.render=function(e,t,n,s,r,o){const i=In("SfIcon"),l=In("SchemaEditor");return zs(),Ks("div",{class:H(["sf-array",{errors:o.fieldErrors.length}])},[Ys("div",Jo,[Ys("span",Go,G(o.title),1),Ys("span",Xo,G(r.items.length),1),Ys("button",{type:"button",class:"sf-btn sf-btn-add",onClick:t[0]||(t[0]=e=>o.addItem())},[er(i,{name:"plus"}),t[4]||(t[4]=nr(" Add ",-1))]),r.items.length?(zs(),Ks("span",{key:0,class:"sf-array-collapse-toggle",title:r.allCollapsed?"Expand all":"Collapse all",onClick:t[1]||(t[1]=(...e)=>o.toggleCollapseAll&&o.toggleCollapseAll(...e))},[er(i,{name:r.allCollapsed?"chevron-down":"chevron-up"},null,8,["name"])],8,Yo)):rr("v-if",!0)]),Ys("div",ei,[(zs(!0),Ks(Fs,null,Tn(r.items,(e,s)=>(zs(),Ks("div",{key:e._key,class:H(["sf-array-item",{"sf-drag-over":r.dragOverIndex===s,"sf-dragging":r.dragSourceIndex===s}]),draggable:"true",onDragstart:e=>o.onDragStart(s,e),onDragover:ho(e=>o.onDragOver(s),["prevent"]),onDragleave:e=>o.onDragLeave(s),onDrop:ho(e=>o.onDrop(s),["prevent"]),onDragend:t[3]||(t[3]=(...e)=>o.onDragEnd&&o.onDragEnd(...e))},[Ys("div",ni,[Ys("div",si,[Ys("span",ri,[er(i,{name:"grip"})]),Ys("span",oi,"#"+G(s+1),1)]),Ys("div",ii,[s>0?(zs(),Ks("button",{key:0,type:"button",class:"sf-btn sf-btn-sm",onClick:e=>o.moveItem(s,-1)},[er(i,{name:"arrow-up"})],8,li)):rr("v-if",!0),s<r.items.length-1?(zs(),Ks("button",{key:1,type:"button",class:"sf-btn sf-btn-sm",onClick:e=>o.moveItem(s,1)},[er(i,{name:"arrow-down"})],8,ai)):rr("v-if",!0),Ys("button",{type:"button",class:"sf-btn sf-btn-sm sf-btn-danger",onClick:e=>o.removeItem(s)},[er(i,{name:"times"})],8,ci)])]),Ys("div",{class:"sf-array-item-body",onDragover:t[2]||(t[2]=ho(()=>{},["prevent"])),onDrop:ho(e=>o.onDrop(s),["prevent"])},[er(l,{ref_for:!0,ref:"itemEditors",schema:o.itemSchema,"model-value":e.value,path:[...n.path,String(s)],form:n.form,"onUpdate:modelValue":e=>o.onItemChange(s,e)},null,8,["schema","model-value","path","form","onUpdate:modelValue"])],40,ui)],42,ti))),128))]),o.fieldErrors.length?(zs(),Ks("ul",hi,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},Qo.__file="src/editors/ArrayEditor.vue";var di={name:"NullableEditor",beforeCreate(){this.$options.components||(this.$options.components={}),this.$options.components.SchemaEditor=Di,this.$options.components.SfIcon=Do},props:{schema:{type:Object,required:!0},modelValue:{default:null},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],data(){return{isNull:null===this.modelValue||void 0===this.modelValue}},computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},isRequired(){if(this.path.length<2||!this.form)return!1;const e=this.path.slice(0,-1),t=this.path[this.path.length-1],n=this.form.getSchemaAtPath(e);return n&&Array.isArray(n.required)&&n.required.includes(t)},innerSchema(){const e={...this.schema};return delete e._nullable,e},toggleClass(){return this.isNull?"sf-btn sf-btn-sm sf-btn-add":"sf-btn sf-btn-sm sf-btn-danger"},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},watch:{modelValue(e){this.isNull=null==e}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",toggle(){this.isNull?(this.isNull=!1,this.$emit("update:modelValue",Ko(this.innerSchema))):(this.isNull=!0,this.$emit("update:modelValue",null))}}};const pi={class:"sf-nullable-header"},fi={class:"sf-nullable-body"},mi={key:0,class:"errorlist"};di.render=function(e,t,n,s,r,o){const i=In("SfIcon"),l=In("SchemaEditor");return zs(),Ks("div",{class:H(["sf-nullable",{errors:o.fieldErrors.length}])},[Ys("div",pi,[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),Ys("button",{type:"button",class:H(o.toggleClass),onClick:t[0]||(t[0]=(...e)=>o.toggle&&o.toggle(...e))},[r.isNull?(zs(),Ks(Fs,{key:0},[er(i,{name:"plus"}),t[2]||(t[2]=nr(" Add ",-1))],64)):(zs(),Ks(Fs,{key:1},[er(i,{name:"times"}),t[3]||(t[3]=nr(" Remove ",-1))],64))],2)]),Ys("div",fi,[r.isNull?rr("v-if",!0):(zs(),Zs(l,{key:0,schema:o.innerSchema,"model-value":n.modelValue,path:n.path,form:n.form,"onUpdate:modelValue":t[1]||(t[1]=t=>e.$emit("update:modelValue",t))},null,8,["schema","model-value","path","form"]))]),o.fieldErrors.length?(zs(),Ks("ul",mi,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},di.__file="src/editors/NullableEditor.vue";var gi={name:"UnionEditor",beforeCreate(){this.$options.components||(this.$options.components={}),this.$options.components.SchemaEditor=Di},props:{schema:{type:Object,required:!0},modelValue:{default:null},path:{type:Array,default:()=>[]},form:{type:Object,required:!0}},emits:["update:modelValue"],data(){const e=this.schema.discriminator.propertyName,t=this.schema.discriminator.mapping;return{discriminatorProp:e,mapping:t,currentType:this.modelValue?this.modelValue[e]:Object.keys(t)[0]}},computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},typeKeys(){return Object.keys(this.mapping)},currentSchema(){const e=this.mapping[this.currentType];return this.form.resolveSchema({$ref:e})},innerValue(){if(this.modelValue&&this.modelValue[this.discriminatorProp]===this.currentType)return this.modelValue;const e=Ko(this.currentSchema);return e[this.discriminatorProp]=this.currentType,e}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",onTypeChange(e){this.currentType=e.target.value;const t=Ko(this.currentSchema);t[this.discriminatorProp]=this.currentType,this.$emit("update:modelValue",t)},onInnerChange(e){e&&(e[this.discriminatorProp]=this.currentType),this.$emit("update:modelValue",e)}}};const vi={class:"sf-union"},yi={class:"sf-field"},_i={class:"sf-label"},bi=["value"],Si=["value"],xi={class:"sf-union-body"};gi.render=function(e,t,n,s,r,o){const i=In("SchemaEditor");return zs(),Ks("div",vi,[Ys("div",yi,[Ys("label",_i,G(o.title),1),Ys("select",{class:"sf-input sf-select",value:r.currentType,onChange:t[0]||(t[0]=(...e)=>o.onTypeChange&&o.onTypeChange(...e))},[(zs(!0),Ks(Fs,null,Tn(o.typeKeys,e=>(zs(),Ks("option",{key:e,value:e},G(o.humanize(e)),9,Si))),128))],40,bi)]),Ys("div",xi,[(zs(),Zs(i,{key:r.currentType,schema:o.currentSchema,"model-value":o.innerValue,path:n.path,form:n.form,"onUpdate:modelValue":o.onInnerChange},null,8,["schema","model-value","path","form","onUpdate:modelValue"]))])])},gi.__file="src/editors/UnionEditor.vue";var ki={name:"RelationEditor",components:{SfIcon:Do},props:{schema:{type:Object,required:!0},modelValue:{default:null},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],data(){const e=!!this.schema.multiple,t=this.modelValue;let n;return n=e?Array.isArray(t)?[...t]:[]:t?[t]:[],{isMultiple:e,allowClear:this.schema.options?.select2?.allowClear??!0,placeholder:this.schema.options?.select2?.placeholder||"Search...",searchUrl:this.schema.options?.select2?.ajax?.url||"",selected:n,dropdownVisible:!1,searchResults:[],currentPage:1,hasMore:!1,loading:!1,highlightIndex:-1,searchQuery:""}},computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},isRequired(){if(this.path.length<2||!this.form)return!1;const e=this.path.slice(0,-1),t=this.path[this.path.length-1],n=this.form.getSchemaAtPath(e);return n&&Array.isArray(n.required)&&n.required.includes(t)},showSearch(){return!(!this.isMultiple&&this.selected.length>0)},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]},filteredResults(){const e=new Set(this.selected.map(e=>this.itemKey(e)));return this.searchResults.filter(t=>!e.has(this.itemKey(t)))}},created(){this._doSearch=function(e,t){let n;return function(...s){clearTimeout(n),n=setTimeout(()=>e.apply(this,s),t)}}(e=>this.fetchResults(e,1),300),this._onDocClick=e=>{this.$refs.root&&!this.$refs.root.contains(e.target)&&this.closeDropdown()}},mounted(){document.addEventListener("click",this._onDocClick)},beforeUnmount(){document.removeEventListener("click",this._onDocClick)},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",getDisplayName(e){if(!e)return"";for(const t of["__str__","name","title","label"])if(e[t])return String(e[t]);return`#${e.id||"?"}`},itemKey:e=>`${e.id}-${e.model||""}`,onSearchInput(){this._doSearch(this.searchQuery)},openDropdown(){this.dropdownVisible||(this.dropdownVisible=!0,this.fetchResults(this.searchQuery,1))},closeDropdown(){this.dropdownVisible=!1,this.highlightIndex=-1},async fetchResults(e,t){if(this.searchUrl){this.loading=!0,this.currentPage=t;try{const n=new URL(this.searchUrl,window.location.origin);n.searchParams.set("_q",e||""),n.searchParams.set("page",String(t));const s=await fetch(n,{credentials:"same-origin"});if(!s.ok)return;const r=await s.json();this.searchResults=1===t?r.items||[]:this.searchResults.concat(r.items||[]),this.hasMore=r.more}finally{this.loading=!1}}},handleKeyDown(e){this.filteredResults.length&&("ArrowDown"===e.key?(e.preventDefault(),this.highlightIndex=Math.min(this.highlightIndex+1,this.filteredResults.length-1)):"ArrowUp"===e.key?(e.preventDefault(),this.highlightIndex=Math.max(this.highlightIndex-1,0)):"Enter"===e.key?(e.preventDefault(),this.highlightIndex>=0&&this.highlightIndex<this.filteredResults.length&&this.selectItem(this.filteredResults[this.highlightIndex])):"Escape"===e.key&&this.closeDropdown())},selectItem(e){this.isMultiple?this.selected.push(e):this.selected=[e],this.searchQuery="",this.highlightIndex=-1,this.closeDropdown(),this.emitValue()},removeItem(e){this.selected=this.selected.filter(t=>!(t.id===e.id&&(t.model||"")===(e.model||""))),this.emitValue()},emitValue(){this.isMultiple?this.$emit("update:modelValue",[...this.selected]):this.$emit("update:modelValue",this.selected[0]||null)}}};const Ci={class:"sf-relation-wrapper"},Ei={key:0,class:"sf-relation-selected"},wi={class:"sf-relation-tag-text"},Ai=["onClick"],Vi={class:"sf-relation-search"},Oi=["placeholder"],Pi={class:"sf-relation-dropdown"},ji={key:0,class:"sf-relation-dropdown-empty"},Ii=["onClick"],$i={key:0,class:"errorlist"};ki.render=function(e,t,n,s,r,o){const i=In("SfIcon");return zs(),Ks("div",{class:H(["sf-field sf-relation",{errors:o.fieldErrors.length}]),ref:"root"},[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),Ys("div",Ci,[rr(" Selected items "),r.selected.length?(zs(),Ks("div",Ei,[(zs(!0),Ks(Fs,null,Tn(r.selected,e=>(zs(),Ks("div",{key:o.itemKey(e),class:"sf-relation-tag"},[Ys("span",wi,G(o.getDisplayName(e)),1),r.isMultiple||r.allowClear?(zs(),Ks("button",{key:0,type:"button",class:"sf-relation-tag-remove",onClick:ho(t=>o.removeItem(e),["stop"])},[er(i,{name:"times"})],8,Ai)):rr("v-if",!0)]))),128))])):rr("v-if",!0),rr(" Search box "),Jt(Ys("div",Vi,[Jt(Ys("input",{ref:"searchInput",type:"text",class:"sf-input sf-relation-input",placeholder:r.placeholder,autocomplete:"off","onUpdate:modelValue":t[0]||(t[0]=e=>r.searchQuery=e),onInput:t[1]||(t[1]=(...e)=>o.onSearchInput&&o.onSearchInput(...e)),onFocus:t[2]||(t[2]=(...e)=>o.openDropdown&&o.openDropdown(...e)),onKeydown:t[3]||(t[3]=(...e)=>o.handleKeyDown&&o.handleKeyDown(...e))},null,40,Oi),[[ao,r.searchQuery]]),rr(" Dropdown "),Jt(Ys("div",Pi,[0!==o.filteredResults.length||r.loading?rr("v-if",!0):(zs(),Ks("div",ji," No results found ")),(zs(!0),Ks(Fs,null,Tn(o.filteredResults,(e,t)=>(zs(),Ks("div",{key:o.itemKey(e),class:H(["sf-relation-dropdown-item",{highlighted:t===r.highlightIndex}]),onClick:t=>o.selectItem(e)},G(o.getDisplayName(e)),11,Ii))),128)),r.hasMore?(zs(),Ks("div",{key:1,class:"sf-relation-dropdown-more",onClick:t[4]||(t[4]=e=>o.fetchResults(r.searchQuery,r.currentPage+1))}," Load more... ")):rr("v-if",!0)],512),[[Rr,r.dropdownVisible]])],512),[[Rr,o.showSearch]])]),o.fieldErrors.length?(zs(),Ks("ul",$i,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},ki.__file="src/editors/RelationEditor.vue";var Di={name:"SchemaEditor",components:{StringEditor:t,NumberEditor:So,BooleanEditor:Co,SelectEditor:Vo,HiddenEditor:Io,ObjectEditor:Mo,ArrayEditor:Qo,NullableEditor:di,UnionEditor:gi,RelationEditor:ki},props:{schema:{type:Object,required:!0},modelValue:{default:void 0},path:{type:Array,default:()=>[]},form:{type:Object,required:!0}},emits:["update:modelValue"],methods:{collapseAll(){const e=this.$refs.editor;e?.collapse&&e.collapse(),e?.collapseAll&&e.collapseAll()},expandAll(){const e=this.$refs.editor;e?.expand&&e.expand(),e?.expandAll&&e.expandAll()}},computed:{editorComponent(){const e=this.schema;return this.path.length>12?"StringEditor":"relation"===e.type?"RelationEditor":e.oneOf&&e.discriminator?"UnionEditor":"const"in e||e.enum&&1===e.enum.length&&"string"===e.type?"HiddenEditor":e._nullable?"NullableEditor":"object"===e.type&&e.properties?"ObjectEditor":"array"===e.type?"ArrayEditor":e.enum?"SelectEditor":"boolean"===e.type?"BooleanEditor":"number"===e.type||"integer"===e.type?"NumberEditor":"StringEditor"}}};Di.render=function(e,t,n,s,r,o){return zs(),Zs((i=o.editorComponent,y(i)?Dn(jn,i,!1)||i:i||$n),{ref:"editor",schema:n.schema,"model-value":n.modelValue,path:n.path,form:n.form,"onUpdate:modelValue":t[0]||(t[0]=t=>e.$emit("update:modelValue",t))},null,8,["schema","model-value","path","form"]);var i},Di.__file="src/editors/SchemaEditor.vue";var Ri={name:"SchemaForm",components:{SchemaEditor:Di},props:{schema:{type:[Object,String],default:()=>({})},initialData:{default:void 0},errors:{type:Object,default:()=>({})}},emits:["change"],expose:["getValue"],data(){const e="string"==typeof this.schema?JSON.parse(this.schema):this.schema;return{rootSchema:e,defs:e.$defs||e.definitions||{},currentValue:null!=this.initialData?Ho(this.initialData):void 0}},computed:{resolvedSchema(){return this.resolveSchema(this.rootSchema)},formApi(){return{resolveSchema:e=>this.resolveSchema(e),getSchemaAtPath:e=>this.getSchemaAtPath(e),getErrorsForPath:e=>this.getErrorsForPath(e)}}},watch:{schema:{handler(e){const t="string"==typeof e?JSON.parse(e):e;this.rootSchema=t,this.defs=t.$defs||t.definitions||{}},deep:!0},initialData:{handler(e){this.currentValue=null!=e?Ho(e):void 0},deep:!0}},methods:{resolveSchema(e){if(!e)return{type:"string"};if(e.$ref){const t=e.$ref.replace(/^#\/\$defs\//,"").replace(/^#\/definitions\//,""),n=this.defs[t];if(!n)return{type:"string",title:t};const{$ref:s,...r}=e;return{...this.resolveSchema(n),...r}}if(e.anyOf){const t=e.anyOf.filter(e=>"null"!==e.type);if(e.anyOf.some(e=>"null"===e.type)&&1===t.length){const n=this.resolveSchema(t[0]);return{...n,_nullable:!0,title:e.title||n.title,default:"default"in e?e.default:null}}if(t.length>=1)return this.resolveSchema(t[0])}if(e.oneOf&&e.discriminator)return e;if(e.oneOf){const t=e.oneOf.filter(e=>"null"!==e.type);if(e.oneOf.some(e=>"null"===e.type)&&1===t.length){const n=this.resolveSchema(t[0]);return{...n,_nullable:!0,title:e.title||n.title,default:"default"in e?e.default:null}}if(t.length>=1)return this.resolveSchema(t[0])}return e},getSchemaAtPath(e){let t=this.resolveSchema(this.rootSchema);for(const n of e){if(!t)return null;if(t.properties&&t.properties[n])t=this.resolveSchema(t.properties[n]);else{if(!t.items)return null;t=this.resolveSchema(t.items)}}return t},onValueChange(e){this.currentValue=e,this.$emit("change",e)},getErrorsForPath(e){if(!this.errors||"object"!=typeof this.errors)return[];const t=e.join(".");return this.errors[t]||[]},getValue(){return this.currentValue}}};const Ti={class:"structured-field-editor"};Ri.render=function(e,t,n,s,r,o){const i=In("SchemaEditor");return zs(),Ks("div",Ti,[o.resolvedSchema?(zs(),Zs(i,{key:0,schema:o.resolvedSchema,"model-value":r.currentValue,path:[],form:o.formApi,"onUpdate:modelValue":o.onValueChange},null,8,["schema","model-value","form","onUpdate:modelValue"])):rr("v-if",!0)])},Ri.__file="src/SchemaForm.vue";const Fi=function(e,t,n){let s=function(e,t){return v(e)?(()=>c({name:e.name},t,{setup:e}))():e}(e,t);C(s)&&(s=c({},s,t));class r extends no{constructor(e){super(s,e,n)}}return r.def=s,r}({...Ri,shadowRoot:!1});return e.ArrayEditor=Qo,e.BooleanEditor=Co,e.HiddenEditor=Io,e.NullableEditor=di,e.NumberEditor=So,e.ObjectEditor=Mo,e.RelationEditor=ki,e.SchemaEditor=Di,e.SchemaForm=Ri,e.SchemaFormElement=Fi,e.SelectEditor=Vo,e.StringEditor=t,e.UnionEditor=gi,e.registerCustomElement=function(e="schema-form"){customElements.get(e)||customElements.define(e,Fi)},e}({});
|
|
26
26
|
//# sourceMappingURL=structured-widget-editor.js.map
|
|
@@ -20,5 +20,5 @@ let ee,te;class ne{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,
|
|
|
20
20
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
21
21
|
* @license MIT
|
|
22
22
|
**/
|
|
23
|
-
let wr;const Ar="undefined"!=typeof window&&window.trustedTypes;if(Ar)try{wr=Ar.createPolicy("vue",{createHTML:e=>e})}catch(e){}const Vr=wr?e=>wr.createHTML(e):e=>e,Or="undefined"!=typeof document?document:null,Pr=Or&&Or.createElement("template"),jr={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,s)=>{const r="svg"===t?Or.createElementNS("http://www.w3.org/2000/svg",e):"mathml"===t?Or.createElementNS("http://www.w3.org/1998/Math/MathML",e):n?Or.createElement(e,{is:n}):Or.createElement(e);return"select"===e&&s&&null!=s.multiple&&r.setAttribute("multiple",s.multiple),r},createText:e=>Or.createTextNode(e),createComment:e=>Or.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>Or.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,s,r,o){const i=n?n.previousSibling:t.lastChild;if(r&&(r===o||r.nextSibling))for(;t.insertBefore(r.cloneNode(!0),n),r!==o&&(r=r.nextSibling););else{Pr.innerHTML=Vr("svg"===s?`<svg>${e}</svg>`:"mathml"===s?`<math>${e}</math>`:e);const r=Pr.content;if("svg"===s||"mathml"===s){const e=r.firstChild;for(;e.firstChild;)r.appendChild(e.firstChild);r.removeChild(e)}t.insertBefore(r,n)}return[i?i.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},Ir=Symbol("_vtc");const $r=Symbol("_vod"),Dr=Symbol("_vsh"),Rr={name:"show",beforeMount(e,{value:t},{transition:n}){e[$r]="none"===e.style.display?"":e.style.display,n&&t?n.beforeEnter(e):Tr(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:s}){!t!=!n&&(s?t?(s.beforeEnter(e),Tr(e,!0),s.enter(e)):s.leave(e,()=>{Tr(e,!1)}):Tr(e,t))},beforeUnmount(e,{value:t}){Tr(e,t)}};function Tr(e,t){e.style.display=t?e[$r]:"none",e[Dr]=!t}const Fr=Symbol(""),Mr=/(?:^|;)\s*display\s*:/;const Nr=/\s*!important$/;function Ur(e,t,n){if(p(n))n.forEach(n=>Ur(e,t,n));else if(null==n&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const s=function(e,t){const n=qr[t];if(n)return n;let s=O(t);if("filter"!==s&&s in e)return qr[t]=s;s=I(s);for(let n=0;n<Lr.length;n++){const r=Lr[n]+s;if(r in e)return qr[t]=r}return t}(e,t);Nr.test(n)?e.setProperty(j(s),n.replace(Nr,""),"important"):e[s]=n}}const Lr=["Webkit","Moz","ms"],qr={};const zr="http://www.w3.org/1999/xlink";function Wr(e,t,n,s,r,o=K(t)){s&&t.startsWith("xlink:")?null==n?e.removeAttributeNS(zr,t.slice(6,t.length)):e.setAttributeNS(zr,t,n):null==n||o&&!Z(n)?e.removeAttribute(t):e.setAttribute(t,o?"":_(n)?String(n):n)}function Br(e,t,n,s,r){if("innerHTML"===t||"textContent"===t)return void(null!=n&&(e[t]="innerHTML"===t?Vr(n):n));const o=e.tagName;if("value"===t&&"PROGRESS"!==o&&!o.includes("-")){const s="OPTION"===o?e.getAttribute("value")||"":e.value,r=null==n?"checkbox"===e.type?"on":"":String(n);return s===r&&"_value"in e||(e.value=r),null==n&&e.removeAttribute(t),void(e._value=n)}let i=!1;if(""===n||null==n){const s=typeof e[t];"boolean"===s?n=Z(n):null==n&&"string"===s?(n="",i=!0):"number"===s&&(n=0,i=!0)}try{e[t]=n}catch(e){}i&&e.removeAttribute(r||t)}function Hr(e,t,n,s){e.addEventListener(t,n,s)}const Kr=Symbol("_vei");function Zr(e,t,n,s,r=null){const o=e[Kr]||(e[Kr]={}),i=o[t];if(s&&i)i.value=s;else{const[n,l]=function(e){let t;if(Qr.test(e)){let n;for(t={};n=e.match(Qr);)e=e.slice(0,e.length-n[0].length),t[n[0].toLowerCase()]=!0}const n=":"===e[2]?e.slice(3):j(e.slice(2));return[n,t]}(t);if(s){const i=o[t]=function(e,t){const n=e=>{if(e._vts){if(e._vts<=n.attached)return}else e._vts=Date.now();jt(function(e,t){if(p(t)){const n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(e=>t=>!t._stopped&&e&&e(t))}return t}(e,n.value),t,5,[e])};return n.value=e,n.attached=Xr(),n}(s,r);Hr(e,n,i,l)}else i&&(!function(e,t,n,s){e.removeEventListener(t,n,s)}(e,n,i,l),o[t]=void 0)}}const Qr=/(?:Once|Passive|Capture)$/;let Jr=0;const Gr=Promise.resolve(),Xr=()=>Jr||(Gr.then(()=>Jr=0),Jr=Date.now());const Yr=e=>111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123;const eo={};const to="undefined"!=typeof HTMLElement?HTMLElement:class{};class no extends to{constructor(e,t={},n=vo){super(),this._def=e,this._props=t,this._createApp=n,this._isVueCE=!0,this._instance=null,this._app=null,this._nonce=this._def.nonce,this._connected=!1,this._resolved=!1,this._patching=!1,this._dirty=!1,this._numberProps=null,this._styleChildren=new WeakSet,this._styleAnchors=new WeakMap,this._ob=null,this.shadowRoot&&n!==vo?this._root=this.shadowRoot:!1!==e.shadowRoot?(this.attachShadow(c({},e.shadowRootOptions,{mode:"open"})),this._root=this.shadowRoot):this._root=this}connectedCallback(){if(!this.isConnected)return;this.shadowRoot||this._resolved||this._parseSlots(),this._connected=!0;let e=this;for(;e=e&&(e.assignedSlot||e.parentNode||e.host);)if(e instanceof no){this._parent=e;break}this._instance||(this._resolved?this._mount(this._def):e&&e._pendingResolve?this._pendingResolve=e._pendingResolve.then(()=>{this._pendingResolve=void 0,this._resolveDef()}):this._resolveDef())}_setParent(e=this._parent){e&&(this._instance.parent=e._instance,this._inheritParentContext(e))}_inheritParentContext(e=this._parent){e&&this._app&&Object.setPrototypeOf(this._app._context.provides,e._instance.provides)}disconnectedCallback(){this._connected=!1,Ut(()=>{this._connected||(this._ob&&(this._ob.disconnect(),this._ob=null),this._app&&this._app.unmount(),this._instance&&(this._instance.ce=void 0),this._app=this._instance=null,this._teleportTargets&&(this._teleportTargets.clear(),this._teleportTargets=void 0))})}_processMutations(e){for(const t of e)this._setAttr(t.attributeName)}_resolveDef(){if(this._pendingResolve)return;for(let e=0;e<this.attributes.length;e++)this._setAttr(this.attributes[e].name);this._ob=new MutationObserver(this._processMutations.bind(this)),this._ob.observe(this,{attributes:!0});const e=(e,t=!1)=>{this._resolved=!0,this._pendingResolve=void 0;const{props:n,styles:s}=e;let r;if(n&&!p(n))for(const e in n){const t=n[e];(t===Number||t&&t.type===Number)&&(e in this._props&&(this._props[e]=M(this._props[e])),(r||(r=Object.create(null)))[O(e)]=!0)}this._numberProps=r,this._resolveProps(e),this.shadowRoot&&this._applyStyles(s),this._mount(e)},t=this._def.__asyncLoader;t?this._pendingResolve=t().then(t=>{t.configureApp=this._def.configureApp,e(this._def=t,!0)}):e(this._def)}_mount(e){this._app=this._createApp(e),this._inheritParentContext(),e.configureApp&&e.configureApp(this._app),this._app._ceVNode=this._createVNode(),this._app.mount(this._root);const t=this._instance&&this._instance.exposed;if(t)for(const e in t)d(this,e)||Object.defineProperty(this,e,{get:()=>St(t[e])})}_resolveProps(e){const{props:t}=e,n=p(t)?t:Object.keys(t||{});for(const e of Object.keys(this))"_"!==e[0]&&n.includes(e)&&this._setProp(e,this[e]);for(const e of n.map(O))Object.defineProperty(this,e,{get(){return this._getProp(e)},set(t){this._setProp(e,t,!0,!this._patching)}})}_setAttr(e){if(e.startsWith("data-v-"))return;const t=this.hasAttribute(e);let n=t?this.getAttribute(e):eo;const s=O(e);t&&this._numberProps&&this._numberProps[s]&&(n=M(n)),this._setProp(s,n,!1,!0)}_getProp(e){return this._props[e]}_setProp(e,t,n=!0,s=!1){if(t!==this._props[e]&&(this._dirty=!0,t===eo?delete this._props[e]:(this._props[e]=t,"key"===e&&this._app&&(this._app._ceVNode.key=t)),s&&this._instance&&this._update(),n)){const n=this._ob;n&&(this._processMutations(n.takeRecords()),n.disconnect()),!0===t?this.setAttribute(j(e),""):"string"==typeof t||"number"==typeof t?this.setAttribute(j(e),t+""):t||this.removeAttribute(j(e)),n&&n.observe(this,{attributes:!0})}}_update(){const e=this._createVNode();this._app&&(e.appContext=this._app._context),go(e,this._root)}_createVNode(){const e={};this.shadowRoot||(e.onVnodeMounted=e.onVnodeUpdated=this._renderSlots.bind(this));const t=er(this._def,c(e,this._props));return this._instance||(t.ce=e=>{this._instance=e,e.ce=this,e.isCE=!0;const t=(e,t)=>{this.dispatchEvent(new CustomEvent(e,C(t[0])?c({detail:t},t[0]):{detail:t}))};e.emit=(e,...n)=>{t(e,n),j(e)!==e&&t(j(e),n)},this._setParent()}),t}_applyStyles(e,t,n){if(!e)return;if(t){if(t===this._def||this._styleChildren.has(t))return;this._styleChildren.add(t)}const s=this._nonce,r=this.shadowRoot,o=n?this._getStyleAnchor(n)||this._getStyleAnchor(this._def):this._getRootStyleInsertionAnchor(r);let i=null;for(let l=e.length-1;l>=0;l--){const a=document.createElement("style");s&&a.setAttribute("nonce",s),a.textContent=e[l],r.insertBefore(a,i||o),i=a,0===l&&(n||this._styleAnchors.set(this._def,a),t&&this._styleAnchors.set(t,a))}}_getStyleAnchor(e){if(!e)return null;const t=this._styleAnchors.get(e);return t&&t.parentNode===this.shadowRoot?t:(t&&this._styleAnchors.delete(e),null)}_getRootStyleInsertionAnchor(e){for(let t=0;t<e.childNodes.length;t++){const n=e.childNodes[t];if(!(n instanceof HTMLStyleElement))return n}return null}_parseSlots(){const e=this._slots={};let t;for(;t=this.firstChild;){const n=1===t.nodeType&&t.getAttribute("slot")||"default";(e[n]||(e[n]=[])).push(t),this.removeChild(t)}}_renderSlots(){const e=this._getSlots(),t=this._instance.type.__scopeId;for(let n=0;n<e.length;n++){const s=e[n],r=s.getAttribute("name")||"default",o=this._slots[r],i=s.parentNode;if(o)for(const e of o){if(t&&1===e.nodeType){const n=t+"-s",s=document.createTreeWalker(e,1);let r;for(e.setAttribute(n,"");r=s.nextNode();)r.setAttribute(n,"")}i.insertBefore(e,s)}else for(;s.firstChild;)i.insertBefore(s.firstChild,s);i.removeChild(s)}}_getSlots(){const e=[this];this._teleportTargets&&e.push(...this._teleportTargets);const t=new Set;for(const n of e){const e=n.querySelectorAll("slot");for(let n=0;n<e.length;n++)t.add(e[n])}return Array.from(t)}_injectChildStyle(e,t){this._applyStyles(e.styles,e,t)}_beginPatch(){this._patching=!0,this._dirty=!1}_endPatch(){this._patching=!1,this._dirty&&this._instance&&this._update()}_hasShadowRoot(){return!1!==this._def.shadowRoot}_removeChildStyle(e){}}const so=e=>{const t=e.props["onUpdate:modelValue"]||!1;return p(t)?e=>R(t,e):t};function ro(e){e.target.composing=!0}function oo(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const io=Symbol("_assign");function lo(e,t,n){return t&&(e=e.trim()),n&&(e=F(e)),e}const ao={created(e,{modifiers:{lazy:t,trim:n,number:s}},r){e[io]=so(r);const o=s||r.props&&"number"===r.props.type;Hr(e,t?"change":"input",t=>{t.target.composing||e[io](lo(e.value,n,o))}),(n||o)&&Hr(e,"change",()=>{e.value=lo(e.value,n,o)}),t||(Hr(e,"compositionstart",ro),Hr(e,"compositionend",oo),Hr(e,"change",oo))},mounted(e,{value:t}){e.value=null==t?"":t},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:s,trim:r,number:o}},i){if(e[io]=so(i),e.composing)return;const l=null==t?"":t;if((!o&&"number"!==e.type||/^0\d/.test(e.value)?e.value:F(e.value))!==l){if(document.activeElement===e&&"range"!==e.type){if(s&&t===n)return;if(r&&e.value.trim()===l)return}e.value=l}}},co=["ctrl","shift","alt","meta"],uo={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&0!==e.button,middle:e=>"button"in e&&1!==e.button,right:e=>"button"in e&&2!==e.button,exact:(e,t)=>co.some(n=>e[`${n}Key`]&&!t.includes(n))},ho=(e,t)=>{if(!e)return e;const n=e._withMods||(e._withMods={}),s=t.join(".");return n[s]||(n[s]=(n,...s)=>{for(let e=0;e<t.length;e++){const s=uo[t[e]];if(s&&s(n,t))return}return e(n,...s)})},po=c({patchProp:(e,t,n,s,r,o)=>{const i="svg"===r;"class"===t?function(e,t,n){const s=e[Ir];s&&(t=(t?[t,...s]:[...s]).join(" ")),null==t?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}(e,s,i):"style"===t?function(e,t,n){const s=e.style,r=y(n);let o=!1;if(n&&!r){if(t)if(y(t))for(const e of t.split(";")){const t=e.slice(0,e.indexOf(":")).trim();null==n[t]&&Ur(s,t,"")}else for(const e in t)null==n[e]&&Ur(s,e,"");for(const e in n)"display"===e&&(o=!0),Ur(s,e,n[e])}else if(r){if(t!==n){const e=s[Fr];e&&(n+=";"+e),s.cssText=n,o=Mr.test(n)}}else t&&e.removeAttribute("style");$r in e&&(e[$r]=o?s.display:"",e[Dr]&&(s.display="none"))}(e,n,s):l(t)?a(t)||Zr(e,t,0,s,o):("."===t[0]?(t=t.slice(1),1):"^"===t[0]?(t=t.slice(1),0):function(e,t,n,s){if(s)return"innerHTML"===t||"textContent"===t||!!(t in e&&Yr(t)&&v(n));if("spellcheck"===t||"draggable"===t||"translate"===t||"autocorrect"===t)return!1;if("sandbox"===t&&"IFRAME"===e.tagName)return!1;if("form"===t)return!1;if("list"===t&&"INPUT"===e.tagName)return!1;if("type"===t&&"TEXTAREA"===e.tagName)return!1;if("width"===t||"height"===t){const t=e.tagName;if("IMG"===t||"VIDEO"===t||"CANVAS"===t||"SOURCE"===t)return!1}if(Yr(t)&&y(n))return!1;return t in e}(e,t,s,i))?(Br(e,t,s),e.tagName.includes("-")||"value"!==t&&"checked"!==t&&"selected"!==t||Wr(e,t,s,i,0,"value"!==t)):e._isVueCE&&(function(e,t){const n=e._def.props;if(!n)return!1;const s=O(t);return Array.isArray(n)?n.some(e=>O(e)===s):Object.keys(n).some(e=>O(e)===s)}(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!y(s)))?Br(e,O(t),s,0,t):("true-value"===t?e._trueValue=s:"false-value"===t&&(e._falseValue=s),Wr(e,t,s,i))}},jr);let fo;function mo(){return fo||(fo=Os(po))}const go=(...e)=>{mo().render(...e)},vo=(...e)=>{const t=mo().createApp(...e),{mount:n}=t;return t.mount=e=>{const s=function(e){if(y(e)){return document.querySelector(e)}return e}(e);if(!s)return;const r=t._component;v(r)||r.render||r.template||(r.template=s.innerHTML),1===s.nodeType&&(s.textContent="");const o=n(s,!1,function(e){if(e instanceof SVGElement)return"svg";if("function"==typeof MathMLElement&&e instanceof MathMLElement)return"mathml"}(s));return s instanceof Element&&(s.removeAttribute("v-cloak"),s.setAttribute("data-v-app","")),o},t};const yo=["value","placeholder"],_o=["value","placeholder"],bo={key:2,class:"errorlist"};t.render=function(e,t,n,s,r,o){return zs(),Ks("div",{class:H(["sf-field",{errors:o.fieldErrors.length}])},[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),o.isLong?(zs(),Ks("textarea",{key:0,class:"sf-input sf-textarea",rows:"3",value:n.modelValue,placeholder:n.schema.placeholder||"",onInput:t[0]||(t[0]=t=>e.$emit("update:modelValue",t.target.value))},null,40,yo)):(zs(),Ks("input",{key:1,type:"text",class:"sf-input",value:null!=n.modelValue?String(n.modelValue):"",placeholder:n.schema.placeholder||"",onInput:t[1]||(t[1]=t=>e.$emit("update:modelValue",t.target.value))},null,40,_o)),o.fieldErrors.length?(zs(),Ks("ul",bo,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},t.__file="src/editors/StringEditor.vue";var So={name:"NumberEditor",props:{schema:{type:Object,required:!0},modelValue:{default:0},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},isRequired(){if(this.path.length<2||!this.form)return!1;const e=this.path.slice(0,-1),t=this.path[this.path.length-1],n=this.form.getSchemaAtPath(e);return n&&Array.isArray(n.required)&&n.required.includes(t)},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",onInput(e){const t=e.target.value;""===t?this.$emit("update:modelValue",0):this.$emit("update:modelValue","integer"===this.schema.type?parseInt(t,10):parseFloat(t))}}};const xo=["step","min","max","value"],ko={key:0,class:"errorlist"};So.render=function(e,t,n,s,r,o){return zs(),Ks("div",{class:H(["sf-field",{errors:o.fieldErrors.length}])},[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),Ys("input",{type:"number",class:"sf-input",step:"integer"===n.schema.type?"1":"any",min:null!=n.schema.minimum?String(n.schema.minimum):void 0,max:null!=n.schema.maximum?String(n.schema.maximum):void 0,value:null!=n.modelValue?n.modelValue:"",onInput:t[0]||(t[0]=(...e)=>o.onInput&&o.onInput(...e))},null,40,xo),o.fieldErrors.length?(zs(),Ks("ul",ko,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},So.__file="src/editors/NumberEditor.vue";var Co={name:"BooleanEditor",props:{schema:{type:Object,required:!0},modelValue:{default:!1},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):""}};const Eo={class:"sf-checkbox-label"},wo=["checked"],Ao={key:0,class:"errorlist"};Co.render=function(e,t,n,s,r,o){return zs(),Ks("div",{class:H(["sf-field sf-field-boolean",{errors:o.fieldErrors.length}])},[Ys("label",Eo,[Ys("input",{type:"checkbox",class:"sf-checkbox",checked:!!n.modelValue,onChange:t[0]||(t[0]=t=>e.$emit("update:modelValue",t.target.checked))},null,40,wo),nr(" "+G(o.title),1)]),o.fieldErrors.length?(zs(),Ks("ul",Ao,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},Co.__file="src/editors/BooleanEditor.vue";var Vo={name:"SelectEditor",props:{schema:{type:Object,required:!0},modelValue:{default:""},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},isRequired(){if(this.path.length<2||!this.form)return!1;const e=this.path.slice(0,-1),t=this.path[this.path.length-1],n=this.form.getSchemaAtPath(e);return n&&Array.isArray(n.required)&&n.required.includes(t)},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):""}};const Oo=["value"],Po=["value"],jo={key:0,class:"errorlist"};Vo.render=function(e,t,n,s,r,o){return zs(),Ks("div",{class:H(["sf-field",{errors:o.fieldErrors.length}])},[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),Ys("select",{class:"sf-input sf-select",value:null!=n.modelValue?String(n.modelValue):"",onChange:t[0]||(t[0]=t=>e.$emit("update:modelValue",t.target.value))},[(zs(!0),Ks(Fs,null,Tn(n.schema.enum||[],e=>(zs(),Ks("option",{key:e,value:String(e)},G(e),9,Po))),128))],40,Oo),o.fieldErrors.length?(zs(),Ks("ul",jo,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},Vo.__file="src/editors/SelectEditor.vue";var Io={name:"HiddenEditor",props:{schema:{type:Object,required:!0},modelValue:{default:null},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],computed:{resolvedValue(){return"const"in this.schema?this.schema.const:this.schema.enum&&1===this.schema.enum.length?this.schema.enum[0]:this.modelValue}},mounted(){this.resolvedValue!==this.modelValue&&this.$emit("update:modelValue",this.resolvedValue)},methods:{getValue(){return this.resolvedValue}}};const $o={style:{display:"none"}};Io.render=function(e,t,n,s,r,o){return zs(),Ks("div",$o)},Io.__file="src/editors/HiddenEditor.vue";var Do={name:"SfIcon",props:{name:{type:String,required:!0},size:{type:[Number,String],default:14}}};const Ro=["width","height"],To={key:4,points:"6 9 12 15 18 9"},Fo={key:5,points:"18 15 12 9 6 15"};Do.render=function(e,t,n,s,r,o){return zs(),Ks("svg",{class:"sf-icon",width:n.size,height:n.size,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"},["plus"===n.name?(zs(),Ks(Fs,{key:0},[t[0]||(t[0]=Ys("line",{x1:"12",y1:"5",x2:"12",y2:"19"},null,-1)),t[1]||(t[1]=Ys("line",{x1:"5",y1:"12",x2:"19",y2:"12"},null,-1))],64)):"times"===n.name?(zs(),Ks(Fs,{key:1},[t[2]||(t[2]=Ys("line",{x1:"6",y1:"6",x2:"18",y2:"18"},null,-1)),t[3]||(t[3]=Ys("line",{x1:"6",y1:"18",x2:"18",y2:"6"},null,-1))],64)):"arrow-up"===n.name?(zs(),Ks(Fs,{key:2},[t[4]||(t[4]=Ys("line",{x1:"12",y1:"19",x2:"12",y2:"5"},null,-1)),t[5]||(t[5]=Ys("polyline",{points:"5 12 12 5 19 12"},null,-1))],64)):"arrow-down"===n.name?(zs(),Ks(Fs,{key:3},[t[6]||(t[6]=Ys("line",{x1:"12",y1:"5",x2:"12",y2:"19"},null,-1)),t[7]||(t[7]=Ys("polyline",{points:"19 12 12 19 5 12"},null,-1))],64)):"chevron-down"===n.name?(zs(),Ks("polyline",To)):"chevron-up"===n.name?(zs(),Ks("polyline",Fo)):"grip"===n.name?(zs(),Ks(Fs,{key:6},[t[8]||(t[8]=sr('<circle cx="9" cy="7" r="1" fill="currentColor" stroke="none"></circle><circle cx="15" cy="7" r="1" fill="currentColor" stroke="none"></circle><circle cx="9" cy="12" r="1" fill="currentColor" stroke="none"></circle><circle cx="15" cy="12" r="1" fill="currentColor" stroke="none"></circle><circle cx="9" cy="17" r="1" fill="currentColor" stroke="none"></circle><circle cx="15" cy="17" r="1" fill="currentColor" stroke="none"></circle>',6))],64)):rr("v-if",!0)],8,Ro)},Do.__file="src/editors/SfIcon.vue";var Mo={name:"ObjectEditor",beforeCreate(){this.$options.components||(this.$options.components={}),this.$options.components.SchemaEditor=Di,this.$options.components.SfIcon=Do},props:{schema:{type:Object,required:!0},modelValue:{default:()=>({})},path:{type:Array,default:()=>[]},form:{type:Object,required:!0}},emits:["update:modelValue"],data:()=>({collapsed:!1}),computed:{isRoot(){return 0===this.path.length},title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},summary(){const e=this.modelValue||{},t=[];for(const n of Object.keys(this.schema.properties||{})){if(t.length>=3)break;const s=e[n];null!=s&&""!==s&&"object"!=typeof s&&t.push(String(s))}return t.join(" · ")}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",collapse(){this.collapsed=!0},expand(){this.collapsed=!1},onChildChange(e,t){const n={...this.modelValue||{},[e]:t};this.$emit("update:modelValue",n)}}};const No={key:0,class:"sf-object sf-object-root"},Uo={class:"sf-object-fields"},Lo={class:"sf-object-title"},qo=["aria-label"],zo={class:"sf-object-title-text"},Wo={key:0,class:"sf-object-summary"},Bo={class:"sf-object-fields"};function Ho(e){if(null===e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(Ho);const t={};for(const n of Object.keys(e))t[n]=Ho(e[n]);return t}function Ko(e){if("default"in e)return Ho(e.default);if("object"===e.type){const t={};for(const[n,s]of Object.entries(e.properties||{}))"default"in s?t[n]=Ho(s.default):"string"===s.type?t[n]="":"integer"===s.type||"number"===s.type?t[n]=0:"boolean"===s.type?t[n]=!1:"array"===s.type&&(t[n]=[]);return t}return"array"===e.type?[]:"string"===e.type?"":"integer"===e.type||"number"===e.type?0:"boolean"!==e.type&&("relation"===e.type&&e.multiple?[]:null)}Mo.render=function(e,t,n,s,r,o){const i=In("SchemaEditor"),l=In("SfIcon");return o.isRoot?(zs(),Ks("div",No,[Ys("div",Uo,[(zs(!0),Ks(Fs,null,Tn(n.schema.properties||{},(e,t)=>(zs(),Zs(i,{key:t,schema:n.form.resolveSchema(e),"model-value":(n.modelValue||{})[t],path:[...n.path,t],form:n.form,"onUpdate:modelValue":e=>o.onChildChange(t,e)},null,8,["schema","model-value","path","form","onUpdate:modelValue"]))),128))])])):(zs(),Ks("fieldset",{key:1,class:H(["sf-object",{"sf-object-collapsed":r.collapsed}])},[Ys("legend",Lo,[Ys("button",{type:"button",class:"sf-collapse-btn","aria-label":r.collapsed?"Expand":"Collapse",onClick:t[0]||(t[0]=e=>r.collapsed=!r.collapsed)},[er(l,{name:r.collapsed?"chevron-down":"chevron-up",size:12},null,8,["name"])],8,qo),Ys("span",zo,G(o.title),1),r.collapsed&&o.summary?(zs(),Ks("span",Wo,G(o.summary),1)):rr("v-if",!0)]),Jt(Ys("div",Bo,[(zs(!0),Ks(Fs,null,Tn(n.schema.properties||{},(e,t)=>(zs(),Zs(i,{key:t,schema:n.form.resolveSchema(e),"model-value":(n.modelValue||{})[t],path:[...n.path,t],form:n.form,"onUpdate:modelValue":e=>o.onChildChange(t,e)},null,8,["schema","model-value","path","form","onUpdate:modelValue"]))),128))],512),[[Rr,!r.collapsed]])],2))},Mo.__file="src/editors/ObjectEditor.vue";let Zo=0;var Qo={name:"ArrayEditor",beforeCreate(){this.$options.components||(this.$options.components={}),this.$options.components.SchemaEditor=Di,this.$options.components.SfIcon=Do},props:{schema:{type:Object,required:!0},modelValue:{default:()=>[]},path:{type:Array,default:()=>[]},form:{type:Object,required:!0}},emits:["update:modelValue"],data(){return{items:(Array.isArray(this.modelValue)?this.modelValue:[]).map(e=>({_key:Zo++,value:e})),dragSourceIndex:null,dragOverIndex:null,allCollapsed:!1}},computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},itemSchema(){return this.form.resolveSchema(this.schema.items||{})},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",addItem(){const e=Ko(this.itemSchema);this.items.push({_key:Zo++,value:e}),this.emitValue()},removeItem(e){this.items.splice(e,1),this.emitValue()},moveItem(e,t){const n=e+t;if(n<0||n>=this.items.length)return;const s=this.items[e];this.items.splice(e,1,this.items[n]),this.items.splice(n,1,s),this.emitValue()},onItemChange(e,t){this.items[e].value=t,this.emitValue()},onDragStart(e,t){this.dragSourceIndex=e,t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",String(e))},onDragOver(e){null!==this.dragSourceIndex&&e!==this.dragSourceIndex&&(this.dragOverIndex=e)},onDragLeave(e){this.dragOverIndex===e&&(this.dragOverIndex=null)},onDrop(e){if(null===this.dragSourceIndex||this.dragSourceIndex===e)return;const t=this.items.splice(this.dragSourceIndex,1)[0];this.items.splice(e,0,t),this.dragSourceIndex=null,this.dragOverIndex=null,this.emitValue()},onDragEnd(){this.dragSourceIndex=null,this.dragOverIndex=null},toggleCollapseAll(){this.allCollapsed=!this.allCollapsed;const e=this.$refs.itemEditors;if(!e)return;const t=Array.isArray(e)?e:[e];this.allCollapsed?t.forEach(e=>e?.collapseAll?.()):t.forEach(e=>e?.expandAll?.())},emitValue(){this.$emit("update:modelValue",this.items.map(e=>e.value))}}};const Jo={class:"sf-array-header"},Go={class:"sf-label"},Xo={class:"sf-array-count"},Yo=["title"],ei={class:"sf-array-items"},ti=["onDragstart","onDragover","onDragleave","onDrop"],ni={class:"sf-array-item-header"},si={class:"sf-array-item-left"},ri={class:"sf-drag-handle",title:"Drag to reorder"},oi={class:"sf-array-item-index"},ii={class:"sf-array-item-actions"},li=["onClick"],ai=["onClick"],ci=["onClick"],ui=["onDrop"],hi={key:0,class:"errorlist"};Qo.render=function(e,t,n,s,r,o){const i=In("SfIcon"),l=In("SchemaEditor");return zs(),Ks("div",{class:H(["sf-array",{errors:o.fieldErrors.length}])},[Ys("div",Jo,[Ys("span",Go,G(o.title),1),Ys("span",Xo,G(r.items.length),1),Ys("button",{type:"button",class:"sf-btn sf-btn-add",onClick:t[0]||(t[0]=e=>o.addItem())},[er(i,{name:"plus"}),t[4]||(t[4]=nr(" Add ",-1))]),r.items.length?(zs(),Ks("span",{key:0,class:"sf-array-collapse-toggle",title:r.allCollapsed?"Expand all":"Collapse all",onClick:t[1]||(t[1]=(...e)=>o.toggleCollapseAll&&o.toggleCollapseAll(...e))},[er(i,{name:r.allCollapsed?"chevron-down":"chevron-up"},null,8,["name"])],8,Yo)):rr("v-if",!0)]),Ys("div",ei,[(zs(!0),Ks(Fs,null,Tn(r.items,(e,s)=>(zs(),Ks("div",{key:e._key,class:H(["sf-array-item",{"sf-drag-over":r.dragOverIndex===s,"sf-dragging":r.dragSourceIndex===s}]),draggable:"true",onDragstart:e=>o.onDragStart(s,e),onDragover:ho(e=>o.onDragOver(s),["prevent"]),onDragleave:e=>o.onDragLeave(s),onDrop:ho(e=>o.onDrop(s),["prevent"]),onDragend:t[3]||(t[3]=(...e)=>o.onDragEnd&&o.onDragEnd(...e))},[Ys("div",ni,[Ys("div",si,[Ys("span",ri,[er(i,{name:"grip"})]),Ys("span",oi,"#"+G(s+1),1)]),Ys("div",ii,[s>0?(zs(),Ks("button",{key:0,type:"button",class:"sf-btn sf-btn-sm",onClick:e=>o.moveItem(s,-1)},[er(i,{name:"arrow-up"})],8,li)):rr("v-if",!0),Ys("button",{type:"button",class:"sf-btn sf-btn-sm",onClick:e=>o.moveItem(s,1)},[er(i,{name:"arrow-down"})],8,ai),Ys("button",{type:"button",class:"sf-btn sf-btn-sm sf-btn-danger",onClick:e=>o.removeItem(s)},[er(i,{name:"times"})],8,ci)])]),Ys("div",{class:"sf-array-item-body",onDragover:t[2]||(t[2]=ho(()=>{},["prevent"])),onDrop:ho(e=>o.onDrop(s),["prevent"])},[er(l,{ref_for:!0,ref:"itemEditors",schema:o.itemSchema,"model-value":e.value,path:[...n.path,String(s)],form:n.form,"onUpdate:modelValue":e=>o.onItemChange(s,e)},null,8,["schema","model-value","path","form","onUpdate:modelValue"])],40,ui)],42,ti))),128))]),o.fieldErrors.length?(zs(),Ks("ul",hi,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},Qo.__file="src/editors/ArrayEditor.vue";var di={name:"NullableEditor",beforeCreate(){this.$options.components||(this.$options.components={}),this.$options.components.SchemaEditor=Di,this.$options.components.SfIcon=Do},props:{schema:{type:Object,required:!0},modelValue:{default:null},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],data(){return{isNull:null===this.modelValue||void 0===this.modelValue}},computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},isRequired(){if(this.path.length<2||!this.form)return!1;const e=this.path.slice(0,-1),t=this.path[this.path.length-1],n=this.form.getSchemaAtPath(e);return n&&Array.isArray(n.required)&&n.required.includes(t)},innerSchema(){const e={...this.schema};return delete e._nullable,e},toggleClass(){return this.isNull?"sf-btn sf-btn-sm sf-btn-add":"sf-btn sf-btn-sm sf-btn-danger"},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},watch:{modelValue(e){this.isNull=null==e}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",toggle(){this.isNull?(this.isNull=!1,this.$emit("update:modelValue",Ko(this.innerSchema))):(this.isNull=!0,this.$emit("update:modelValue",null))}}};const pi={class:"sf-nullable-header"},fi={class:"sf-nullable-body"},mi={key:0,class:"errorlist"};di.render=function(e,t,n,s,r,o){const i=In("SfIcon"),l=In("SchemaEditor");return zs(),Ks("div",{class:H(["sf-nullable",{errors:o.fieldErrors.length}])},[Ys("div",pi,[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),Ys("button",{type:"button",class:H(o.toggleClass),onClick:t[0]||(t[0]=(...e)=>o.toggle&&o.toggle(...e))},[r.isNull?(zs(),Ks(Fs,{key:0},[er(i,{name:"plus"}),t[2]||(t[2]=nr(" Add ",-1))],64)):(zs(),Ks(Fs,{key:1},[er(i,{name:"times"}),t[3]||(t[3]=nr(" Remove ",-1))],64))],2)]),Ys("div",fi,[r.isNull?rr("v-if",!0):(zs(),Zs(l,{key:0,schema:o.innerSchema,"model-value":n.modelValue,path:n.path,form:n.form,"onUpdate:modelValue":t[1]||(t[1]=t=>e.$emit("update:modelValue",t))},null,8,["schema","model-value","path","form"]))]),o.fieldErrors.length?(zs(),Ks("ul",mi,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},di.__file="src/editors/NullableEditor.vue";var gi={name:"UnionEditor",beforeCreate(){this.$options.components||(this.$options.components={}),this.$options.components.SchemaEditor=Di},props:{schema:{type:Object,required:!0},modelValue:{default:null},path:{type:Array,default:()=>[]},form:{type:Object,required:!0}},emits:["update:modelValue"],data(){const e=this.schema.discriminator.propertyName,t=this.schema.discriminator.mapping;return{discriminatorProp:e,mapping:t,currentType:this.modelValue?this.modelValue[e]:Object.keys(t)[0]}},computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},typeKeys(){return Object.keys(this.mapping)},currentSchema(){const e=this.mapping[this.currentType];return this.form.resolveSchema({$ref:e})},innerValue(){if(this.modelValue&&this.modelValue[this.discriminatorProp]===this.currentType)return this.modelValue;const e=Ko(this.currentSchema);return e[this.discriminatorProp]=this.currentType,e}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",onTypeChange(e){this.currentType=e.target.value;const t=Ko(this.currentSchema);t[this.discriminatorProp]=this.currentType,this.$emit("update:modelValue",t)},onInnerChange(e){e&&(e[this.discriminatorProp]=this.currentType),this.$emit("update:modelValue",e)}}};const vi={class:"sf-union"},yi={class:"sf-field"},_i={class:"sf-label"},bi=["value"],Si=["value"],xi={class:"sf-union-body"};gi.render=function(e,t,n,s,r,o){const i=In("SchemaEditor");return zs(),Ks("div",vi,[Ys("div",yi,[Ys("label",_i,G(o.title),1),Ys("select",{class:"sf-input sf-select",value:r.currentType,onChange:t[0]||(t[0]=(...e)=>o.onTypeChange&&o.onTypeChange(...e))},[(zs(!0),Ks(Fs,null,Tn(o.typeKeys,e=>(zs(),Ks("option",{key:e,value:e},G(o.humanize(e)),9,Si))),128))],40,bi)]),Ys("div",xi,[(zs(),Zs(i,{key:r.currentType,schema:o.currentSchema,"model-value":o.innerValue,path:n.path,form:n.form,"onUpdate:modelValue":o.onInnerChange},null,8,["schema","model-value","path","form","onUpdate:modelValue"]))])])},gi.__file="src/editors/UnionEditor.vue";var ki={name:"RelationEditor",components:{SfIcon:Do},props:{schema:{type:Object,required:!0},modelValue:{default:null},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],data(){const e=!!this.schema.multiple,t=this.modelValue;let n;return n=e?Array.isArray(t)?[...t]:[]:t?[t]:[],{isMultiple:e,allowClear:this.schema.options?.select2?.allowClear??!0,placeholder:this.schema.options?.select2?.placeholder||"Search...",searchUrl:this.schema.options?.select2?.ajax?.url||"",selected:n,dropdownVisible:!1,searchResults:[],currentPage:1,hasMore:!1,loading:!1,highlightIndex:-1,searchQuery:""}},computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},isRequired(){if(this.path.length<2||!this.form)return!1;const e=this.path.slice(0,-1),t=this.path[this.path.length-1],n=this.form.getSchemaAtPath(e);return n&&Array.isArray(n.required)&&n.required.includes(t)},showSearch(){return!(!this.isMultiple&&this.selected.length>0)},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]},filteredResults(){const e=new Set(this.selected.map(e=>this.itemKey(e)));return this.searchResults.filter(t=>!e.has(this.itemKey(t)))}},created(){this._doSearch=function(e,t){let n;return function(...s){clearTimeout(n),n=setTimeout(()=>e.apply(this,s),t)}}(e=>this.fetchResults(e,1),300),this._onDocClick=e=>{this.$refs.root&&!this.$refs.root.contains(e.target)&&this.closeDropdown()}},mounted(){document.addEventListener("click",this._onDocClick)},beforeUnmount(){document.removeEventListener("click",this._onDocClick)},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",getDisplayName(e){if(!e)return"";for(const t of["__str__","name","title","label"])if(e[t])return String(e[t]);return`#${e.id||"?"}`},itemKey:e=>`${e.id}-${e.model||""}`,onSearchInput(){this._doSearch(this.searchQuery)},openDropdown(){this.dropdownVisible||(this.dropdownVisible=!0,this.fetchResults(this.searchQuery,1))},closeDropdown(){this.dropdownVisible=!1,this.highlightIndex=-1},async fetchResults(e,t){if(this.searchUrl){this.loading=!0,this.currentPage=t;try{const n=new URL(this.searchUrl,window.location.origin);n.searchParams.set("_q",e||""),n.searchParams.set("page",String(t));const s=await fetch(n,{credentials:"same-origin"});if(!s.ok)return;const r=await s.json();this.searchResults=1===t?r.items||[]:this.searchResults.concat(r.items||[]),this.hasMore=r.more}finally{this.loading=!1}}},handleKeyDown(e){this.filteredResults.length&&("ArrowDown"===e.key?(e.preventDefault(),this.highlightIndex=Math.min(this.highlightIndex+1,this.filteredResults.length-1)):"ArrowUp"===e.key?(e.preventDefault(),this.highlightIndex=Math.max(this.highlightIndex-1,0)):"Enter"===e.key?(e.preventDefault(),this.highlightIndex>=0&&this.highlightIndex<this.filteredResults.length&&this.selectItem(this.filteredResults[this.highlightIndex])):"Escape"===e.key&&this.closeDropdown())},selectItem(e){this.isMultiple?this.selected.push(e):this.selected=[e],this.searchQuery="",this.highlightIndex=-1,this.closeDropdown(),this.emitValue()},removeItem(e){this.selected=this.selected.filter(t=>!(t.id===e.id&&(t.model||"")===(e.model||""))),this.emitValue()},emitValue(){this.isMultiple?this.$emit("update:modelValue",[...this.selected]):this.$emit("update:modelValue",this.selected[0]||null)}}};const Ci={class:"sf-relation-wrapper"},Ei={key:0,class:"sf-relation-selected"},wi={class:"sf-relation-tag-text"},Ai=["onClick"],Vi={class:"sf-relation-search"},Oi=["placeholder"],Pi={class:"sf-relation-dropdown"},ji={key:0,class:"sf-relation-dropdown-empty"},Ii=["onClick"],$i={key:0,class:"errorlist"};ki.render=function(e,t,n,s,r,o){const i=In("SfIcon");return zs(),Ks("div",{class:H(["sf-field sf-relation",{errors:o.fieldErrors.length}]),ref:"root"},[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),Ys("div",Ci,[rr(" Selected items "),r.selected.length?(zs(),Ks("div",Ei,[(zs(!0),Ks(Fs,null,Tn(r.selected,e=>(zs(),Ks("div",{key:o.itemKey(e),class:"sf-relation-tag"},[Ys("span",wi,G(o.getDisplayName(e)),1),r.isMultiple||r.allowClear?(zs(),Ks("button",{key:0,type:"button",class:"sf-relation-tag-remove",onClick:ho(t=>o.removeItem(e),["stop"])},[er(i,{name:"times"})],8,Ai)):rr("v-if",!0)]))),128))])):rr("v-if",!0),rr(" Search box "),Jt(Ys("div",Vi,[Jt(Ys("input",{ref:"searchInput",type:"text",class:"sf-input sf-relation-input",placeholder:r.placeholder,autocomplete:"off","onUpdate:modelValue":t[0]||(t[0]=e=>r.searchQuery=e),onInput:t[1]||(t[1]=(...e)=>o.onSearchInput&&o.onSearchInput(...e)),onFocus:t[2]||(t[2]=(...e)=>o.openDropdown&&o.openDropdown(...e)),onKeydown:t[3]||(t[3]=(...e)=>o.handleKeyDown&&o.handleKeyDown(...e))},null,40,Oi),[[ao,r.searchQuery]]),rr(" Dropdown "),Jt(Ys("div",Pi,[0!==o.filteredResults.length||r.loading?rr("v-if",!0):(zs(),Ks("div",ji," No results found ")),(zs(!0),Ks(Fs,null,Tn(o.filteredResults,(e,t)=>(zs(),Ks("div",{key:o.itemKey(e),class:H(["sf-relation-dropdown-item",{highlighted:t===r.highlightIndex}]),onClick:t=>o.selectItem(e)},G(o.getDisplayName(e)),11,Ii))),128)),r.hasMore?(zs(),Ks("div",{key:1,class:"sf-relation-dropdown-more",onClick:t[4]||(t[4]=e=>o.fetchResults(r.searchQuery,r.currentPage+1))}," Load more... ")):rr("v-if",!0)],512),[[Rr,r.dropdownVisible]])],512),[[Rr,o.showSearch]])]),o.fieldErrors.length?(zs(),Ks("ul",$i,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},ki.__file="src/editors/RelationEditor.vue";var Di={name:"SchemaEditor",components:{StringEditor:t,NumberEditor:So,BooleanEditor:Co,SelectEditor:Vo,HiddenEditor:Io,ObjectEditor:Mo,ArrayEditor:Qo,NullableEditor:di,UnionEditor:gi,RelationEditor:ki},props:{schema:{type:Object,required:!0},modelValue:{default:void 0},path:{type:Array,default:()=>[]},form:{type:Object,required:!0}},emits:["update:modelValue"],methods:{collapseAll(){const e=this.$refs.editor;e?.collapse&&e.collapse(),e?.collapseAll&&e.collapseAll()},expandAll(){const e=this.$refs.editor;e?.expand&&e.expand(),e?.expandAll&&e.expandAll()}},computed:{editorComponent(){const e=this.schema;return this.path.length>12?"StringEditor":"relation"===e.type?"RelationEditor":e.oneOf&&e.discriminator?"UnionEditor":"const"in e||e.enum&&1===e.enum.length&&"string"===e.type?"HiddenEditor":e._nullable?"NullableEditor":"object"===e.type&&e.properties?"ObjectEditor":"array"===e.type?"ArrayEditor":e.enum?"SelectEditor":"boolean"===e.type?"BooleanEditor":"number"===e.type||"integer"===e.type?"NumberEditor":"StringEditor"}}};Di.render=function(e,t,n,s,r,o){return zs(),Zs((i=o.editorComponent,y(i)?Dn(jn,i,!1)||i:i||$n),{ref:"editor",schema:n.schema,"model-value":n.modelValue,path:n.path,form:n.form,"onUpdate:modelValue":t[0]||(t[0]=t=>e.$emit("update:modelValue",t))},null,8,["schema","model-value","path","form"]);var i},Di.__file="src/editors/SchemaEditor.vue";var Ri={name:"SchemaForm",components:{SchemaEditor:Di},props:{schema:{type:[Object,String],default:()=>({})},initialData:{default:void 0},errors:{type:Object,default:()=>({})}},emits:["change"],expose:["getValue"],data(){const e="string"==typeof this.schema?JSON.parse(this.schema):this.schema;return{rootSchema:e,defs:e.$defs||e.definitions||{},currentValue:null!=this.initialData?Ho(this.initialData):void 0}},computed:{resolvedSchema(){return this.resolveSchema(this.rootSchema)},formApi(){return{resolveSchema:e=>this.resolveSchema(e),getSchemaAtPath:e=>this.getSchemaAtPath(e),getErrorsForPath:e=>this.getErrorsForPath(e)}}},watch:{schema:{handler(e){const t="string"==typeof e?JSON.parse(e):e;this.rootSchema=t,this.defs=t.$defs||t.definitions||{}},deep:!0},initialData:{handler(e){this.currentValue=null!=e?Ho(e):void 0},deep:!0}},methods:{resolveSchema(e){if(!e)return{type:"string"};if(e.$ref){const t=e.$ref.replace(/^#\/\$defs\//,"").replace(/^#\/definitions\//,""),n=this.defs[t];if(!n)return{type:"string",title:t};const{$ref:s,...r}=e;return{...this.resolveSchema(n),...r}}if(e.anyOf){const t=e.anyOf.filter(e=>"null"!==e.type);if(e.anyOf.some(e=>"null"===e.type)&&1===t.length){const n=this.resolveSchema(t[0]);return{...n,_nullable:!0,title:e.title||n.title,default:"default"in e?e.default:null}}if(t.length>=1)return this.resolveSchema(t[0])}if(e.oneOf&&e.discriminator)return e;if(e.oneOf){const t=e.oneOf.filter(e=>"null"!==e.type);if(e.oneOf.some(e=>"null"===e.type)&&1===t.length){const n=this.resolveSchema(t[0]);return{...n,_nullable:!0,title:e.title||n.title,default:"default"in e?e.default:null}}if(t.length>=1)return this.resolveSchema(t[0])}return e},getSchemaAtPath(e){let t=this.resolveSchema(this.rootSchema);for(const n of e){if(!t)return null;if(t.properties&&t.properties[n])t=this.resolveSchema(t.properties[n]);else{if(!t.items)return null;t=this.resolveSchema(t.items)}}return t},onValueChange(e){this.currentValue=e,this.$emit("change",e)},getErrorsForPath(e){if(!this.errors||"object"!=typeof this.errors)return[];const t=e.join(".");return this.errors[t]||[]},getValue(){return this.currentValue}}};const Ti={class:"structured-field-editor"};Ri.render=function(e,t,n,s,r,o){const i=In("SchemaEditor");return zs(),Ks("div",Ti,[o.resolvedSchema?(zs(),Zs(i,{key:0,schema:o.resolvedSchema,"model-value":r.currentValue,path:[],form:o.formApi,"onUpdate:modelValue":o.onValueChange},null,8,["schema","model-value","form","onUpdate:modelValue"])):rr("v-if",!0)])},Ri.__file="src/SchemaForm.vue";const Fi=function(e,t,n){let s=function(e,t){return v(e)?(()=>c({name:e.name},t,{setup:e}))():e}(e,t);C(s)&&(s=c({},s,t));class r extends no{constructor(e){super(s,e,n)}}return r.def=s,r}({...Ri,shadowRoot:!1});return e.ArrayEditor=Qo,e.BooleanEditor=Co,e.HiddenEditor=Io,e.NullableEditor=di,e.NumberEditor=So,e.ObjectEditor=Mo,e.RelationEditor=ki,e.SchemaEditor=Di,e.SchemaForm=Ri,e.SchemaFormElement=Fi,e.SelectEditor=Vo,e.StringEditor=t,e.UnionEditor=gi,e.registerCustomElement=function(e="schema-form"){customElements.get(e)||customElements.define(e,Fi)},e}({});
|
|
23
|
+
let wr;const Ar="undefined"!=typeof window&&window.trustedTypes;if(Ar)try{wr=Ar.createPolicy("vue",{createHTML:e=>e})}catch(e){}const Vr=wr?e=>wr.createHTML(e):e=>e,Or="undefined"!=typeof document?document:null,Pr=Or&&Or.createElement("template"),jr={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,s)=>{const r="svg"===t?Or.createElementNS("http://www.w3.org/2000/svg",e):"mathml"===t?Or.createElementNS("http://www.w3.org/1998/Math/MathML",e):n?Or.createElement(e,{is:n}):Or.createElement(e);return"select"===e&&s&&null!=s.multiple&&r.setAttribute("multiple",s.multiple),r},createText:e=>Or.createTextNode(e),createComment:e=>Or.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>Or.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,s,r,o){const i=n?n.previousSibling:t.lastChild;if(r&&(r===o||r.nextSibling))for(;t.insertBefore(r.cloneNode(!0),n),r!==o&&(r=r.nextSibling););else{Pr.innerHTML=Vr("svg"===s?`<svg>${e}</svg>`:"mathml"===s?`<math>${e}</math>`:e);const r=Pr.content;if("svg"===s||"mathml"===s){const e=r.firstChild;for(;e.firstChild;)r.appendChild(e.firstChild);r.removeChild(e)}t.insertBefore(r,n)}return[i?i.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},Ir=Symbol("_vtc");const $r=Symbol("_vod"),Dr=Symbol("_vsh"),Rr={name:"show",beforeMount(e,{value:t},{transition:n}){e[$r]="none"===e.style.display?"":e.style.display,n&&t?n.beforeEnter(e):Tr(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:s}){!t!=!n&&(s?t?(s.beforeEnter(e),Tr(e,!0),s.enter(e)):s.leave(e,()=>{Tr(e,!1)}):Tr(e,t))},beforeUnmount(e,{value:t}){Tr(e,t)}};function Tr(e,t){e.style.display=t?e[$r]:"none",e[Dr]=!t}const Fr=Symbol(""),Mr=/(?:^|;)\s*display\s*:/;const Nr=/\s*!important$/;function Ur(e,t,n){if(p(n))n.forEach(n=>Ur(e,t,n));else if(null==n&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const s=function(e,t){const n=qr[t];if(n)return n;let s=O(t);if("filter"!==s&&s in e)return qr[t]=s;s=I(s);for(let n=0;n<Lr.length;n++){const r=Lr[n]+s;if(r in e)return qr[t]=r}return t}(e,t);Nr.test(n)?e.setProperty(j(s),n.replace(Nr,""),"important"):e[s]=n}}const Lr=["Webkit","Moz","ms"],qr={};const zr="http://www.w3.org/1999/xlink";function Wr(e,t,n,s,r,o=K(t)){s&&t.startsWith("xlink:")?null==n?e.removeAttributeNS(zr,t.slice(6,t.length)):e.setAttributeNS(zr,t,n):null==n||o&&!Z(n)?e.removeAttribute(t):e.setAttribute(t,o?"":_(n)?String(n):n)}function Br(e,t,n,s,r){if("innerHTML"===t||"textContent"===t)return void(null!=n&&(e[t]="innerHTML"===t?Vr(n):n));const o=e.tagName;if("value"===t&&"PROGRESS"!==o&&!o.includes("-")){const s="OPTION"===o?e.getAttribute("value")||"":e.value,r=null==n?"checkbox"===e.type?"on":"":String(n);return s===r&&"_value"in e||(e.value=r),null==n&&e.removeAttribute(t),void(e._value=n)}let i=!1;if(""===n||null==n){const s=typeof e[t];"boolean"===s?n=Z(n):null==n&&"string"===s?(n="",i=!0):"number"===s&&(n=0,i=!0)}try{e[t]=n}catch(e){}i&&e.removeAttribute(r||t)}function Hr(e,t,n,s){e.addEventListener(t,n,s)}const Kr=Symbol("_vei");function Zr(e,t,n,s,r=null){const o=e[Kr]||(e[Kr]={}),i=o[t];if(s&&i)i.value=s;else{const[n,l]=function(e){let t;if(Qr.test(e)){let n;for(t={};n=e.match(Qr);)e=e.slice(0,e.length-n[0].length),t[n[0].toLowerCase()]=!0}const n=":"===e[2]?e.slice(3):j(e.slice(2));return[n,t]}(t);if(s){const i=o[t]=function(e,t){const n=e=>{if(e._vts){if(e._vts<=n.attached)return}else e._vts=Date.now();jt(function(e,t){if(p(t)){const n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(e=>t=>!t._stopped&&e&&e(t))}return t}(e,n.value),t,5,[e])};return n.value=e,n.attached=Xr(),n}(s,r);Hr(e,n,i,l)}else i&&(!function(e,t,n,s){e.removeEventListener(t,n,s)}(e,n,i,l),o[t]=void 0)}}const Qr=/(?:Once|Passive|Capture)$/;let Jr=0;const Gr=Promise.resolve(),Xr=()=>Jr||(Gr.then(()=>Jr=0),Jr=Date.now());const Yr=e=>111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123;const eo={};const to="undefined"!=typeof HTMLElement?HTMLElement:class{};class no extends to{constructor(e,t={},n=vo){super(),this._def=e,this._props=t,this._createApp=n,this._isVueCE=!0,this._instance=null,this._app=null,this._nonce=this._def.nonce,this._connected=!1,this._resolved=!1,this._patching=!1,this._dirty=!1,this._numberProps=null,this._styleChildren=new WeakSet,this._styleAnchors=new WeakMap,this._ob=null,this.shadowRoot&&n!==vo?this._root=this.shadowRoot:!1!==e.shadowRoot?(this.attachShadow(c({},e.shadowRootOptions,{mode:"open"})),this._root=this.shadowRoot):this._root=this}connectedCallback(){if(!this.isConnected)return;this.shadowRoot||this._resolved||this._parseSlots(),this._connected=!0;let e=this;for(;e=e&&(e.assignedSlot||e.parentNode||e.host);)if(e instanceof no){this._parent=e;break}this._instance||(this._resolved?this._mount(this._def):e&&e._pendingResolve?this._pendingResolve=e._pendingResolve.then(()=>{this._pendingResolve=void 0,this._resolveDef()}):this._resolveDef())}_setParent(e=this._parent){e&&(this._instance.parent=e._instance,this._inheritParentContext(e))}_inheritParentContext(e=this._parent){e&&this._app&&Object.setPrototypeOf(this._app._context.provides,e._instance.provides)}disconnectedCallback(){this._connected=!1,Ut(()=>{this._connected||(this._ob&&(this._ob.disconnect(),this._ob=null),this._app&&this._app.unmount(),this._instance&&(this._instance.ce=void 0),this._app=this._instance=null,this._teleportTargets&&(this._teleportTargets.clear(),this._teleportTargets=void 0))})}_processMutations(e){for(const t of e)this._setAttr(t.attributeName)}_resolveDef(){if(this._pendingResolve)return;for(let e=0;e<this.attributes.length;e++)this._setAttr(this.attributes[e].name);this._ob=new MutationObserver(this._processMutations.bind(this)),this._ob.observe(this,{attributes:!0});const e=(e,t=!1)=>{this._resolved=!0,this._pendingResolve=void 0;const{props:n,styles:s}=e;let r;if(n&&!p(n))for(const e in n){const t=n[e];(t===Number||t&&t.type===Number)&&(e in this._props&&(this._props[e]=M(this._props[e])),(r||(r=Object.create(null)))[O(e)]=!0)}this._numberProps=r,this._resolveProps(e),this.shadowRoot&&this._applyStyles(s),this._mount(e)},t=this._def.__asyncLoader;t?this._pendingResolve=t().then(t=>{t.configureApp=this._def.configureApp,e(this._def=t,!0)}):e(this._def)}_mount(e){this._app=this._createApp(e),this._inheritParentContext(),e.configureApp&&e.configureApp(this._app),this._app._ceVNode=this._createVNode(),this._app.mount(this._root);const t=this._instance&&this._instance.exposed;if(t)for(const e in t)d(this,e)||Object.defineProperty(this,e,{get:()=>St(t[e])})}_resolveProps(e){const{props:t}=e,n=p(t)?t:Object.keys(t||{});for(const e of Object.keys(this))"_"!==e[0]&&n.includes(e)&&this._setProp(e,this[e]);for(const e of n.map(O))Object.defineProperty(this,e,{get(){return this._getProp(e)},set(t){this._setProp(e,t,!0,!this._patching)}})}_setAttr(e){if(e.startsWith("data-v-"))return;const t=this.hasAttribute(e);let n=t?this.getAttribute(e):eo;const s=O(e);t&&this._numberProps&&this._numberProps[s]&&(n=M(n)),this._setProp(s,n,!1,!0)}_getProp(e){return this._props[e]}_setProp(e,t,n=!0,s=!1){if(t!==this._props[e]&&(this._dirty=!0,t===eo?delete this._props[e]:(this._props[e]=t,"key"===e&&this._app&&(this._app._ceVNode.key=t)),s&&this._instance&&this._update(),n)){const n=this._ob;n&&(this._processMutations(n.takeRecords()),n.disconnect()),!0===t?this.setAttribute(j(e),""):"string"==typeof t||"number"==typeof t?this.setAttribute(j(e),t+""):t||this.removeAttribute(j(e)),n&&n.observe(this,{attributes:!0})}}_update(){const e=this._createVNode();this._app&&(e.appContext=this._app._context),go(e,this._root)}_createVNode(){const e={};this.shadowRoot||(e.onVnodeMounted=e.onVnodeUpdated=this._renderSlots.bind(this));const t=er(this._def,c(e,this._props));return this._instance||(t.ce=e=>{this._instance=e,e.ce=this,e.isCE=!0;const t=(e,t)=>{this.dispatchEvent(new CustomEvent(e,C(t[0])?c({detail:t},t[0]):{detail:t}))};e.emit=(e,...n)=>{t(e,n),j(e)!==e&&t(j(e),n)},this._setParent()}),t}_applyStyles(e,t,n){if(!e)return;if(t){if(t===this._def||this._styleChildren.has(t))return;this._styleChildren.add(t)}const s=this._nonce,r=this.shadowRoot,o=n?this._getStyleAnchor(n)||this._getStyleAnchor(this._def):this._getRootStyleInsertionAnchor(r);let i=null;for(let l=e.length-1;l>=0;l--){const a=document.createElement("style");s&&a.setAttribute("nonce",s),a.textContent=e[l],r.insertBefore(a,i||o),i=a,0===l&&(n||this._styleAnchors.set(this._def,a),t&&this._styleAnchors.set(t,a))}}_getStyleAnchor(e){if(!e)return null;const t=this._styleAnchors.get(e);return t&&t.parentNode===this.shadowRoot?t:(t&&this._styleAnchors.delete(e),null)}_getRootStyleInsertionAnchor(e){for(let t=0;t<e.childNodes.length;t++){const n=e.childNodes[t];if(!(n instanceof HTMLStyleElement))return n}return null}_parseSlots(){const e=this._slots={};let t;for(;t=this.firstChild;){const n=1===t.nodeType&&t.getAttribute("slot")||"default";(e[n]||(e[n]=[])).push(t),this.removeChild(t)}}_renderSlots(){const e=this._getSlots(),t=this._instance.type.__scopeId;for(let n=0;n<e.length;n++){const s=e[n],r=s.getAttribute("name")||"default",o=this._slots[r],i=s.parentNode;if(o)for(const e of o){if(t&&1===e.nodeType){const n=t+"-s",s=document.createTreeWalker(e,1);let r;for(e.setAttribute(n,"");r=s.nextNode();)r.setAttribute(n,"")}i.insertBefore(e,s)}else for(;s.firstChild;)i.insertBefore(s.firstChild,s);i.removeChild(s)}}_getSlots(){const e=[this];this._teleportTargets&&e.push(...this._teleportTargets);const t=new Set;for(const n of e){const e=n.querySelectorAll("slot");for(let n=0;n<e.length;n++)t.add(e[n])}return Array.from(t)}_injectChildStyle(e,t){this._applyStyles(e.styles,e,t)}_beginPatch(){this._patching=!0,this._dirty=!1}_endPatch(){this._patching=!1,this._dirty&&this._instance&&this._update()}_hasShadowRoot(){return!1!==this._def.shadowRoot}_removeChildStyle(e){}}const so=e=>{const t=e.props["onUpdate:modelValue"]||!1;return p(t)?e=>R(t,e):t};function ro(e){e.target.composing=!0}function oo(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const io=Symbol("_assign");function lo(e,t,n){return t&&(e=e.trim()),n&&(e=F(e)),e}const ao={created(e,{modifiers:{lazy:t,trim:n,number:s}},r){e[io]=so(r);const o=s||r.props&&"number"===r.props.type;Hr(e,t?"change":"input",t=>{t.target.composing||e[io](lo(e.value,n,o))}),(n||o)&&Hr(e,"change",()=>{e.value=lo(e.value,n,o)}),t||(Hr(e,"compositionstart",ro),Hr(e,"compositionend",oo),Hr(e,"change",oo))},mounted(e,{value:t}){e.value=null==t?"":t},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:s,trim:r,number:o}},i){if(e[io]=so(i),e.composing)return;const l=null==t?"":t;if((!o&&"number"!==e.type||/^0\d/.test(e.value)?e.value:F(e.value))!==l){if(document.activeElement===e&&"range"!==e.type){if(s&&t===n)return;if(r&&e.value.trim()===l)return}e.value=l}}},co=["ctrl","shift","alt","meta"],uo={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&0!==e.button,middle:e=>"button"in e&&1!==e.button,right:e=>"button"in e&&2!==e.button,exact:(e,t)=>co.some(n=>e[`${n}Key`]&&!t.includes(n))},ho=(e,t)=>{if(!e)return e;const n=e._withMods||(e._withMods={}),s=t.join(".");return n[s]||(n[s]=(n,...s)=>{for(let e=0;e<t.length;e++){const s=uo[t[e]];if(s&&s(n,t))return}return e(n,...s)})},po=c({patchProp:(e,t,n,s,r,o)=>{const i="svg"===r;"class"===t?function(e,t,n){const s=e[Ir];s&&(t=(t?[t,...s]:[...s]).join(" ")),null==t?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}(e,s,i):"style"===t?function(e,t,n){const s=e.style,r=y(n);let o=!1;if(n&&!r){if(t)if(y(t))for(const e of t.split(";")){const t=e.slice(0,e.indexOf(":")).trim();null==n[t]&&Ur(s,t,"")}else for(const e in t)null==n[e]&&Ur(s,e,"");for(const e in n)"display"===e&&(o=!0),Ur(s,e,n[e])}else if(r){if(t!==n){const e=s[Fr];e&&(n+=";"+e),s.cssText=n,o=Mr.test(n)}}else t&&e.removeAttribute("style");$r in e&&(e[$r]=o?s.display:"",e[Dr]&&(s.display="none"))}(e,n,s):l(t)?a(t)||Zr(e,t,0,s,o):("."===t[0]?(t=t.slice(1),1):"^"===t[0]?(t=t.slice(1),0):function(e,t,n,s){if(s)return"innerHTML"===t||"textContent"===t||!!(t in e&&Yr(t)&&v(n));if("spellcheck"===t||"draggable"===t||"translate"===t||"autocorrect"===t)return!1;if("sandbox"===t&&"IFRAME"===e.tagName)return!1;if("form"===t)return!1;if("list"===t&&"INPUT"===e.tagName)return!1;if("type"===t&&"TEXTAREA"===e.tagName)return!1;if("width"===t||"height"===t){const t=e.tagName;if("IMG"===t||"VIDEO"===t||"CANVAS"===t||"SOURCE"===t)return!1}if(Yr(t)&&y(n))return!1;return t in e}(e,t,s,i))?(Br(e,t,s),e.tagName.includes("-")||"value"!==t&&"checked"!==t&&"selected"!==t||Wr(e,t,s,i,0,"value"!==t)):e._isVueCE&&(function(e,t){const n=e._def.props;if(!n)return!1;const s=O(t);return Array.isArray(n)?n.some(e=>O(e)===s):Object.keys(n).some(e=>O(e)===s)}(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!y(s)))?Br(e,O(t),s,0,t):("true-value"===t?e._trueValue=s:"false-value"===t&&(e._falseValue=s),Wr(e,t,s,i))}},jr);let fo;function mo(){return fo||(fo=Os(po))}const go=(...e)=>{mo().render(...e)},vo=(...e)=>{const t=mo().createApp(...e),{mount:n}=t;return t.mount=e=>{const s=function(e){if(y(e)){return document.querySelector(e)}return e}(e);if(!s)return;const r=t._component;v(r)||r.render||r.template||(r.template=s.innerHTML),1===s.nodeType&&(s.textContent="");const o=n(s,!1,function(e){if(e instanceof SVGElement)return"svg";if("function"==typeof MathMLElement&&e instanceof MathMLElement)return"mathml"}(s));return s instanceof Element&&(s.removeAttribute("v-cloak"),s.setAttribute("data-v-app","")),o},t};const yo=["value","placeholder"],_o=["value","placeholder"],bo={key:2,class:"errorlist"};t.render=function(e,t,n,s,r,o){return zs(),Ks("div",{class:H(["sf-field",{errors:o.fieldErrors.length}])},[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),o.isLong?(zs(),Ks("textarea",{key:0,class:"sf-input sf-textarea",rows:"3",value:n.modelValue,placeholder:n.schema.placeholder||"",onInput:t[0]||(t[0]=t=>e.$emit("update:modelValue",t.target.value))},null,40,yo)):(zs(),Ks("input",{key:1,type:"text",class:"sf-input",value:null!=n.modelValue?String(n.modelValue):"",placeholder:n.schema.placeholder||"",onInput:t[1]||(t[1]=t=>e.$emit("update:modelValue",t.target.value))},null,40,_o)),o.fieldErrors.length?(zs(),Ks("ul",bo,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},t.__file="src/editors/StringEditor.vue";var So={name:"NumberEditor",props:{schema:{type:Object,required:!0},modelValue:{default:0},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},isRequired(){if(this.path.length<2||!this.form)return!1;const e=this.path.slice(0,-1),t=this.path[this.path.length-1],n=this.form.getSchemaAtPath(e);return n&&Array.isArray(n.required)&&n.required.includes(t)},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",onInput(e){const t=e.target.value;""===t?this.$emit("update:modelValue",0):this.$emit("update:modelValue","integer"===this.schema.type?parseInt(t,10):parseFloat(t))}}};const xo=["step","min","max","value"],ko={key:0,class:"errorlist"};So.render=function(e,t,n,s,r,o){return zs(),Ks("div",{class:H(["sf-field",{errors:o.fieldErrors.length}])},[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),Ys("input",{type:"number",class:"sf-input",step:"integer"===n.schema.type?"1":"any",min:null!=n.schema.minimum?String(n.schema.minimum):void 0,max:null!=n.schema.maximum?String(n.schema.maximum):void 0,value:null!=n.modelValue?n.modelValue:"",onInput:t[0]||(t[0]=(...e)=>o.onInput&&o.onInput(...e))},null,40,xo),o.fieldErrors.length?(zs(),Ks("ul",ko,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},So.__file="src/editors/NumberEditor.vue";var Co={name:"BooleanEditor",props:{schema:{type:Object,required:!0},modelValue:{default:!1},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):""}};const Eo={class:"sf-checkbox-label"},wo=["checked"],Ao={key:0,class:"errorlist"};Co.render=function(e,t,n,s,r,o){return zs(),Ks("div",{class:H(["sf-field sf-field-boolean",{errors:o.fieldErrors.length}])},[Ys("label",Eo,[Ys("input",{type:"checkbox",class:"sf-checkbox",checked:!!n.modelValue,onChange:t[0]||(t[0]=t=>e.$emit("update:modelValue",t.target.checked))},null,40,wo),nr(" "+G(o.title),1)]),o.fieldErrors.length?(zs(),Ks("ul",Ao,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},Co.__file="src/editors/BooleanEditor.vue";var Vo={name:"SelectEditor",props:{schema:{type:Object,required:!0},modelValue:{default:""},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},isRequired(){if(this.path.length<2||!this.form)return!1;const e=this.path.slice(0,-1),t=this.path[this.path.length-1],n=this.form.getSchemaAtPath(e);return n&&Array.isArray(n.required)&&n.required.includes(t)},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):""}};const Oo=["value"],Po=["value"],jo={key:0,class:"errorlist"};Vo.render=function(e,t,n,s,r,o){return zs(),Ks("div",{class:H(["sf-field",{errors:o.fieldErrors.length}])},[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),Ys("select",{class:"sf-input sf-select",value:null!=n.modelValue?String(n.modelValue):"",onChange:t[0]||(t[0]=t=>e.$emit("update:modelValue",t.target.value))},[(zs(!0),Ks(Fs,null,Tn(n.schema.enum||[],e=>(zs(),Ks("option",{key:e,value:String(e)},G(e),9,Po))),128))],40,Oo),o.fieldErrors.length?(zs(),Ks("ul",jo,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},Vo.__file="src/editors/SelectEditor.vue";var Io={name:"HiddenEditor",props:{schema:{type:Object,required:!0},modelValue:{default:null},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],computed:{resolvedValue(){return"const"in this.schema?this.schema.const:this.schema.enum&&1===this.schema.enum.length?this.schema.enum[0]:this.modelValue}},mounted(){this.resolvedValue!==this.modelValue&&this.$emit("update:modelValue",this.resolvedValue)},methods:{getValue(){return this.resolvedValue}}};const $o={style:{display:"none"}};Io.render=function(e,t,n,s,r,o){return zs(),Ks("div",$o)},Io.__file="src/editors/HiddenEditor.vue";var Do={name:"SfIcon",props:{name:{type:String,required:!0},size:{type:[Number,String],default:14}}};const Ro=["width","height"],To={key:4,points:"6 9 12 15 18 9"},Fo={key:5,points:"18 15 12 9 6 15"};Do.render=function(e,t,n,s,r,o){return zs(),Ks("svg",{class:"sf-icon",width:n.size,height:n.size,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"},["plus"===n.name?(zs(),Ks(Fs,{key:0},[t[0]||(t[0]=Ys("line",{x1:"12",y1:"5",x2:"12",y2:"19"},null,-1)),t[1]||(t[1]=Ys("line",{x1:"5",y1:"12",x2:"19",y2:"12"},null,-1))],64)):"times"===n.name?(zs(),Ks(Fs,{key:1},[t[2]||(t[2]=Ys("line",{x1:"6",y1:"6",x2:"18",y2:"18"},null,-1)),t[3]||(t[3]=Ys("line",{x1:"6",y1:"18",x2:"18",y2:"6"},null,-1))],64)):"arrow-up"===n.name?(zs(),Ks(Fs,{key:2},[t[4]||(t[4]=Ys("line",{x1:"12",y1:"19",x2:"12",y2:"5"},null,-1)),t[5]||(t[5]=Ys("polyline",{points:"5 12 12 5 19 12"},null,-1))],64)):"arrow-down"===n.name?(zs(),Ks(Fs,{key:3},[t[6]||(t[6]=Ys("line",{x1:"12",y1:"5",x2:"12",y2:"19"},null,-1)),t[7]||(t[7]=Ys("polyline",{points:"19 12 12 19 5 12"},null,-1))],64)):"chevron-down"===n.name?(zs(),Ks("polyline",To)):"chevron-up"===n.name?(zs(),Ks("polyline",Fo)):"grip"===n.name?(zs(),Ks(Fs,{key:6},[t[8]||(t[8]=sr('<circle cx="9" cy="7" r="1" fill="currentColor" stroke="none"></circle><circle cx="15" cy="7" r="1" fill="currentColor" stroke="none"></circle><circle cx="9" cy="12" r="1" fill="currentColor" stroke="none"></circle><circle cx="15" cy="12" r="1" fill="currentColor" stroke="none"></circle><circle cx="9" cy="17" r="1" fill="currentColor" stroke="none"></circle><circle cx="15" cy="17" r="1" fill="currentColor" stroke="none"></circle>',6))],64)):rr("v-if",!0)],8,Ro)},Do.__file="src/editors/SfIcon.vue";var Mo={name:"ObjectEditor",beforeCreate(){this.$options.components||(this.$options.components={}),this.$options.components.SchemaEditor=Di,this.$options.components.SfIcon=Do},props:{schema:{type:Object,required:!0},modelValue:{default:()=>({})},path:{type:Array,default:()=>[]},form:{type:Object,required:!0}},emits:["update:modelValue"],data:()=>({collapsed:!1}),computed:{isRoot(){return 0===this.path.length},title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},summary(){const e=this.modelValue||{},t=[];for(const n of Object.keys(this.schema.properties||{})){if(t.length>=3)break;const s=e[n];null!=s&&""!==s&&"object"!=typeof s&&t.push(String(s))}return t.join(" · ")}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",collapse(){this.collapsed=!0},expand(){this.collapsed=!1},onChildChange(e,t){const n={...this.modelValue||{},[e]:t};this.$emit("update:modelValue",n)}}};const No={key:0,class:"sf-object sf-object-root"},Uo={class:"sf-object-fields"},Lo={class:"sf-object-title"},qo=["aria-label"],zo={class:"sf-object-title-text"},Wo={key:0,class:"sf-object-summary"},Bo={class:"sf-object-fields"};function Ho(e){if(null===e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(Ho);const t={};for(const n of Object.keys(e))t[n]=Ho(e[n]);return t}function Ko(e){if("default"in e)return Ho(e.default);if("object"===e.type){const t={};for(const[n,s]of Object.entries(e.properties||{}))"default"in s?t[n]=Ho(s.default):"string"===s.type?t[n]="":"integer"===s.type||"number"===s.type?t[n]=0:"boolean"===s.type?t[n]=!1:"array"===s.type&&(t[n]=[]);return t}return"array"===e.type?[]:"string"===e.type?"":"integer"===e.type||"number"===e.type?0:"boolean"!==e.type&&("relation"===e.type&&e.multiple?[]:null)}Mo.render=function(e,t,n,s,r,o){const i=In("SchemaEditor"),l=In("SfIcon");return o.isRoot?(zs(),Ks("div",No,[Ys("div",Uo,[(zs(!0),Ks(Fs,null,Tn(n.schema.properties||{},(e,t)=>(zs(),Zs(i,{key:t,schema:n.form.resolveSchema(e),"model-value":(n.modelValue||{})[t],path:[...n.path,t],form:n.form,"onUpdate:modelValue":e=>o.onChildChange(t,e)},null,8,["schema","model-value","path","form","onUpdate:modelValue"]))),128))])])):(zs(),Ks("fieldset",{key:1,class:H(["sf-object",{"sf-object-collapsed":r.collapsed}])},[Ys("legend",Lo,[Ys("button",{type:"button",class:"sf-collapse-btn","aria-label":r.collapsed?"Expand":"Collapse",onClick:t[0]||(t[0]=e=>r.collapsed=!r.collapsed)},[er(l,{name:r.collapsed?"chevron-down":"chevron-up",size:12},null,8,["name"])],8,qo),Ys("span",zo,G(o.title),1),r.collapsed&&o.summary?(zs(),Ks("span",Wo,G(o.summary),1)):rr("v-if",!0)]),Jt(Ys("div",Bo,[(zs(!0),Ks(Fs,null,Tn(n.schema.properties||{},(e,t)=>(zs(),Zs(i,{key:t,schema:n.form.resolveSchema(e),"model-value":(n.modelValue||{})[t],path:[...n.path,t],form:n.form,"onUpdate:modelValue":e=>o.onChildChange(t,e)},null,8,["schema","model-value","path","form","onUpdate:modelValue"]))),128))],512),[[Rr,!r.collapsed]])],2))},Mo.__file="src/editors/ObjectEditor.vue";let Zo=0;var Qo={name:"ArrayEditor",beforeCreate(){this.$options.components||(this.$options.components={}),this.$options.components.SchemaEditor=Di,this.$options.components.SfIcon=Do},props:{schema:{type:Object,required:!0},modelValue:{default:()=>[]},path:{type:Array,default:()=>[]},form:{type:Object,required:!0}},emits:["update:modelValue"],data(){return{items:(Array.isArray(this.modelValue)?this.modelValue:[]).map(e=>({_key:Zo++,value:e})),dragSourceIndex:null,dragOverIndex:null,allCollapsed:!1}},computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},itemSchema(){return this.form.resolveSchema(this.schema.items||{})},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",addItem(){const e=Ko(this.itemSchema);this.items.push({_key:Zo++,value:e}),this.emitValue()},removeItem(e){this.items.splice(e,1),this.emitValue()},moveItem(e,t){const n=e+t;if(n<0||n>=this.items.length)return;const s=this.items[e];this.items.splice(e,1,this.items[n]),this.items.splice(n,1,s),this.emitValue()},onItemChange(e,t){this.items[e].value=t,this.emitValue()},onDragStart(e,t){this.dragSourceIndex=e,t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",String(e))},onDragOver(e){null!==this.dragSourceIndex&&e!==this.dragSourceIndex&&(this.dragOverIndex=e)},onDragLeave(e){this.dragOverIndex===e&&(this.dragOverIndex=null)},onDrop(e){if(null===this.dragSourceIndex||this.dragSourceIndex===e)return;const t=this.items.splice(this.dragSourceIndex,1)[0];this.items.splice(e,0,t),this.dragSourceIndex=null,this.dragOverIndex=null,this.emitValue()},onDragEnd(){this.dragSourceIndex=null,this.dragOverIndex=null},toggleCollapseAll(){this.allCollapsed=!this.allCollapsed;const e=this.$refs.itemEditors;if(!e)return;const t=Array.isArray(e)?e:[e];this.allCollapsed?t.forEach(e=>e?.collapseAll?.()):t.forEach(e=>e?.expandAll?.())},emitValue(){this.$emit("update:modelValue",this.items.map(e=>e.value))}}};const Jo={class:"sf-array-header"},Go={class:"sf-label"},Xo={class:"sf-array-count"},Yo=["title"],ei={class:"sf-array-items"},ti=["onDragstart","onDragover","onDragleave","onDrop"],ni={class:"sf-array-item-header"},si={class:"sf-array-item-left"},ri={class:"sf-drag-handle",title:"Drag to reorder"},oi={class:"sf-array-item-index"},ii={class:"sf-array-item-actions"},li=["onClick"],ai=["onClick"],ci=["onClick"],ui=["onDrop"],hi={key:0,class:"errorlist"};Qo.render=function(e,t,n,s,r,o){const i=In("SfIcon"),l=In("SchemaEditor");return zs(),Ks("div",{class:H(["sf-array",{errors:o.fieldErrors.length}])},[Ys("div",Jo,[Ys("span",Go,G(o.title),1),Ys("span",Xo,G(r.items.length),1),Ys("button",{type:"button",class:"sf-btn sf-btn-add",onClick:t[0]||(t[0]=e=>o.addItem())},[er(i,{name:"plus"}),t[4]||(t[4]=nr(" Add ",-1))]),r.items.length?(zs(),Ks("span",{key:0,class:"sf-array-collapse-toggle",title:r.allCollapsed?"Expand all":"Collapse all",onClick:t[1]||(t[1]=(...e)=>o.toggleCollapseAll&&o.toggleCollapseAll(...e))},[er(i,{name:r.allCollapsed?"chevron-down":"chevron-up"},null,8,["name"])],8,Yo)):rr("v-if",!0)]),Ys("div",ei,[(zs(!0),Ks(Fs,null,Tn(r.items,(e,s)=>(zs(),Ks("div",{key:e._key,class:H(["sf-array-item",{"sf-drag-over":r.dragOverIndex===s,"sf-dragging":r.dragSourceIndex===s}]),draggable:"true",onDragstart:e=>o.onDragStart(s,e),onDragover:ho(e=>o.onDragOver(s),["prevent"]),onDragleave:e=>o.onDragLeave(s),onDrop:ho(e=>o.onDrop(s),["prevent"]),onDragend:t[3]||(t[3]=(...e)=>o.onDragEnd&&o.onDragEnd(...e))},[Ys("div",ni,[Ys("div",si,[Ys("span",ri,[er(i,{name:"grip"})]),Ys("span",oi,"#"+G(s+1),1)]),Ys("div",ii,[s>0?(zs(),Ks("button",{key:0,type:"button",class:"sf-btn sf-btn-sm",onClick:e=>o.moveItem(s,-1)},[er(i,{name:"arrow-up"})],8,li)):rr("v-if",!0),s<r.items.length-1?(zs(),Ks("button",{key:1,type:"button",class:"sf-btn sf-btn-sm",onClick:e=>o.moveItem(s,1)},[er(i,{name:"arrow-down"})],8,ai)):rr("v-if",!0),Ys("button",{type:"button",class:"sf-btn sf-btn-sm sf-btn-danger",onClick:e=>o.removeItem(s)},[er(i,{name:"times"})],8,ci)])]),Ys("div",{class:"sf-array-item-body",onDragover:t[2]||(t[2]=ho(()=>{},["prevent"])),onDrop:ho(e=>o.onDrop(s),["prevent"])},[er(l,{ref_for:!0,ref:"itemEditors",schema:o.itemSchema,"model-value":e.value,path:[...n.path,String(s)],form:n.form,"onUpdate:modelValue":e=>o.onItemChange(s,e)},null,8,["schema","model-value","path","form","onUpdate:modelValue"])],40,ui)],42,ti))),128))]),o.fieldErrors.length?(zs(),Ks("ul",hi,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},Qo.__file="src/editors/ArrayEditor.vue";var di={name:"NullableEditor",beforeCreate(){this.$options.components||(this.$options.components={}),this.$options.components.SchemaEditor=Di,this.$options.components.SfIcon=Do},props:{schema:{type:Object,required:!0},modelValue:{default:null},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],data(){return{isNull:null===this.modelValue||void 0===this.modelValue}},computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},isRequired(){if(this.path.length<2||!this.form)return!1;const e=this.path.slice(0,-1),t=this.path[this.path.length-1],n=this.form.getSchemaAtPath(e);return n&&Array.isArray(n.required)&&n.required.includes(t)},innerSchema(){const e={...this.schema};return delete e._nullable,e},toggleClass(){return this.isNull?"sf-btn sf-btn-sm sf-btn-add":"sf-btn sf-btn-sm sf-btn-danger"},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]}},watch:{modelValue(e){this.isNull=null==e}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",toggle(){this.isNull?(this.isNull=!1,this.$emit("update:modelValue",Ko(this.innerSchema))):(this.isNull=!0,this.$emit("update:modelValue",null))}}};const pi={class:"sf-nullable-header"},fi={class:"sf-nullable-body"},mi={key:0,class:"errorlist"};di.render=function(e,t,n,s,r,o){const i=In("SfIcon"),l=In("SchemaEditor");return zs(),Ks("div",{class:H(["sf-nullable",{errors:o.fieldErrors.length}])},[Ys("div",pi,[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),Ys("button",{type:"button",class:H(o.toggleClass),onClick:t[0]||(t[0]=(...e)=>o.toggle&&o.toggle(...e))},[r.isNull?(zs(),Ks(Fs,{key:0},[er(i,{name:"plus"}),t[2]||(t[2]=nr(" Add ",-1))],64)):(zs(),Ks(Fs,{key:1},[er(i,{name:"times"}),t[3]||(t[3]=nr(" Remove ",-1))],64))],2)]),Ys("div",fi,[r.isNull?rr("v-if",!0):(zs(),Zs(l,{key:0,schema:o.innerSchema,"model-value":n.modelValue,path:n.path,form:n.form,"onUpdate:modelValue":t[1]||(t[1]=t=>e.$emit("update:modelValue",t))},null,8,["schema","model-value","path","form"]))]),o.fieldErrors.length?(zs(),Ks("ul",mi,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},di.__file="src/editors/NullableEditor.vue";var gi={name:"UnionEditor",beforeCreate(){this.$options.components||(this.$options.components={}),this.$options.components.SchemaEditor=Di},props:{schema:{type:Object,required:!0},modelValue:{default:null},path:{type:Array,default:()=>[]},form:{type:Object,required:!0}},emits:["update:modelValue"],data(){const e=this.schema.discriminator.propertyName,t=this.schema.discriminator.mapping;return{discriminatorProp:e,mapping:t,currentType:this.modelValue?this.modelValue[e]:Object.keys(t)[0]}},computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},typeKeys(){return Object.keys(this.mapping)},currentSchema(){const e=this.mapping[this.currentType];return this.form.resolveSchema({$ref:e})},innerValue(){if(this.modelValue&&this.modelValue[this.discriminatorProp]===this.currentType)return this.modelValue;const e=Ko(this.currentSchema);return e[this.discriminatorProp]=this.currentType,e}},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",onTypeChange(e){this.currentType=e.target.value;const t=Ko(this.currentSchema);t[this.discriminatorProp]=this.currentType,this.$emit("update:modelValue",t)},onInnerChange(e){e&&(e[this.discriminatorProp]=this.currentType),this.$emit("update:modelValue",e)}}};const vi={class:"sf-union"},yi={class:"sf-field"},_i={class:"sf-label"},bi=["value"],Si=["value"],xi={class:"sf-union-body"};gi.render=function(e,t,n,s,r,o){const i=In("SchemaEditor");return zs(),Ks("div",vi,[Ys("div",yi,[Ys("label",_i,G(o.title),1),Ys("select",{class:"sf-input sf-select",value:r.currentType,onChange:t[0]||(t[0]=(...e)=>o.onTypeChange&&o.onTypeChange(...e))},[(zs(!0),Ks(Fs,null,Tn(o.typeKeys,e=>(zs(),Ks("option",{key:e,value:e},G(o.humanize(e)),9,Si))),128))],40,bi)]),Ys("div",xi,[(zs(),Zs(i,{key:r.currentType,schema:o.currentSchema,"model-value":o.innerValue,path:n.path,form:n.form,"onUpdate:modelValue":o.onInnerChange},null,8,["schema","model-value","path","form","onUpdate:modelValue"]))])])},gi.__file="src/editors/UnionEditor.vue";var ki={name:"RelationEditor",components:{SfIcon:Do},props:{schema:{type:Object,required:!0},modelValue:{default:null},path:{type:Array,default:()=>[]},form:{type:Object,default:null}},emits:["update:modelValue"],data(){const e=!!this.schema.multiple,t=this.modelValue;let n;return n=e?Array.isArray(t)?[...t]:[]:t?[t]:[],{isMultiple:e,allowClear:this.schema.options?.select2?.allowClear??!0,placeholder:this.schema.options?.select2?.placeholder||"Search...",searchUrl:this.schema.options?.select2?.ajax?.url||"",selected:n,dropdownVisible:!1,searchResults:[],currentPage:1,hasMore:!1,loading:!1,highlightIndex:-1,searchQuery:""}},computed:{title(){return this.schema.title||this.humanize(this.path[this.path.length-1])||""},isRequired(){if(this.path.length<2||!this.form)return!1;const e=this.path.slice(0,-1),t=this.path[this.path.length-1],n=this.form.getSchemaAtPath(e);return n&&Array.isArray(n.required)&&n.required.includes(t)},showSearch(){return!(!this.isMultiple&&this.selected.length>0)},fieldErrors(){return this.form&&this.form.getErrorsForPath?this.form.getErrorsForPath(this.path):[]},filteredResults(){const e=new Set(this.selected.map(e=>this.itemKey(e)));return this.searchResults.filter(t=>!e.has(this.itemKey(t)))}},created(){this._doSearch=function(e,t){let n;return function(...s){clearTimeout(n),n=setTimeout(()=>e.apply(this,s),t)}}(e=>this.fetchResults(e,1),300),this._onDocClick=e=>{this.$refs.root&&!this.$refs.root.contains(e.target)&&this.closeDropdown()}},mounted(){document.addEventListener("click",this._onDocClick)},beforeUnmount(){document.removeEventListener("click",this._onDocClick)},methods:{humanize:e=>e?e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()):"",getDisplayName(e){if(!e)return"";for(const t of["__str__","name","title","label"])if(e[t])return String(e[t]);return`#${e.id||"?"}`},itemKey:e=>`${e.id}-${e.model||""}`,onSearchInput(){this._doSearch(this.searchQuery)},openDropdown(){this.dropdownVisible||(this.dropdownVisible=!0,this.fetchResults(this.searchQuery,1))},closeDropdown(){this.dropdownVisible=!1,this.highlightIndex=-1},async fetchResults(e,t){if(this.searchUrl){this.loading=!0,this.currentPage=t;try{const n=new URL(this.searchUrl,window.location.origin);n.searchParams.set("_q",e||""),n.searchParams.set("page",String(t));const s=await fetch(n,{credentials:"same-origin"});if(!s.ok)return;const r=await s.json();this.searchResults=1===t?r.items||[]:this.searchResults.concat(r.items||[]),this.hasMore=r.more}finally{this.loading=!1}}},handleKeyDown(e){this.filteredResults.length&&("ArrowDown"===e.key?(e.preventDefault(),this.highlightIndex=Math.min(this.highlightIndex+1,this.filteredResults.length-1)):"ArrowUp"===e.key?(e.preventDefault(),this.highlightIndex=Math.max(this.highlightIndex-1,0)):"Enter"===e.key?(e.preventDefault(),this.highlightIndex>=0&&this.highlightIndex<this.filteredResults.length&&this.selectItem(this.filteredResults[this.highlightIndex])):"Escape"===e.key&&this.closeDropdown())},selectItem(e){this.isMultiple?this.selected.push(e):this.selected=[e],this.searchQuery="",this.highlightIndex=-1,this.closeDropdown(),this.emitValue()},removeItem(e){this.selected=this.selected.filter(t=>!(t.id===e.id&&(t.model||"")===(e.model||""))),this.emitValue()},emitValue(){this.isMultiple?this.$emit("update:modelValue",[...this.selected]):this.$emit("update:modelValue",this.selected[0]||null)}}};const Ci={class:"sf-relation-wrapper"},Ei={key:0,class:"sf-relation-selected"},wi={class:"sf-relation-tag-text"},Ai=["onClick"],Vi={class:"sf-relation-search"},Oi=["placeholder"],Pi={class:"sf-relation-dropdown"},ji={key:0,class:"sf-relation-dropdown-empty"},Ii=["onClick"],$i={key:0,class:"errorlist"};ki.render=function(e,t,n,s,r,o){const i=In("SfIcon");return zs(),Ks("div",{class:H(["sf-field sf-relation",{errors:o.fieldErrors.length}]),ref:"root"},[Ys("label",{class:H(["sf-label",{required:o.isRequired}])},G(o.title),3),Ys("div",Ci,[rr(" Selected items "),r.selected.length?(zs(),Ks("div",Ei,[(zs(!0),Ks(Fs,null,Tn(r.selected,e=>(zs(),Ks("div",{key:o.itemKey(e),class:"sf-relation-tag"},[Ys("span",wi,G(o.getDisplayName(e)),1),r.isMultiple||r.allowClear?(zs(),Ks("button",{key:0,type:"button",class:"sf-relation-tag-remove",onClick:ho(t=>o.removeItem(e),["stop"])},[er(i,{name:"times"})],8,Ai)):rr("v-if",!0)]))),128))])):rr("v-if",!0),rr(" Search box "),Jt(Ys("div",Vi,[Jt(Ys("input",{ref:"searchInput",type:"text",class:"sf-input sf-relation-input",placeholder:r.placeholder,autocomplete:"off","onUpdate:modelValue":t[0]||(t[0]=e=>r.searchQuery=e),onInput:t[1]||(t[1]=(...e)=>o.onSearchInput&&o.onSearchInput(...e)),onFocus:t[2]||(t[2]=(...e)=>o.openDropdown&&o.openDropdown(...e)),onKeydown:t[3]||(t[3]=(...e)=>o.handleKeyDown&&o.handleKeyDown(...e))},null,40,Oi),[[ao,r.searchQuery]]),rr(" Dropdown "),Jt(Ys("div",Pi,[0!==o.filteredResults.length||r.loading?rr("v-if",!0):(zs(),Ks("div",ji," No results found ")),(zs(!0),Ks(Fs,null,Tn(o.filteredResults,(e,t)=>(zs(),Ks("div",{key:o.itemKey(e),class:H(["sf-relation-dropdown-item",{highlighted:t===r.highlightIndex}]),onClick:t=>o.selectItem(e)},G(o.getDisplayName(e)),11,Ii))),128)),r.hasMore?(zs(),Ks("div",{key:1,class:"sf-relation-dropdown-more",onClick:t[4]||(t[4]=e=>o.fetchResults(r.searchQuery,r.currentPage+1))}," Load more... ")):rr("v-if",!0)],512),[[Rr,r.dropdownVisible]])],512),[[Rr,o.showSearch]])]),o.fieldErrors.length?(zs(),Ks("ul",$i,[(zs(!0),Ks(Fs,null,Tn(o.fieldErrors,(e,t)=>(zs(),Ks("li",{key:t},G(e),1))),128))])):rr("v-if",!0)],2)},ki.__file="src/editors/RelationEditor.vue";var Di={name:"SchemaEditor",components:{StringEditor:t,NumberEditor:So,BooleanEditor:Co,SelectEditor:Vo,HiddenEditor:Io,ObjectEditor:Mo,ArrayEditor:Qo,NullableEditor:di,UnionEditor:gi,RelationEditor:ki},props:{schema:{type:Object,required:!0},modelValue:{default:void 0},path:{type:Array,default:()=>[]},form:{type:Object,required:!0}},emits:["update:modelValue"],methods:{collapseAll(){const e=this.$refs.editor;e?.collapse&&e.collapse(),e?.collapseAll&&e.collapseAll()},expandAll(){const e=this.$refs.editor;e?.expand&&e.expand(),e?.expandAll&&e.expandAll()}},computed:{editorComponent(){const e=this.schema;return this.path.length>12?"StringEditor":"relation"===e.type?"RelationEditor":e.oneOf&&e.discriminator?"UnionEditor":"const"in e||e.enum&&1===e.enum.length&&"string"===e.type?"HiddenEditor":e._nullable?"NullableEditor":"object"===e.type&&e.properties?"ObjectEditor":"array"===e.type?"ArrayEditor":e.enum?"SelectEditor":"boolean"===e.type?"BooleanEditor":"number"===e.type||"integer"===e.type?"NumberEditor":"StringEditor"}}};Di.render=function(e,t,n,s,r,o){return zs(),Zs((i=o.editorComponent,y(i)?Dn(jn,i,!1)||i:i||$n),{ref:"editor",schema:n.schema,"model-value":n.modelValue,path:n.path,form:n.form,"onUpdate:modelValue":t[0]||(t[0]=t=>e.$emit("update:modelValue",t))},null,8,["schema","model-value","path","form"]);var i},Di.__file="src/editors/SchemaEditor.vue";var Ri={name:"SchemaForm",components:{SchemaEditor:Di},props:{schema:{type:[Object,String],default:()=>({})},initialData:{default:void 0},errors:{type:Object,default:()=>({})}},emits:["change"],expose:["getValue"],data(){const e="string"==typeof this.schema?JSON.parse(this.schema):this.schema;return{rootSchema:e,defs:e.$defs||e.definitions||{},currentValue:null!=this.initialData?Ho(this.initialData):void 0}},computed:{resolvedSchema(){return this.resolveSchema(this.rootSchema)},formApi(){return{resolveSchema:e=>this.resolveSchema(e),getSchemaAtPath:e=>this.getSchemaAtPath(e),getErrorsForPath:e=>this.getErrorsForPath(e)}}},watch:{schema:{handler(e){const t="string"==typeof e?JSON.parse(e):e;this.rootSchema=t,this.defs=t.$defs||t.definitions||{}},deep:!0},initialData:{handler(e){this.currentValue=null!=e?Ho(e):void 0},deep:!0}},methods:{resolveSchema(e){if(!e)return{type:"string"};if(e.$ref){const t=e.$ref.replace(/^#\/\$defs\//,"").replace(/^#\/definitions\//,""),n=this.defs[t];if(!n)return{type:"string",title:t};const{$ref:s,...r}=e;return{...this.resolveSchema(n),...r}}if(e.anyOf){const t=e.anyOf.filter(e=>"null"!==e.type);if(e.anyOf.some(e=>"null"===e.type)&&1===t.length){const n=this.resolveSchema(t[0]);return{...n,_nullable:!0,title:e.title||n.title,default:"default"in e?e.default:null}}if(t.length>=1)return this.resolveSchema(t[0])}if(e.oneOf&&e.discriminator)return e;if(e.oneOf){const t=e.oneOf.filter(e=>"null"!==e.type);if(e.oneOf.some(e=>"null"===e.type)&&1===t.length){const n=this.resolveSchema(t[0]);return{...n,_nullable:!0,title:e.title||n.title,default:"default"in e?e.default:null}}if(t.length>=1)return this.resolveSchema(t[0])}return e},getSchemaAtPath(e){let t=this.resolveSchema(this.rootSchema);for(const n of e){if(!t)return null;if(t.properties&&t.properties[n])t=this.resolveSchema(t.properties[n]);else{if(!t.items)return null;t=this.resolveSchema(t.items)}}return t},onValueChange(e){this.currentValue=e,this.$emit("change",e)},getErrorsForPath(e){if(!this.errors||"object"!=typeof this.errors)return[];const t=e.join(".");return this.errors[t]||[]},getValue(){return this.currentValue}}};const Ti={class:"structured-field-editor"};Ri.render=function(e,t,n,s,r,o){const i=In("SchemaEditor");return zs(),Ks("div",Ti,[o.resolvedSchema?(zs(),Zs(i,{key:0,schema:o.resolvedSchema,"model-value":r.currentValue,path:[],form:o.formApi,"onUpdate:modelValue":o.onValueChange},null,8,["schema","model-value","form","onUpdate:modelValue"])):rr("v-if",!0)])},Ri.__file="src/SchemaForm.vue";const Fi=function(e,t,n){let s=function(e,t){return v(e)?(()=>c({name:e.name},t,{setup:e}))():e}(e,t);C(s)&&(s=c({},s,t));class r extends no{constructor(e){super(s,e,n)}}return r.def=s,r}({...Ri,shadowRoot:!1});return e.ArrayEditor=Qo,e.BooleanEditor=Co,e.HiddenEditor=Io,e.NullableEditor=di,e.NumberEditor=So,e.ObjectEditor=Mo,e.RelationEditor=ki,e.SchemaEditor=Di,e.SchemaForm=Ri,e.SchemaFormElement=Fi,e.SelectEditor=Vo,e.StringEditor=t,e.UnionEditor=gi,e.registerCustomElement=function(e="schema-form"){customElements.get(e)||customElements.define(e,Fi)},e}({});
|
|
24
24
|
//# sourceMappingURL=structured-widget-editor.js.map
|