@devtable/dashboard 13.23.0 → 13.23.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.
@@ -59,7 +59,7 @@ Check the top-level render call using <`+L+">.")}return A}}function _g(C,A){{if(
59
59
  `,textSerializers:l={}}=n||{};let c="",u=!0;return e.nodesBetween(s,i,(d,p,h,f)=>{var m;const y=l==null?void 0:l[d.type.name];y?(d.isBlock&&!u&&(c+=a,u=!0),h&&(c+=y({node:d,pos:p,parent:h,index:f,range:t}))):d.isText?(c+=(m=d==null?void 0:d.text)===null||m===void 0?void 0:m.slice(Math.max(s,p)-p,i-p),u=!1):d.isBlock&&!u&&(c+=a,u=!0)}),c}function rx(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,n])=>[t,n.spec.toText]))}qt.create({name:"clipboardTextSerializer",addProseMirrorPlugins(){return[new xr({key:new yr("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:s,selection:i}=t,{ranges:a}=i,l=Math.min(...a.map(p=>p.$from.pos)),c=Math.max(...a.map(p=>p.$to.pos)),u=rx(n);return nx(s,{from:l,to:c},{textSerializers:u})}}})]}});const sx=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),ix=(e=!1)=>({commands:t})=>t.setContent("",e),ax=()=>({state:e,tr:t,dispatch:n})=>{const{selection:s}=t,{ranges:i}=s;return n&&i.forEach(({$from:a,$to:l})=>{e.doc.nodesBetween(a.pos,l.pos,(c,u)=>{if(c.type.isText)return;const{doc:d,mapping:p}=t,h=d.resolve(p.map(u)),f=d.resolve(p.map(u+c.nodeSize)),m=h.blockRange(f);if(!m)return;const y=Um(m);if(c.type.isTextblock){const{defaultType:j}=h.parent.contentMatchAt(h.index());t.setNodeMarkup(m.start,j)}(y||y===0)&&t.lift(m,y)})}),!0},ox=e=>t=>e(t),lx=()=>({state:e,dispatch:t})=>De.createParagraphNear(e,t),cx=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,s=n.$anchor.node();if(s.content.size>0)return!1;const i=e.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===s.type){if(t){const c=i.before(a),u=i.after(a);e.delete(c,u).scrollIntoView()}return!0}return!1},ux=e=>({tr:t,state:n,dispatch:s})=>{const i=Oe(e,n.schema),a=t.selection.$anchor;for(let l=a.depth;l>0;l-=1)if(a.node(l).type===i){if(s){const u=a.before(l),d=a.after(l);t.delete(u,d).scrollIntoView()}return!0}return!1},dx=e=>({tr:t,dispatch:n})=>{const{from:s,to:i}=e;return n&&t.delete(s,i),!0},px=()=>({state:e,dispatch:t})=>De.deleteSelection(e,t),hx=()=>({commands:e})=>e.keyboardShortcut("Enter"),fx=()=>({state:e,dispatch:t})=>De.exitCode(e,t);function fs(e,t,n={strict:!0}){const s=Object.keys(t);return s.length?s.every(i=>n.strict?t[i]===e[i]:ex(t[i])?t[i].test(e[i]):t[i]===e[i]):!0}function qi(e,t,n={}){return e.find(s=>s.type===t&&fs(s.attrs,n))}function gx(e,t,n={}){return!!qi(e,t,n)}function Qc(e,t,n={}){if(!e||!t)return;let s=e.parent.childAfter(e.parentOffset);if(e.parentOffset===s.offset&&s.offset!==0&&(s=e.parent.childBefore(e.parentOffset)),!s.node)return;const i=qi([...s.node.marks],t,n);if(!i)return;let a=s.index,l=e.start()+s.offset,c=a+1,u=l+s.node.nodeSize;for(qi([...s.node.marks],t,n);a>0&&i.isInSet(e.parent.child(a-1).marks);)a-=1,l-=e.parent.child(a).nodeSize;for(;c<e.parent.childCount&&gx([...e.parent.child(c).marks],t,n);)u+=e.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function ln(e,t){if(typeof e=="string"){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}const mx=(e,t={})=>({tr:n,state:s,dispatch:i})=>{const a=ln(e,s.schema),{doc:l,selection:c}=n,{$from:u,from:d,to:p}=c;if(i){const h=Qc(u,a,t);if(h&&h.from<=d&&h.to>=p){const f=Se.create(l,h.from,h.to);n.setSelection(f)}}return!0},xx=e=>t=>{const n=typeof e=="function"?e(t):e;for(let s=0;s<n.length;s+=1)if(n[s](t))return!0;return!1};function Uc(e){return e instanceof Se}function Sn(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function yx(e,t=null){if(!t)return null;const n=fe.atStart(e),s=fe.atEnd(e);if(t==="start"||t===!0)return n;if(t==="end")return s;const i=n.from,a=s.to;return t==="all"?Se.create(e,Sn(0,i,a),Sn(e.content.size,i,a)):Se.create(e,Sn(t,i,a),Sn(t,i,a))}function Vi(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const bx=(e=null,t={})=>({editor:n,view:s,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};const l=()=>{Vi()&&s.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(s.focus(),t!=null&&t.scrollIntoView&&n.commands.scrollIntoView())})};if(s.hasFocus()&&e===null||e===!1)return!0;if(a&&e===null&&!Uc(n.state.selection))return l(),!0;const c=yx(i.doc,e)||n.state.selection,u=n.state.selection.eq(c);return a&&(u||i.setSelection(c),u&&i.storedMarks&&i.setStoredMarks(i.storedMarks),l()),!0},vx=(e,t)=>n=>e.every((s,i)=>t(s,{...n,index:i})),_x=(e,t)=>({tr:n,commands:s})=>s.insertContentAt({from:n.selection.from,to:n.selection.to},e,t);function Yc(e){const t=`<body>${e}</body>`;return new window.DOMParser().parseFromString(t,"text/html").body}function gs(e,t,n){if(n={slice:!0,parseOptions:{},...n},typeof e=="object"&&e!==null)try{return Array.isArray(e)&&e.length>0?H.fromArray(e.map(s=>t.nodeFromJSON(s))):t.nodeFromJSON(e)}catch(s){return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",s),gs("",t,n)}if(typeof e=="string"){const s=Bm.fromSchema(t);return n.slice?s.parseSlice(Yc(e),n.parseOptions).content:s.parse(Yc(e),n.parseOptions)}return gs("",t,n)}function jx(e,t,n){const s=e.steps.length-1;if(s<t)return;const i=e.steps[s];if(!(i instanceof Bt||i instanceof Cn))return;const a=e.mapping.maps[s];let l=0;a.forEach((c,u,d,p)=>{l===0&&(l=p)}),e.setSelection(fe.near(e.doc.resolve(l),n))}const wx=e=>e.toString().startsWith("<"),Cx=(e,t,n)=>({tr:s,dispatch:i,editor:a})=>{if(i){n={parseOptions:{},updateSelection:!0,...n};const l=gs(t,a.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if(l.toString()==="<>")return!0;let{from:c,to:u}=typeof e=="number"?{from:e,to:e}:e,d=!0,p=!0;if((wx(l)?l:[l]).forEach(f=>{f.check(),d=d?f.isText&&f.marks.length===0:!1,p=p?f.isBlock:!1}),c===u&&p){const{parent:f}=s.doc.resolve(c);f.isTextblock&&!f.type.spec.code&&!f.childCount&&(c-=1,u+=1)}d?Array.isArray(t)?s.insertText(t.map(f=>f.text||"").join(""),c,u):typeof t=="object"&&t&&t.text?s.insertText(t.text,c,u):s.insertText(t,c,u):s.replaceWith(c,u,l),n.updateSelection&&jx(s,s.steps.length-1,-1)}return!0},Sx=()=>({state:e,dispatch:t})=>De.joinUp(e,t),kx=()=>({state:e,dispatch:t})=>De.joinDown(e,t),Tx=()=>({state:e,dispatch:t})=>De.joinBackward(e,t),Dx=()=>({state:e,dispatch:t})=>De.joinForward(e,t);function Kc(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Mx(e){const t=e.split(/-(?!$)/);let n=t[t.length-1];n==="Space"&&(n=" ");let s,i,a,l;for(let c=0;c<t.length-1;c+=1){const u=t[c];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))s=!0;else if(/^(c|ctrl|control)$/i.test(u))i=!0;else if(/^s(hift)?$/i.test(u))a=!0;else if(/^mod$/i.test(u))Vi()||Kc()?l=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${u}`)}return s&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),l&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}const zx=e=>({editor:t,view:n,tr:s,dispatch:i})=>{const a=Mx(e).split(/-(?!$)/),l=a.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),c=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),u=t.captureTransaction(()=>{n.someProp("handleKeyDown",d=>d(n,c))});return u==null||u.steps.forEach(d=>{const p=d.map(s.mapping);p&&i&&s.maybeStep(p)}),!0};function Ni(e,t,n={}){const{from:s,to:i,empty:a}=e.selection,l=t?Oe(t,e.schema):null,c=[];e.doc.nodesBetween(s,i,(h,f)=>{if(h.isText)return;const m=Math.max(s,f),y=Math.min(i,f+h.nodeSize);c.push({node:h,from:m,to:y})});const u=i-s,d=c.filter(h=>l?l.name===h.node.type.name:!0).filter(h=>fs(h.node.attrs,n,{strict:!1}));return a?!!d.length:d.reduce((h,f)=>h+f.to-f.from,0)>=u}const Ix=(e,t={})=>({state:n,dispatch:s})=>{const i=Oe(e,n.schema);return Ni(n,i,t)?De.lift(n,s):!1},Ex=()=>({state:e,dispatch:t})=>De.liftEmptyBlock(e,t),Ax=e=>({state:t,dispatch:n})=>{const s=Oe(e,t.schema);return _i.liftListItem(s)(t,n)},Px=()=>({state:e,dispatch:t})=>De.newlineInCode(e,t);function Xc(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function Jc(e,t){const n=typeof t=="string"?[t]:t;return Object.keys(e).reduce((s,i)=>(n.includes(i)||(s[i]=e[i]),s),{})}const Ox=(e,t)=>({tr:n,state:s,dispatch:i})=>{let a=null,l=null;const c=Xc(typeof e=="string"?e:e.name,s.schema);return c?(c==="node"&&(a=Oe(e,s.schema)),c==="mark"&&(l=ln(e,s.schema)),i&&n.selection.ranges.forEach(u=>{s.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,p)=>{a&&a===d.type&&n.setNodeMarkup(p,void 0,Jc(d.attrs,t)),l&&d.marks.length&&d.marks.forEach(h=>{l===h.type&&n.addMark(p,p+d.nodeSize,l.create(Jc(h.attrs,t)))})})}),!0):!1},Lx=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),Bx=()=>({tr:e,commands:t})=>t.setTextSelection({from:0,to:e.doc.content.size}),qx=()=>({state:e,dispatch:t})=>De.selectNodeBackward(e,t),Vx=()=>({state:e,dispatch:t})=>De.selectNodeForward(e,t),Nx=()=>({state:e,dispatch:t})=>De.selectParentNode(e,t),$x=()=>({state:e,dispatch:t})=>De.selectTextblockEnd(e,t),Fx=()=>({state:e,dispatch:t})=>De.selectTextblockStart(e,t);function Gx(e,t,n={}){return gs(e,t,{slice:!1,parseOptions:n})}const Wx=(e,t=!1,n={})=>({tr:s,editor:i,dispatch:a})=>{const{doc:l}=s,c=Gx(e,i.schema,n);return a&&s.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!t),!0};function Rx(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Qx(e,t){for(let n=e.depth;n>0;n-=1){const s=e.node(n);if(t(s))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:s}}}function $i(e){return t=>Qx(t.$from,e)}function Ux(e,t){const n=ln(t,e.schema),{from:s,to:i,empty:a}=e.selection,l=[];a?(e.storedMarks&&l.push(...e.storedMarks),l.push(...e.selection.$head.marks())):e.doc.nodesBetween(s,i,u=>{l.push(...u.marks)});const c=l.find(u=>u.type.name===n.name);return c?{...c.attrs}:{}}function ms(e,t,n){return Object.fromEntries(Object.entries(n).filter(([s])=>{const i=e.find(a=>a.type===t&&a.name===s);return i?i.attribute.keepOnSplit:!1}))}function Yx(e,t,n={}){const{empty:s,ranges:i}=e.selection,a=t?ln(t,e.schema):null;if(s)return!!(e.storedMarks||e.selection.$from.marks()).filter(h=>a?a.name===h.type.name:!0).find(h=>fs(h.attrs,n,{strict:!1}));let l=0;const c=[];if(i.forEach(({$from:h,$to:f})=>{const m=h.pos,y=f.pos;e.doc.nodesBetween(m,y,(j,k)=>{if(!j.isText&&!j.marks.length)return;const S=Math.max(m,k),T=Math.min(y,k+j.nodeSize),z=T-S;l+=z,c.push(...j.marks.map(I=>({mark:I,from:S,to:T})))})}),l===0)return!1;const u=c.filter(h=>a?a.name===h.mark.type.name:!0).filter(h=>fs(h.mark.attrs,n,{strict:!1})).reduce((h,f)=>h+f.to-f.from,0),d=c.filter(h=>a?h.mark.type!==a&&h.mark.type.excludes(a):!0).reduce((h,f)=>h+f.to-f.from,0);return(u>0?u+d:u)>=l}function Zc(e,t){const{nodeExtensions:n}=Zm(t),s=n.find(l=>l.name===e);if(!s)return!1;const i={name:s.name,options:s.options,storage:s.storage},a=jt(nt(s,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function Kx(e,t,n){var s;const{selection:i}=t;let a=null;if(Uc(i)&&(a=i.$cursor),a){const c=(s=e.storedMarks)!==null&&s!==void 0?s:a.marks();return!!n.isInSet(c)||!c.some(u=>u.type.excludes(n))}const{ranges:l}=i;return l.some(({$from:c,$to:u})=>{let d=c.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(c.pos,u.pos,(p,h,f)=>{if(d)return!1;if(p.isInline){const m=!f||f.type.allowsMarkType(n),y=!!n.isInSet(p.marks)||!p.marks.some(j=>j.type.excludes(n));d=m&&y}return!d}),d})}const Xx=(e,t={})=>({tr:n,state:s,dispatch:i})=>{const{selection:a}=n,{empty:l,ranges:c}=a,u=ln(e,s.schema);if(i)if(l){const d=Ux(s,u);n.addStoredMark(u.create({...d,...t}))}else c.forEach(d=>{const p=d.$from.pos,h=d.$to.pos;s.doc.nodesBetween(p,h,(f,m)=>{const y=Math.max(m,p),j=Math.min(m+f.nodeSize,h);f.marks.find(S=>S.type===u)?f.marks.forEach(S=>{u===S.type&&n.addMark(y,j,u.create({...S.attrs,...t}))}):n.addMark(y,j,u.create(t))})});return Kx(s,n,u)},Jx=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),Zx=(e,t={})=>({state:n,dispatch:s,chain:i})=>{const a=Oe(e,n.schema);return a.isTextblock?i().command(({commands:l})=>De.setBlockType(a,t)(n)?!0:l.clearNodes()).command(({state:l})=>De.setBlockType(a,t)(l,s)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Hx=e=>({tr:t,dispatch:n})=>{if(n){const{doc:s}=t,i=Sn(e,0,s.content.size),a=tt.create(s,i);t.setSelection(a)}return!0},ey=e=>({tr:t,dispatch:n})=>{if(n){const{doc:s}=t,{from:i,to:a}=typeof e=="number"?{from:e,to:e}:e,l=Se.atStart(s).from,c=Se.atEnd(s).to,u=Sn(i,l,c),d=Sn(a,l,c),p=Se.create(s,u,d);t.setSelection(p)}return!0},ty=e=>({state:t,dispatch:n})=>{const s=Oe(e,t.schema);return _i.sinkListItem(s)(t,n)};function Hc(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const s=n.filter(i=>t==null?void 0:t.includes(i.type.name));e.tr.ensureMarks(s)}}const ny=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:s,editor:i})=>{const{selection:a,doc:l}=t,{$from:c,$to:u}=a,d=i.extensionManager.attributes,p=ms(d,c.node().type.name,c.node().attrs);if(a instanceof tt&&a.node.isBlock)return!c.parentOffset||!ds(l,c.pos)?!1:(s&&(e&&Hc(n,i.extensionManager.splittableMarks),t.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;if(s){const h=u.parentOffset===u.parent.content.size;a instanceof Se&&t.deleteSelection();const f=c.depth===0?void 0:Rx(c.node(-1).contentMatchAt(c.indexAfter(-1)));let m=h&&f?[{type:f,attrs:p}]:void 0,y=ds(t.doc,t.mapping.map(c.pos),1,m);if(!m&&!y&&ds(t.doc,t.mapping.map(c.pos),1,f?[{type:f}]:void 0)&&(y=!0,m=f?[{type:f,attrs:p}]:void 0),y&&(t.split(t.mapping.map(c.pos),1,m),f&&!h&&!c.parentOffset&&c.parent.type!==f)){const j=t.mapping.map(c.before()),k=t.doc.resolve(j);c.node(-1).canReplaceWith(k.index(),k.index()+1,f)&&t.setNodeMarkup(t.mapping.map(c.before()),f)}e&&Hc(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return!0},ry=e=>({tr:t,state:n,dispatch:s,editor:i})=>{var a;const l=Oe(e,n.schema),{$from:c,$to:u}=n.selection,d=n.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(u))return!1;const p=c.node(-1);if(p.type!==l)return!1;const h=i.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(s){let k=H.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let R=c.depth-S;R>=c.depth-3;R-=1)k=H.from(c.node(R).copy(k));const T=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,z=ms(h,c.node().type.name,c.node().attrs),I=((a=l.contentMatch.defaultType)===null||a===void 0?void 0:a.createAndFill(z))||void 0;k=k.append(H.from(l.createAndFill(null,I)||void 0));const E=c.before(c.depth-(S-1));t.replace(E,c.after(-T),new re(k,4-S,0));let N=-1;t.doc.nodesBetween(E,t.doc.content.size,(R,pe)=>{if(N>-1)return!1;R.isTextblock&&R.content.size===0&&(N=pe+1)}),N>-1&&t.setSelection(Se.near(t.doc.resolve(N))),t.scrollIntoView()}return!0}const f=u.pos===c.end()?p.contentMatchAt(0).defaultType:null,m=ms(h,p.type.name,p.attrs),y=ms(h,c.node().type.name,c.node().attrs);t.delete(c.pos,u.pos);const j=f?[{type:l,attrs:m},{type:f,attrs:y}]:[{type:l,attrs:m}];if(!ds(t.doc,c.pos,2))return!1;if(s){const{selection:k,storedMarks:S}=n,{splittableMarks:T}=i.extensionManager,z=S||k.$to.parentOffset&&k.$from.marks();if(t.split(c.pos,2,j).scrollIntoView(),!z||!s)return!0;const I=z.filter(E=>T.includes(E.type.name));t.ensureMarks(I)}return!0},Fi=(e,t)=>{const n=$i(l=>l.type===t)(e.selection);if(!n)return!0;const s=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(s===void 0)return!0;const i=e.doc.nodeAt(s);return n.node.type===(i==null?void 0:i.type)&&qc(e.doc,n.pos)&&e.join(n.pos),!0},Gi=(e,t)=>{const n=$i(l=>l.type===t)(e.selection);if(!n)return!0;const s=e.doc.resolve(n.start).after(n.depth);if(s===void 0)return!0;const i=e.doc.nodeAt(s);return n.node.type===(i==null?void 0:i.type)&&qc(e.doc,s)&&e.join(s),!0};var sy=Object.freeze({__proto__:null,blur:sx,clearContent:ix,clearNodes:ax,command:ox,createParagraphNear:lx,deleteCurrentNode:cx,deleteNode:ux,deleteRange:dx,deleteSelection:px,enter:hx,exitCode:fx,extendMarkRange:mx,first:xx,focus:bx,forEach:vx,insertContent:_x,insertContentAt:Cx,joinUp:Sx,joinDown:kx,joinBackward:Tx,joinForward:Dx,keyboardShortcut:zx,lift:Ix,liftEmptyBlock:Ex,liftListItem:Ax,newlineInCode:Px,resetAttributes:Ox,scrollIntoView:Lx,selectAll:Bx,selectNodeBackward:qx,selectNodeForward:Vx,selectParentNode:Nx,selectTextblockEnd:$x,selectTextblockStart:Fx,setContent:Wx,setMark:Xx,setMeta:Jx,setNode:Zx,setNodeSelection:Hx,setTextSelection:ey,sinkListItem:ty,splitBlock:ny,splitListItem:ry,toggleList:(e,t,n,s={})=>({editor:i,tr:a,state:l,dispatch:c,chain:u,commands:d,can:p})=>{const{extensions:h,splittableMarks:f}=i.extensionManager,m=Oe(e,l.schema),y=Oe(t,l.schema),{selection:j,storedMarks:k}=l,{$from:S,$to:T}=j,z=S.blockRange(T),I=k||j.$to.parentOffset&&j.$from.marks();if(!z)return!1;const E=$i(N=>Zc(N.type.name,h))(j);if(z.depth>=1&&E&&z.depth-E.depth<=1){if(E.node.type===m)return d.liftListItem(y);if(Zc(E.node.type.name,h)&&m.validContent(E.node.content)&&c)return u().command(()=>(a.setNodeMarkup(E.pos,m),!0)).command(()=>Fi(a,m)).command(()=>Gi(a,m)).run()}return!n||!I||!c?u().command(()=>p().wrapInList(m,s)?!0:d.clearNodes()).wrapInList(m,s).command(()=>Fi(a,m)).command(()=>Gi(a,m)).run():u().command(()=>{const N=p().wrapInList(m,s),R=I.filter(pe=>f.includes(pe.type.name));return a.ensureMarks(R),N?!0:d.clearNodes()}).wrapInList(m,s).command(()=>Fi(a,m)).command(()=>Gi(a,m)).run()},toggleMark:(e,t={},n={})=>({state:s,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,l=ln(e,s.schema);return Yx(s,l,t)?i.unsetMark(l,{extendEmptyMarkRange:a}):i.setMark(l,t)},toggleNode:(e,t,n={})=>({state:s,commands:i})=>{const a=Oe(e,s.schema),l=Oe(t,s.schema);return Ni(s,a,n)?i.setNode(l):i.setNode(a,n)},toggleWrap:(e,t={})=>({state:n,commands:s})=>{const i=Oe(e,n.schema);return Ni(n,i,t)?s.lift(i):s.wrapIn(i,t)},undoInputRule:()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let s=0;s<n.length;s+=1){const i=n[s];let a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){const l=e.tr,c=a.transform;for(let u=c.steps.length-1;u>=0;u-=1)l.step(c.steps[u].invert(c.docs[u]));if(a.text){const u=l.doc.resolve(a.from).marks();l.replaceWith(a.from,a.to,e.schema.text(a.text,u))}else l.delete(a.from,a.to)}return!0}}return!1},unsetAllMarks:()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:s,ranges:i}=n;return s||t&&i.forEach(a=>{e.removeMark(a.$from.pos,a.$to.pos)}),!0},unsetMark:(e,t={})=>({tr:n,state:s,dispatch:i})=>{var a;const{extendEmptyMarkRange:l=!1}=t,{selection:c}=n,u=ln(e,s.schema),{$from:d,empty:p,ranges:h}=c;if(!i)return!0;if(p&&l){let{from:f,to:m}=c;const y=(a=d.marks().find(k=>k.type===u))===null||a===void 0?void 0:a.attrs,j=Qc(d,u,y);j&&(f=j.from,m=j.to),n.removeMark(f,m,u)}else h.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,u)});return n.removeStoredMark(u),!0},updateAttributes:(e,t={})=>({tr:n,state:s,dispatch:i})=>{let a=null,l=null;const c=Xc(typeof e=="string"?e:e.name,s.schema);return c?(c==="node"&&(a=Oe(e,s.schema)),c==="mark"&&(l=ln(e,s.schema)),i&&n.selection.ranges.forEach(u=>{const d=u.$from.pos,p=u.$to.pos;s.doc.nodesBetween(d,p,(h,f)=>{a&&a===h.type&&n.setNodeMarkup(f,void 0,{...h.attrs,...t}),l&&h.marks.length&&h.marks.forEach(m=>{if(l===m.type){const y=Math.max(f,d),j=Math.min(f+h.nodeSize,p);n.addMark(y,j,l.create({...m.attrs,...t}))}})})}),!0):!1},wrapIn:(e,t={})=>({state:n,dispatch:s})=>{const i=Oe(e,n.schema);return De.wrapIn(i,t)(n,s)},wrapInList:(e,t={})=>({state:n,dispatch:s})=>{const i=Oe(e,n.schema);return _i.wrapInList(i,t)(n,s)}});qt.create({name:"commands",addCommands(){return{...sy}}}),qt.create({name:"editable",addProseMirrorPlugins(){return[new xr({key:new yr("editable"),props:{editable:()=>this.editor.options.editable}})]}}),qt.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new xr({key:new yr("focusEvents"),props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const s=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(s),!1},blur:(t,n)=>{e.isFocused=!1;const s=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(s),!1}}}})]}}),qt.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:c})=>{const{selection:u,doc:d}=c,{empty:p,$anchor:h}=u,{pos:f,parent:m}=h,y=fe.atStart(d).from===f;return!p||!y||!m.type.isTextblock||m.textContent.length?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),s={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},i={...s},a={...s,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Vi()||Kc()?a:i},addProseMirrorPlugins(){return[new xr({key:new yr("clearDocument"),appendTransaction:(e,t,n)=>{if(!(e.some(y=>y.docChanged)&&!t.doc.eq(n.doc)))return;const{empty:i,from:a,to:l}=t.selection,c=fe.atStart(t.doc).from,u=fe.atEnd(t.doc).to;if(i||!(a===c&&l===u)||!(n.doc.textBetween(0,n.doc.content.size," "," ").length===0))return;const h=n.tr,f=Rc({state:n,transaction:h}),{commands:m}=new Jm({editor:this.editor,state:f});if(m.clearNodes(),!!h.steps.length)return h}})]}}),qt.create({name:"tabindex",addProseMirrorPlugins(){return[new xr({key:new yr("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});class xs{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=jt(nt(this,"addOptions",{name:this.name}))),this.storage=jt(nt(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new xs(t)}configure(t={}){const n=this.extend();return n.options=Bi(this.options,t),n.storage=jt(nt(n,"addStorage",{name:n.name,options:n.options})),n}extend(t={}){const n=new xs(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=jt(nt(n,"addOptions",{name:n.name})),n.storage=jt(nt(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:t,mark:n}){const{tr:s}=t.state,i=t.state.selection.$from;if(i.pos===i.end()){const l=i.marks();if(!!!l.find(d=>(d==null?void 0:d.type.name)===n.name))return!1;const u=l.find(d=>(d==null?void 0:d.type.name)===n.name);return u&&s.removeStoredMark(u),s.insertText(" ",i.pos),t.view.dispatch(s),!0}return!1}}const eu=qt.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize.replace(/['"]+/g,""),renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),iy=["8","10","12","14","16","18","20","24","30","36","48","60","72"].map(e=>`${e}px`),ay=[{label:"auto",value:""}].concat(iy.map(e=>({label:e,value:e}))),oy={input:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important"}},ly=({editor:e})=>{const t=e.getAttributes("textStyle").fontSize;return r.jsx(Q.RichTextEditor.ControlsGroup,{children:r.jsx(o.NativeSelect,{size:"xs",icon:r.jsx(M.IconTextSize,{stroke:1.5,size:16}),data:ay,styles:oy,value:t||"",onChange:n=>{const s=n.currentTarget.value;s?e.chain().focus().setFontSize(s).run():e.chain().focus().unsetFontSize().run()}})})},Wi="function color({ variables }, { filters, context }, utils) {",tu="}",cy=[Wi,' return "red";',tu].join(`
60
60
  `);function uy(e){const t=e.split(`
61
61
  `);if(t.length===2)return console.warn("[getDynamicColorRestrictions]unexpected lines of code: ",e),[];const n=t[t.length-2];return n?[{range:[2,1,t.length-1,n.length+1],label:"body",allowMultiline:!0}]:[]}const dy=e=>!e||e.startsWith(Wi)?e:[Wi,e,tu].join(`
62
- `),nu=e=>{const n="abcdefghijklmnopqrstuvwxyz",i=`1234567890${n}${n.toUpperCase()}`.split(""),a=new Uint8Array(e);return crypto.getRandomValues(a),a.reduce((l,c)=>`${l}${i[c&61]}`,"")};function py(e,t,n){const s={},i=l=>new Function(`return ${dy(l)}`)()({variables:n},t,vt);return e.querySelectorAll("dynamic-color").forEach(l=>{const c=l.getAttribute("data-value");c&&(s[`#${l.id}`]={color:i(c)})}),s}const br="data-value",hy=br,ru="dynamicColor",su=xs.create({name:ru,addAttributes(){return{id:{default:nu(6),parseHTML:e=>e.getAttribute("id")},[br]:{default:null,parseHTML:e=>e.getAttribute(br)}}},parseHTML(){return[{tag:"dynamic-color",getAttrs:e=>typeof e=="string"?(console.debug(e),!1):[e.getAttribute(br)]}]},renderHTML({HTMLAttributes:e}){return["dynamic-color",e,0]},addCommands(){return{setDynamicColor:e=>({commands:t})=>t.setMark(this.name,{[br]:e}),unsetDynamicColor:()=>({commands:e})=>e.unsetMark(this.name)}}}),fy=({value:e,onChange:t,onMount:n})=>{const s=i=>{if(!i){t("");return}t(i)};return r.jsx(et,{className:"function-editor",height:"100%",defaultLanguage:"javascript",value:e,onChange:s,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1}},onMount:n})},Nn=g.forwardRef(({value:e,onChange:t,label:n,defaultValue:s,restrictions:i=[]},a)=>{const{t:l}=_.useTranslation(),[c,u]=g.useState(e),d=()=>{t(c)},p=()=>{u(e)},h=()=>{u(s)};g.useEffect(()=>{u(e)},[e]);const f=g.useCallback((j,k)=>{if(i.length===0)return;const S=Dg.constrainedEditor(k),T=j.getModel();if(S.initializeIn(j),S.addRestrictionsTo(T,i),!!T&&!T._hasHighlight){S.toggleDevMode(),T.toggleHighlightOfEditableAreas();const z=T.getCurrentEditableRanges(),I=T.getValueInEditableRanges();console.debug({model:T,currentRanges:z,currentValue:I})}},[]),m=c!==e,y=typeof c=="string"&&c.length===0;return r.jsxs(o.Stack,{spacing:4,sx:{height:"100%",".editableArea--multi-line":{backgroundColor:"rgba(255,183,78, 0.1)"},".editableArea--single-line":{backgroundColor:"rgba(255,183,78, 0.1)"}},children:[r.jsxs(o.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[r.jsx(o.Group,{position:"left",children:r.jsx(iu,{})}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:h,size:"xs",variant:"default",leftIcon:r.jsx(M.IconPlayerSkipBack,{size:16}),children:l("common.actions.reset_to_default")}),r.jsx(o.Button,{onClick:p,color:"red",size:"xs",disabled:!m,leftIcon:r.jsx(M.IconRecycle,{size:16}),children:l("common.actions.revert_changes")}),r.jsx(o.Button,{color:"green",size:"xs",onClick:d,disabled:!m,leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),children:l("common.actions.save_changes")})]})]}),r.jsx(o.Text,{size:14,children:n}),r.jsxs(o.Box,{sx:{position:"relative",flexGrow:1},children:[y&&r.jsx(o.Overlay,{center:!0,color:"#fff",opacity:.5,children:r.jsx(o.Button,{color:"blue",radius:"xl",onClick:h,children:l("common.actions.init_with_default")})}),r.jsx(fy,{value:c,onChange:u,onMount:f})]})]})}),Ri=g.forwardRef(({title:e,value:t,onChange:n,label:s,description:i=null,triggerLabel:a="Edit",triggerButtonProps:l={},renderTriggerButton:c,defaultValue:u,zIndex:d=320,restrictions:p},h)=>{const[f,{open:m,close:y}]=he.useDisclosure(!1);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Modal,{opened:f,onClose:y,title:e,withinPortal:!0,zIndex:d,size:"900px",children:[i,r.jsx(o.Box,{h:600,children:r.jsx(Nn,{value:t,onChange:n,defaultValue:u,label:s,restrictions:p})})]}),c==null?void 0:c({onClick:m}),!c&&r.jsx(o.Button,{onClick:m,...l,children:a})]})}),gy=({onClick:e})=>{const{t}=_.useTranslation();return r.jsx(o.Tooltip,{label:t("rich_text.dynamic_color.label"),children:r.jsx(o.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important",color:"rgb(190, 75, 219)"},onClick:e,children:r.jsx(M.IconMathFunction,{stroke:2,size:16})})})},my=({editor:e})=>{const{t}=_.useTranslation(),n=e.getAttributes(ru)[hy]??"";return r.jsx(Ri,{title:t("rich_text.dynamic_color.edit"),label:"",triggerLabel:"",value:n,onChange:s=>{s?e.chain().focus().setDynamicColor(s).run():e.chain().focus().unsetDynamicColor().run()},defaultValue:cy,renderTriggerButton:gy,restrictions:uy(n),zIndex:340})},vr=({value:e,styles:t={},sx:n={},dashboardState:s=Yi(),varaiables:i={}})=>{const a=ic.useEditor({extensions:[ac,sc,Q.Link,Jl,Xl,Yl,ec.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),rc,nc,tc,Zl.configure({types:["heading","paragraph"]}),Kl.configure({placeholder:"This is placeholder"}),Hl,Ul.Color,eu,su],content:e,editable:!1});g.useEffect(()=>{a==null||a.commands.setContent(e)},[e,a]);const l=g.useMemo(()=>new DOMParser().parseFromString(e,"text/html"),[e]),c=g.useMemo(()=>py(l,s,i),[l,s,i]),u=g.useMemo(()=>v.defaultsDeep({},{content:{...Ti,...c}},t),[t,c]);return r.jsx(Q.RichTextEditor,{editor:a,styles:u,sx:n,children:r.jsx(Q.RichTextEditor.Content,{})})};function iu(){const{t:e}=_.useTranslation(),[t,{open:n,close:s}]=he.useDisclosure(!1);return r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{opened:t,onClose:s,title:e("function_utils.modal_title"),zIndex:330,withinPortal:!0,children:r.jsx(vr,{value:wm(e),styles:{root:{border:"none"},content:{padding:0,table:{marginBottom:0}}}})}),r.jsx(o.Button,{variant:"light",color:"violet",size:"xs",onClick:n,leftIcon:r.jsx(M.IconInfoCircle,{size:16}),children:e("function_utils.trigger_text")})]})}const au=g.forwardRef((e,t)=>{const{label:n,description:s,...i}=e;return r.jsx("div",{ref:t,...i,children:r.jsxs(o.Group,{position:"apart",noWrap:!0,children:[r.jsx(o.Text,{children:n}),r.jsx(o.Text,{size:"xs",color:"dimmed",children:s})]})})}),Qi=({value:e,onChange:t,height:n="200px",defaultLanguage:s="sql",theme:i="vs-dark"})=>{const a=c=>{t==null||t(c??"")},l=!t;return r.jsx(et,{className:"minimal-monaco-editor",height:n,defaultLanguage:s,value:e,onChange:l?void 0:a,theme:i,options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:l||!t,"semanticHighlighting.enabled":!0}})},xy={"dynamic-color":{position:"relative"},"dynamic-color:after":{content:'""',position:"absolute",bottom:"-2px",left:0,width:"100%",height:"1px",border:"double 1px purple"}};function yy(){const{editor:e}=Q.useRichTextEditorContext();return r.jsx(Q.RichTextEditor.Control,{onClick:()=>e==null?void 0:e.commands.insertTable({rows:3,cols:3,withHeaderRow:!0}),"aria-label":"Insert table",title:"Insert table",children:r.jsx(M.IconBorderAll,{stroke:1.5,size:16})})}const ys=g.forwardRef(({value:e,onChange:t,styles:n={},label:s,autoSubmit:i,onSubmit:a},l)=>{console.log("value:",e);const[c,u]=g.useState(e),d=ic.useEditor({extensions:[ac,sc,Q.Link,Jl,Xl,Yl,ec.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),rc,nc,tc,Zl.configure({types:["heading","paragraph"]}),Kl.configure({placeholder:"This is placeholder"}),Hl,Ul.Color,eu,su],content:c,onUpdate:({editor:m})=>{const y=m.getHTML();u(y)}});g.useEffect(()=>{u(m=>e===m?m:(d==null||d.commands.setContent(e),e))},[e]);const p=()=>{t(c),a==null||a()},h=e!==c;g.useEffect(()=>{i&&p()},[i,h]);const f=g.useMemo(()=>v.defaultsDeep({},{content:{...Ti,...xy}},n),[n]);return d?r.jsxs(o.Stack,{spacing:4,sx:{flexGrow:1,position:"relative"},children:[r.jsxs(o.Group,{align:"center",children:[r.jsx(o.Text,{size:14,fw:500,children:s}),!i&&r.jsx(o.ActionIcon,{color:"green",disabled:!h,onClick:p,children:r.jsx(M.IconDeviceFloppy,{size:18})})]}),r.jsxs(Q.RichTextEditor,{editor:d,styles:f,children:[r.jsxs(Q.RichTextEditor.Toolbar,{sticky:!0,stickyOffset:0,children:[r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.ColorPicker,{colors:["#25262b","#868e96","#fa5252","#e64980","#be4bdb","#7950f2","#4c6ef5","#228be6","#15aabf","#12b886","#40c057","#82c91e","#fab005","#fd7e14"],popoverProps:{zIndex:320}}),r.jsx(my,{editor:d})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.Bold,{}),r.jsx(Q.RichTextEditor.Italic,{}),r.jsx(Q.RichTextEditor.Underline,{}),r.jsx(Q.RichTextEditor.ClearFormatting,{}),r.jsx(Q.RichTextEditor.Highlight,{}),r.jsx(Q.RichTextEditor.Code,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.H1,{}),r.jsx(Q.RichTextEditor.H2,{}),r.jsx(Q.RichTextEditor.H3,{}),r.jsx(Q.RichTextEditor.H4,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.Blockquote,{}),r.jsx(Q.RichTextEditor.Hr,{}),r.jsx(Q.RichTextEditor.BulletList,{}),r.jsx(Q.RichTextEditor.OrderedList,{}),r.jsx(Q.RichTextEditor.Subscript,{}),r.jsx(Q.RichTextEditor.Superscript,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.Link,{}),r.jsx(Q.RichTextEditor.Unlink,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.AlignLeft,{}),r.jsx(Q.RichTextEditor.AlignCenter,{}),r.jsx(Q.RichTextEditor.AlignJustify,{}),r.jsx(Q.RichTextEditor.AlignRight,{})]}),r.jsx(Q.RichTextEditor.ControlsGroup,{children:r.jsx(yy,{})}),r.jsx(ly,{editor:d})]}),r.jsx(Q.RichTextEditor.Content,{})]})]}):null});function by(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function Vt({data_field:e,aggregation:t},n){return is(n,e,t)}function rt({formatter:e,aggregation:t},n){if(typeof n!="string"&&typeof n!="number")return by(n);if(t.type==="custom")return n;try{return U(n,e)}catch(s){return console.error(s),n}}function vy(e,t){return e.replaceAll(/(\$\{([^{\}]+(?=}))\})/g,(...s)=>{const i=s[2],a=t.variableStyleMap[i];if(!a)return`{{${i}}}`;const{variable:l,...c}=a,u=Object.entries(c).map(([f,m])=>`${f}:${m}`).join(";"),d=l.color;if(d.type!=="continuous")return`<span style="${u}">{{${i}}}</span>`;const p=nu(6),h=`try {
62
+ `),nu=e=>{const n="abcdefghijklmnopqrstuvwxyz",i=`1234567890${n}${n.toUpperCase()}`.split(""),a=new Uint8Array(e);return crypto.getRandomValues(a),a.reduce((l,c)=>`${l}${i[c&61]}`,"")};function py(e,t,n){const s={},i=l=>new Function(`return ${dy(l)}`)()({variables:n},t,vt);return e.querySelectorAll("dynamic-color").forEach(l=>{const c=l.getAttribute("data-value");c&&(s[`#${l.id}`]={color:i(c)})}),s}const br="data-value",hy=br,ru="dynamicColor",su=xs.create({name:ru,addAttributes(){return{id:{default:nu(6),parseHTML:e=>e.getAttribute("id")},[br]:{default:null,parseHTML:e=>e.getAttribute(br)}}},parseHTML(){return[{tag:"dynamic-color",getAttrs:e=>typeof e=="string"?(console.debug(e),!1):[e.getAttribute(br)]}]},renderHTML({HTMLAttributes:e}){return["dynamic-color",e,0]},addCommands(){return{setDynamicColor:e=>({commands:t})=>t.setMark(this.name,{[br]:e}),unsetDynamicColor:()=>({commands:e})=>e.unsetMark(this.name)}}}),fy=({value:e,onChange:t,onMount:n})=>{const s=i=>{if(!i){t("");return}t(i)};return r.jsx(et,{className:"function-editor",height:"100%",defaultLanguage:"javascript",value:e,onChange:s,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1}},onMount:n})},Nn=g.forwardRef(({value:e,onChange:t,label:n,defaultValue:s,restrictions:i=[]},a)=>{const{t:l}=_.useTranslation(),[c,u]=g.useState(e),d=()=>{t(c)},p=()=>{u(e)},h=()=>{u(s)};g.useEffect(()=>{u(e)},[e]);const f=g.useCallback((j,k)=>{if(i.length===0)return;const S=Dg.constrainedEditor(k),T=j.getModel();if(S.initializeIn(j),S.addRestrictionsTo(T,i),!!T&&!T._hasHighlight){S.toggleDevMode(),T.toggleHighlightOfEditableAreas();const z=T.getCurrentEditableRanges(),I=T.getValueInEditableRanges();console.debug({model:T,currentRanges:z,currentValue:I})}},[]),m=c!==e,y=typeof c=="string"&&c.length===0;return r.jsxs(o.Stack,{spacing:4,sx:{height:"100%",".editableArea--multi-line":{backgroundColor:"rgba(255,183,78, 0.1)"},".editableArea--single-line":{backgroundColor:"rgba(255,183,78, 0.1)"}},children:[r.jsxs(o.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[r.jsx(o.Group,{position:"left",children:r.jsx(iu,{})}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:h,size:"xs",variant:"default",leftIcon:r.jsx(M.IconPlayerSkipBack,{size:16}),children:l("common.actions.reset_to_default")}),r.jsx(o.Button,{onClick:p,color:"red",size:"xs",disabled:!m,leftIcon:r.jsx(M.IconRecycle,{size:16}),children:l("common.actions.revert_changes")}),r.jsx(o.Button,{color:"green",size:"xs",onClick:d,disabled:!m,leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),children:l("common.actions.save_changes")})]})]}),r.jsx(o.Text,{size:14,children:n}),r.jsxs(o.Box,{sx:{position:"relative",flexGrow:1},children:[y&&r.jsx(o.Overlay,{center:!0,color:"#fff",opacity:.5,children:r.jsx(o.Button,{color:"blue",radius:"xl",onClick:h,children:l("common.actions.init_with_default")})}),r.jsx(fy,{value:c,onChange:u,onMount:f})]})]})}),Ri=g.forwardRef(({title:e,value:t,onChange:n,label:s,description:i=null,triggerLabel:a="Edit",triggerButtonProps:l={},renderTriggerButton:c,defaultValue:u,zIndex:d=320,restrictions:p},h)=>{const[f,{open:m,close:y}]=he.useDisclosure(!1);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Modal,{opened:f,onClose:y,title:e,withinPortal:!0,zIndex:d,size:"900px",children:[i,r.jsx(o.Box,{h:600,children:r.jsx(Nn,{value:t,onChange:n,defaultValue:u,label:s,restrictions:p})})]}),c==null?void 0:c({onClick:m}),!c&&r.jsx(o.Button,{onClick:m,...l,children:a})]})}),gy=({onClick:e})=>{const{t}=_.useTranslation();return r.jsx(o.Tooltip,{label:t("rich_text.dynamic_color.label"),children:r.jsx(o.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important",color:"rgb(190, 75, 219)"},onClick:e,children:r.jsx(M.IconMathFunction,{stroke:2,size:16})})})},my=({editor:e})=>{const{t}=_.useTranslation(),n=e.getAttributes(ru)[hy]??"";return r.jsx(Ri,{title:t("rich_text.dynamic_color.edit"),label:"",triggerLabel:"",value:n,onChange:s=>{s?e.chain().focus().setDynamicColor(s).run():e.chain().focus().unsetDynamicColor().run()},defaultValue:cy,renderTriggerButton:gy,restrictions:uy(n),zIndex:340})},vr=({value:e,styles:t={},sx:n={},dashboardState:s=Yi(),varaiables:i={}})=>{const a=ic.useEditor({extensions:[ac,sc,Q.Link,Jl,Xl,Yl,ec.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),rc,nc,tc,Zl.configure({types:["heading","paragraph"]}),Kl.configure({placeholder:"This is placeholder"}),Hl,Ul.Color,eu,su],content:e,editable:!1});g.useEffect(()=>{a==null||a.commands.setContent(e)},[e,a]);const l=g.useMemo(()=>new DOMParser().parseFromString(e,"text/html"),[e]),c=g.useMemo(()=>py(l,s,i),[l,s,i]),u=g.useMemo(()=>v.defaultsDeep({},{content:{...Ti,...c}},t),[t,c]);return r.jsx(Q.RichTextEditor,{editor:a,styles:u,sx:n,children:r.jsx(Q.RichTextEditor.Content,{})})};function iu(){const{t:e}=_.useTranslation(),[t,{open:n,close:s}]=he.useDisclosure(!1);return r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{opened:t,onClose:s,title:e("function_utils.modal_title"),zIndex:330,withinPortal:!0,children:r.jsx(vr,{value:wm(e),styles:{root:{border:"none"},content:{padding:0,table:{marginBottom:0}}}})}),r.jsx(o.Button,{variant:"light",color:"violet",size:"xs",onClick:n,leftIcon:r.jsx(M.IconInfoCircle,{size:16}),children:e("function_utils.trigger_text")})]})}const au=g.forwardRef((e,t)=>{const{label:n,description:s,...i}=e;return r.jsx("div",{ref:t,...i,children:r.jsxs(o.Group,{position:"apart",noWrap:!0,children:[r.jsx(o.Text,{children:n}),r.jsx(o.Text,{size:"xs",color:"dimmed",children:s})]})})}),Qi=({value:e,onChange:t,height:n="200px",defaultLanguage:s="sql",theme:i="vs-dark"})=>{const a=c=>{t==null||t(c??"")},l=!t;return r.jsx(et,{className:"minimal-monaco-editor",height:n,defaultLanguage:s,value:e,onChange:l?void 0:a,theme:i,options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:l||!t,"semanticHighlighting.enabled":!0}})},xy={"dynamic-color":{position:"relative"},"dynamic-color:after":{content:'""',position:"absolute",bottom:"-2px",left:0,width:"100%",height:"1px",border:"double 1px purple"}};function yy(){const{editor:e}=Q.useRichTextEditorContext();return r.jsx(Q.RichTextEditor.Control,{onClick:()=>e==null?void 0:e.commands.insertTable({rows:3,cols:3,withHeaderRow:!0}),"aria-label":"Insert table",title:"Insert table",children:r.jsx(M.IconBorderAll,{stroke:1.5,size:16})})}const ys=g.forwardRef(({value:e,onChange:t,styles:n={},label:s,autoSubmit:i,onSubmit:a},l)=>{const[c,u]=g.useState(e),d=ic.useEditor({extensions:[ac,sc,Q.Link,Jl,Xl,Yl,ec.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),rc,nc,tc,Zl.configure({types:["heading","paragraph"]}),Kl.configure({placeholder:"This is placeholder"}),Hl,Ul.Color,eu,su],content:c,onUpdate:({editor:m})=>{const y=m.getHTML();u(y)}});g.useEffect(()=>{u(m=>e===m?m:(d==null||d.commands.setContent(e),e))},[e]);const p=()=>{t(c),a==null||a()},h=e!==c;g.useEffect(()=>{i&&p()},[i,h]);const f=g.useMemo(()=>v.defaultsDeep({},{content:{...Ti,...xy}},n),[n]);return d?r.jsxs(o.Stack,{spacing:4,sx:{flexGrow:1,position:"relative"},children:[r.jsxs(o.Group,{align:"center",children:[r.jsx(o.Text,{size:14,fw:500,children:s}),!i&&r.jsx(o.ActionIcon,{color:"green",disabled:!h,onClick:p,children:r.jsx(M.IconDeviceFloppy,{size:18})})]}),r.jsxs(Q.RichTextEditor,{editor:d,styles:f,children:[r.jsxs(Q.RichTextEditor.Toolbar,{sticky:!0,stickyOffset:0,children:[r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.ColorPicker,{colors:["#25262b","#868e96","#fa5252","#e64980","#be4bdb","#7950f2","#4c6ef5","#228be6","#15aabf","#12b886","#40c057","#82c91e","#fab005","#fd7e14"],popoverProps:{zIndex:320}}),r.jsx(my,{editor:d})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.Bold,{}),r.jsx(Q.RichTextEditor.Italic,{}),r.jsx(Q.RichTextEditor.Underline,{}),r.jsx(Q.RichTextEditor.ClearFormatting,{}),r.jsx(Q.RichTextEditor.Highlight,{}),r.jsx(Q.RichTextEditor.Code,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.H1,{}),r.jsx(Q.RichTextEditor.H2,{}),r.jsx(Q.RichTextEditor.H3,{}),r.jsx(Q.RichTextEditor.H4,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.Blockquote,{}),r.jsx(Q.RichTextEditor.Hr,{}),r.jsx(Q.RichTextEditor.BulletList,{}),r.jsx(Q.RichTextEditor.OrderedList,{}),r.jsx(Q.RichTextEditor.Subscript,{}),r.jsx(Q.RichTextEditor.Superscript,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.Link,{}),r.jsx(Q.RichTextEditor.Unlink,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.AlignLeft,{}),r.jsx(Q.RichTextEditor.AlignCenter,{}),r.jsx(Q.RichTextEditor.AlignJustify,{}),r.jsx(Q.RichTextEditor.AlignRight,{})]}),r.jsx(Q.RichTextEditor.ControlsGroup,{children:r.jsx(yy,{})}),r.jsx(ly,{editor:d})]}),r.jsx(Q.RichTextEditor.Content,{})]})]}):null});function by(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function Vt({data_field:e,aggregation:t},n){return is(n,e,t)}function rt({formatter:e,aggregation:t},n){if(typeof n!="string"&&typeof n!="number")return by(n);if(t.type==="custom")return n;try{return U(n,e)}catch(s){return console.error(s),n}}function vy(e,t){return e.replaceAll(/(\$\{([^{\}]+(?=}))\}\})/g,(...s)=>{const i=s[2],a=t.variableStyleMap[i];if(!a)return`{{${i}}}`;const{variable:l,...c}=a,u=Object.entries(c).map(([f,m])=>`${f}:${m}`).join(";"),d=l.color;if(d.type!=="continuous")return`<span style="${u}">{{${i}}}</span>`;const p=nu(6),h=`try {
63
63
  return utils.popmotion.interpolate(${JSON.stringify(d.valueRange)}, ${JSON.stringify(d.colorRange)})(variables["${i}"]);
64
64
  } catch (error) {
65
65
  console.error(error);
@@ -71,7 +71,7 @@ Check the top-level render call using <`+L+">.")}return A}}function _g(C,A){{if(
71
71
  ${Object.entries(t).map(([s,i])=>`const ${s} = '${i}';`).join(`
72
72
  `)}
73
73
  return ${e};
74
- `)(n)}catch(s){return console.error(s),console.log(e),e}}function du(e,t,n,s){const i=Oy(t,s),a=/^(.+)\}\}(.*)$/;return e.split("{{").map(l=>{const c=a.exec(l);if(!c)return l;const u=i[c[1]];if(u){const p=c[2]??"";return`${u}${p}`}const d=Ly(c[1]);return`${By(d,i,n)}${c[2]}`}).join("")}function qy(e,t){const n=lc.decode(t);n!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:n}),console.groupEnd())}async function Vy({query:e,name:t,payload:n,additionals:s},i){if(!e.sql)return[];const{type:a,key:l,sql:c,pre_process:u,post_process:d}=e,p=wi(c,n),h=Cm({sql:p,pre_process:u}),f=lc.encode(h);qy(h,f);let m=await Ot.query(i)({type:a,key:l,query:f,...s},{params:{name:t}});return m=Sm(d,m,Ki(n)),m}async function Ny({type:e,key:t,configString:n,name:s,additionals:i},a){try{return await Ot.httpDataSourceQuery(a)({type:e,key:t,query:n,...i},{params:{name:s}})}catch(l){if(At.isCancel(l))throw l;return console.error(l),l}}async function Xi(){try{return(await Ot.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function pu(){try{return(await Ot.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class hu{constructor(t){B(this,"rootRef");this.rootRef=X.observable({current:t})}async deleteItem(t){X.runInAction(()=>{v.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?X.toJS(this.rootRef.current):v.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(v.isObject(n))X.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else X.runInAction(()=>{v.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,s){return X.reaction(()=>this.getValueFromRoot(t),(i,a)=>{n(i,a)},{requiresObservable:!0,fireImmediately:v.get(s,"fireImmediately",!1)})}}class $y{constructor(){B(this,"channels",new Map);B(this,"globalChannel",new cc)}getChannel(t){const n=this.channels.get(t);if(n)return n;const s=new cc;return this.channels.set(t,s),s}}class Fy{constructor(t){B(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const n=this.instances.get(t.id);if(n)return n;const s={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new $y,instanceData:new hu(t.viz.conf)};return this.instances.set(t.id,s),s}}function fu(e,t,n,s){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new hu({}),colorPalette:{getColor(){return()=>""}},data:t,variables:s}}const Gy=e=>{const{panel:t,measure:n,vizManager:s,data:i,variables:a}=e,l=s.resolveComponent(t.viz.type),c=s.getOrCreateInstance(t),u={...fu(c,i,s,a),viewport:{width:n.w,height:n.h}},d=l.viewRender;return r.jsx(d,{context:u,instance:c,...v.omit(e,["panel","vizManager","data"])})},Wy=e=>{const{vizManager:t,panel:n,data:s,variables:i}=e,a=t.resolveComponent(n.viz.type),l=t.getOrCreateInstance(n),c={...fu(l,s,t,i)},u=a.configRender;return r.jsx(u,{context:c,instance:l,...v.omit(e,["panel","vizManager","data"])})},gu=(e,t)=>{const n=Qt.bezier(e),s=Qt.bezier(t);return function(i){return i<50?n(i*2/100).hex():s((i-50)*2/100).hex()}},_s=e=>{const t=Qt.bezier(e);return function(n){return t(n/100).hex()}},Ry={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:gu(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Qy={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:gu(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Uy={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:_s(["#fff7f1","darkred"]),name:"red",category:"sequential"},Yy={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:_s(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Ky={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:_s(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Xy={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:_s(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class Jy{constructor(t){B(this,"symbol");this.symbol=Symbol(t)}}function Kt(e){return new Jy(e)}class Ji{constructor(){B(this,"parent");B(this,"factoryRegistry",new Map);B(this,"instanceRegistry",new Map)}createScoped(){const t=new Ji;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const n=this.factoryRegistry.get(t.symbol);if(n){const s=n(this);return this.instanceRegistry.set(t.symbol,s),s}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=v.get(t,"dispose");v.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const mu="13.23.0",Zy=Object.freeze(Object.defineProperty({__proto__:null,version:mu},Symbol.toStringTag,{value:"Module"}));class Hy{constructor(t){B(this,"staticColors",new Map);B(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(s=>{this.register(s)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(n,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class eb{constructor(){B(this,"plugins",new Map);B(this,"vizComponents",new Map);B(this,"factory",{viz:t=>{const n=this.vizComponents.get(t);if(n)return n;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const n of t.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class tb{constructor(){B(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,s){var l;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const i=this.migrations.filter(c=>c.version>t.from&&c.version<=t.to),a=v.orderBy(i,"version","asc");if(((l=v.last(a))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return a.reduce((c,u)=>u.handler(c,s),n)}}class me extends tb{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(s,i)=>({version:t,...n(s,i)}))}async migrate({configData:t,panelModel:n}){const s=await t.getItem(null),i=v.get(s,"version",0),a=this.run({from:i,to:this.VERSION},s,{panelModel:n});await t.setItem(null,a)}async needMigration({configData:t}){const n=await t.getItem(null);return v.get(n,"version",0)<this.VERSION}}const $=(e,t)=>{const[n,{setFalse:s}]=W.useBoolean(!0),[i,a]=g.useState();g.useEffect(()=>(e.getItem(t).then(c=>{a(c),s()}),e.watchItem(t,c=>{a(c)})));const l=g.useCallback(async c=>{await e.setItem(t,c),a(c)},[e,t]);return{loading:n,value:i,set:l}},Qe={top:16,right:16,bottom:16,left:16},wt=e=>Math.max(0,e-Qe.left-Qe.right),Ct=e=>Math.max(0,e-Qe.top-Qe.bottom),jr=(e,t)=>({width:wt(e),height:Ct(t)}),Ue=({width:e,height:t,children:n})=>r.jsx(o.Box,{pt:Qe.top,pr:Qe.right,pb:Qe.bottom,pl:Qe.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:n}),Zi={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};function nb({context:e}){const{value:t}=$(e.instanceData,"config"),n=e.data,{width:s,height:i}=e.viewport,{x_axis_data_key:a,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:p}=v.defaults({},t,Zi),h=g.useMemo(()=>rs(n,a),[n,a]),{x:f,y:m,z:y}=g.useMemo(()=>({x:O(a),y:O(l),z:O(c)}),[a,l,c]),{min:j,max:k}=g.useMemo(()=>{const T=v.minBy(h,I=>I[y.columnKey]),z=v.maxBy(h,I=>I[y.columnKey]);return{min:v.get(T,y.columnKey),max:v.get(z,y.columnKey)}},[h,y]),S={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:j,max:k,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:p,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(T=>[T[f.columnKey],T[m.columnKey],T[y.columnKey]])}]};return t?r.jsx(Ue,{width:s,height:i,children:r.jsx(Pe,{echarts:Ae,option:S,style:jr(s,i),notMerge:!0,theme:"merico-light"})}):null}const xu=g.createContext(null),Hi=xu.Provider;function ea(){const e=g.useContext(xu);if(!e)throw new Error("Please use DashboardModelContextProvider");return e}const Z=()=>ea(),yu=()=>ea(),bu=g.createContext({searchButtonProps:{}}),ta=bu.Provider;function vu(){return g.useContext(bu)}const _u=g.createContext(null),na=_u.Provider;function ju(){const e=g.useContext(_u);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const Y=()=>ju(),_e=()=>ju(),rb={inEditMode:!1},js=g.createContext(rb),wu=g.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),ra=wu.Provider;function Cu(){const e=g.useContext(wu);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const St=()=>Cu(),Ge=()=>Cu(),sb={fullScreenPanelID:"",setFullScreenPanelID:v.noop},sa=g.createContext(sb);function Su(){const e=g.useContext(sa);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const ib={en:"en",zh:"zh-cn"};function ia({children:e}){const{i18n:t}=_.useTranslation(),n=g.useMemo(()=>{const s=t.language;return ib[s]??"en"},[t.language]);return r.jsx(uc.DatesProvider,{settings:{locale:n,firstDayOfWeek:1},children:e})}const F=D.observer(g.forwardRef(({label:e,required:t,description:n,value:s,onChange:i,queryID:a,clearable:l=!1,sx:c,...u},d)=>{const{panel:p}=Ge(),h=g.useMemo(()=>p.dataFieldOptions(s,l,a),[s,l,a]);if(h.length===0){const f=p.explainDataKey(s);return r.jsxs(o.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.Box,{children:r.jsx(o.TextInput,{label:e,required:t,defaultValue:f.columnKey,readOnly:!0,disabled:!0})})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsxs(o.Group,{position:"left",spacing:0,children:[r.jsx(o.Text,{size:"xs",color:f.queryName?"black":"red",sx:{fontFamily:"monospace"},children:f.queryName??f.queryID}),r.jsx(o.Text,{size:"xs",color:"black",sx:{fontFamily:"monospace"},children:"."}),r.jsx(o.Text,{size:"xs",color:"red",sx:{fontFamily:"monospace"},children:f.columnKey})]})})]})}return r.jsx(o.Select,{ref:d,label:e,description:n,data:h,value:s,onChange:i,required:t,sx:c,maxDropdownHeight:500,...u})}));function ab({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=v.defaults({},t,Zi),{control:i,handleSubmit:a,reset:l}=b.useForm({defaultValues:s});return g.useEffect(()=>{l(s)},[t]),t?r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:a(n),children:[r.jsx(o.Text,{children:"X Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Text,{mt:"lg",children:"Y Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Text,{mt:"lg",children:"Z Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:r.jsxs(o.Button,{color:"blue",type:"submit",children:[r.jsx(V.DeviceFloppy,{size:20}),r.jsx(o.Text,{ml:"md",children:"Save"})]})})]})}):null}const ob=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function lb(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis_data_key:i,y_axis_data_key:a,z_axis_data_key:l,...c}=e;return{...c,x_axis_data_key:s(i),y_axis_data_key:s(a),z_axis_data_key:s(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class cb extends me{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>{const{config:i}=n;return{...n,version:2,config:lb(i,s)}})}}const ub={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new cb,name:"bar-3d",viewRender:nb,configRender:ab,createConfig(){return{version:2,config:v.cloneDeep(Zi)}},translation:ob},db=({disabled:e,value:t,onChange:n})=>{const s=i=>{i&&n(i)};return r.jsxs(o.Box,{sx:{position:"relative"},children:[e&&r.jsx(o.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),r.jsx(et,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})};function Ye({enabled:e,func_content:t}){return(n,s)=>{if(!e)return n;try{return new Function(`return ${t}`)()(n,s)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),n}}}function Le(){return{enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
74
+ `)(n)}catch(s){return console.error(s),console.log(e),e}}function du(e,t,n,s){const i=Oy(t,s);return e.replaceAll(/(\{\{([^{\}]+(?=}))\}\})/g,(...l)=>{const c=l[2];if(!c)return c;const u=i[c];if(u)return u;const d=Ly(c);return By(d,i,n)})}function qy(e,t){const n=lc.decode(t);n!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:n}),console.groupEnd())}async function Vy({query:e,name:t,payload:n,additionals:s},i){if(!e.sql)return[];const{type:a,key:l,sql:c,pre_process:u,post_process:d}=e,p=wi(c,n),h=Cm({sql:p,pre_process:u}),f=lc.encode(h);qy(h,f);let m=await Ot.query(i)({type:a,key:l,query:f,...s},{params:{name:t}});return m=Sm(d,m,Ki(n)),m}async function Ny({type:e,key:t,configString:n,name:s,additionals:i},a){try{return await Ot.httpDataSourceQuery(a)({type:e,key:t,query:n,...i},{params:{name:s}})}catch(l){if(At.isCancel(l))throw l;return console.error(l),l}}async function Xi(){try{return(await Ot.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function pu(){try{return(await Ot.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class hu{constructor(t){B(this,"rootRef");this.rootRef=X.observable({current:t})}async deleteItem(t){X.runInAction(()=>{v.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?X.toJS(this.rootRef.current):v.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(v.isObject(n))X.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else X.runInAction(()=>{v.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,s){return X.reaction(()=>this.getValueFromRoot(t),(i,a)=>{n(i,a)},{requiresObservable:!0,fireImmediately:v.get(s,"fireImmediately",!1)})}}class $y{constructor(){B(this,"channels",new Map);B(this,"globalChannel",new cc)}getChannel(t){const n=this.channels.get(t);if(n)return n;const s=new cc;return this.channels.set(t,s),s}}class Fy{constructor(t){B(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const n=this.instances.get(t.id);if(n)return n;const s={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new $y,instanceData:new hu(t.viz.conf)};return this.instances.set(t.id,s),s}}function fu(e,t,n,s){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new hu({}),colorPalette:{getColor(){return()=>""}},data:t,variables:s}}const Gy=e=>{const{panel:t,measure:n,vizManager:s,data:i,variables:a}=e,l=s.resolveComponent(t.viz.type),c=s.getOrCreateInstance(t),u={...fu(c,i,s,a),viewport:{width:n.w,height:n.h}},d=l.viewRender;return r.jsx(d,{context:u,instance:c,...v.omit(e,["panel","vizManager","data"])})},Wy=e=>{const{vizManager:t,panel:n,data:s,variables:i}=e,a=t.resolveComponent(n.viz.type),l=t.getOrCreateInstance(n),c={...fu(l,s,t,i)},u=a.configRender;return r.jsx(u,{context:c,instance:l,...v.omit(e,["panel","vizManager","data"])})},gu=(e,t)=>{const n=Qt.bezier(e),s=Qt.bezier(t);return function(i){return i<50?n(i*2/100).hex():s((i-50)*2/100).hex()}},_s=e=>{const t=Qt.bezier(e);return function(n){return t(n/100).hex()}},Ry={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:gu(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Qy={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:gu(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Uy={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:_s(["#fff7f1","darkred"]),name:"red",category:"sequential"},Yy={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:_s(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Ky={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:_s(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Xy={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:_s(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class Jy{constructor(t){B(this,"symbol");this.symbol=Symbol(t)}}function Kt(e){return new Jy(e)}class Ji{constructor(){B(this,"parent");B(this,"factoryRegistry",new Map);B(this,"instanceRegistry",new Map)}createScoped(){const t=new Ji;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const n=this.factoryRegistry.get(t.symbol);if(n){const s=n(this);return this.instanceRegistry.set(t.symbol,s),s}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=v.get(t,"dispose");v.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const mu="13.23.1",Zy=Object.freeze(Object.defineProperty({__proto__:null,version:mu},Symbol.toStringTag,{value:"Module"}));class Hy{constructor(t){B(this,"staticColors",new Map);B(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(s=>{this.register(s)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(n,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class eb{constructor(){B(this,"plugins",new Map);B(this,"vizComponents",new Map);B(this,"factory",{viz:t=>{const n=this.vizComponents.get(t);if(n)return n;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const n of t.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class tb{constructor(){B(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,s){var l;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const i=this.migrations.filter(c=>c.version>t.from&&c.version<=t.to),a=v.orderBy(i,"version","asc");if(((l=v.last(a))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return a.reduce((c,u)=>u.handler(c,s),n)}}class me extends tb{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(s,i)=>({version:t,...n(s,i)}))}async migrate({configData:t,panelModel:n}){const s=await t.getItem(null),i=v.get(s,"version",0),a=this.run({from:i,to:this.VERSION},s,{panelModel:n});await t.setItem(null,a)}async needMigration({configData:t}){const n=await t.getItem(null);return v.get(n,"version",0)<this.VERSION}}const $=(e,t)=>{const[n,{setFalse:s}]=W.useBoolean(!0),[i,a]=g.useState();g.useEffect(()=>(e.getItem(t).then(c=>{a(c),s()}),e.watchItem(t,c=>{a(c)})));const l=g.useCallback(async c=>{await e.setItem(t,c),a(c)},[e,t]);return{loading:n,value:i,set:l}},Qe={top:16,right:16,bottom:16,left:16},wt=e=>Math.max(0,e-Qe.left-Qe.right),Ct=e=>Math.max(0,e-Qe.top-Qe.bottom),jr=(e,t)=>({width:wt(e),height:Ct(t)}),Ue=({width:e,height:t,children:n})=>r.jsx(o.Box,{pt:Qe.top,pr:Qe.right,pb:Qe.bottom,pl:Qe.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:n}),Zi={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};function nb({context:e}){const{value:t}=$(e.instanceData,"config"),n=e.data,{width:s,height:i}=e.viewport,{x_axis_data_key:a,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:p}=v.defaults({},t,Zi),h=g.useMemo(()=>rs(n,a),[n,a]),{x:f,y:m,z:y}=g.useMemo(()=>({x:O(a),y:O(l),z:O(c)}),[a,l,c]),{min:j,max:k}=g.useMemo(()=>{const T=v.minBy(h,I=>I[y.columnKey]),z=v.maxBy(h,I=>I[y.columnKey]);return{min:v.get(T,y.columnKey),max:v.get(z,y.columnKey)}},[h,y]),S={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:j,max:k,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:p,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(T=>[T[f.columnKey],T[m.columnKey],T[y.columnKey]])}]};return t?r.jsx(Ue,{width:s,height:i,children:r.jsx(Pe,{echarts:Ae,option:S,style:jr(s,i),notMerge:!0,theme:"merico-light"})}):null}const xu=g.createContext(null),Hi=xu.Provider;function ea(){const e=g.useContext(xu);if(!e)throw new Error("Please use DashboardModelContextProvider");return e}const Z=()=>ea(),yu=()=>ea(),bu=g.createContext({searchButtonProps:{}}),ta=bu.Provider;function vu(){return g.useContext(bu)}const _u=g.createContext(null),na=_u.Provider;function ju(){const e=g.useContext(_u);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const Y=()=>ju(),_e=()=>ju(),rb={inEditMode:!1},js=g.createContext(rb),wu=g.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),ra=wu.Provider;function Cu(){const e=g.useContext(wu);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const St=()=>Cu(),Ge=()=>Cu(),sb={fullScreenPanelID:"",setFullScreenPanelID:v.noop},sa=g.createContext(sb);function Su(){const e=g.useContext(sa);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const ib={en:"en",zh:"zh-cn"};function ia({children:e}){const{i18n:t}=_.useTranslation(),n=g.useMemo(()=>{const s=t.language;return ib[s]??"en"},[t.language]);return r.jsx(uc.DatesProvider,{settings:{locale:n,firstDayOfWeek:1},children:e})}const F=D.observer(g.forwardRef(({label:e,required:t,description:n,value:s,onChange:i,queryID:a,clearable:l=!1,sx:c,...u},d)=>{const{panel:p}=Ge(),h=g.useMemo(()=>p.dataFieldOptions(s,l,a),[s,l,a]);if(h.length===0){const f=p.explainDataKey(s);return r.jsxs(o.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.Box,{children:r.jsx(o.TextInput,{label:e,required:t,defaultValue:f.columnKey,readOnly:!0,disabled:!0})})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsxs(o.Group,{position:"left",spacing:0,children:[r.jsx(o.Text,{size:"xs",color:f.queryName?"black":"red",sx:{fontFamily:"monospace"},children:f.queryName??f.queryID}),r.jsx(o.Text,{size:"xs",color:"black",sx:{fontFamily:"monospace"},children:"."}),r.jsx(o.Text,{size:"xs",color:"red",sx:{fontFamily:"monospace"},children:f.columnKey})]})})]})}return r.jsx(o.Select,{ref:d,label:e,description:n,data:h,value:s,onChange:i,required:t,sx:c,maxDropdownHeight:500,...u})}));function ab({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=v.defaults({},t,Zi),{control:i,handleSubmit:a,reset:l}=b.useForm({defaultValues:s});return g.useEffect(()=>{l(s)},[t]),t?r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:a(n),children:[r.jsx(o.Text,{children:"X Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Text,{mt:"lg",children:"Y Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Text,{mt:"lg",children:"Z Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:r.jsxs(o.Button,{color:"blue",type:"submit",children:[r.jsx(V.DeviceFloppy,{size:20}),r.jsx(o.Text,{ml:"md",children:"Save"})]})})]})}):null}const ob=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function lb(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis_data_key:i,y_axis_data_key:a,z_axis_data_key:l,...c}=e;return{...c,x_axis_data_key:s(i),y_axis_data_key:s(a),z_axis_data_key:s(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class cb extends me{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>{const{config:i}=n;return{...n,version:2,config:lb(i,s)}})}}const ub={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new cb,name:"bar-3d",viewRender:nb,configRender:ab,createConfig(){return{version:2,config:v.cloneDeep(Zi)}},translation:ob},db=({disabled:e,value:t,onChange:n})=>{const s=i=>{i&&n(i)};return r.jsxs(o.Box,{sx:{position:"relative"},children:[e&&r.jsx(o.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),r.jsx(et,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})};function Ye({enabled:e,func_content:t}){return(n,s)=>{if(!e)return n;try{return new Function(`return ${t}`)()(n,s)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),n}}}function Le(){return{enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
75
75
  `)}}const kt=g.forwardRef(({value:e,onChange:t,triggerButtonText:n},s)=>{const{t:i}=_.useTranslation(),[a,{setTrue:l,setFalse:c}]=W.useBoolean(),[u,d]=g.useState(e);g.useEffect(()=>{d(e)},[e]);const p=k=>{d({...u,enabled:k})},h=()=>{c();const{enabled:k,func_content:S}=u,T={enabled:k,func_content:S};d(T),t(T)},f=()=>{c(),d(e)},m=k=>{d(S=>({...S,func_content:k}))},y=()=>{m(Le().func_content)},j=n??i("chart.axis.customize_label");return r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{variant:"filled",color:"grape",leftIcon:r.jsx(M.IconMathFunction,{size:16}),mt:24,onClick:l,sx:{flexGrow:0},children:j}),r.jsx(o.Modal,{size:800,title:j,opened:a,onClose:c,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:a&&r.jsxs(o.Stack,{children:[r.jsx(o.Checkbox,{mt:10,label:i("common.enabled"),checked:u.enabled,onChange:k=>p(k.currentTarget.checked)}),r.jsx(db,{value:u.func_content,onChange:m,disabled:!u.enabled}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:y,color:"red",leftIcon:r.jsx(V.Recycle,{size:20}),children:i("common.actions.reset_to_default")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:f,variant:"subtle",children:i("common.actions.cancel")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),onClick:h,children:i("common.actions.save")})]})]})]})})]})}),Tn={x_axis_scroll:!1,y_axis_scroll:!1,x_axis_slider:!1,y_axis_slider:!1};function ku(){return v.cloneDeep(Tn)}const pb=[{lang:"en",resources:{boxplot:{viz_name:"Boxplot Chart",box:"Box",outlier:"Outlier",scatter:"Scatter",click_series:{label:"Click box, scatter or outlier"}}}},{lang:"zh",resources:{boxplot:{viz_name:"箱线图",box:"箱体",outlier:"异常点",scatter:"散点",click_series:{label:"点击箱体、散点或异常点"}}}}],Tu={id:"builtin:echarts:click-echart:series",displayName:"viz.boxplot.click_series.label",nameRender:fb,configRender:hb,payload:[{name:"type",description:"Always 'click'",valueType:"string"},{name:"seriesType",description:"'boxplot'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"Record of 'name', 'min', 'q1', 'median', 'q3', 'max'",valueType:"object"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function hb(e){return r.jsx(r.Fragment,{})}function fb(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.boxplot.click_series.label")})}const ws=g.forwardRef(({sectionTitle:e,value:t,onChange:n},s)=>{const{t:i,i18n:a}=_.useTranslation(),l=u=>d=>{const p=v.cloneDeep(t);v.set(p,u,d),n(p)},c=g.useMemo(()=>[{label:i("chart.axis.overflow.truncate"),value:"truncate"},{label:i("chart.axis.overflow.break_line"),value:"break"},{label:i("chart.axis.overflow.break_word"),value:"breakAll"}],[a.language]);return r.jsxs(o.Stack,{spacing:0,children:[e&&r.jsx(o.Divider,{mb:-5,mt:5,variant:"dotted",label:e,labelPosition:"right",labelProps:{color:"dimmed"}}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.NumberInput,{label:i("chart.axis.overflow.max_width"),hideControls:!0,value:t.width,onChange:l("width")}),r.jsx(o.Select,{label:i("chart.axis.overflow.label"),data:c,value:t.overflow,onChange:l("overflow")}),r.jsx(o.TextInput,{label:i("chart.axis.overflow.ellipsis"),value:t.ellipsis,disabled:!0})]})]})}),Tt=g.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=_.useTranslation(),i=l=>{t({...e,on_axis:l})},a=l=>{t({...e,in_tooltip:l})};return r.jsxs(o.Stack,{ref:n,spacing:0,children:[r.jsx(ws,{sectionTitle:s("chart.axis.overflow.section_title.on_axis"),value:e.on_axis,onChange:i}),r.jsx(ws,{sectionTitle:s("chart.axis.overflow.section_title.in_tooltip"),value:e.in_tooltip,onChange:a})]})});function Ke(){return{on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}}}function ut({overflow:e,width:t}){const n={truncate:"initial",break:"break-all",breakAll:"break-word"}[e],s=e==="truncate"?"nowrap":"initial",i={truncate:"ellipsis",break:"clip",breakAll:"clip"}[e];return`
76
76
  max-width: ${t}px;
77
77
  word-break: ${n};