UNPKG

amis-model-design

Version:

amis模型设计器

6 lines (5 loc) 580 kB
/** * amis-model-design v0.0.13 * Copyright 2018-2025 @fex */ import e from"moment";import t from"lodash/omitBy";import i from"lodash/isPlainObject";import n from"lodash/omit";import a from"lodash/isEqual";import{isExpression as r,guid as l,toast as o,isObject as s,normalizeApi as d,JSONValueMap as u,openContextMenus as c,TooltipWrapper as p,Icon as m,registerIcon as f,autobind as y,render as h,Checkbox as b,InputBox as v,Button as g}from"amis";import{toJS as k,isObservable as x,action as F,computed as w,reaction as S,observable as T}from"mobx";import E from"lodash/get";import O from"lodash/pick";import A from"lodash/sortBy";import C from"lodash/cloneDeep";import M from"lodash/uniq";import D from"lodash/isEmpty";import*as I from"react";import N from"react";import B from"lodash/findIndex";import{addApiRequestAdaptor as L}from"amis-core";import K from"lodash/last";import $ from"lodash/xor";import R from"lodash/debounce";import V from"lodash/uniqBy";import P from"lodash/uniqWith";import j from"hoist-non-react-statics";import q from"lodash/isObjectLike";import _ from"classnames";import z from"qs";import{parse as U}from"amis-formula";import{i18n as Q}from"i18n-runtime";import{findDOMNode as H}from"react-dom";import G from"sortablejs";var Y=["id","name","key","type","length","isRequired","isNullable","isBuiltIn","relationId","relation","isPrimayKey","isPrimayKey","isGenerated","isForeignKey","isUnique","modified","isArray","defaultValue","comment","isCreateDate","isUpdateDate","isDeleteDate","isOrderNumber","isTreeParentId","isTreePath","isTenantId","referencedColumnName","validations","validationErrors","parentId","parentKey","parentModelKey","parentName"],W=["id","relationMode","fieldId","field","key","target","targetName","targetKey","inverseSide","modified","isNullable","withCustomProps","joinColumnAtTarget","thirdModelId","foreignKey","joinTable"];function J(e,t,i,n,a){var r={};return Object.keys(n).forEach((function(e){r[e]=n[e]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=i.slice().reverse().reduce((function(i,n){return n(e,t,i)||i}),r),a&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(a):void 0,r.initializer=void 0),void 0===r.initializer?(Object.defineProperty(e,t,r),null):r}function Z(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i<t;i++)n[i]=e[i];return n}function X(e,t,i,n,a,r,l){try{var o=e[r](l),s=o.value}catch(e){return void i(e)}o.done?t(s):Promise.resolve(s).then(n,a)}function ee(e){return function(){var t=this,i=arguments;return new Promise((function(n,a){var r=e.apply(t,i);function l(e){X(r,n,a,l,o,"next",e)}function o(e){X(r,n,a,l,o,"throw",e)}l(void 0)}))}}function te(e,t,i){return t=de(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,pe()?Reflect.construct(t,i||[],de(e).constructor):t.apply(e,i))}function ie(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ne(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,xe(n.key),n)}}function ae(e,t,i){return t&&ne(e.prototype,t),i&&ne(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function re(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=we(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,l=!0,o=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return l=e.done,e},e:function(e){o=!0,r=e},f:function(){try{l||null==i.return||i.return()}finally{if(o)throw r}}}}function le(e,t,i){return(t=xe(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function oe(){return oe=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)({}).hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},oe.apply(null,arguments)}function se(){return se="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,i){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=de(e)););return e}(e,t);if(n){var a=Object.getOwnPropertyDescriptor(n,t);return a.get?a.get.call(arguments.length<3?e:i):a.value}},se.apply(null,arguments)}function de(e){return de=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},de(e)}function ue(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&be(e,t)}function ce(e,t,i,n){i&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(n):void 0})}function pe(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(pe=function(){return!!e})()}function me(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function fe(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?me(Object(i),!0).forEach((function(t){le(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):me(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function ye(e,t){if(null==e)return{};var i,n,a=function(e,t){if(null==e)return{};var i={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;i[n]=e[n]}return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n<r.length;n++)i=r[n],-1===t.indexOf(i)&&{}.propertyIsEnumerable.call(e,i)&&(a[i]=e[i])}return a}function he(){he=function(){return t};var e,t={},i=Object.prototype,n=i.hasOwnProperty,a=Object.defineProperty||function(e,t,i){e[t]=i.value},r="function"==typeof Symbol?Symbol:{},l=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",s=r.toStringTag||"@@toStringTag";function d(e,t,i){return Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{d({},"")}catch(e){d=function(e,t,i){return e[t]=i}}function u(e,t,i,n){var r=t&&t.prototype instanceof b?t:b,l=Object.create(r.prototype),o=new M(n||[]);return a(l,"_invoke",{value:E(e,i,o)}),l}function c(e,t,i){try{return{type:"normal",arg:e.call(t,i)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var p="suspendedStart",m="suspendedYield",f="executing",y="completed",h={};function b(){}function v(){}function g(){}var k={};d(k,l,(function(){return this}));var x=Object.getPrototypeOf,F=x&&x(x(D([])));F&&F!==i&&n.call(F,l)&&(k=F);var w=g.prototype=b.prototype=Object.create(k);function S(e){["next","throw","return"].forEach((function(t){d(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,t){function i(a,r,l,o){var s=c(e[a],e,r);if("throw"!==s.type){var d=s.arg,u=d.value;return u&&"object"==typeof u&&n.call(u,"__await")?t.resolve(u.__await).then((function(e){i("next",e,l,o)}),(function(e){i("throw",e,l,o)})):t.resolve(u).then((function(e){d.value=e,l(d)}),(function(e){return i("throw",e,l,o)}))}o(s.arg)}var r;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){i(e,n,t,a)}))}return r=r?r.then(a,a):a()}})}function E(t,i,n){var a=p;return function(r,l){if(a===f)throw Error("Generator is already running");if(a===y){if("throw"===r)throw l;return{value:e,done:!0}}for(n.method=r,n.arg=l;;){var o=n.delegate;if(o){var s=O(o,n);if(s){if(s===h)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===p)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=f;var d=c(t,i,n);if("normal"===d.type){if(a=n.done?y:m,d.arg===h)continue;return{value:d.arg,done:n.done}}"throw"===d.type&&(a=y,n.method="throw",n.arg=d.arg)}}}function O(t,i){var n=i.method,a=t.iterator[n];if(a===e)return i.delegate=null,"throw"===n&&t.iterator.return&&(i.method="return",i.arg=e,O(t,i),"throw"===i.method)||"return"!==n&&(i.method="throw",i.arg=new TypeError("The iterator does not provide a '"+n+"' method")),h;var r=c(a,t.iterator,i.arg);if("throw"===r.type)return i.method="throw",i.arg=r.arg,i.delegate=null,h;var l=r.arg;return l?l.done?(i[t.resultName]=l.value,i.next=t.nextLoc,"return"!==i.method&&(i.method="next",i.arg=e),i.delegate=null,h):l:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,h)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function M(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function D(t){if(t||""===t){var i=t[l];if(i)return i.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,r=function i(){for(;++a<t.length;)if(n.call(t,a))return i.value=t[a],i.done=!1,i;return i.value=e,i.done=!0,i};return r.next=r}}throw new TypeError(typeof t+" is not iterable")}return v.prototype=g,a(w,"constructor",{value:g,configurable:!0}),a(g,"constructor",{value:v,configurable:!0}),v.displayName=d(g,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,d(e,s,"GeneratorFunction")),e.prototype=Object.create(w),e},t.awrap=function(e){return{__await:e}},S(T.prototype),d(T.prototype,o,(function(){return this})),t.AsyncIterator=T,t.async=function(e,i,n,a,r){void 0===r&&(r=Promise);var l=new T(u(e,i,n,a),r);return t.isGeneratorFunction(i)?l:l.next().then((function(e){return e.done?e.value:l.next()}))},S(w),d(w,s,"Generator"),d(w,l,(function(){return this})),d(w,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),i=[];for(var n in t)i.push(n);return i.reverse(),function e(){for(;i.length;){var n=i.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=D,M.prototype={constructor:M,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(C),!t)for(var i in this)"t"===i.charAt(0)&&n.call(this,i)&&!isNaN(+i.slice(1))&&(this[i]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var i=this;function a(n,a){return o.type="throw",o.arg=t,i.next=n,a&&(i.method="next",i.arg=e),!!a}for(var r=this.tryEntries.length-1;r>=0;--r){var l=this.tryEntries[r],o=l.completion;if("root"===l.tryLoc)return a("end");if(l.tryLoc<=this.prev){var s=n.call(l,"catchLoc"),d=n.call(l,"finallyLoc");if(s&&d){if(this.prev<l.catchLoc)return a(l.catchLoc,!0);if(this.prev<l.finallyLoc)return a(l.finallyLoc)}else if(s){if(this.prev<l.catchLoc)return a(l.catchLoc,!0)}else{if(!d)throw Error("try statement without catch or finally");if(this.prev<l.finallyLoc)return a(l.finallyLoc)}}}},abrupt:function(e,t){for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var r=a;break}}r&&("break"===e||"continue"===e)&&r.tryLoc<=t&&t<=r.finallyLoc&&(r=null);var l=r?r.completion:{};return l.type=e,l.arg=t,r?(this.method="next",this.next=r.finallyLoc,h):this.complete(l)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.finallyLoc===e)return this.complete(i.completion,i.afterLoc),C(i),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.tryLoc===e){var n=i.completion;if("throw"===n.type){var a=n.arg;C(i)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,i,n){return this.delegate={iterator:D(t),resultName:i,nextLoc:n},"next"===this.method&&(this.arg=e),h}},t}function be(e,t){return be=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},be(e,t)}function ve(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var n,a,r,l,o=[],s=!0,d=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;s=!1}else for(;!(s=(n=r.call(i)).done)&&(o.push(n.value),o.length!==t);s=!0);}catch(e){d=!0,a=e}finally{try{if(!s&&null!=i.return&&(l=i.return(),Object(l)!==l))return}finally{if(d)throw a}}return o}}(e,t)||we(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ge(e,t,i,n){var a=se(de(1&n?e.prototype:e),t,i);return 2&n&&"function"==typeof a?function(e){return a.apply(i,e)}:a}function ke(e){return function(e){if(Array.isArray(e))return Z(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||we(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function xe(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function Fe(e){return Fe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Fe(e)}function we(e,t){if(e){if("string"==typeof e)return Z(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Z(e,t):void 0}}var Se=function(e,t){return"string"==typeof(e=fe({},e)).dbType&&(e.dbType=e.dbType.toUpperCase()),e.id||(e.id=Ve()),void 0!==e.isPrimayKey&&void 0===e.isPrimaryKey&&(e.isPrimaryKey=e.isPrimayKey,delete e.isPrimayKey),e},Te=function(e){return k(e,{recurseEverything:!0})};function Ee(e){return"".concat(e.slice(0,1).toLowerCase()).concat(e.slice(1))}function Oe(e,t){return(i=e)&&i.relationMode&&!i.type?t.fields.find((function(t){return"relation"===t.type&&t.relationId===e.id})):e;var i}function Ae(e,t,i){return i.map((function(i){return fe(fe({},i),{},{parentId:t.id,parentKey:t.key,parentName:e.name,parentModelKey:t.targetKey,parentModelName:t.targetName})}))}function Ce(e){return e?e.replace(/\{\{(.*?)\}\}/g,(function(e,t){return"${".concat(t,"}")})):e}function Me(e,t){e&&e.type&&(t(e),Object.keys(e).forEach((function(i){var n=e[i];Array.isArray(n)?n.forEach((function(e){return Me(e,t)})):Me(n,t)})))}function De(e,t){try{var i=U(e,{evalMode:!1}),n=[];Me(i,(function(e){"variable"===e.type&&n.push(e)})),e=n.reduceRight((function(e,i){return e.substring(0,i.start.index)+t+e.substring(i.start.index)}),e)}catch(e){console.warn(e)}return e}function Ie(e,t){return fe(fe({},t?n(t,W):null),n(e,Y))}function Ne(e){return fe(fe({},Ie(e,e.relation)),e)}function Be(e,t,n){for(var a,r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],l=[{value:e,key:"",host:null}],o=function(){var e=l.shift(),a=e.value,o=e.key,s=e.host;return null!=n&&n(a,o,s)?0:t(a,o,s)?{v:a}:void(Array.isArray(a)?l[r?"unshift":"push"].apply(l,ke(a.map((function(e,t){return{value:e,key:t,host:a}})))):i(a)&&l[r?"unshift":"push"].apply(l,ke(Object.keys(a).map((function(e){return{value:a[e],key:e,host:a}})))))};l.length;)if(0!==(a=o())&&a)return a.v}function Le(e,t){if(void 0!==t){var i="function"==typeof t?t:function(e){return e===t},n=e.findIndex(i);return~n?e.splice(n,1)[0]:void 0}}function Ke(e,t,i){if(!i)return e.find(t);for(var n=i,a=e.length;n<a;n++)if(t(e[n],n,e))return e[n]}function $e(e,t,i){var n=e?Object.create(e,fe(fe({},i),{},{__super:{value:e,writable:!1,enumerable:!1}})):Object.create(Object.prototype,i);return t&&Object.keys(t).forEach((function(e){return n[e]=t[e]})),n}var Re=function(){return("00000000000000000"+(0x10000000000000000*Math.random()).toString(16)).slice(-16)},Ve=function(){var e=Re(),t=Re();return e.slice(0,8)+"-"+e.slice(8,12)+"-4"+e.slice(13)+"-a"+t.slice(1,4)+"-"+t.slice(4)},Pe=/(?:^|raw\:)(get|post|put|delete|patch|options|head|jsonp|js):/i;function je(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"get";if("string"==typeof e){var i=Pe.test(e)?RegExp.$1:"";i&&(e=e.replace(i+":","")),e={method:i||t,url:e}}else e=fe({},e);return e.url="string"==typeof e.url?e.url.trim():e.url,e}function qe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{arrayFormat:"indices",encodeValuesOnly:!0};return(arguments.length>2?arguments[2]:void 0)&&Object.keys(e).forEach((function(t){Array.isArray(e[t])&&!e[t].length&&(e[t]="")})),z.stringify(e,t)}function _e(e){var t="string"==typeof(e=je(e)).url?e.url.indexOf("?"):-1;return~t&&(e.query=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{arrayFormat:"indices",encodeValuesOnly:!0,depth:1e3,arrayLimit:1e3};return z.parse(e,t)}(e.url.substring(t+1))),e}var ze={};function Ue(e,t){var i=[];return"string"==typeof e&&ze[e]?ze[e]:(Me("string"==typeof e?U(e,{evalMode:null!=t&&t}):e,(function(e){"variable"===e.type&&i.push(e.name)})),"string"==typeof e&&(ze[e]=i),i)}function Qe(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+e()}function He(){return"u:".concat(Qe())}var Ge=void 0;function Ye(e,t){return Ge?Ge(e,t):e.replace(/(\\)?\{\{([\s\S]+?)\}\}/g,(function(e,i,n){var a;return i?e.substring(1):null!==(a=null==t?void 0:t[n])&&void 0!==a?a:e}))}function We(e){Ge=e}var Je=function(e){return"relation"!==e.type&&!e.isForeignKey&&(e.isBuiltIn||e.isPrimaryKey||e.isCreateDate||e.isUpdateDate||e.isDeleteDate||e.isCreateUser||e.isUpdateUser||e.isDeleteUser)};function Ze(e,t){return Xe.apply(this,arguments)}function Xe(){return Xe=ee(he().mark((function e(t,n){var a,r,l,o,s,d,u,c,p,m,f=arguments;return he().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=f.length>2&&void 0!==f[2]?f[2]:[],!Array.isArray(t)){e.next=9;break}return r=!1,e.next=5,Promise.all(t.map(function(){var e=ee(he().mark((function e(l,o){var s;return he().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!i(l)&&!Array.isArray(l)){e.next=13;break}return e.t0=n,e.next=4,Ze(l,n,[t].concat(a));case 4:return e.t1=e.sent,e.t2=o,e.t3=t,e.t4=[t].concat(a),e.next=10,(0,e.t0)(e.t1,e.t2,e.t3,e.t4);case 10:s=e.sent,e.next=16;break;case 13:return e.next=15,n(l,o,t,[t].concat(a));case 15:s=e.sent;case 16:if(s===l){e.next=19;break}return r=!0,e.abrupt("return",s);case 19:return e.abrupt("return",l);case 20:case"end":return e.stop()}}),e)})));return function(t,i){return e.apply(this,arguments)}}()));case 5:return l=e.sent,e.abrupt("return",r?l:t);case 9:if(i(t)){e.next=11;break}return e.abrupt("return",t);case 11:o=!1,s={},d=0,u=Object.keys(t);case 14:if(!(d<u.length)){e.next=38;break}if(c=u[d],p=t[c],m=void 0,!i(p)&&!Array.isArray(p)){e.next=31;break}return e.t0=n,e.next=22,Ze(p,n,[t].concat(a));case 22:return e.t1=e.sent,e.t2=c,e.t3=t,e.t4=[t].concat(a),e.next=28,(0,e.t0)(e.t1,e.t2,e.t3,e.t4);case 28:m=e.sent,e.next=34;break;case 31:return e.next=33,n(p,c,t,[t].concat(a));case 33:m=e.sent;case 34:m!==p&&(o=!0,s[c]=m);case 35:d++,e.next=14;break;case 38:return e.abrupt("return",o?fe(fe({},t),s):t);case 39:case"end":return e.stop()}}),e)}))),Xe.apply(this,arguments)}var et=function(e,t){var i,n;return null!==(i=e.keyPath)&&void 0!==i?i:e.isCascadingField&&e.parentKey?"".concat(null!==(n=e.parentKey)&&void 0!==n?n:e.modelKey,".").concat(e.key):t},tt=function(e,t){var i,n,a,r;return null!==(i=null!==(n=e.isCascadingField?"".concat(null!==(a=null!==(r=e.modelLabel)&&void 0!==r?r:e.parentModelName)&&void 0!==a?a:e.parentName,".").concat(e.name):e.name)&&void 0!==n?n:t)&&void 0!==i?i:Ye(Q("a74ed1efd23cc2365f6c48d7d6b4a17e"))},it=function(e,t){var i=["id","type","typeLabel","key","name",Q("d304ba20e96d87411588eeabac850e34"),Q("2063c1608d6e0baf80249c42e2be5804"),"modelValue","modelKey"],n={label:tt(e),value:et(e,e.value),masterModelId:t&&"string"==typeof t?t:""};return n="relation"!==e.type?fe(fe({},O(e,i)),n):fe(fe(fe({},O(e,i)),n),{},{targetId:E(e,"relation.target",""),targetKey:E(e,"relation.targetKey",""),targetName:E(e,"relation.targetName",""),relationMode:E(e,"relation.relationMode",""),inverseSide:E(e,"relation.inverseSide","")})},nt=function(e,t){return{viewable:t.isFieldVisible(e),insertable:t.isFieldInsertable(e),updateable:t.isFieldUpdateable(e),filterable:t.isFieldFilterable(e),searchable:t.isFieldSearchable(e),removable:t.isFieldRemovable(e)}},at=function(e,t,i){var n=!1;switch(i){case"List":case"View":default:n=t.isFieldVisible(e);break;case"Insert":n=t.isFieldInsertable(e);break;case"Edit":case"BulkEdit":n=t.isFieldUpdateable(e);break;case"Delete":case"BulkDelete":n=t.isFieldRemovable(e);break;case"SimpleQuery":case"FuzzyQuery":case"AdvancedQuery":n=t.isFieldFilterable(e)||t.isFieldSearchable(e)}return n},rt=function(e,t){var i=!1;switch(t){case"List":case"View":default:i=!0===e.viewable;break;case"Insert":i=!0===e.insertable;break;case"Edit":case"BulkEdit":i=!0===e.updateable;break;case"Delete":case"BulkDelete":i=!0===e.removable;break;case"SimpleQuery":case"FuzzyQuery":case"AdvancedQuery":i=!0===e.filterable||!0===e.searchable}return i},lt=function(){var e=ee(he().mark((function e(t,i,n,a){var r,l,o,s,d,u,c,p;return he().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=a.enableCB,l=a.defaultChecked,o=a.feat,s=a.excludeSelf,d=a.filterFn,u=a.mapperFn,c=(Array.isArray(o)?o:[o]).filter((function(e){return e&&"string"==typeof e})),e.next=4,Promise.all(t.map(function(){var e=ee(he().mark((function e(t){var a,o,p,m,f,y,h,b;return he().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(m=!0===s?t.parentModelKey:"relation"===t.type?t.parentKey||i.plainData.key:t.parentModelKey||t.parentKey||i.plainData.key,t&&t.id&&m){e.next=3;break}return e.abrupt("return",null);case 3:if(f=n.store.getModelByKey(m),y=null==f?void 0:f.getFieldById(t.id),f&&y){e.next=7;break}return e.abrupt("return",null);case 7:if(!d||"function"!=typeof d||!1!==d(t)){e.next=9;break}return e.abrupt("return",null);case 9:if(!(c&&c.length>0&&c.some((function(e){return!at(y,f,e)})))){e.next=11;break}return e.abrupt("return",null);case 11:if(h=Te(Se(y,f.plainData)),e.t0=Te,e.t1=fe,e.t2=fe(fe(fe({},h),O(t,["relation","keyPath","parentId","parentKey","parentName","parentModelKey","parentModelName","parentModelId"])),{},{value:h.key,label:h.name,checked:!0===l||!!t.checked,isCascadingField:t.keyPath!==t.key,modelValue:f.plainData.value,modelLabel:f.plainData.label,modelKey:f.plainData.key},nt(y,f)),!r){e.next=24;break}return e.t4=null!==(a=null===(o=n.getFieldType(t.type))||void 0===o?void 0:o.allowedFilterOp)&&void 0!==a?a:[],e.t5=null===(p=n.getFieldType(t.type))||void 0===p?void 0:p.defaultFilterOp,e.next=20,n.buildFieldConditionFieldConfig(f.plainData,y,{type:"text",name:t.keyPath,label:t.name});case 20:e.t6=e.sent,e.t3={allowedFilterOp:e.t4,defaultFilterOp:e.t5,CBFieldSchema:e.t6},e.next=25;break;case 24:e.t3={};case 25:if(e.t7=e.t3,e.t8=(0,e.t1)(e.t2,e.t7),b=(0,e.t0)(e.t8),!u||"function"!=typeof u){e.next=30;break}return e.abrupt("return",u(b));case 30:return e.abrupt("return",b);case 31:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 4:return p=e.sent.filter((function(e){return null!=e})),e.abrupt("return",p);case 6:case"end":return e.stop()}}),e)})));return function(t,i,n,a){return e.apply(this,arguments)}}();function ot(e,t){if(Array.isArray(e)){var i=!1,n=e.map((function(e){var n=ot(e,t);return n!==e&&(i=!0),n}));return i?n:e}if(!q(e)||x(e))return e;var a=!1,r={};return e.$$id&&(a=!0,r.$$id=void 0),Object.keys(e).forEach((function(i){var n=e[i];if("function"==typeof t?t(i,n):!1!==t&&"__"===i.substring(0,2))return r[i]=void 0,void(a=!0);var l=ot(n,t);l!==n&&(a=!0,r[i]=l)})),a&&(e=function(e){if(!q(e))return e;return Object.keys(e).forEach((function(t){void 0===e[t]&&delete e[t]})),e}(fe(fe({},e),r))),e}var st,dt=(st="me-",function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];var n=_.apply(void 0,ke(t));return n&&st?n.replace(/(^|\s)([A-Z])/g,"$1"+st+"$2").replace(/(^|\s)\:/g,"$1"):n||""});function ut(e,t){return!(!i(e)||!i(t))&&a(ot(e),ot(t))}var ct={eq:"=",ne:"<>",gt:">",ge:">=",lt:"<",le:"<=",bt:"between",in:"in",like:"like",sw:"like",ew:"like"},pt={equal:"=",not_equal:"<>",is_not_empty:"IS NOT NULL",is_empty:"IS NULL",less:"<",less_or_equal:"<=",greater:">",greater_or_equal:">=",not_between:"NOT BETWEEN",not_like:"ILIKE",like:"LIKE",starts_with:"LIKE",ends_with:"LIKE"},mt={eq:"equal",ne:"not_equal",gt:"greater",ge:"greater_or_equal",lt:"less",le:"less_or_equal",like:"like",sw:"starts_with",ew:"ends_with",bt:"between",in:"select_any_in",is_empty:"is_empty",is_not_empty:"is_not_empty"},ft=function(){function e(){ie(this,e)}return ae(e,null,[{key:"getOptionLabel",value:function(t){var i;return null===(i=[e.optionEqual,e.optionNotEqual,e.optionGreatThan,e.optionGreatThanOrEqual,e.optionLessThan,e.optionLessThanOrEqual,e.optionLike,e.optionStartWith,e.optionEndWith,e.optionBetween,e.optionIn].find((function(e){return e.value===t})))||void 0===i?void 0:i.label}},{key:"filterOPToJsonQLWhereOp",value:function(e){return ct[e]||pt[e]||e}},{key:"filterOpToConditionBuilderOp",value:function(e){return mt[e]||e}},{key:"ConditonBuilder2JSONQLWhere",value:function(t,i){if(t){if(Array.isArray(t)?t.forEach((function(t){e.ConditonBuilder2JSONQLWhere(t,i)})):Array.isArray(t.children)&&e.ConditonBuilder2JSONQLWhere(t.children,i),t.conjunction&&(t.operator=t.conjunction,delete t.conjunction),t.left&&t.left.field&&(t.left.column=t.left.field,delete t.left.field,t.right&&r(t.right))){var n="".concat(t.left.column.replaceAll(".","_"),"_").concat(l());i[n]=t.right,t.right="{{".concat(n,"}}")}var a=e.filterOPToJsonQLWhereOp(t.op);if(t.op&&a){switch(t.op){case"like":t.right="%".concat(t.right,"%");break;case"starts_with":t.right="".concat(t.right,"%");break;case"ends_with":t.right="%".concat(t.right)}t.op=a}return t}}}])}();ft.optionEqual={label:Ye("等于"),value:"eq"},ft.optionNotEqual={label:Ye("不等于"),value:"ne"},ft.optionGreatThan={label:Ye("大于"),value:"gt"},ft.optionGreatThanOrEqual={label:Ye("大于或等于"),value:"ge"},ft.optionLessThan={label:Ye("小于"),value:"lt"},ft.optionLessThanOrEqual={label:Ye("小于或等于"),value:"le"},ft.optionLike={label:Ye("模糊匹配"),value:"like"},ft.optionStartWith={label:Ye("匹配开头"),value:"sw"},ft.optionEndWith={label:Ye("匹配结尾"),value:"ew"},ft.optionBetween={label:Ye("范围匹配"),value:"bt"},ft.optionIn={label:Ye("包含"),value:"in"},ft.opValueToJsonQLRight=function(e,t){switch(e){case"like":return"%{{".concat(t,"}}%");case"sw":return"{{".concat(t,"}}%");case"ew":return"%{{".concat(t,"}}");default:return"{{".concat(t,"}}")}};var yt=function(){return ae((function e(t,i,n){ie(this,e),this.idParam="",this.strategy="restful",this.scene="list",this.selects=[],this.wheres=[],this.orders=[],this.vars=[],this.query={},this.setIdParam(t||""),this.strategy=null!=i?i:"restful",this.scene=null!=n?n:"list"}),[{key:"hasQuery",get:function(){return!!Object.keys(this.query).length}},{key:"setIdParam",value:function(e){this.idParam=e}},{key:"addVar",value:function(e){return e&&"string"==typeof e&&!this.vars.includes(e)&&this.vars.push(e),this.vars}},{key:"addQuery",value:function(e,t){this.query[e]=t}},{key:"select",value:function(e,t){this.selects=[],e&&this.addSelect(e,t)}},{key:"addSelect",value:function(e,t){e&&(Array.isArray(e)?this.selects=P([].concat(ke(this.selects),ke(e)),(function(e,t){return e.column===t.column})):this.selects.find((function(i){return t?i.alias===t:i.column===e}))||this.selects.push({column:e,alias:t}))}},{key:"resolveSelectFields",value:function(e,t){if(!e||!Array.isArray(e)||0===e.length)return[{column:"*"}];if((t=t||{})&&"Edit"===t.feat&&"GET"===t.method){var i=[];e.forEach((function(e){var t,n;"relation"===e.type&&"n:1"===(null===(t=e.relation)||void 0===t?void 0:t.relationMode)&&null!==(n=e.relation)&&void 0!==n&&null!==(n=n.field)&&void 0!==n&&n.id&&i.push(fe(fe({},e.relation.field),{},{checked:!0}))})),e=[].concat(ke(e),i)}return e.map((function(e){var t,i;return!(!e.checked||!e.id)&&{column:null!==(t=e.keyPath)&&void 0!==t?t:e.isCascadingField?"".concat(null!==(i=e.modelKey)&&void 0!==i?i:e.parentModelKey,".").concat(e.key):e.key}})).filter((function(e){return!!e}))}},{key:"where",value:function(e){this.wheres=[],e&&this.addWhere(e)}},{key:"addWhere",value:function(e){this.wheres.push(e)}},{key:"setWhereAndQueryByConditionBuilder",value:function(e){if(e&&i(e)){var t=C(e),n={},a=ft.ConditonBuilder2JSONQLWhere(t,n);this.where(a),this.query=n}}},{key:"orderBy",value:function(e){this.orders=[],e&&this.addOrderBy(e)}},{key:"addOrderBy",value:function(e){e&&(Array.isArray(e)?this.orders=P([].concat(ke(this.orders),ke(e)),(function(e,t){return e.column===t.column})):this.orders.find((function(t){return t.column===e.column}))||this.orders.push(e))}},{key:"resolveOrderByFields",value:function(e,t){if(!Array.isArray(e)||!1===t)return[];var i=e.filter((function(e){return!!e.field})).map((function(e){return{column:e.field,sort:!1===e.order?"desc":"asc"}}));return[].concat(ke(i),[{column:"${orderBy}",sort:"${orderDir}"}])}},{key:"buildVariable",value:function(e,t){return e&&"{{".concat("string"==typeof e?e:e.toString()).concat(void 0!==t?" || "+t:"","}}")}}])}(),ht={};function bt(e,t,i){var n=ht[e]||{};return"function"==typeof n?n(t,i):n?t?fe(fe({},n),t):n:null}function vt(e,t){ht[e]=t}function gt(e){return!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?function(t){return void 0===t?e:t}:function(t){return t||e}}var kt=function(){return ae((function e(t){ie(this,e),this.manager=t}),[{key:"overridFieldSchema",value:function(e,t){var i,n,a,r,l,o,s;e.label=null!==(i=t.label)&&void 0!==i?i:e.label,e.description=null!==(n=t.description)&&void 0!==n?n:e.description,e.labelRemark=null!==(a=t.labelRemark)&&void 0!==a?a:e.labelRemark,e.isStatic=null!==(r=t.isStatic)&&void 0!==r?r:e.isStatic,e.size=null!==(l=t.size)&&void 0!==l?l:e.size,e.sortable=null!==(o=t.sortable)&&void 0!==o?o:e.sortable,e.remark=null!==(s=t.remark)&&void 0!==s?s:e.remark}},{key:"addSelect",value:function(e,t){e.addSelect(t.parentKey?"".concat(t.parentKey,".").concat(t.key):t.key)}},{key:"buildFieldViewQuickEditSettingForm",value:(r=ee(he().mark((function e(t){var i,n;return he().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=this.manager.store.getModelByKey(t.model.key),"form"===t.viewType||!i.isFieldUpdateable(t.field)){e.next=7;break}return e.next=4,this.manager.buildFieldEditSettingForm(t.model,t.field,fe(fe({},t),{},{settingFor:"quick-edit"}));case 4:e.t0=e.sent,e.next=8;break;case 7:e.t0=null;case 8:return n=e.t0,e.abrupt("return",[bt("me:setting:QuickEdit"),Array.isArray(null==n?void 0:n.body)&&null!=n&&n.body.length?bt("me:setting:formitem",{type:"container",className:"me-SettingSubContainer",wrapperBody:!1,visibleOn:"${quickEdit}",body:[{type:"combo",name:"quickEditSettings",label:!1,items:n.body,multiLine:!0,multiple:!1,noBorder:!0,subFormMode:"horizontal",itemClassName:"no-bg",subFormHorizontal:{justify:!0}}]}):null].filter((function(e){return e})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"buildQuickEdit",value:(a=ee(he().mark((function e(t,i,n){var a,r,l,o,s,d,u,c,p=arguments;return he().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=p.length>3&&void 0!==p[3]&&p[3],!n.quickEdit){e.next=30;break}if((r=this.manager.store.getModelByKey(i.model.key)).isFieldUpdateable(i.field)){e.next=5;break}return e.abrupt("return");case 5:return e.next=7,this.manager.buildFieldEditSchema(i.model,i.field,i,n.quickEditSettings);case 7:if(l=e.sent,t.quickEdit=fe(fe({},l),{},{label:""}),!a){e.next=30;break}o=this.manager.makeApiStrategy(i.model.key,i.apiStrategyOptions,i.apiStrategy),s=new yt("${"+(i.model.primaryField||"id")+"}"),d=re(r.primaryFields.concat(i.field)),e.prev=13,d.s();case 15:if((u=d.n()).done){e.next=21;break}return c=u.value,e.next=19,this.manager.buildFieldEditSchema(i.model,c,{mode:"quick-edit"},void 0,s);case 19:e.next=15;break;case 21:e.next=26;break;case 23:e.prev=23,e.t0=e.catch(13),d.e(e.t0);case 26:return e.prev=26,d.f(),e.finish(26);case 29:t.quickEdit={initApi:o.detailApi(s,{primaryKey:i.model.primaryField}),body:[t.quickEdit]};case 30:case"end":return e.stop()}}),e,this,[[13,23,26,29]])}))),function(e,t,i){return a.apply(this,arguments)})},{key:"buildFieldViewSearchableSettingForm",value:(i=ee(he().mark((function e(t){var i,n;return he().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=this.manager.store.getModelByKey(t.model.key),"form"===t.viewType||!i.isFieldSearchable(t.field,!0)){e.next=7;break}return e.next=4,this.manager.buildFieldFilterSettingForm(t.model,t.field,fe(fe({},t),{},{settingFor:"embed"}));case 4:e.t0=e.sent,e.next=8;break;case 7:e.t0=null;case 8:if(n=e.t0,Array.isArray(null==n?void 0:n.body)&&null!=n&&n.body.length){e.next=11;break}return e.abrupt("return",[]);case 11:return e.abrupt("return",[bt("me:setting:Searchable"),bt("me:setting:formitem",{type:"container",className:"me-SettingSubContainer",wrapperBody:!1,visibleOn:"${searchable !== false}",body:ke(n.body)})].filter((function(e){return e})));case 12:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"buildFieldFilterSchema",value:(t=ee(he().mark((function e(t,i,a,r){var l,o,s,d;return he().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((null===(l=i.fieldType)||void 0===l?void 0:l.plugin)===this){e.next=2;break}return e.abrupt("return");case 2:return o=(null==a?void 0:a.searchOp)||i.fieldType.defaultFilterOp||"eq",e.next=5,this.manager.buildFieldEditSchema(i.model,i.field,fe(fe({},i),{},{mode:"filter"}),void 0,void 0,t);case 5:if(t){e.next=7;break}return e.abrupt("return");case 7:delete t.required,t.clearable=!0,"bt"===o?(s=n(t,["label","mode","description"]),Object.keys(s).forEach((function(e){return delete t[e]})),t.type="group",t.body=[fe(fe({},s),{},{placeholder:Ye("开头"),name:"".concat(s.name,"[bt][from]"),mode:"inline",size:"xs"}),fe(fe({},s),{},{placeholder:Ye("结尾"),name:"".concat(s.name,"[bt][to]"),mode:"inline",size:"xs"})],r&&r.addWhere({left:{column:i.field.key},op:ft.filterOPToJsonQLWhereOp(o),right:["${"+s.name+".bt.from || null}","${"+s.name+".bt.to || null}"]})):"in"===o?(d=n(t,["name","label","mode","description"]),Object.keys(d).forEach((function(e){return delete t[e]})),t.type="input-array",t.name+="[in]",t.joinValues=!1,t.extractValue=!0,t.items=d,r&&r.addWhere({left:{column:i.field.key},op:ft.filterOPToJsonQLWhereOp(o),right:"${"+t.name+" || null}"})):("eq"!==o&&(t.name+="."+o),r&&r.addWhere({left:{column:i.field.key},op:ft.filterOPToJsonQLWhereOp(o),right:"${"+t.name+" || null}"}));case 10:case"end":return e.stop()}}),e,this)}))),function(e,i,n,a){return t.apply(this,arguments)})},{key:"buildFieldConditionFieldConfig",value:(e=ee(he().mark((function e(t,i){var n,a,r,l;return he().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((a=i.fieldType).filterable&&a.CBType){e.next=4;break}return t.type=void 0,e.abrupt("return");case 4:r=mt.like,l=0===(l=(null!==(n=i.fieldType.allowedFilterOp)&&void 0!==n?n:[]).map((function(e){return ft.filterOpToConditionBuilderOp(e.value)}))).length?[r]:l,i.field.isNullable&&(l=l.concat(mt.is_empty,mt.is_not_empty)),t.operators=l,t.type=a.CBType;case 10:case"end":return e.stop()}}),e)}))),function(t,i){return e.apply(this,arguments)})}]);var e,t,i,a,r}();var xt,Ft,wt,St,Tt,Et,Ot,At,Ct,Mt,Dt,It,Nt,Bt,Lt,Kt,$t,Rt,Vt,Pt,jt,qt,_t,zt,Ut,Qt,Ht,Gt,Yt,Wt,Jt,Zt,Xt,ei,ti,ii,ni,ai,ri,li,oi,si,di,ui,ci,pi,mi,fi,yi,hi,bi,vi,gi,ki,xi,Fi,wi,Si,Ti,Ei,Oi,Ai,Ci,Mi,Di,Ii,Ni,Bi,Li,Ki,$i=function(){return ae((function e(){ie(this,e),this.listeners=[]}),[{key:"on",value:function(e,t){this.listeners.push({type:e,fn:t})}},{key:"off",value:function(e,t){var i=B(this.listeners,(function(i){return i.type===e&&i.fn===t}));~i&&this.listeners.splice(i,1)}},{key:"trigger",value:function(e,t,i){var n=function(e,t){var i={context:t,type:e,prevented:!1,stoped:!1,preventDefault:function(){i.prevented=!0},stopPropagation:function(){i.stoped=!0},get data(){return i.context.data},setData:function(e){i.context.data=e}};return i}(e,t),a=this.listeners.filter((function(t){return t.type===e})).concat(i||[]),r=[];return a.some((function(e){var t=e.fn.call(null,n);return!1===t?(n.preventDefault(),n.stopPropagation()):null!=t&&t.then?r.push(t):void 0!==t&&n.setData(t),n.stoped})),r.length&&(n.pending=Promise.all(r)),n}}])}(),Ri=ae((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;ie(this,e),this.x=t,this.y=i,this.z=n,this.parent=void 0,this.value=void 0})),Vi=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;ie(this,e),this.x=t,this.y=i,this.width=n,this.height=a,this.right=void 0,this.bottom=void 0,this.right=t+n,this.bottom=i+a}return ae(e,[{key:"getCenterPoint",value:function(){return new Ri(this.x+this.width/2,this.y+this.height)}},{key:"update",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.width,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.height;this.x=e,this.y=t,this.width=i,this.height=n,this.right=e+i,this.bottom=t+n}},{key:"setY",value:function(e){this.y=e,this.bottom=e+this.height}},{key:"setX",value:function(e){this.x=e,this.right=e+this.width}},{key:"moveTo",value:function(e,t){var i=e-this.x,n=t-this.y;this.x=e,this.y=t,this.right+=i,this.bottom+=n}},{key:"moveBy",value:function(e,t){this.moveTo(this.x+e,this.y+t)}},{key:"contains",value:function(e){return this.x<=e.x&&this.y<=e.y&&this.right>=e.right&&this.bottom>=e.bottom}},{key:"hasPoint",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.x-t<=e.x&&this.y-t<=e.y&&this.right+t>=e.x&&this.bottom+t>=e.y}},{key:"overlaps",value:function(e){return this.x<e.right&&this.right>e.x&&this.y<e.bottom&&this.bottom>e.y}},{key:"xOverlaps",value:function(e){return this.x<e.right&&this.right>e.x}},{key:"yOverlaps",value:function(e){return this.y<e.bottom&&this.bottom>e.y}},{key:"getMaximalFreeRects",value:function(t){var i=[];return this.right>t.right&&i.push(new e(t.right,this.y,this.right-t.right,this.height)),this.bottom>t.bottom&&i.push(new e(this.x,t.bottom,this.width,this.bottom-t.bottom)),this.x<t.x&&i.push(new e(this.x,this.y,t.x-this.x,this.height)),this.y<t.y&&i.push(new e(this.x,this.y,this.width,t.y-this.y)),i}},{key:"canFit",value:function(e){return this.width>=e.width&&this.height>=e.height-1}},{key:"xDistanceOf",value:function(e){return this.overlaps(e)?0:Math.min(Math.abs(e.x-this.right),Math.abs(this.x-e.right))}},{key:"yDistanceOf",value:function(e){return this.overlaps(e)?0:Math.min(Math.abs(e.y-this.bottom),Math.abs(this.y-e.bottom))}}])}(),Pi=function(){function e(t,i){var n;return ie(this,e),(n=te(this,e,[t,i,0])).x=t,n.y=i,n.parent=void 0,n}return ue(e,Ri),ae(e,[{key:"add",value:function(t){return new e(this.x+t.x,this.y+t.y)}},{key:"multiply",value:function(t){return new e(this.x*t,this.y*t)}},{key:"isPrallel",value:function(e){return 0===this.cross(e)}},{key:"isZero",value:function(){return!this.x&&!this.y}},{key:"isSameSite",value:function(e){return this.dot(e)>0}},{key:"isSameDirection",value:function(e){return this.isPrallel(e)&&this.isSameSite(e)}},{key:"dot",value:function(e){return this.x*e.x+this.y*e.y}},{key:"cross",value:function(e){return this.x*e.y-this.y*e.x}},{key:"angle",value:function(){return Math.atan2(this.y,this.x)}},{key:"toVertialVector",value:function(){return new e(0,this.y)}},{key:"toHorizontalVector",value:function(){return new e(this.x,0)}},{key:"m",value:function(){return Math.sqrt(this.x*this.x+this.y*this.y)}},{key:"toUnitVector",value:function(){if(!this.x&&!this.y)return!1;var t=this.m();return new e(this.x/t,this.y/t)}},{key:"isHorizontalOrVertial",value:function(){return 0===this.x||0===this.y}},{key:"manhattanDistance",value:function(){return Math.abs(this.x)+Math.abs(this.y)}},{key:"xDistance",value:function(){return Math.abs(this.x)}},{key:"yDistance",value:function(){return Math.abs(this.y)}}],[{key:"fromPoints",value:function(t,i){return new e(i.x-t.x,i.y-t.y)}}])}(),ji=function(){function e(t,i,n,a){ie(this,e),this.relation=t,this.inverseRelation=i,this.className=n,this.onClick=a,this.svg=void 0,this.startpont=void 0,this.endpont=void 0,this.linePath=void 0,this.maskLinePath=void 0,this.startText=void 0,this.endText=void 0,this.start=void 0,this.startDir=void 0,this.end=void 0,this.endDir=void 0}return ae(e,[{key:"init",value:function(){if(!this.svg){var e=this.relation,t=this.inverseRelation,i=e.relationMode.split(":"),n='\n <defs>\n <clipPath id="border-radius">\n <path d="M24,0 C26.209139,-4.05812251e-16 28,1.790861 28,4 L28,20 C28,22.209139 26.209139,24 24,24 L4,24 C1.790861,24 2.705415e-16,22.209139 0,20 L0,4 C-2.705415e-16,1.790861 1.790861,4.05812251e-16 4,0 L24,0 Z">\n </path>\n </clipPath>\n </defs>\n <g data-role="line">\n <path id="mask" fill="none" stroke="transparent" stroke-width="15"\n d="M 5190 5025.25 Q 5220 5025.25 5290.5 5119.25 T 5391 5213.25"></path>\n <path id="line" fill="none" stroke="currentColor" stroke-width="2"\n d="M 5190 5025.25 Q 5220 5025.25 5290.5 5119.25 T 5391 5213.25"></path>\n '.concat(t?'<circle id="endpoint" stroke="currentColor" fill="#fff" stroke-width="2" r="3"></circle>':'<polygon id="endpoint" fill="currentColor" stroke="none"></polygon>','\n <circle id="startpoint" stroke="currentColor" fill="#fff" stroke-width="2" r="3" ></circle>\n\n <g class="text" id="startText">\n <g transform="translate(-14 -12)" clip-path="url(#border-radius)">\n <polygon points="0,0 28,0 28,24 0,24 0,0" stroke="none" fill="#528EFF">\n </polygon>\n </g>\n <g transform="translate(-3.5 -9.0)">\n <text transform="translate(0.3999999999999999 13.0)" font-family="PingFangSC-Regular, PingFang SC" font-size="12.0" font-weight="normal" fill="#FFFFFF" text-anchor="center">\n ').concat(i[0],'\n </text>\n </g>\n </g>\n\n <g class="text" id="endText">\n <g transform="translate(-14 -12)" clip-path="url(#border-radius)">\n <polygon points="0,0 28,0 28,24 0,24 0,0" stroke="none" fill="#528EFF">\n </polygon>\n </g>\n <g transform="translate(-3.5 -9.0)">\n <text transform="translate(0.3999999999999999 13.0)" font-family="PingFangSC-Regular, PingFang SC" font-size="12.0" font-weight="normal" fill="#FFFFFF" text-anchor="center">\n ').concat(i[1],"\n </text>\n </g>\n </g>\n </g>\n "),a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.innerHTML=n,this.svg=a,this.className&&a.classList.add(this.className),this.linePath=a.querySelector("#line"),this.maskLinePath=a.querySelector("#mask"),this.startpont=a.querySelector("#startpoint"),this.endpont=a.querySelector("#endpoint"),this.startText=a.querySelector("#startText"),this.endText=a.querySelector("#endText"),this.onClick&&a.addEventListener("click",this.onClick)}}},{key:"draw",value:function(t){this.init();var i=t.querySelector('[data-id="'.concat(this.relation.placeholder.id,'"]'))||t.querySelector('[data-id="'.concat(this.relation.model.id,'"] > div:first-child')),n=this.inverseRelation&&t.querySelector('[data-id="'.concat(this.inverseRelation.placeholder.id,'"]'))||t.querySelector('[data-id="'.concat(this.relation.targetModel.id,'"]>div:first-child'));if(i&&n){var a=e.getRelativeRect(i,t),r=e.getRelativeRect(n,t),l=a.x+a.width/2<r.x+r.width/2?1:-1;i.classList.remove("line-anchor-left"),i.classList.remove("line-anchor-right"),i.classList.add(1===l?"line-anchor-right":"line-anchor-left"),this.inverseRelation&&(n.classList.remove("line-anchor-left"),n.classList.remove("line-anchor-right"),n.classList.add(1===l?"line-anchor-left":"line-anchor-right"));var o=new Ri(1===l?a.right:a.x,a.y+("field"===i.getAttribute("data-role")?a.height/2:a.height)),s=new Ri(1===l?r.x:r.right,r.y+(this.inverseRelation?r.height/2:r.height)),d=new Pi(1===l?1:-1,0),u=d;this.start=o,this.startDir=d,this.end=s,this.endDir=u;var c=new Vi(Math.min(o.x,s.x),Math.min(o.y,s.y),Math.abs(o.x-s.x),Math.abs(o.y-s.y)),p=Math.max(c.width,10),m=Math.max(c.height,10),f=this.svg;f.setAttribute("viewBox","".concat(c.x," ").concat(c.y," ").concat(p," ").concat(m)),f.setAttribute("width","".concat(p)),f.setAttribute("height","".concat(m)),f.style.cssText+="position:absolute;top:".concat(c.y,"px;left: ").concat(c.x,"px;"),this.drawLine(),this.drawStartPoint(),this.drawEndPoint(),this.drawText(),f.parentElement!==t&&t.appendChild(f)}}},{key:"drawLine",value:function(){var e=this.startDir,t=this.endDir,i=new Ri(this.start.x,this.start.y),n=new Ri(this.end.x-t.x*(this.inverseRelation?0:9),this.end.y),a=new Pi(i.x,i.y).add(e.multiply(30)),r=new Pi(n.x,n.y).add(t.multiply(-30)),l=[i,a],o=Pi.fromPoints(a,r);if(e.isSameDirection(t)&&o.isSameSite(e)&&(i.x===n.x||i.y===n.y));else if(o.toVertialVector().toUnitVector()){var s=new Pi(a.x,a.y).add(o.multiply(.5));l.push(s)}l.push(r,n);var d="";d=l.length<=4?"M ".concat(i.x," ").concat(i.y," L ").concat(n.x," ").concat(n.y):l.length<=5?"M ".concat(l[0].x," ").concat(l[0].y," ")+"Q ".concat(l[1].x," ").concat(l[1].y," ").concat(l[2].x," ").concat(l[2].y," ")+"T ".concat(l[4].x," ").concat(l[4].y):"M ".concat(l[0].x," ").concat(l[0].y," ")+"Q ".concat(l[1].x," ").concat(l[1].y," ").concat(l[2].x," ").concat(l[2].y," ")+"T ".concat(l[3].x," ").concat(l[3].y," ")+"T ".concat(l[4].x," ").concat(l[4].y," ")+"Q ".concat(l[5].x," ").concat(l[5].y," ").concat(l[6].x," ").concat(l[6].y),this.linePath.setAttribute("d",d),this.maskLinePath.setAttribute("d",d)}},{key:"drawStartPoint",value:function(){var e=this.start;this.startpont.setAttribute("cx","".concat(e.x)),this.startpont.setAttribute("cy","".concat(e.y))}},{key:"drawEndPoint",value:function(){var e=this.end,t=this.endDir;if("circle"===this.endpont.tagName){var i=this.endpont;i.setAttribute("cx","".concat(e.x)),i.setAttribute("cy","".concat(e.y))}else this.endpont.setAttribute("points","".concat(e.x-9*t.x,",").concat(e.y-5," ").concat(e.x,",").concat(e.y," ").concat(e.x-9*t.x,",").concat(e.y+5," "))}},{key:"drawText",value:function(){var e=this.startText,t=this.endText,i=this.linePath,n=i.getTotalLength(),a=i.getPointAtLength(.25*n),r=i.getPointAtLength(.75*n);e.setAttribute("transform","translate(".concat(a.x," ").concat(a.y,")")),t.setAttribute("transform","translate(".concat(r.x," ").concat(r.y,")"))}},{key:"setActive",value:function(e){if(this.svg){var t=this.svg.classList;t.remove("is-active"),e&&t.add("is-active")}}},{key:"onDiagramViewModeChange",value:function(e){if(this.svg){var t=this.svg.classList;t.remove("is-mini"),"more"===e&&t.add("is-mini")}}},{key:"dispose",value:function(){var e,t;this.onClick&&(null===(e=this.svg)||void 0===e||e.removeEventListener("click",this.onClick)),null===(t=this.svg)||void 0===t||null===(t=t.parentElement)||void 0===t||t.removeChild(this.svg)}}],[{key:"getRelativeRect",value:function(e,t){var i=t.getBoundingClientRect(),n=e.getBoundingClientRect(),a=n.width/e.offsetWidth;return new Vi((n.x-i.x)/a,(n.y-i.y)/a,n.width/a,n.height/a)}}])}(),qi=function(e,t,i,n,a){var r,l={deletedBy:Ye("删除人"),deletedAt:Ye("删除时间"),createdBy:Ye("创建人"),createdAt:Ye("创建时间"),updatedBy:Ye("更新人"),updatedAt:Ye("更新时间")};e.fields=Array.isArray(e.fields)?e.fields.concat():[];var o,s="object"===Fe(e[t])&&"string"==typeof e[t][i]&&e[t][i]||(null==a?void 0:a[i])||i,d="deletedAt"===i?e.useSoftDelete:("boolean"==typeof e[t]?e[t]:!(null===(r=e[t])||void 0===r||!r[i]))&&("deletedBy"!==i||e.useSoftDelete),u=e.fields.findIndex((function(e){return e[n]}));if(d)~u&&e.fields[u].key!==s&&(e.fields.splice(u,1,fe(fe({},e.fields[u]),{},le({type:"saveTimestamp"===t?"datetime":"user"},n,!1))),u=-1),~(u=~u?u:e.fields.findIndex((function(e){return e.key===s})))?e.fields.splice(u,1,fe(fe({},e.fields[u]),{},le({type:"saveTimestamp"===t?"datetime":"user"},n,!0))):e.fields.push(Se(fe(fe({name:Ye(l[i])},(null===(o=e.dbTable)||void 0===o?void 0:o.fields.find((function(e){return e.key==