@blocklet/pages-kit-inner-components 0.5.56 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/lib/cjs/add-component.js +21 -23
  2. package/lib/cjs/chunks/{draft-data-CuZfaQ4s.js → draft-data-D44_IEV2.js} +1 -1
  3. package/lib/cjs/chunks/home-BYk01EUy.js +39 -0
  4. package/lib/cjs/chunks/index-BRgYwvuv.js +475 -0
  5. package/lib/cjs/chunks/publish-button-C8XPA4g_.js +1 -0
  6. package/lib/cjs/chunks/session-BRtsDvA-.js +1 -0
  7. package/lib/cjs/chunks/site-state-gSkcvhcV.js +57 -0
  8. package/lib/cjs/chunks/state-B6BF5wJ-.js +1 -0
  9. package/lib/cjs/components.js +1 -1
  10. package/lib/cjs/home.js +1 -1
  11. package/lib/cjs/project-html.js +7 -7
  12. package/lib/cjs/resources.js +1 -1
  13. package/lib/cjs/setting.js +3 -3
  14. package/lib/cjs/site-state.js +1 -1
  15. package/lib/cjs/theme.js +1 -1
  16. package/lib/es/add-component.js +385 -2356
  17. package/lib/es/chunks/{draft-data-CWM--ooz.js → draft-data-CafrGKeh.js} +1 -1
  18. package/lib/es/chunks/home-DW8SdyfO.js +594 -0
  19. package/lib/es/chunks/index-D5gXPe_7.js +2326 -0
  20. package/lib/es/chunks/publish-button-XSZrDaTQ.js +498 -0
  21. package/lib/es/chunks/session-C72Dq8zg.js +19 -0
  22. package/lib/es/chunks/site-state-W2H7XCSQ.js +2077 -0
  23. package/lib/es/chunks/state-0gvZF3k2.js +573 -0
  24. package/lib/es/components.js +1 -1
  25. package/lib/es/home.js +5 -5
  26. package/lib/es/project-html.js +131 -141
  27. package/lib/es/resources.js +106 -107
  28. package/lib/es/setting.js +1772 -1489
  29. package/lib/es/site-state.js +1 -1
  30. package/lib/es/theme.js +50 -51
  31. package/package.json +46 -47
  32. package/lib/cjs/chunks/array-BqHuYyfx.js +0 -475
  33. package/lib/cjs/chunks/config-string-4bVR9Vc8.js +0 -1
  34. package/lib/cjs/chunks/home-BMjMYgq3.js +0 -38
  35. package/lib/cjs/chunks/publish-button-CGfGqrov.js +0 -1
  36. package/lib/cjs/chunks/session-BA7Qrcia.js +0 -1
  37. package/lib/cjs/chunks/site-state-BtZ8o3J2.js +0 -57
  38. package/lib/cjs/chunks/state-BVdbNJCA.js +0 -1
  39. package/lib/es/chunks/array-c6HYTLze.js +0 -2224
  40. package/lib/es/chunks/config-string-WMpFf-7V.js +0 -88
  41. package/lib/es/chunks/home-PDsc59QG.js +0 -566
  42. package/lib/es/chunks/publish-button-Ds7OBvxV.js +0 -462
  43. package/lib/es/chunks/session-CVblGhSp.js +0 -21
  44. package/lib/es/chunks/site-state-D-moj9fA.js +0 -2125
  45. package/lib/es/chunks/state-l--dTdHq.js +0 -603
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),A=require("./chunks/state-BVdbNJCA.js"),Ae=require("@arcblock/ux/lib/Empty"),N=require("@arcblock/ux/lib/Locale/context"),ne=require("@blocklet/code-editor"),Ve=require("@mui/icons-material/AddRounded"),De=require("@mui/icons-material/ArrowDownward"),ze=require("@mui/icons-material/ArrowUpward"),Fe=require("@mui/icons-material/DeleteOutline"),r=require("@mui/material"),qe=require("lodash/sortBy"),T=require("react"),ve=require("react-use"),ye=require("@blocklet/pages-kit/builtin/color-picker"),Ue=require("./chunks/config-string-4bVR9Vc8.js"),Me=require("lodash/isEmpty"),We=require("lodash/set"),Le=require("yaml"),q=require("@blocklet/pages-kit/builtin/uploader"),Ke=require("lodash/cloneDeep"),Je=require("@arcblock/ux/lib/Toast"),Z=require("@blocklet/pages-kit/components"),He=require("@blocklet/pages-kit/utils/property"),Pe=require("@mui/base"),E=require("@mui/icons-material"),G=require("@syncedstore/core"),Se=require("ahooks"),Ye=require("lodash/assign"),$e=require("lodash/get"),Ge=require("lodash/has"),Qe=require("lodash/isEqual"),Xe=require("lodash/isNil"),Ze=require("lodash/isObject"),et=require("lodash/keyBy"),tt=require("lodash/omit"),rt=require("lodash/pick"),st=require("lodash/reduce"),U=require("material-ui-popup-state/hooks"),it=require("react-error-boundary"),ot=require("@emotion/css"),re=require("react-dnd"),we=require("@blocklet/pages-kit/utils/common"),O=t=>t&&t.__esModule?t:{default:t};function lt(t){if(t&&t.__esModule)return t;const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const i in t)if(i!=="default"){const o=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(s,i,o.get?o:{enumerable:!0,get:()=>t[i]})}}return s.default=t,Object.freeze(s)}const Q=O(Ae),nt=O(Ve),ct=O(De),ut=O(ze),at=O(Fe),V=O(qe),W=O(Me),Ce=O(We),se=lt(Le),dt=O(Ke),ie=O(Je),pt=O(Ye),xt=O($e),mt=O(Ge),ft=O(Qe),ee=O(Xe),bt=O(Ze),ht=O(et),jt=O(tt),yt=O(rt),gt=O(st);function kt({onClick:t,disabled:s,sx:i,...o}){return e.jsx(r.IconButton,{size:"small",color:"warning",variant:"outlined",disabled:s,onClick:t,...o,children:e.jsx(at.default,{fontSize:"small"})})}function vt({onClick:t,disabled:s,sx:i,...o}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...o,children:e.jsx(ut.default,{fontSize:"small"})})}function Pt({onClick:t,disabled:s,sx:i,...o}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...o,children:e.jsx(ct.default,{fontSize:"small"})})}function St({label:t,value:s,onChange:i,disabled:o=!1,itemLabel:f="",emptyHeight:g=40,property:x,renderItem:S,...v}){const{t:h,locale:k}=N.useLocaleContext(),y=ve.useUpdate(),l=T.useCallback(p=>{i(A.transformValue(p,x.type))},[i,x.type]),u=T.useMemo(()=>Array.isArray(s)?s:[],[s]),c=T.useCallback(()=>{const p=[...u,""];l(p),y()},[u,l,y]),d=T.useCallback(()=>{if(!x||!x.subProperties)return c();const p={};V.default(Object.values(x.subProperties),"index").forEach(({data:B})=>{var _,D;if(!B.key)return;const R=((D=(_=B.locales)==null?void 0:_[k])==null?void 0:D.defaultValue)??"";p[B.key]=R});const I=[...u,p];l(I),y()},[u,l,y,x,k,c]),a=T.useCallback(p=>{try{const w=JSON.parse(p);Array.isArray(w)?l(w):console.error("JSON解析结果不是数组")}catch(w){console.error("JSON解析错误:",w)}},[l]),P=T.useCallback(p=>{const w=u.filter((I,B)=>B!==p);l(w),y()},[u,l,y]),n=T.useCallback(p=>{if(p<=0)return;const w=[...u],I=w[p];w[p]=w[p-1],w[p-1]=I,l(w),y()},[u,l,y]),b=T.useCallback(p=>{if(p>=u.length-1)return;const w=[...u],I=w[p];w[p]=w[p+1],w[p+1]=I,l(w),y()},[u,l,y]),m=T.useCallback((p,w)=>{const I=[...u];I[p]=w,l(I)},[u,l]),j=x&&x.subProperties&&Object.keys(x.subProperties).length>0,C=T.useMemo(()=>[{field:"index",headerName:"#",width:40,align:"center",renderCell:({index:p})=>e.jsx(r.Typography,{variant:"body1",sx:{bgcolor:"action.hover",borderRadius:"50%",width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:p+1})},{field:"content",headerName:"",renderCell:({row:p,index:w})=>S&&j?S({item:p,index:w,property:x,onChange:I=>m(w,I)}):e.jsx(r.TextField,{fullWidth:!0,size:"small",disabled:o,value:p,placeholder:f||`${h("item")} ${w+1}`,onChange:I=>m(w,I.target.value),...v})},{field:"actions",headerName:"",width:30,align:"center",renderCell:({index:p})=>e.jsxs(r.Stack,{direction:"column",spacing:.25,children:[e.jsx(vt,{disabled:o||p===0,onClick:()=>n(p)}),e.jsx(Pt,{disabled:o||p===u.length-1,onClick:()=>b(p)}),e.jsx(kt,{disabled:o,onClick:()=>P(p)})]})}],[S,j,x,m,f,h,o,v,P,n,b,u.length]);return j?e.jsxs(r.Stack,{width:"100%",gap:1,children:[t&&e.jsx(r.FormLabel,{children:t}),u.length>0?e.jsx(r.TableContainer,{component:r.Paper,variant:"outlined",sx:{borderRadius:1,mb:1},children:e.jsxs(r.Table,{size:"small",sx:{"& .MuiTableCell-root":{py:.25,px:1,whiteSpace:"nowrap"},"& .MuiTableCell-head":{backgroundColor:"action.hover",py:.25,px:1},borderCollapse:"collapse"},children:[e.jsx(r.TableHead,{sx:{display:"none"},children:e.jsx(r.TableRow,{children:C.map(p=>e.jsx(r.TableCell,{width:p.width,align:p.align||"left",sx:{fontWeight:"bold"},children:p.renderHeader?p.renderHeader():p.headerName},p.field))})}),e.jsx(r.TableBody,{children:u.map((p,w,I)=>e.jsx(r.TableRow,{sx:{borderBottom:w<I.length-1?"1px solid":"none",borderColor:"divider","&:hover":{backgroundColor:"action.hover"}},children:C.map(B=>e.jsx(r.TableCell,{width:B.width,align:B.align||"left",sx:{borderBottom:"none"},children:B.renderCell({row:p,index:w,onChange:R=>m(w,R)})},`${w}-${B.field}`))},w))})]})}):e.jsx(Q.default,{style:{fontSize:12,height:g},children:h("maker.properties.arrayEmpty")}),e.jsx(r.Button,{fullWidth:!0,size:"small",variant:"outlined",disabled:o,startIcon:e.jsx(nt.default,{}),onClick:d,children:h("maker.properties.addArrayItem")})]}):e.jsxs(r.Stack,{width:"100%",gap:1,children:[t&&e.jsx(r.FormLabel,{children:t}),e.jsx(r.Box,{sx:{border:1,borderColor:"divider",borderRadius:1,minHeight:150},children:e.jsx(ne.CodeEditor,{keyId:x.id,locale:k,language:"json",value:JSON.stringify(u,null,2),onChange:p=>a(p||""),fullScreenOptions:{enableEscExit:!0,targetContainer:()=>document.getElementById("parameters-config-dialog")||null}},x.id)})]})}function wt({value:t,onChange:s,...i}){const o=T.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(Ue.ConfigString,{...i,value:t,onChange:s,InputProps:{endAdornment:e.jsx(r.InputAdornment,{position:"end",children:e.jsx(ye.ColorItem,{color:t??"",style:{width:"1.5rem",height:"1.5rem",padding:0},onClick:()=>{var f;(f=o.current)==null||f.open({value:t??""})}})})}}),e.jsx(ye.ConfigColorDialog,{ref:o,onSave:({value:f},g)=>{s(f),g()}})]})}function Ct({label:t,value:s,onChange:i,property:o,component:f,defaultLocale:g,allComponents:x,PropertyValueField:S,onUpload:v}){const{locale:h}=N.useLocaleContext(),k=T.useRef(null);if(!W.default(o.subProperties)){const l=V.default(Object.values(o.subProperties||{}),"index").filter(u=>u.data.visible!==!1&&u.data.key);return e.jsxs(r.Stack,{width:"100%",children:[e.jsx(r.FormLabel,{sx:{px:.25,py:.5},children:t}),e.jsx(r.Box,{children:e.jsx(r.Box,{sx:{position:"relative"},children:l.map((u,c)=>{const{data:d}=u,a=d.key??d.id,P=c===l.length-1;let n=null;try{s&&typeof s=="object"?n=s[a]:typeof s=="string"&&(n=(o.type==="yaml"?se.parse(s||""):JSON.parse(s||"{}"))[a])}catch{}n==null&&(d.locales&&h&&d.locales[h]?n=d.locales[h].defaultValue:d.locales&&g&&d.locales[g]&&(n=d.locales[g].defaultValue));const b=j=>{try{let C={};if(typeof s=="string")try{C=o.type==="yaml"?se.parse(s||""):JSON.parse(s||"{}")}catch{}else typeof s=="object"&&s!==null&&(C={...s});Ce.default(C,a,j);const p=A.transformValue(C,o.type);i==null||i(p)}catch(C){console.error("Error updating property:",C)}},m=8;return e.jsxs(r.Box,{sx:{mb:P?0:1,display:"flex",flexDirection:"row"},children:[e.jsxs(r.Box,{sx:{position:"relative",width:24,flexShrink:0},children:[e.jsx(r.Box,{sx:{position:"absolute",left:m,top:0,height:16,width:0,borderLeft:"1px dashed",borderColor:"divider"}}),e.jsx(r.Box,{sx:{position:"absolute",left:m,top:16,width:12,height:0,borderTop:"1px dashed",borderColor:"divider"}}),!P&&e.jsx(r.Box,{sx:{position:"absolute",left:m,top:16,bottom:-8,width:0,borderLeft:"1px dashed",borderColor:"divider"}})]}),e.jsx(r.Box,{sx:{flexGrow:1},children:e.jsx(S,{component:f,property:d,value:n,onChange:b,size:"small",fullWidth:!0,defaultLocale:g,allComponents:x})})]},d.id)})})})]})}return e.jsx(r.Stack,{width:"100%",gap:2,children:e.jsxs(r.Stack,{sx:{width:"100%",position:"relative",pt:1,pb:"6px",px:"1px",minHeight:50,".monaco-editor,.overflow-guard":{borderRadius:1}},children:[e.jsx(r.FormLabel,{sx:{position:"absolute",left:0,top:0,transform:"translate(0px, -7px) scale(0.75)"},children:t}),e.jsx(ne.CodeEditor,{keyId:o.id,locale:h,language:o.type==="yaml"?"yaml":"json",value:typeof s=="string"?s:"",onChange:l=>{i==null||i(l)},onUpload:l=>{k.current=l,v&&v(l)},fullScreenOptions:{enableEscExit:!0,targetContainer:()=>document.getElementById("parameters-config-dialog")||null}},o.id),e.jsx(r.Box,{component:"fieldset",sx:{pointerEvents:"none",position:"absolute",left:0,top:-5,width:"100%",height:"100%",border:1,borderColor:"rgba(0, 0, 0, 0.23)",borderRadius:1,px:1,py:0},children:e.jsx(r.Box,{component:"legend",sx:{fontSize:"0.75em"},children:e.jsx(r.Box,{component:"span",sx:{opacity:0},children:t})})})]})})}const It=["string","multiline","json","yaml","url","component","custom","array"];function ge(t){return t.type?!It.includes(t.type):!1}function Ie({disabled:t,list:s,renderItem:i,...o}){const f=T.useRef(null),g=T.useId(),x=Se.useUpdate(),S=V.default(Object.entries(s),u=>u[1].index).map(u=>u[0]),v=T.useRef(S),h=T.useCallback(u=>{v.current=u,x()},[x]),k=T.useCallback(({index:u},{index:c})=>{const d=[...v.current];d.splice(c,0,...d.splice(u,1)),h(d)},[h]);T.useEffect(()=>{h(S)},[S.join("-")]);const[{isOver:y},l]=re.useDrop({accept:g,collect:u=>({isOver:u.isOver()}),canDrop:()=>!t,drop:()=>{var d;const u=()=>{v.current.forEach((a,P)=>{const n=s[a];n&&(n.index=P)})},c=(d=G.getYjsValue(s))==null?void 0:d.doc;c?c.transact(()=>{u()}):u()}});return T.useEffect(()=>{y||h(S)},[y]),l(f),e.jsx(r.Box,{...o,ref:f,className:ot.cx(y&&"isDragging"),children:v.current.map((u,c)=>e.jsx(Tt,{type:g,disabled:t,id:u,index:c,itemIndex:d=>v.current.indexOf(d),move:k,children:d=>{const a=s[u];return a?i(a.data,c,d):null}},u))})}function Tt({disabled:t,id:s,index:i,type:o,children:f,itemIndex:g,move:x}){const S=T.useRef(),[{isDragging:v},h,k]=re.useDrag({type:o,item:()=>({id:s}),canDrag:()=>!t,collect:l=>({isDragging:l.isDragging()})}),[,y]=re.useDrop({accept:o,canDrop:()=>!t,hover(l,u){var m;if(!S.current)return;const c=g(l.id),d=i;if(c===d)return;const a=(m=S.current)==null?void 0:m.getBoundingClientRect(),P=(a.bottom-a.top)/2,b=u.getClientOffset().y-a.top;c<d&&b<P||c>d&&b>P||x({id:l.id,index:c},{id:s,index:i})}});return typeof f=="function"?f({isDragging:v,drag:h,drop:l=>(S.current=l,y(l)),preview:k}):(h(y(k(S))),e.jsx(r.Box,{ref:S,children:f}))}function Bt({drop:t,preview:s,drag:i,disabled:o,isDragging:f,children:g,onDelete:x,onVisibilityChange:S,visible:v=!0,actions:h,alwaysShowActions:k=!1}){const{t:y}=N.useLocaleContext();return e.jsx(r.Box,{ref:t,sx:{":hover .hover-visible":{maxWidth:"100%"},opacity:v?1:.5},children:e.jsxs(r.Box,{sx:{position:"relative"},children:[e.jsx(r.Box,{ref:s,sx:{flex:1,borderRadius:.5,bgcolor:f?"action.hover":"background.paper",opacity:.9999},children:g}),!o&&e.jsx(r.Box,{className:k?"":"hover-visible",sx:{maxWidth:k?"100%":0,overflow:"hidden",position:"absolute",right:2,top:2,transition:"max-width 0.3s ease-in-out"},children:e.jsxs(r.Stack,{direction:"row",sx:{bgcolor:l=>r.alpha(l.palette.grey[200],.9),borderRadius:1,p:.5,[`.${r.buttonClasses.root}`]:{minWidth:24,width:24,height:24,p:0}},children:[h,S&&e.jsx(r.Tooltip,{title:y(v?"hideParameter":"showParameter"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:()=>S(!v),children:v?e.jsx(E.VisibilityOffRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}}):e.jsx(E.VisibilityRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),x&&e.jsx(r.Tooltip,{title:y("delete"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:x,children:e.jsx(E.DeleteOutlineRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),e.jsx(r.Tooltip,{title:y("dragSort"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{ref:i,children:e.jsx(E.DragIndicatorRounded,{sx:{color:"grey.500"}})})})]})})]})})}function Ot(t){const s=["string","json","array","url","multiline"],i=["style","fontSize","color","content","type"];return!!(s.includes(t.type||"")&&!i.includes(t.key||""))}function Nt(t,s,i){return t.locales&&t.locales[s]&&t.locales[s].name?t.locales[s].name:i&&t.locales&&t.locales[i]&&t.locales[i].name?t.locales[i].name:t.key?t.key:t.id}const Te=(t,s,i,o)=>{const f={};return V.default(Object.entries(t),([,x])=>x.index).forEach(([x,S])=>{const v=S.data;if(!v)return;const h=v.key||v.id,k=i?Nt(v,i,o||""):h,y=s==null?void 0:s[v.id],l={key:h,isNeedGenerate:(y==null?void 0:y.isNeedGenerate)??Ot(v),describe:(y==null?void 0:y.describe)??"",displayName:k};v.subProperties&&!W.default(v.subProperties)&&(l.subProperties=Te(v.subProperties,y==null?void 0:y.subProperties,i,o)),f[v.id]=l}),f};function Rt({open:t,onClose:s,onConfirm:i,component:o,initialConfig:f,locale:g,defaultLocale:x,title:S,loading:v=!1}){const{t:h}=N.useLocaleContext(),[k,y]=T.useState(null);T.useEffect(()=>{if(t&&o){const a={properties:{}};if(o.properties){const P=f==null?void 0:f.properties;a.properties=Te(o.properties,P,g,x)}y(a)}},[t,o,f,g,x]);const l=()=>{s()},u=()=>{k&&(i(k),s())},c=(a,P,n)=>{if(!k||!a.length)return;const b=JSON.parse(JSON.stringify(k));let m=b.properties,j=null;for(let p=0;p<a.length-1;p++){const w=a[p];if(!w||!m[w])return;j=m;const I=m[w];I.subProperties||(I.subProperties={}),m=I.subProperties}const C=a[a.length-1];if(C){if("isNeedGenerate"in n){const p=n.isNeedGenerate,w={...P,...n};if(P.subProperties&&!W.default(P.subProperties)){const I=(B,R)=>{const _={};return Object.entries(B).forEach(([D,z])=>{const F={...z};R!==null&&(F.isNeedGenerate=R),z.subProperties&&!W.default(z.subProperties)&&(F.subProperties=I(z.subProperties,R!==null?R:null)),_[D]=F}),_};w.subProperties=I(P.subProperties,p===!1?!1:null)}if(a.length===1)b.properties[C]=w;else if(j&&a.length>=2){const I=a[a.length-2];I&&j[I]&&(j[I].subProperties||(j[I].subProperties={}),j[I].subProperties[C]=w)}}else if(a.length===1)b.properties[C]={...P,...n};else if(j&&a.length>=2){const p=a[a.length-2];p&&j[p]&&j[p].subProperties&&(j[p].subProperties[C]={...P,...n})}y(b)}},d=(a,P=[],n=!0)=>{if(!a||W.default(a))return e.jsx(Q.default,{children:h("maker.properties.noProperties")});const b=V.default(Object.entries(a),([,m])=>m.displayName);return e.jsx(r.Stack,{spacing:1.5,children:b.map(([m,j],C)=>{const p=[...P,m],w=C===b.length-1,I=j.subProperties&&!W.default(j.subProperties),B=j.displayName||m,R=!n;return e.jsx(r.Box,{sx:{position:"relative"},children:e.jsxs(r.Stack,{direction:"row",children:[P.length>0&&e.jsxs(r.Box,{sx:{position:"relative",width:24,flexShrink:0},children:[e.jsx(r.Box,{sx:{position:"absolute",left:8,top:0,height:16,width:0,borderLeft:"1px dashed",borderColor:"divider"}}),e.jsx(r.Box,{sx:{position:"absolute",left:8,top:16,width:12,height:0,borderTop:"1px dashed",borderColor:"divider"}}),!w&&e.jsx(r.Box,{sx:{position:"absolute",left:8,top:16,bottom:-12,width:0,borderLeft:"1px dashed",borderColor:"divider"}})]}),e.jsxs(r.Stack,{spacing:1.5,sx:{flexGrow:1},children:[e.jsxs(r.Stack,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},spacing:1.5,width:"100%",children:[e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:j.isNeedGenerate,disabled:R,onChange:_=>{c(p,j,{isNeedGenerate:_.target.checked})}}),label:B,sx:{minWidth:"180px",maxWidth:"280px",mr:2,"& .MuiFormControlLabel-label":{wordBreak:"break-word"}}}),e.jsx(r.TextField,{size:"small",fullWidth:!0,label:h("maker.properties.llmPropertyDescribe"),value:j.describe,onChange:_=>{c(p,j,{describe:_.target.value})},disabled:!j.isNeedGenerate})]}),I&&e.jsx(r.Box,{sx:{ml:3},children:d(j.subProperties,p,j.isNeedGenerate&&n)})]})]})},m)})})};return e.jsxs(r.Dialog,{open:t,onClose:l,maxWidth:"lg",fullWidth:!0,children:[e.jsx(r.DialogTitle,{children:S||h("maker.properties.llmConfigTitle")}),e.jsx(r.DialogContent,{children:e.jsx(r.Box,{my:3,children:v?e.jsx(r.Typography,{children:h("maker.properties.loading")}):o?k?e.jsxs(r.Stack,{spacing:3,children:[e.jsx(r.Typography,{variant:"subtitle2",children:h("maker.properties.llmConfigInstructions")}),d(k.properties)]}):e.jsx(r.Typography,{children:h("maker.properties.loading")}):e.jsx(r.Typography,{color:"error",children:h("maker.properties.componentNotFound")})})}),e.jsxs(r.DialogActions,{children:[e.jsx(r.Button,{onClick:l,children:h("common.cancel")}),e.jsx(r.Button,{variant:"contained",onClick:u,disabled:!k||v,children:h("common.confirm")})]})]})}function _t({label:t,value:s,onChange:i}){const[o,f]=T.useState(!1);return e.jsxs(r.Stack,{gap:1,children:[e.jsx(r.TextField,{label:t,size:"small",value:s,onChange:g=>i==null?void 0:i(g.target.value),InputProps:{sx:{pr:0},endAdornment:e.jsx(r.InputAdornment,{position:"end",children:e.jsx(q.UploaderButton,{onChange:({response:g})=>{var S;const x=(S=g==null?void 0:g.data)==null?void 0:S.filename;x&&(i==null||i(x))}})})}}),s&&e.jsx(r.Box,{component:"img",sx:{objectFit:"contain",borderRadius:1,cursor:"pointer"},src:A.getImageAbsoluteUrl(s),alt:t,maxWidth:100,maxHeight:100,width:"100%",onClick:()=>f(!0)}),e.jsx(r.Dialog,{open:o,onClose:()=>f(!1),children:e.jsx(r.Box,{component:"img",sx:{objectFit:"contain"},src:A.getImageAbsoluteUrl(s),alt:t})})]})}function oe(t,s=""){return gt.default(t,(i,o,f)=>{const g=s?`${s}.${f}`:f;return bt.default(o)?pt.default(i,oe(o,g)):i[g]=o,i},{})}const Et=[{value:"string",label:"Text"},{value:"multiline",label:"Text (Multiline)"},{value:"number",label:"Number"},{value:"decimal",label:"Decimal"},{value:"boolean",label:"Boolean"},{value:"color",label:"Color"},{value:"url",label:"URL (Upload)"},{value:"json",label:"JSON"},{value:"yaml",label:"YAML"},{value:"array",label:"Array"},{value:"component",label:"Component"},{value:"custom",label:"Custom (Render by a Component)"}];function X(t,s,i){return!t||!i?!1:Object.values(t).some(({data:o})=>o.id!==s&&o.key===i)}function le(t,s){var i;return!t||!s?!1:((i=t[s])==null?void 0:i.data.visible)??!0}function At({componentId:t}){const{state:{components:s}}=A.useStore(),i=s[t],o=i==null?void 0:i.data;return o?e.jsx(r.Stack,{maxHeight:"100%",overflow:"auto",children:e.jsx(r.Box,{p:2,children:e.jsx(it.ErrorBoundary,{FallbackComponent:A.ErrorView,resetKeys:[t],children:e.jsx(Vt,{value:o,componentId:t})})})}):null}function Vt({value:t,componentId:s}){var y,l,u;const{t:i}=N.useLocaleContext(),{localState:{currentLocale:o,customComponentPreviewerProperties:f},state:{config:{defaultLocale:g}},localActions:{setCustomComponentPreviewerProperties:x}}=A.useStore(),S=G.getYjsValue(t).doc,v=A.useAllComponents(),h=T.useMemo(()=>(f==null?void 0:f[s])??{},[s,f]),k=Se.useReactive({componentId:s,propertiesValue:{...h}});return T.useEffect(()=>{k.componentId!==s&&(k.componentId=s,k.propertiesValue={...h})},[s,h,k]),T.useEffect(()=>{if(k.componentId!==s)return;const c=Object.fromEntries(Object.values(t.properties??{}).map(({data:d})=>{var a,P,n,b,m;return[d.id,{value:((a=k.propertiesValue[d.id])==null?void 0:a.value)??He.parsePropertyValue(d,((n=(P=d.locales)==null?void 0:P[o])==null?void 0:n.defaultValue)??((m=(b=d.locales)==null?void 0:b[g])==null?void 0:m.defaultValue),{locale:o,defaultLocale:g})}]}));x(s,c)},[JSON.stringify(k.propertiesValue),s,k.componentId]),e.jsx(r.Stack,{height:"100%",children:e.jsxs(r.Stack,{gap:2,children:[e.jsx(Be,{config:t}),e.jsx(Ne,{config:t,currentLocale:o,defaultLocale:g,allComponents:v,onUpdateConfig:c=>{S.transact(()=>{c(t)})}}),e.jsxs(r.Stack,{gap:2,direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(r.Typography,{variant:"subtitle1",children:i("renderer")}),e.jsxs(r.TextField,{hiddenLabel:!0,size:"small",select:!0,SelectProps:{autoWidth:!0},value:((y=t.renderer)==null?void 0:y.type)||"react-component",onChange:c=>{S.transact(()=>{const d=c.target.value;t.renderer??(t.renderer={type:d}),t.renderer.type=d})},children:[e.jsx(r.MenuItem,{value:"react-component",children:"React Component"}),e.jsx(r.MenuItem,{value:"component",children:"Custom Component"})]})]}),((l=t.renderer)==null?void 0:l.type)==="component"&&e.jsx(Wt,{value:t}),((u=t.renderer)==null?void 0:u.type)==="react-component"&&e.jsx(Mt,{value:t}),e.jsx(ce,{config:t,currentLocale:o,defaultLocale:g,allComponents:v,propertiesValue:k.propertiesValue,onChange:({value:c,id:d,path:a})=>{const P=[...a,"data"];if(!xt.default(t,P)){ie.default.warning(i("cannotFindPropertyKey",{key:P.join(".")}));return}k.propertiesValue[d]={value:c.value}}})]})})}function Be({config:t}){const{t:s}=N.useLocaleContext();return e.jsx(q.UploaderProvider,{children:e.jsxs(r.Stack,{gap:2,children:[e.jsx(r.Typography,{variant:"subtitle1",children:s("basicInfo")}),e.jsx(r.TextField,{label:s("name"),size:"small",value:t.name||"",onChange:i=>t.name=i.target.value}),e.jsx(r.TextField,{label:s("description"),size:"small",multiline:!0,minRows:2,maxRows:10,inputProps:{maxLength:200},value:t.description||"",onChange:i=>t.description=i.target.value,InputProps:{endAdornment:e.jsx(r.InputAdornment,{position:"end",sx:{mt:-1.5},children:e.jsx(Lt,{config:t})})}}),e.jsx(r.Autocomplete,{size:"small",options:[],multiple:!0,freeSolo:!0,value:t.tags??[],onChange:(i,o)=>t.tags=o,renderInput:i=>e.jsx(r.TextField,{label:s("tags"),...i})}),e.jsx(_t,{label:s("previewImage"),value:t.previewImage||"",onChange:i=>t.previewImage=i})]})})}function Oe({data:t,params:s,visible:i,config:o,currentLocale:f,defaultLocale:g,allComponents:x,onUpdateConfig:S}){var k,y,l,u,c,d;const{t:v}=N.useLocaleContext(),h=T.useMemo(()=>t.type==="json"||t.type==="yaml"||t.type==="array"?qt:L,[t.type]);return e.jsx(Bt,{preview:s.preview,drop:s.drop,drag:s.drag,isDragging:s.isDragging,onDelete:()=>{S(a=>{if(a.properties){const n=Object.entries(a.properties).sort(([,m],[,j])=>m.index-j.index);delete a.properties[t.id],n.filter(([m])=>m!==t.id).forEach(([,m],j)=>{m.index=j})}})},visible:i,onVisibilityChange:a=>{S(P=>{const n=P.properties[t.id].data;n.visible=a})},alwaysShowActions:!0,children:e.jsxs(r.Stack,{direction:"column",gap:2,children:[e.jsx(r.TextField,{label:v("key"),size:"small",required:!0,sx:{width:"calc(100% - 80px - 8px)",flex:1,"& .MuiOutlinedInput-root":{borderColor:t.key?X(o.properties,t.id,t.key)?"warning.main":void 0:"error.main"},"& .MuiFormLabel-root":{color:t.key?X(o.properties,t.id,t.key)?"warning.main":"text.secondary":"error.main"},"& .MuiFormLabel-root.Mui-focused":{color:t.key?X(o.properties,t.id,t.key)?"warning.main":"primary.main":"error.main"}},value:t.key||"",onChange:a=>{S(P=>{const n=P.properties[t.id].data;n.key=a.target.value.trim()})},InputProps:{endAdornment:!t.key||t.key&&X(o.properties,t.id,t.key)?e.jsx(r.InputAdornment,{position:"end",sx:{width:16,ml:0},children:e.jsx(r.Tooltip,{title:t.key?v("duplicateKey"):v("requiredKey"),children:e.jsx(E.InfoRounded,{sx:{color:t.key?"warning.main":"error.main",fontSize:16}})})}):null}}),e.jsxs(r.Stack,{direction:"row",gap:1,children:[e.jsx(r.TextField,{label:v("label"),size:"small",sx:{flex:1},value:(((y=(k=t.locales)==null?void 0:k[f])==null?void 0:y.name)??((u=(l=t.locales)==null?void 0:l[g])==null?void 0:u.name))||"",onChange:a=>{S(P=>{var b;const n=P.properties[t.id].data;n.locales??(n.locales={}),(b=n.locales)[f]??(b[f]={}),n.locales[f].name=a.target.value})}}),e.jsx(r.TextField,{label:v("type"),size:"small",select:!0,sx:{flex:1},value:t.type==="string"&&t.multiline?"multiline":t.type||"string",onChange:a=>{S(P=>{const n=P.properties[t.id].data;if(n.locales)for(const m of Object.keys(n.locales))n.locales[m].defaultValue=void 0;const b=a.target.value;b==="multiline"?(n.type="string",n.multiline=!0):(typeof n.multiline<"u"&&delete n.multiline,n.type=b)})},children:Et.map(a=>e.jsx(r.MenuItem,{value:a.value,children:a.label},a.value))})]}),e.jsxs(r.Stack,{direction:"row",gap:1,children:[e.jsx(h,{allComponents:x,defaultLocale:g,component:o,property:t,label:v("defaultValue"),size:"small",fullWidth:!0,value:(d=(c=t.locales)==null?void 0:c[f])==null?void 0:d.defaultValue,onChange:(a,P)=>{S(n=>{var m;const b=n.properties[t.id].data;if(P!=null&&P.forceUpdateProperty){const j=oe(b),C=oe(a);Object.keys(C).forEach(p=>{j[p]||Ce.default(b,p,C[p])})}else b.locales??(b.locales={}),(m=b.locales)[f]??(m[f]={}),b.locales[f].defaultValue=a})}}),t.type==="custom"?e.jsx(r.Box,{children:e.jsx(zt,{property:t,allComponents:x})}):null]})]})})}function Dt(t,s){const[i,o]=T.useState(0);return T.useEffect(()=>{const g=setTimeout(()=>{if(t.current){let x=t.current.parentElement,S=0;for(;x;)x.classList.contains("property-container")&&S++,x=x.parentElement;o(S)}},100);return()=>clearTimeout(g)},[t,s]),i}function Ne({config:t,currentLocale:s,defaultLocale:i,allComponents:o,onUpdateConfig:f,useI18nEditor:g=!0}){const{t:x}=N.useLocaleContext(),S=U.usePopupState({variant:"dialog"}),v=t.properties&&V.default(Object.values(t.properties),"index");return e.jsx(q.UploaderProvider,{children:e.jsxs(r.Stack,{gap:2,children:[e.jsxs(r.Stack,{direction:"row",gap:1,alignItems:"center",justifyContent:"space-between",children:[e.jsx(r.Typography,{variant:"subtitle1",children:x("properties")}),e.jsx(r.Box,{flex:1}),g&&e.jsx(r.Button,{sx:{minWidth:32,minHeight:32,p:0},...U.bindTrigger(S),children:e.jsx(E.TranslateRounded,{fontSize:"small"})})]}),t.properties&&Object.keys(t.properties).length>0?e.jsx(Ie,{component:r.Stack,gap:2,list:t.properties,renderItem:(h,k,y)=>{const l=le(t.properties,h.id);return e.jsx(r.Paper,{elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:l?"1px solid":"1px dashed",borderColor:"divider"},children:e.jsx(r.Stack,{gap:2,children:e.jsx(Oe,{data:h,params:y,visible:l,config:t,currentLocale:s,defaultLocale:i,allComponents:o,onUpdateConfig:f})})},h.id)}}):e.jsx(Q.default,{style:{fontSize:12},children:x("maker.properties.noProperties")}),e.jsx(r.Button,{fullWidth:!0,variant:"outlined",className:"ignore-style-override",onClick:()=>{f(h=>{var y;const k=we.nextId();h.properties??(h.properties={}),(y=h.properties)[k]??(y[k]={index:(v==null?void 0:v.length)||0,data:{id:k}})})},startIcon:e.jsx(E.AddRounded,{}),children:x("addObject",{object:x("property")})}),g&&e.jsx(Re,{...U.bindDialog(S),component:t})]})})}function zt({property:t,allComponents:s}){const i=U.usePopupState({variant:"popper"});return e.jsxs(e.Fragment,{children:[e.jsx(r.Button,{sx:{minWidth:0},...U.bindTrigger(i),children:e.jsx(E.SettingsRounded,{fontSize:"small"})}),e.jsx(r.Popper,{...U.bindPopper(i),children:e.jsx(Pe.ClickAwayListener,{onClickAway:i.close,children:e.jsx(r.Paper,{children:e.jsx(r.Box,{width:500,p:2,children:e.jsx(te,{value:t.componentId,onChange:(o,f)=>t.componentId=f,allComponents:s})})})})})]})}function Ft({value:t,valueImmutable:s,onChange:i,defaultLocale:o,allComponents:f}){var k;const[g,x]=T.useState(!1),{t:S,locale:v}=N.useLocaleContext(),h=typeof(t==null?void 0:t.componentId)=="string"?(k=f[t.componentId])==null?void 0:k.data:void 0;return h?e.jsxs(r.Box,{sx:{width:"100%",position:"relative"},children:[e.jsx(r.IconButton,{sx:{minWidth:0},disabled:!h,size:"small",onClick:()=>x(!g),color:g?"primary":"default",children:e.jsx(E.SettingsRounded,{fontSize:"small"})}),g&&e.jsx(r.Collapse,{in:g,timeout:"auto",unmountOnExit:!0,sx:{width:"100%",zIndex:10},children:e.jsxs(r.Paper,{elevation:1,sx:{mt:1,p:2,borderRadius:1,border:"1px solid",borderColor:"divider",width:"100%"},children:[e.jsx(r.Box,{width:"100%",mb:2,children:e.jsx(ce,{config:h,currentLocale:v,defaultLocale:o,allComponents:f,propertiesValue:t==null?void 0:t.properties,onChange:({id:y,value:l})=>{const u=dt.default(l.value),c=JSON.parse(JSON.stringify(t));c!=null&&c.componentId&&(s?i==null||i({...c,properties:{...c.properties,[y]:{value:u}}}):(c.properties=c.properties??{},c.properties[y]={value:u},i==null||i(c)))}})}),e.jsx(r.Button,{size:"small",onClick:()=>x(!1),sx:{mt:1},children:S("close")})]})})]}):null}function Re({type:t="properties",component:s,...i}){var y,l,u;const{t:o}=N.useLocaleContext(),{state:{components:f,supportedLocales:g,config:{defaultLocale:x}}}=A.useStore(),S=A.useAllComponents(),v=G.getYjsValue(s).doc,h=t==="properties"?s.properties:t==="parameters"&&((y=s.renderer)==null?void 0:y.type)==="component"?(l=f[s.renderer.componentId])==null?void 0:l.data.properties:void 0,k=((u=s.renderer)==null?void 0:u.type)==="component"?s:void 0;return e.jsxs(r.Dialog,{...i,fullWidth:!0,maxWidth:"lg",children:[e.jsx(r.DialogTitle,{children:o("i18nEditorTitle")}),e.jsx(r.DialogContent,{children:h&&e.jsx(r.Stack,{children:e.jsxs(r.Table,{stickyHeader:!0,sx:{td:{verticalAlign:"top"}},children:[e.jsx(r.TableHead,{children:e.jsx(r.TableRow,{children:g.map(({locale:c,name:d})=>e.jsx(r.TableCell,{children:e.jsxs(r.Typography,{color:"text.primary",children:[d,x===c&&e.jsx(E.StarRounded,{sx:{fontSize:12}})]})},c))})}),e.jsx(r.TableBody,{children:V.default(Object.values(h),"index").map(({data:c})=>e.jsx(r.TableRow,{children:g.map(({locale:d})=>{var a,P,n,b,m,j,C,p,w,I,B,R,_,D,z,F,J,H,Y,$,ue,ae,de,pe,xe,me;return e.jsx(r.TableCell,{children:e.jsx(r.Stack,{gap:1,children:t==="properties"?e.jsxs(e.Fragment,{children:[e.jsx(r.TextField,{size:"small",label:"Key",value:c.key||"",onChange:K=>{v.transact(()=>{c.key=K.target.value.trim()})}}),e.jsx(r.TextField,{size:"small",label:o("label"),value:(((P=(a=c.locales)==null?void 0:a[d])==null?void 0:P.name)??((b=(n=c.locales)==null?void 0:n[x])==null?void 0:b.name))||"",onChange:K=>{v.transact(()=>{var M;c.locales??(c.locales={}),(M=c.locales)[d]??(M[d]={}),c.locales[d].name=K.target.value})}}),e.jsx(r.Box,{children:e.jsx(L,{allComponents:S,defaultLocale:x,component:s,property:c,size:"small",fullWidth:!0,label:"Default Value",valueImmutable:ee.default((j=(m=c.locales)==null?void 0:m[d])==null?void 0:j.defaultValue),value:((p=(C=c.locales)==null?void 0:C[d])==null?void 0:p.defaultValue)??((I=(w=c.locales)==null?void 0:w[x])==null?void 0:I.defaultValue),onChange:K=>{v.transact(()=>{var M;c.locales??(c.locales={}),(M=c.locales)[d]??(M[d]={}),c.locales[d].defaultValue=K})}})})]}):t==="parameters"&&k?e.jsx(r.Box,{children:e.jsx(L,{allComponents:S,defaultLocale:x,component:s,property:c,size:"small",fullWidth:!0,valueImmutable:ee.default((D=(_=(R=(B=k.renderer.properties)==null?void 0:B[c.id])==null?void 0:R.locales)==null?void 0:_[d])==null?void 0:D.value),value:((H=(J=(F=(z=k.renderer.properties)==null?void 0:z[c.id])==null?void 0:F.locales)==null?void 0:J[d])==null?void 0:H.value)??((ae=(ue=($=(Y=k.renderer.properties)==null?void 0:Y[c.id])==null?void 0:$.locales)==null?void 0:ue[x])==null?void 0:ae.value)??((pe=(de=c.locales)==null?void 0:de[d])==null?void 0:pe.defaultValue)??((me=(xe=c.locales)==null?void 0:xe[x])==null?void 0:me.defaultValue),onChange:K=>{v.transact(()=>{var M,fe,be,he,je;(M=k.renderer).properties??(M.properties={}),(fe=k.renderer.properties)[be=c.id]??(fe[be]={}),(he=k.renderer.properties[c.id]).locales??(he.locales={}),(je=k.renderer.properties[c.id].locales)[d]??(je[d]={}),k.renderer.properties[c.id].locales[d].value=K})}})}):null},c.id)},d)})},c.id))})]})})}),e.jsx(r.DialogActions,{children:e.jsx(r.Button,{onClick:c=>{var d;return(d=i.onClose)==null?void 0:d.call(i,c,"escapeKeyDown")},children:o("close")})})]})}const ke=(t,s)=>i=>{const o=[i.palette.info.main,i.palette.primary.main,i.palette.secondary.main,i.palette.success.main,i.palette.warning.main],f=Math.min(o.length-1,t),g=o[f],x=r.alpha(g,.5),S=r.alpha(g,1);return{borderColor:`${x} !important`,borderLeft:"3px solid !important",borderLeftColor:x,color:S,...s}};function qt({property:t,onChange:s,defaultLocale:i,allComponents:o}){const{t:f,locale:g}=N.useLocaleContext(),x=T.useRef(null),S=Dt(x,t),v=T.useCallback(()=>{if(!(t.type!=="json"&&t.type!=="yaml"&&t.type!=="array")&&t.subProperties)try{let h={};V.default(Object.values(t.subProperties),"index").filter(l=>l.data.visible!==!1&&l.data.key).forEach(({data:l})=>{var c,d,a,P;if(!l.key)return;let u=((d=(c=l.locales)==null?void 0:c[g])==null?void 0:d.defaultValue)??((P=(a=l.locales)==null?void 0:a[i])==null?void 0:P.defaultValue);if(l.type==="number")u=Number(u);else if(l.type==="boolean")u=u===!0||u==="true";else if((l.type==="json"||l.type==="yaml")&&typeof u=="string")try{l.type==="json"?u=JSON.parse(u):u=se.parse(u)}catch(n){console.error("Error parsing nested value",u,n),u={}}h[l.key]=u}),t.type==="array"&&!Array.isArray(h)&&(h=W.default(h)?[]:[h]);const y=A.transformValue(h,t.type);s==null||s(y)}catch(h){console.error("Error converting structure to text:",h)}},[t,g,i,s]);return t.type!=="json"&&t.type!=="yaml"&&t.type!=="array"?null:e.jsxs(r.Stack,{direction:"column",gap:1.5,sx:{width:"100%"},ref:x,children:[e.jsx(r.Divider,{sx:{mt:-1},children:e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:f("maker.properties.subProperties")})}),t.subProperties&&Object.keys(t.subProperties).length>0?e.jsx(Ie,{component:r.Stack,gap:2,list:t.subProperties,renderItem:(h,k,y)=>{const l=h.visible!==!1;return e.jsx(r.Paper,{elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:l?"1px solid":"1px dashed","&":ke(S)},children:e.jsx(r.Stack,{gap:2,children:e.jsx(Oe,{data:h,params:y,visible:l,config:{properties:t.subProperties},currentLocale:g,defaultLocale:i,allComponents:o,onUpdateConfig:u=>{try{const c={properties:t.subProperties||{}};u(c);const d={...t,subProperties:c.properties};s==null||s(d,{forceUpdateProperty:!0}),v()}catch(c){console.error("Error updating property:",c)}}})})},h.id)}}):e.jsx(Q.default,{style:{fontSize:12,height:100},children:f("maker.properties.noSubProperties")}),e.jsx(r.Button,{fullWidth:!0,variant:"outlined",className:"ignore-style-override",size:"small",startIcon:e.jsx(E.AddRounded,{}),onClick:()=>{try{const h=t.subProperties||{},k=we.nextId(),l={index:Object.values(h).length,data:{id:k,key:"",type:"string",visible:!0,locales:{[g]:{name:"",defaultValue:""}},subProperties:{}}},u={...t,subProperties:{...h,[k]:l}};s==null||s(u,{forceUpdateProperty:!0}),v()}catch(h){console.error("Error adding property:",h)}},sx:{"&":ke(S,{})},children:f("maker.properties.addSubProperty")})]})}function L({component:t,property:s,value:i,onChange:o,valueImmutable:f,defaultLocale:g,allComponents:x,...S}){var u,c,d,a,P;const{locale:v}=N.useLocaleContext(),h=q.useUploader(),k=T.useRef(null),y=()=>{var b;const n=(b=h==null?void 0:h.current)==null?void 0:b.getUploader();n==null||n.open(),k.current&&n.onceUploadSuccess(({response:m})=>{var C,p;let j=((C=m==null?void 0:m.data)==null?void 0:C.filename)||"";j&&(j=`mediakit://${j}`,i&&!i.includes("mediakit://")&&(j+=" # please use < import { getMediaKitAbsoluteUrl } from '@blocklet/pages-kit/builtin/utils' > to get the full address")),(p=k.current)==null||p.call(k,j)})},l=S.label??(((c=(u=s.locales)==null?void 0:u[v])==null?void 0:c.name)||((a=(d=s.locales)==null?void 0:d[g])==null?void 0:a.name)||s.key||s.id);if(s.type==="number")return e.jsx(Ut,{...S,label:l,NumberProps:{value:["number","string"].includes(typeof i)?i:null,onChange:(n,b)=>o==null?void 0:o(b)}});if(s.type==="decimal")return e.jsx(r.TextField,{...S,label:l,type:"text",value:i??"",onChange:n=>{const b=n.target.value;if(b===""||b==="-"){o==null||o(b);return}if(/^-?(?!.*\..*\.)[0-9]*(\.[0-9]{0,9})?$/.test(b)){let j=b;/^-?[1-9]+[0-9]*(\.[0-9]{1,9})?$/.test(j)&&(j=Number(j)),o==null||o(j)}}});if(s.type==="boolean")return e.jsx(r.FormControlLabel,{label:l,labelPlacement:"start",control:e.jsx(r.Switch,{checked:i===!0,onChange:(n,b)=>o==null?void 0:o(b)})});if(s.type==="color")return e.jsx(wt,{label:l,value:i,onChange:n=>{o==null||o(n)}});if(s.type==="json"||s.type==="yaml")return e.jsx(Ct,{label:l,value:i,onChange:n=>{o==null||o(n)},property:s,component:t,defaultLocale:g,allComponents:x,PropertyValueField:L,onUpload:n=>{k.current=n,y()}});if(s.type==="custom"){const n=(P=x[s.componentId])==null?void 0:P.data;return n?e.jsx(r.Box,{width:"100%",children:e.jsx(Z.CustomComponentRenderer,{componentId:n.id,props:{label:l,value:i,onChange:o},locale:v,dev:{mode:"draft",components:x,defaultLocale:g}})}):e.jsx(r.TextField,{...S,label:l,disabled:!0,placeholder:"Click right button select a component"})}if(s.type==="component")return e.jsxs(r.Stack,{width:"100%",direction:"column",gap:1,children:[e.jsx(te,{allComponents:x,label:l,value:i==null?void 0:i.componentId,onChange:(n,b)=>{f||!i?o==null||o({...i&&JSON.parse(JSON.stringify(i)),componentId:b}):typeof i=="object"&&(i.componentId=b,o==null||o({...i&&JSON.parse(JSON.stringify(i)),componentId:b}))}}),(i==null?void 0:i.componentId)&&e.jsx(Ft,{value:i,valueImmutable:f,onChange:o,defaultLocale:g,allComponents:x})]});if(!s.type||["string","url","multiline"].includes(s.type)){let n=s.type==="string"?s.multiline:void 0;s.type==="multiline"&&(n=!0);const b=s.type==="url"?i==null?void 0:i.url:i;return e.jsx(r.TextField,{...S,label:l,value:typeof b=="string"?b:"",multiline:n,minRows:n?2:void 0,maxRows:n?10:void 0,onChange:m=>o==null?void 0:o(s.type==="url"?{...i,url:m.target.value,mediaKitUrl:m.target.value}:m.target.value),InputProps:s.type==="url"?{sx:{pr:0},endAdornment:e.jsxs(r.InputAdornment,{position:"end",sx:{display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(q.UploaderButton,{onChange:async({response:m})=>{var w,I,B;const j=((w=m==null?void 0:m.data)==null?void 0:w.url)||((I=m==null?void 0:m.data)==null?void 0:I.fileUrl);let C;j&&(C=await q.getImageSize(j).catch(()=>q.getVideoSize(j)).catch(()=>{}));let p=((B=m==null?void 0:m.data)==null?void 0:B.filename)||"";p&&(p=`mediakit://${p}`),o==null||o({url:j,mediaKitUrl:p,width:C==null?void 0:C.naturalWidth,height:C==null?void 0:C.naturalHeight})}}),e.jsx(r.Tooltip,{title:"If you are using the 'mediaKitUrl' property, please use < import { getMediaKitAbsoluteUrl } from '@blocklet/pages-kit/builtin/utils' > to get the full address.",children:e.jsx(E.InfoRounded,{sx:{cursor:"default",mr:1},fontSize:"small"})})]})}:void 0})}return s.type==="array"?e.jsx(St,{label:l,value:Array.isArray(i)?i:[],onChange:n=>o==null?void 0:o(n),property:s,renderItem:({item:n,index:b,onChange:m})=>s.subProperties&&Object.keys(s.subProperties).length>0?e.jsx(r.Stack,{gap:1,width:"100%",children:V.default(Object.values(s.subProperties),"index").filter(j=>j.data.visible!==!1).map(({data:j})=>j.key?e.jsx(L,{component:t,property:j,value:n[j.key],onChange:C=>{const p={...n,[j.key]:C};m(p)},size:"small",fullWidth:!0,defaultLocale:g,allComponents:x},j.id):null)},b):e.jsx(r.TextField,{size:S.size,fullWidth:!0,value:n,onChange:j=>m(j.target.value)})}):(console.error("Unsupported property type",s.type),null)}function Ut({NumberProps:t,...s}){const{getInputProps:i}=Pe.unstable_useNumberInput(t),o=i();return e.jsx(r.TextField,{...s,inputProps:o})}const _e=`import React from '@blocklet/pages-kit/builtin/react'
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),R=require("./chunks/state-B6BF5wJ-.js"),je=require("@arcblock/ux/lib/Empty"),O=require("@arcblock/ux/lib/Locale/context"),ee=require("@blocklet/code-editor"),ye=require("@mui/icons-material/AddRounded"),Ce=require("@mui/icons-material/ArrowDownward"),ve=require("@mui/icons-material/ArrowUpward"),ke=require("@mui/icons-material/DeleteOutline"),r=require("@mui/material"),Pe=require("lodash/sortBy"),v=require("react"),te=require("react-use"),se=require("@blocklet/pages-kit/builtin/color-picker"),V=require("@blocklet/pages-kit/builtin/uploader"),Se=require("@iconify-icon/react"),we=require("lodash/isEmpty"),Ie=require("lodash/set"),Te=require("yaml"),Be=require("lodash/cloneDeep"),Oe=require("@arcblock/ux/lib/Toast"),K=require("@blocklet/pages-kit/components"),Re=require("@blocklet/pages-kit/utils/property"),ie=require("@mui/base"),_=require("@mui/icons-material"),L=require("@syncedstore/core"),le=require("ahooks"),Ne=require("lodash/assign"),Ve=require("lodash/get"),_e=require("lodash/has"),ze=require("lodash/isEqual"),Ee=require("lodash/isNil"),Ae=require("lodash/isObject"),De=require("lodash/keyBy"),Fe=require("lodash/omit"),qe=require("lodash/pick"),Le=require("lodash/reduce"),A=require("material-ui-popup-state/hooks"),Ue=require("react-error-boundary"),Me=require("@emotion/css"),$=require("react-dnd"),ae=require("@blocklet/pages-kit/utils/common"),T=t=>t&&t.__esModule?t:{default:t};function We(t){if(t&&t.__esModule)return t;const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const i in t)if(i!=="default"){const l=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(s,i,l.get?l:{enumerable:!0,get:()=>t[i]})}}return s.default=t,Object.freeze(s)}const U=T(je),Ke=T(ye),Je=T(Ce),He=T(ve),Ye=T(ke),z=T(Pe),D=T(we),ce=T(Ie),G=We(Te),$e=T(Be),Q=T(Oe),Ge=T(Ne),Qe=T(Ve),Xe=T(_e),Ze=T(ze),J=T(Ee),et=T(Ae),tt=T(De),rt=T(Fe),st=T(qe),nt=T(Le);function ot({onClick:t,disabled:s,sx:i,...l}){return e.jsx(r.IconButton,{size:"small",color:"warning",variant:"outlined",disabled:s,onClick:t,...l,children:e.jsx(Ye.default,{fontSize:"small"})})}function it({onClick:t,disabled:s,sx:i,...l}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...l,children:e.jsx(He.default,{fontSize:"small"})})}function lt({onClick:t,disabled:s,sx:i,...l}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...l,children:e.jsx(Je.default,{fontSize:"small"})})}function at({label:t,value:s,onChange:i,disabled:l=!1,itemLabel:f="",emptyHeight:x=40,property:d,renderItem:b,...m}){const{t:u,locale:a}=O.useLocaleContext(),c=te.useUpdate(),o=v.useCallback(j=>{i(R.transformValue(j,d.type))},[i,d.type]),n=v.useMemo(()=>Array.isArray(s)?s:[],[s]),h=v.useCallback(()=>{const j=[...n,""];o(j),c()},[n,o,c]),g=v.useCallback(()=>{if(!d||!d.subProperties)return h();const j={};z.default(Object.values(d.subProperties),"index").forEach(({data:N})=>{if(!N.key)return;const E=N.locales?.[a]?.defaultValue??"";j[N.key]=E});const w=[...n,j];o(w),c()},[n,o,c,d,a,h]),p=v.useCallback(j=>{try{const C=JSON.parse(j);Array.isArray(C)?o(C):console.error("JSON解析结果不是数组")}catch(C){console.error("JSON解析错误:",C)}},[o]),y=v.useCallback(j=>{const C=n.filter((w,N)=>N!==j);o(C),c()},[n,o,c]),P=v.useCallback(j=>{if(j<=0)return;const C=[...n],w=C[j];C[j]=C[j-1],C[j-1]=w,o(C),c()},[n,o,c]),I=v.useCallback(j=>{if(j>=n.length-1)return;const C=[...n],w=C[j];C[j]=C[j+1],C[j+1]=w,o(C),c()},[n,o,c]),S=v.useCallback((j,C)=>{const w=[...n];w[j]=C,o(w)},[n,o]),k=d&&d.subProperties&&Object.keys(d.subProperties).length>0,B=v.useMemo(()=>[{field:"index",headerName:"#",width:40,align:"center",renderCell:({index:j})=>e.jsx(r.Typography,{variant:"body1",sx:{bgcolor:"action.hover",borderRadius:"50%",width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:j+1})},{field:"content",headerName:"",renderCell:({row:j,index:C})=>b&&k?b({item:j,index:C,property:d,onChange:w=>S(C,w)}):e.jsx(r.TextField,{fullWidth:!0,size:"small",disabled:l,value:j,placeholder:f||`${u("item")} ${C+1}`,onChange:w=>S(C,w.target.value),...m})},{field:"actions",headerName:"",width:30,align:"center",renderCell:({index:j})=>e.jsxs(r.Stack,{direction:"column",spacing:.25,children:[e.jsx(it,{disabled:l||j===0,onClick:()=>P(j)}),e.jsx(lt,{disabled:l||j===n.length-1,onClick:()=>I(j)}),e.jsx(ot,{disabled:l,onClick:()=>y(j)})]})}],[b,k,d,S,f,u,l,m,y,P,I,n.length]);return k?e.jsxs(r.Stack,{sx:{width:"100%",gap:1},children:[t&&e.jsx(r.FormLabel,{children:t}),n.length>0?e.jsx(r.TableContainer,{component:r.Paper,variant:"outlined",sx:{borderRadius:1,mb:1},children:e.jsxs(r.Table,{size:"small",sx:{"& .MuiTableCell-root":{py:.25,px:1,whiteSpace:"nowrap"},"& .MuiTableCell-head":{backgroundColor:"action.hover",py:.25,px:1},borderCollapse:"collapse"},children:[e.jsx(r.TableHead,{sx:{display:"none"},children:e.jsx(r.TableRow,{children:B.map(j=>e.jsx(r.TableCell,{width:j.width,align:j.align||"left",sx:{fontWeight:"bold"},children:j.renderHeader?j.renderHeader():j.headerName},j.field))})}),e.jsx(r.TableBody,{children:n.map((j,C,w)=>e.jsx(r.TableRow,{sx:{borderBottom:C<w.length-1?"1px solid":"none",borderColor:"divider","&:hover":{backgroundColor:"action.hover"}},children:B.map(N=>e.jsx(r.TableCell,{width:N.width,align:N.align||"left",sx:{borderBottom:"none"},children:N.renderCell({row:j,index:C,onChange:E=>S(C,E)})},`${C}-${N.field}`))},C))})]})}):e.jsx(U.default,{style:{fontSize:12,height:x},children:u("maker.properties.arrayEmpty")}),e.jsx(r.Button,{fullWidth:!0,size:"small",variant:"outlined",disabled:l,startIcon:e.jsx(Ke.default,{}),onClick:g,children:u("maker.properties.addArrayItem")})]}):e.jsxs(r.Stack,{sx:{width:"100%",gap:1},children:[t&&e.jsx(r.FormLabel,{children:t}),e.jsx(r.Box,{sx:{border:1,borderColor:"divider",borderRadius:1,minHeight:150},children:e.jsx(ee.CodeEditor,{keyId:d.id,locale:a,language:"json",value:JSON.stringify(n,null,2),onChange:j=>p(j||""),fullScreenOptions:{enableEscExit:!0,targetContainer:()=>document.getElementById("parameters-config-dialog")||null}},d.id)})]})}function ct({ref:t,showMarkdown:s,markdown:i,onMarkdownChange:l,showUploader:f,value:x,meta:d,onChange:b,...m}){const[u,a]=v.useState("");v.useEffect(()=>{a(x||"")},[x,a]);const c=async()=>{if(u!==x){const n=R.getImageAbsoluteUrl(u);if(!n){b(u,void 0);return}const h=await V.getImageSize(n).catch(()=>V.getVideoSize(n)).catch(()=>{});b(u,{...h,filename:u})}};te.useDebounce(()=>{u!==x&&b(u)},300,[u]),v.useImperativeHandle(t,()=>({submit:c}));const o={};return f&&(o.InputProps={sx:{pr:0},endAdornment:e.jsx(r.InputAdornment,{position:"end",sx:{mx:.5},children:e.jsx(V.UploaderButton,{onChange:async({response:n})=>{const h=n?.data?.filename,g=R.getImageAbsoluteUrl(h)||"";let p={};g&&(p=await V.getImageSize(g).catch(()=>V.getVideoSize(g)).catch(()=>{})),b(h,{...p,filename:h})}})})}),e.jsx(r.TextField,{size:"small",fullWidth:!0,...m,label:e.jsxs(r.Stack,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[m.label,s&&e.jsxs(e.Fragment,{children:[" (",e.jsx(r.FormControlLabel,{checked:i,label:e.jsx(r.Box,{component:Se.Icon,icon:"tabler:markdown",sx:{verticalAlign:"middle"}}),labelPlacement:"start",control:e.jsx(r.Switch,{size:"small"}),sx:{ml:.25,pr:1},onChange:(n,h)=>l?.(h)}),")"]})]}),value:u,onChange:n=>a(n.target.value),...o,onKeyDown:n=>{n.keyCode!==229&&n.key==="Enter"&&c()},slotProps:{inputLabel:{shrink:!0,...m.InputLabelProps}}})}function ut({value:t,onChange:s,...i}){const l=v.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(ct,{...i,value:t,onChange:s,InputProps:{endAdornment:e.jsx(r.InputAdornment,{position:"end",children:e.jsx(se.ColorItem,{color:t??"",style:{width:"1.5rem",height:"1.5rem",padding:0},onClick:()=>{l.current?.open({value:t??""})}})})}}),e.jsx(se.ConfigColorDialog,{ref:l,onSave:({value:f},x)=>{s(f),x()}})]})}function dt({label:t,value:s,onChange:i,property:l,component:f,defaultLocale:x,allComponents:d,PropertyValueField:b,onUpload:m}){const{locale:u}=O.useLocaleContext(),a=v.useRef(null);if(!D.default(l.subProperties)){const o=z.default(Object.values(l.subProperties||{}),"index").filter(n=>n.data.visible!==!1&&n.data.key);return e.jsxs(r.Stack,{sx:{width:"100%"},children:[e.jsx(r.FormLabel,{sx:{px:.25,py:.5},children:t}),e.jsx(r.Box,{children:e.jsx(r.Box,{sx:{position:"relative"},children:o.map((n,h)=>{const{data:g}=n,p=g.key??g.id,y=h===o.length-1;let P=null;try{s&&typeof s=="object"?P=s[p]:typeof s=="string"&&(P=(l.type==="yaml"?G.parse(s||""):JSON.parse(s||"{}"))[p])}catch{}P==null&&(g.locales&&u&&g.locales[u]?P=g.locales[u].defaultValue:g.locales&&x&&g.locales[x]&&(P=g.locales[x].defaultValue));const I=k=>{try{let B={};if(typeof s=="string")try{B=l.type==="yaml"?G.parse(s||""):JSON.parse(s||"{}")}catch{}else typeof s=="object"&&s!==null&&(B={...s});ce.default(B,p,k);const j=R.transformValue(B,l.type);i?.(j)}catch(B){console.error("Error updating property:",B)}},S=8;return e.jsxs(r.Box,{sx:{mb:y?0:1,display:"flex",flexDirection:"row"},children:[e.jsxs(r.Box,{sx:{position:"relative",width:24,flexShrink:0},children:[e.jsx(r.Box,{sx:{position:"absolute",left:S,top:0,height:16,width:0,borderLeft:"1px dashed",borderColor:"divider"}}),e.jsx(r.Box,{sx:{position:"absolute",left:S,top:16,width:12,height:0,borderTop:"1px dashed",borderColor:"divider"}}),!y&&e.jsx(r.Box,{sx:{position:"absolute",left:S,top:16,bottom:-8,width:0,borderLeft:"1px dashed",borderColor:"divider"}})]}),e.jsx(r.Box,{sx:{flexGrow:1},children:e.jsx(b,{component:f,property:g,value:P,onChange:I,size:"small",fullWidth:!0,defaultLocale:x,allComponents:d})})]},g.id)})})})]})}return e.jsx(r.Stack,{sx:{width:"100%",gap:2},children:e.jsxs(r.Stack,{sx:{width:"100%",position:"relative",pt:1,pb:"6px",px:"1px",minHeight:50,".monaco-editor,.overflow-guard":{borderRadius:1}},children:[e.jsx(r.FormLabel,{sx:{position:"absolute",left:0,top:0,transform:"translate(0px, -7px) scale(0.75)"},children:t}),e.jsx(ee.CodeEditor,{keyId:l.id,locale:u,language:l.type==="yaml"?"yaml":"json",value:typeof s=="string"?s:"",onChange:o=>{i?.(o)},onUpload:o=>{a.current=o,m&&m(o)},fullScreenOptions:{enableEscExit:!0,targetContainer:()=>document.getElementById("parameters-config-dialog")||null}},l.id),e.jsx(r.Box,{component:"fieldset",sx:{pointerEvents:"none",position:"absolute",left:0,top:-5,width:"100%",height:"100%",border:1,borderColor:"rgba(0, 0, 0, 0.23)",borderRadius:1,px:1,py:0},children:e.jsx(r.Box,{component:"legend",sx:{fontSize:"0.75em"},children:e.jsx(r.Box,{component:"span",sx:{opacity:0},children:t})})})]})})}const pt=["string","multiline","json","yaml","url","component","custom","array"];function ne(t){return t.type?!pt.includes(t.type):!1}function ue({disabled:t,list:s,renderItem:i,...l}){const f=v.useRef(null),x=v.useId(),d=le.useUpdate(),b=z.default(Object.entries(s),n=>n[1].index).map(n=>n[0]),m=v.useRef(b),u=v.useCallback(n=>{m.current=n,d()},[d]),a=v.useCallback(({index:n},{index:h})=>{const g=[...m.current];g.splice(h,0,...g.splice(n,1)),u(g)},[u]);v.useEffect(()=>{u(b)},[b.join("-")]);const[{isOver:c},o]=$.useDrop({accept:x,collect:n=>({isOver:n.isOver()}),canDrop:()=>!t,drop:()=>{const n=()=>{m.current.forEach((g,p)=>{const y=s[g];y&&(y.index=p)})},h=L.getYjsValue(s)?.doc;h?h.transact(()=>{n()}):n()}});return v.useEffect(()=>{c||u(b)},[c]),o(f),e.jsx(r.Box,{...l,ref:f,className:Me.cx(c&&"isDragging"),children:m.current.map((n,h)=>e.jsx(xt,{type:x,disabled:t,id:n,index:h,itemIndex:g=>m.current.indexOf(g),move:a,children:g=>{const p=s[n];return p?i(p.data,h,g):null}},n))})}function xt({disabled:t,id:s,index:i,type:l,children:f,itemIndex:x,move:d}){const b=v.useRef(void 0),[{isDragging:m},u,a]=$.useDrag({type:l,item:()=>({id:s}),canDrag:()=>!t,collect:o=>({isDragging:o.isDragging()})}),[,c]=$.useDrop({accept:l,canDrop:()=>!t,hover(o,n){if(!b.current)return;const h=x(o.id),g=i;if(h===g)return;const p=b.current?.getBoundingClientRect(),y=(p.bottom-p.top)/2,I=n.getClientOffset().y-p.top;h<g&&I<y||h>g&&I>y||d({id:o.id,index:h},{id:s,index:i})}});return typeof f=="function"?f({isDragging:m,drag:u,drop:o=>(b.current=o,c(o)),preview:a}):(u(c(a(b))),e.jsx(r.Box,{ref:b,children:f}))}function mt({drop:t,preview:s,drag:i,disabled:l,isDragging:f,children:x,onDelete:d,onVisibilityChange:b,visible:m=!0,actions:u,alwaysShowActions:a=!1}){const{t:c}=O.useLocaleContext();return e.jsx(r.Box,{ref:t,sx:{":hover .hover-visible":{maxWidth:"100%"},opacity:m?1:.5},children:e.jsxs(r.Box,{sx:{position:"relative"},children:[e.jsx(r.Box,{ref:s,sx:{flex:1,borderRadius:.5,bgcolor:f?"action.hover":"background.paper",opacity:.9999},children:x}),!l&&e.jsx(r.Box,{className:a?"":"hover-visible",sx:{maxWidth:a?"100%":0,overflow:"hidden",position:"absolute",right:2,top:2,transition:"max-width 0.3s ease-in-out"},children:e.jsxs(r.Stack,{direction:"row",sx:{bgcolor:o=>r.alpha(o.palette.grey[200],.9),borderRadius:1,p:.5,[`.${r.buttonClasses.root}`]:{minWidth:24,width:24,height:24,p:0}},children:[u,b&&e.jsx(r.Tooltip,{title:c(m?"hideParameter":"showParameter"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:()=>b(!m),children:m?e.jsx(_.VisibilityOffRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}}):e.jsx(_.VisibilityRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),d&&e.jsx(r.Tooltip,{title:c("delete"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:d,children:e.jsx(_.DeleteOutlineRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),e.jsx(r.Tooltip,{title:c("dragSort"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{ref:i,children:e.jsx(_.DragIndicatorRounded,{sx:{color:"grey.500"}})})})]})})]})})}function ft(t){const s=["string","json","array","url","multiline"],i=["style","fontSize","color","content","type"];return!!(s.includes(t.type||"")&&!i.includes(t.key||""))}function ht(t,s,i){return t.locales&&t.locales[s]&&t.locales[s].name?t.locales[s].name:i&&t.locales&&t.locales[i]&&t.locales[i].name?t.locales[i].name:t.key?t.key:t.id}const de=(t,s,i,l)=>{const f={};return z.default(Object.entries(t),([,d])=>d.index).forEach(([d,b])=>{const m=b.data;if(!m)return;const u=m.key||m.id,a=i?ht(m,i,l||""):u,c=s?.[m.id],o={key:u,isNeedGenerate:c?.isNeedGenerate??ft(m),describe:c?.describe??"",displayName:a};m.subProperties&&!D.default(m.subProperties)&&(o.subProperties=de(m.subProperties,c?.subProperties,i,l)),f[m.id]=o}),f};function bt({open:t,onClose:s,onConfirm:i,component:l,initialConfig:f,locale:x,defaultLocale:d,title:b,loading:m=!1}){const{t:u}=O.useLocaleContext(),[a,c]=v.useState(null);v.useEffect(()=>{if(t&&l){const p={properties:{}};if(l.properties){const y=f?.properties;p.properties=de(l.properties,y,x,d)}c(p)}},[t,l,f,x,d]);const o=()=>{s()},n=()=>{a&&(i(a),s())},h=(p,y,P)=>{if(!a||!p.length)return;const I=JSON.parse(JSON.stringify(a));let S=I.properties,k=null;for(let j=0;j<p.length-1;j++){const C=p[j];if(!C||!S[C])return;k=S;const w=S[C];w.subProperties||(w.subProperties={}),S=w.subProperties}const B=p[p.length-1];if(B){if("isNeedGenerate"in P){const j=P.isNeedGenerate,C={...y,...P};if(y.subProperties&&!D.default(y.subProperties)){const w=(N,E)=>{const q={};return Object.entries(N).forEach(([ge,M])=>{const Y={...M};E!==null&&(Y.isNeedGenerate=E),M.subProperties&&!D.default(M.subProperties)&&(Y.subProperties=w(M.subProperties,E!==null?E:null)),q[ge]=Y}),q};C.subProperties=w(y.subProperties,j===!1?!1:null)}if(p.length===1)I.properties[B]=C;else if(k&&p.length>=2){const w=p[p.length-2];w&&k[w]&&(k[w].subProperties||(k[w].subProperties={}),k[w].subProperties[B]=C)}}else if(p.length===1)I.properties[B]={...y,...P};else if(k&&p.length>=2){const j=p[p.length-2];j&&k[j]&&k[j].subProperties&&(k[j].subProperties[B]={...y,...P})}c(I)}},g=(p,y=[],P=!0)=>{if(!p||D.default(p))return e.jsx(U.default,{children:u("maker.properties.noProperties")});const I=z.default(Object.entries(p),([,S])=>S.displayName);return e.jsx(r.Stack,{spacing:1.5,children:I.map(([S,k],B)=>{const j=[...y,S],C=B===I.length-1,w=k.subProperties&&!D.default(k.subProperties),N=k.displayName||S,E=!P;return e.jsx(r.Box,{sx:{position:"relative"},children:e.jsxs(r.Stack,{direction:"row",children:[y.length>0&&e.jsxs(r.Box,{sx:{position:"relative",width:24,flexShrink:0},children:[e.jsx(r.Box,{sx:{position:"absolute",left:8,top:0,height:16,width:0,borderLeft:"1px dashed",borderColor:"divider"}}),e.jsx(r.Box,{sx:{position:"absolute",left:8,top:16,width:12,height:0,borderTop:"1px dashed",borderColor:"divider"}}),!C&&e.jsx(r.Box,{sx:{position:"absolute",left:8,top:16,bottom:-12,width:0,borderLeft:"1px dashed",borderColor:"divider"}})]}),e.jsxs(r.Stack,{spacing:1.5,sx:{flexGrow:1},children:[e.jsxs(r.Stack,{direction:{xs:"column",md:"row"},spacing:1.5,sx:{alignItems:{xs:"flex-start",md:"center"},width:"100%"},children:[e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:k.isNeedGenerate,disabled:E,onChange:q=>{h(j,k,{isNeedGenerate:q.target.checked})}}),label:N,sx:{minWidth:"180px",maxWidth:"280px",mr:2,"& .MuiFormControlLabel-label":{wordBreak:"break-word"}}}),e.jsx(r.TextField,{size:"small",fullWidth:!0,label:u("maker.properties.llmPropertyDescribe"),value:k.describe,onChange:q=>{h(j,k,{describe:q.target.value})},disabled:!k.isNeedGenerate})]}),w&&e.jsx(r.Box,{sx:{ml:3},children:g(k.subProperties,j,k.isNeedGenerate&&P)})]})]})},S)})})};return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"lg",fullWidth:!0,children:[e.jsx(r.DialogTitle,{children:b||u("maker.properties.llmConfigTitle")}),e.jsx(r.DialogContent,{children:e.jsx(r.Box,{sx:{my:3},children:m?e.jsx(r.Typography,{children:u("maker.properties.loading")}):l?a?e.jsxs(r.Stack,{spacing:3,children:[e.jsx(r.Typography,{variant:"subtitle2",children:u("maker.properties.llmConfigInstructions")}),g(a.properties)]}):e.jsx(r.Typography,{children:u("maker.properties.loading")}):e.jsx(r.Typography,{color:"error",children:u("maker.properties.componentNotFound")})})}),e.jsxs(r.DialogActions,{children:[e.jsx(r.Button,{onClick:o,children:u("common.cancel")}),e.jsx(r.Button,{variant:"contained",onClick:n,disabled:!a||m,children:u("common.confirm")})]})]})}function gt({label:t,value:s,onChange:i}){const[l,f]=v.useState(!1);return e.jsxs(r.Stack,{sx:{gap:1},children:[e.jsx(r.TextField,{label:t,size:"small",value:s,onChange:x=>i?.(x.target.value),slotProps:{input:{sx:{pr:0},endAdornment:e.jsx(r.InputAdornment,{position:"end",children:e.jsx(V.UploaderButton,{onChange:({response:x})=>{const d=x?.data?.filename;d&&i?.(d)}})})}}}),s&&e.jsx(r.Box,{component:"img",src:R.getImageAbsoluteUrl(s),alt:t,onClick:()=>f(!0),sx:{maxWidth:100,maxHeight:100,width:"100%",objectFit:"contain",borderRadius:1,cursor:"pointer"}}),e.jsx(r.Dialog,{open:l,onClose:()=>f(!1),children:e.jsx(r.Box,{component:"img",sx:{objectFit:"contain"},src:R.getImageAbsoluteUrl(s),alt:t})})]})}function X(t,s=""){return nt.default(t,(i,l,f)=>{const x=s?`${s}.${f}`:f;return et.default(l)?Ge.default(i,X(l,x)):i[x]=l,i},{})}const jt=[{value:"string",label:"Text"},{value:"multiline",label:"Text (Multiline)"},{value:"number",label:"Number"},{value:"decimal",label:"Decimal"},{value:"boolean",label:"Boolean"},{value:"color",label:"Color"},{value:"url",label:"URL (Upload)"},{value:"json",label:"JSON"},{value:"yaml",label:"YAML"},{value:"array",label:"Array"},{value:"component",label:"Component"},{value:"custom",label:"Custom (Render by a Component)"}];function W(t,s,i){return!t||!i?!1:Object.values(t).some(({data:l})=>l.id!==s&&l.key===i)}function Z(t,s){return!t||!s?!1:t[s]?.data.visible??!0}function yt({componentId:t}){const{state:{components:s}}=R.useStore(),l=s[t]?.data;return l?e.jsx(r.Stack,{sx:{maxHeight:"100%",overflow:"auto"},children:e.jsx(r.Box,{sx:{p:2},children:e.jsx(Ue.ErrorBoundary,{FallbackComponent:R.ErrorView,resetKeys:[t],children:e.jsx(Ct,{value:l,componentId:t})})})}):null}function Ct({value:t,componentId:s}){const{t:i}=O.useLocaleContext(),{localState:{currentLocale:l,customComponentPreviewerProperties:f},state:{config:{defaultLocale:x}},localActions:{setCustomComponentPreviewerProperties:d}}=R.useStore(),b=L.getYjsValue(t).doc,m=R.useAllComponents(),u=v.useMemo(()=>f?.[s]??{},[s,f]),a=le.useReactive({componentId:s,propertiesValue:{...u}});return v.useEffect(()=>{a.componentId!==s&&(a.componentId=s,a.propertiesValue={...u})},[s,u,a]),v.useEffect(()=>{if(a.componentId!==s)return;const c=Object.fromEntries(Object.values(t.properties??{}).map(({data:o})=>[o.id,{value:a.propertiesValue[o.id]?.value??Re.parsePropertyValue(o,o.locales?.[l]?.defaultValue??o.locales?.[x]?.defaultValue,{locale:l,defaultLocale:x})}]));d(s,c)},[JSON.stringify(a.propertiesValue),s,a.componentId]),e.jsx(r.Stack,{sx:{height:"100%"},children:e.jsxs(r.Stack,{sx:{gap:2},children:[e.jsx(pe,{config:t}),e.jsx(me,{config:t,currentLocale:l,defaultLocale:x,allComponents:m,onUpdateConfig:c=>{b.transact(()=>{c(t)})}}),e.jsxs(r.Stack,{direction:"row",sx:{gap:2,justifyContent:"space-between",alignItems:"center"},children:[e.jsx(r.Typography,{variant:"subtitle1",children:i("renderer")}),e.jsxs(r.TextField,{hiddenLabel:!0,size:"small",select:!0,value:t.renderer?.type||"react-component",onChange:c=>{b.transact(()=>{const o=c.target.value;t.renderer??={type:o},t.renderer.type=o})},slotProps:{select:{autoWidth:!0}},children:[e.jsx(r.MenuItem,{value:"react-component",children:"React Component"}),e.jsx(r.MenuItem,{value:"component",children:"Custom Component"})]})]}),t.renderer?.type==="component"&&e.jsx(Tt,{value:t}),t.renderer?.type==="react-component"&&e.jsx(It,{value:t}),e.jsx(re,{config:t,currentLocale:l,defaultLocale:x,allComponents:m,propertiesValue:a.propertiesValue,onChange:({value:c,id:o,path:n})=>{const h=[...n,"data"];if(!Qe.default(t,h)){Q.default.warning(i("cannotFindPropertyKey",{key:h.join(".")}));return}a.propertiesValue[o]={value:c.value}}})]})})}function pe({config:t}){const{t:s}=O.useLocaleContext();return e.jsx(V.UploaderProvider,{children:e.jsxs(r.Stack,{sx:{gap:2},children:[e.jsx(r.Typography,{variant:"subtitle1",children:s("basicInfo")}),e.jsx(r.TextField,{label:s("name"),size:"small",value:t.name||"",onChange:i=>t.name=i.target.value}),e.jsx(r.TextField,{label:s("description"),size:"small",multiline:!0,minRows:2,maxRows:10,value:t.description||"",onChange:i=>t.description=i.target.value,slotProps:{input:{endAdornment:e.jsx(r.InputAdornment,{position:"end",sx:{mt:-1.5},children:e.jsx(Bt,{config:t})})},htmlInput:{maxLength:200}}}),e.jsx(r.Autocomplete,{size:"small",options:[],multiple:!0,freeSolo:!0,value:t.tags??[],onChange:(i,l)=>t.tags=l,renderInput:i=>e.jsx(r.TextField,{label:s("tags"),...i})}),e.jsx(gt,{label:s("previewImage"),value:t.previewImage||"",onChange:i=>t.previewImage=i})]})})}function xe({data:t,params:s,visible:i,config:l,currentLocale:f,defaultLocale:x,allComponents:d,onUpdateConfig:b}){const{t:m}=O.useLocaleContext(),u=v.useMemo(()=>t.type==="json"||t.type==="yaml"||t.type==="array"?St:F,[t.type]);return e.jsx(mt,{preview:s.preview,drop:s.drop,drag:s.drag,isDragging:s.isDragging,onDelete:()=>{b(a=>{if(a.properties){const o=Object.entries(a.properties).sort(([,h],[,g])=>h.index-g.index);delete a.properties[t.id],o.filter(([h])=>h!==t.id).forEach(([,h],g)=>{h.index=g})}})},visible:i,onVisibilityChange:a=>{b(c=>{const o=c.properties[t.id].data;o.visible=a})},alwaysShowActions:!0,children:e.jsxs(r.Stack,{direction:"column",sx:{gap:2},children:[e.jsx(r.TextField,{label:m("key"),size:"small",required:!0,sx:{width:"calc(100% - 80px - 8px)",flex:1,"& .MuiOutlinedInput-root":{borderColor:t.key?W(l.properties,t.id,t.key)?"warning.main":void 0:"error.main"},"& .MuiFormLabel-root":{color:t.key?W(l.properties,t.id,t.key)?"warning.main":"text.secondary":"error.main"},"& .MuiFormLabel-root.Mui-focused":{color:t.key?W(l.properties,t.id,t.key)?"warning.main":"primary.main":"error.main"}},value:t.key||"",onChange:a=>{b(c=>{const o=c.properties[t.id].data;o.key=a.target.value.trim()})},slotProps:{input:{endAdornment:!t.key||t.key&&W(l.properties,t.id,t.key)?e.jsx(r.InputAdornment,{position:"end",sx:{width:16,ml:0},children:e.jsx(r.Tooltip,{title:t.key?m("duplicateKey"):m("requiredKey"),children:e.jsx(_.InfoRounded,{sx:{color:t.key?"warning.main":"error.main",fontSize:16}})})}):null}}}),e.jsxs(r.Stack,{direction:"row",sx:{gap:1},children:[e.jsx(r.TextField,{label:m("label"),size:"small",sx:{flex:1},value:(t.locales?.[f]?.name??t.locales?.[x]?.name)||"",onChange:a=>{b(c=>{const o=c.properties[t.id].data;o.locales??={},o.locales[f]??={},o.locales[f].name=a.target.value})}}),e.jsx(r.TextField,{label:m("type"),size:"small",select:!0,sx:{flex:1},value:t.type==="string"&&t.multiline?"multiline":t.type||"string",onChange:a=>{b(c=>{const o=c.properties[t.id].data;if(o.locales)for(const h of Object.keys(o.locales))o.locales[h].defaultValue=void 0;const n=a.target.value;n==="multiline"?(o.type="string",o.multiline=!0):(typeof o.multiline<"u"&&delete o.multiline,o.type=n)})},children:jt.map(a=>e.jsx(r.MenuItem,{value:a.value,children:a.label},a.value))})]}),e.jsxs(r.Stack,{direction:"row",sx:{gap:1},children:[e.jsx(u,{allComponents:d,defaultLocale:x,component:l,property:t,label:m("defaultValue"),size:"small",fullWidth:!0,value:t.locales?.[f]?.defaultValue,onChange:(a,c)=>{b(o=>{const n=o.properties[t.id].data;if(c?.forceUpdateProperty){const h=X(n),g=X(a);Object.keys(g).forEach(p=>{h[p]||ce.default(n,p,g[p])})}else n.locales??={},n.locales[f]??={},n.locales[f].defaultValue=a})}}),t.type==="custom"?e.jsx(r.Box,{children:e.jsx(kt,{property:t,allComponents:d})}):null]})]})})}function vt(t,s){const[i,l]=v.useState(0);return v.useEffect(()=>{const x=setTimeout(()=>{if(t.current){let d=t.current.parentElement,b=0;for(;d;)d.classList.contains("property-container")&&b++,d=d.parentElement;l(b)}},100);return()=>clearTimeout(x)},[t,s]),i}function me({config:t,currentLocale:s,defaultLocale:i,allComponents:l,onUpdateConfig:f,useI18nEditor:x=!0}){const{t:d}=O.useLocaleContext(),b=A.usePopupState({variant:"dialog"}),m=t.properties&&z.default(Object.values(t.properties),"index");return e.jsx(V.UploaderProvider,{children:e.jsxs(r.Stack,{sx:{gap:2},children:[e.jsxs(r.Stack,{direction:"row",sx:{gap:1,alignItems:"center",justifyContent:"space-between"},children:[e.jsx(r.Typography,{variant:"subtitle1",children:d("properties")}),e.jsx(r.Box,{sx:{flex:1}}),x&&e.jsx(r.Button,{sx:{minWidth:32,minHeight:32,p:0},...A.bindTrigger(b),children:e.jsx(_.TranslateRounded,{fontSize:"small"})})]}),t.properties&&Object.keys(t.properties).length>0?e.jsx(ue,{component:r.Stack,gap:2,list:t.properties,renderItem:(u,a,c)=>{const o=Z(t.properties,u.id);return e.jsx(r.Paper,{elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:o?"1px solid":"1px dashed",borderColor:"divider"},children:e.jsx(r.Stack,{sx:{gap:2},children:e.jsx(xe,{data:u,params:c,visible:o,config:t,currentLocale:s,defaultLocale:i,allComponents:l,onUpdateConfig:f})})},u.id)}}):e.jsx(U.default,{style:{fontSize:12},children:d("maker.properties.noProperties")}),e.jsx(r.Button,{fullWidth:!0,variant:"outlined",className:"ignore-style-override",onClick:()=>{f(u=>{const a=ae.nextId();u.properties??={},u.properties[a]??={index:m?.length||0,data:{id:a}}})},startIcon:e.jsx(_.AddRounded,{}),children:d("addObject",{object:d("property")})}),x&&e.jsx(fe,{...A.bindDialog(b),component:t})]})})}function kt({property:t,allComponents:s}){const i=A.usePopupState({variant:"popper"});return e.jsxs(e.Fragment,{children:[e.jsx(r.Button,{sx:{minWidth:0},...A.bindTrigger(i),children:e.jsx(_.SettingsRounded,{fontSize:"small"})}),e.jsx(r.Popper,{...A.bindPopper(i),children:e.jsx(ie.ClickAwayListener,{onClickAway:i.close,children:e.jsx(r.Paper,{children:e.jsx(r.Box,{sx:{width:500,p:2},children:e.jsx(H,{value:t.componentId,onChange:(l,f)=>t.componentId=f,allComponents:s})})})})})]})}function Pt({value:t,valueImmutable:s,onChange:i,defaultLocale:l,allComponents:f}){const[x,d]=v.useState(!1),{t:b,locale:m}=O.useLocaleContext(),u=typeof t?.componentId=="string"?f[t.componentId]?.data:void 0;return u?e.jsxs(r.Box,{sx:{width:"100%",position:"relative"},children:[e.jsx(r.IconButton,{sx:{minWidth:0},disabled:!u,size:"small",onClick:()=>d(!x),color:x?"primary":"default",children:e.jsx(_.SettingsRounded,{fontSize:"small"})}),x&&e.jsx(r.Collapse,{in:x,timeout:"auto",unmountOnExit:!0,sx:{width:"100%",zIndex:10},children:e.jsxs(r.Paper,{elevation:1,sx:{mt:1,p:2,borderRadius:1,border:"1px solid",borderColor:"divider",width:"100%"},children:[e.jsx(r.Box,{sx:{width:"100%",mb:2},children:e.jsx(re,{config:u,currentLocale:m,defaultLocale:l,allComponents:f,propertiesValue:t?.properties,onChange:({id:a,value:c})=>{const o=$e.default(c.value),n=JSON.parse(JSON.stringify(t));n?.componentId&&(s?i?.({...n,properties:{...n.properties,[a]:{value:o}}}):(n.properties=n.properties??{},n.properties[a]={value:o},i?.(n)))}})}),e.jsx(r.Button,{size:"small",onClick:()=>d(!1),sx:{mt:1},children:b("close")})]})})]}):null}function fe({type:t="properties",component:s,...i}){const{t:l}=O.useLocaleContext(),{state:{components:f,supportedLocales:x,config:{defaultLocale:d}}}=R.useStore(),b=R.useAllComponents(),m=L.getYjsValue(s).doc,u=t==="properties"?s.properties:t==="parameters"&&s.renderer?.type==="component"?f[s.renderer.componentId]?.data.properties:void 0,a=s.renderer?.type==="component"?s:void 0;return e.jsxs(r.Dialog,{...i,fullWidth:!0,maxWidth:"lg",children:[e.jsx(r.DialogTitle,{children:l("i18nEditorTitle")}),e.jsx(r.DialogContent,{children:u&&e.jsx(r.Stack,{children:e.jsxs(r.Table,{stickyHeader:!0,sx:{td:{verticalAlign:"top"}},children:[e.jsx(r.TableHead,{children:e.jsx(r.TableRow,{children:x.map(({locale:c,name:o})=>e.jsx(r.TableCell,{children:e.jsxs(r.Typography,{sx:{color:"text.primary"},children:[o,d===c&&e.jsx(_.StarRounded,{sx:{fontSize:12}})]})},c))})}),e.jsx(r.TableBody,{children:z.default(Object.values(u),"index").map(({data:c})=>e.jsx(r.TableRow,{children:x.map(({locale:o})=>e.jsx(r.TableCell,{children:e.jsx(r.Stack,{sx:{gap:1},children:t==="properties"?e.jsxs(e.Fragment,{children:[e.jsx(r.TextField,{size:"small",label:"Key",value:c.key||"",onChange:n=>{m.transact(()=>{c.key=n.target.value.trim()})}}),e.jsx(r.TextField,{size:"small",label:l("label"),value:(c.locales?.[o]?.name??c.locales?.[d]?.name)||"",onChange:n=>{m.transact(()=>{c.locales??={},c.locales[o]??={},c.locales[o].name=n.target.value})}}),e.jsx(r.Box,{children:e.jsx(F,{allComponents:b,defaultLocale:d,component:s,property:c,size:"small",fullWidth:!0,label:"Default Value",valueImmutable:J.default(c.locales?.[o]?.defaultValue),value:c.locales?.[o]?.defaultValue??c.locales?.[d]?.defaultValue,onChange:n=>{m.transact(()=>{c.locales??={},c.locales[o]??={},c.locales[o].defaultValue=n})}})})]}):t==="parameters"&&a?e.jsx(r.Box,{children:e.jsx(F,{allComponents:b,defaultLocale:d,component:s,property:c,size:"small",fullWidth:!0,valueImmutable:J.default(a.renderer.properties?.[c.id]?.locales?.[o]?.value),value:a.renderer.properties?.[c.id]?.locales?.[o]?.value??a.renderer.properties?.[c.id]?.locales?.[d]?.value??c.locales?.[o]?.defaultValue??c.locales?.[d]?.defaultValue,onChange:n=>{m.transact(()=>{a.renderer.properties??={},a.renderer.properties[c.id]??={},a.renderer.properties[c.id].locales??={},a.renderer.properties[c.id].locales[o]??={},a.renderer.properties[c.id].locales[o].value=n})}})}):null},c.id)},o))},c.id))})]})})}),e.jsx(r.DialogActions,{children:e.jsx(r.Button,{onClick:c=>i.onClose?.(c,"escapeKeyDown"),children:l("close")})})]})}const oe=(t,s)=>i=>{const l=[i.palette.info.main,i.palette.primary.main,i.palette.secondary.main,i.palette.success.main,i.palette.warning.main],f=Math.min(l.length-1,t),x=l[f],d=r.alpha(x,.5),b=r.alpha(x,1);return{borderColor:`${d} !important`,borderLeft:"3px solid !important",borderLeftColor:d,color:b,...s}};function St({property:t,onChange:s,defaultLocale:i,allComponents:l}){const{t:f,locale:x}=O.useLocaleContext(),d=v.useRef(null),b=vt(d,t),m=v.useCallback(()=>{if(!(t.type!=="json"&&t.type!=="yaml"&&t.type!=="array")&&t.subProperties)try{let u={};z.default(Object.values(t.subProperties),"index").filter(o=>o.data.visible!==!1&&o.data.key).forEach(({data:o})=>{if(!o.key)return;let n=o.locales?.[x]?.defaultValue??o.locales?.[i]?.defaultValue;if(o.type==="number")n=Number(n);else if(o.type==="boolean")n=n===!0||n==="true";else if((o.type==="json"||o.type==="yaml")&&typeof n=="string")try{o.type==="json"?n=JSON.parse(n):n=G.parse(n)}catch(h){console.error("Error parsing nested value",n,h),n={}}u[o.key]=n}),t.type==="array"&&!Array.isArray(u)&&(u=D.default(u)?[]:[u]);const c=R.transformValue(u,t.type);s?.(c)}catch(u){console.error("Error converting structure to text:",u)}},[t,x,i,s]);return t.type!=="json"&&t.type!=="yaml"&&t.type!=="array"?null:e.jsxs(r.Stack,{direction:"column",ref:d,sx:{gap:1.5,width:"100%"},children:[e.jsx(r.Divider,{sx:{mt:-1},children:e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary"},children:f("maker.properties.subProperties")})}),t.subProperties&&Object.keys(t.subProperties).length>0?e.jsx(ue,{component:r.Stack,gap:2,list:t.subProperties,renderItem:(u,a,c)=>{const o=u.visible!==!1;return e.jsx(r.Paper,{elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:o?"1px solid":"1px dashed","&":oe(b)},children:e.jsx(r.Stack,{sx:{gap:2},children:e.jsx(xe,{data:u,params:c,visible:o,config:{properties:t.subProperties},currentLocale:x,defaultLocale:i,allComponents:l,onUpdateConfig:n=>{try{const h={properties:t.subProperties||{}};n(h);const g={...t,subProperties:h.properties};s?.(g,{forceUpdateProperty:!0}),m()}catch(h){console.error("Error updating property:",h)}}})})},u.id)}}):e.jsx(U.default,{style:{fontSize:12,height:100},children:f("maker.properties.noSubProperties")}),e.jsx(r.Button,{fullWidth:!0,variant:"outlined",className:"ignore-style-override",size:"small",startIcon:e.jsx(_.AddRounded,{}),onClick:()=>{try{const u=t.subProperties||{},a=ae.nextId(),o={index:Object.values(u).length,data:{id:a,key:"",type:"string",visible:!0,locales:{[x]:{name:"",defaultValue:""}},subProperties:{}}},n={...t,subProperties:{...u,[a]:o}};s?.(n,{forceUpdateProperty:!0}),m()}catch(u){console.error("Error adding property:",u)}},sx:{"&":oe(b,{})},children:f("maker.properties.addSubProperty")})]})}function F({component:t,property:s,value:i,onChange:l,valueImmutable:f,defaultLocale:x,allComponents:d,...b}){const{locale:m}=O.useLocaleContext(),u=V.useUploader(),a=v.useRef(null),c=()=>{const n=u?.current?.getUploader();n?.open(),a.current&&n.onceUploadSuccess(({response:h})=>{let g=h?.data?.filename||"";g&&(g=`mediakit://${g}`,i&&!i.includes("mediakit://")&&(g+=" # please use < import { getMediaKitAbsoluteUrl } from '@blocklet/pages-kit/builtin/utils' > to get the full address")),a.current?.(g)})},o=b.label??(s.locales?.[m]?.name||s.locales?.[x]?.name||s.key||s.id);if(s.type==="number")return e.jsx(wt,{...b,label:o,NumberProps:{value:["number","string"].includes(typeof i)?i:null,onChange:(n,h)=>l?.(h)}});if(s.type==="decimal")return e.jsx(r.TextField,{...b,label:o,type:"text",value:i??"",onChange:n=>{const h=n.target.value;if(h===""||h==="-"){l?.(h);return}if(/^-?(?!.*\..*\.)[0-9]*(\.[0-9]{0,9})?$/.test(h)){let p=h;/^-?[1-9]+[0-9]*(\.[0-9]{1,9})?$/.test(p)&&(p=Number(p)),l?.(p)}}});if(s.type==="boolean")return e.jsx(r.FormControlLabel,{label:o,labelPlacement:"start",control:e.jsx(r.Switch,{checked:i===!0,onChange:(n,h)=>l?.(h)})});if(s.type==="color")return e.jsx(ut,{label:o,value:i,onChange:n=>{l?.(n)}});if(s.type==="json"||s.type==="yaml")return e.jsx(dt,{label:o,value:i,onChange:n=>{l?.(n)},property:s,component:t,defaultLocale:x,allComponents:d,PropertyValueField:F,onUpload:n=>{a.current=n,c()}});if(s.type==="custom"){const n=d[s.componentId]?.data;return n?e.jsx(r.Box,{sx:{width:"100%"},children:e.jsx(K.CustomComponentRenderer,{componentId:n.id,props:{label:o,value:i,onChange:l},locale:m,dev:{mode:"draft",components:d,defaultLocale:x}})}):e.jsx(r.TextField,{...b,label:o,disabled:!0,placeholder:"Click right button select a component"})}if(s.type==="component")return e.jsxs(r.Stack,{direction:"column",sx:{width:"100%",gap:1},children:[e.jsx(H,{allComponents:d,label:o,value:i?.componentId,onChange:(n,h)=>{f||!i?l?.({...i&&JSON.parse(JSON.stringify(i)),componentId:h}):typeof i=="object"&&(i.componentId=h,l?.({...i&&JSON.parse(JSON.stringify(i)),componentId:h}))}}),i?.componentId&&e.jsx(Pt,{value:i,valueImmutable:f,onChange:l,defaultLocale:x,allComponents:d})]});if(!s.type||["string","url","multiline"].includes(s.type)){let n=s.type==="string"?s.multiline:void 0;s.type==="multiline"&&(n=!0);const h=s.type==="url"?i?.url:i;return e.jsx(r.TextField,{...b,label:o,value:typeof h=="string"?h:"",multiline:n,minRows:n?2:void 0,maxRows:n?10:void 0,onChange:g=>l?.(s.type==="url"?{...i,url:g.target.value,mediaKitUrl:g.target.value}:g.target.value),slotProps:{input:s.type==="url"?{sx:{pr:0},endAdornment:e.jsxs(r.InputAdornment,{position:"end",sx:{display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(V.UploaderButton,{onChange:async({response:g})=>{const p=g?.data?.url||g?.data?.fileUrl;let y;p&&(y=await V.getImageSize(p).catch(()=>V.getVideoSize(p)).catch(()=>{}));let P=g?.data?.filename||"";P&&(P=`mediakit://${P}`),l?.({url:p,mediaKitUrl:P,width:y?.naturalWidth,height:y?.naturalHeight})}}),e.jsx(r.Tooltip,{title:"If you are using the 'mediaKitUrl' property, please use < import { getMediaKitAbsoluteUrl } from '@blocklet/pages-kit/builtin/utils' > to get the full address.",children:e.jsx(_.InfoRounded,{sx:{cursor:"default",mr:1},fontSize:"small"})})]})}:void 0}})}return s.type==="array"?e.jsx(at,{label:o,value:Array.isArray(i)?i:[],onChange:n=>l?.(n),property:s,renderItem:({item:n,index:h,onChange:g})=>s.subProperties&&Object.keys(s.subProperties).length>0?e.jsx(r.Stack,{sx:{gap:1,width:"100%"},children:z.default(Object.values(s.subProperties),"index").filter(p=>p.data.visible!==!1).map(({data:p})=>p.key?e.jsx(F,{component:t,property:p,value:n[p.key],onChange:y=>{const P={...n,[p.key]:y};g(P)},size:"small",fullWidth:!0,defaultLocale:x,allComponents:d},p.id):null)},h):e.jsx(r.TextField,{size:b.size,fullWidth:!0,value:n,onChange:p=>g(p.target.value)})}):(console.error("Unsupported property type",s.type),null)}function wt({NumberProps:t,...s}){const{getInputProps:i}=ie.unstable_useNumberInput(t),l=i();return e.jsx(r.TextField,{...s,slotProps:{htmlInput:l}})}const he=`import React from '@blocklet/pages-kit/builtin/react'
2
2
  import { Box } from '@blocklet/pages-kit/builtin/mui/material'
3
3
 
4
4
  export default function () {
@@ -7,5 +7,5 @@ export default function () {
7
7
  Hello World
8
8
  </Box>
9
9
  )
10
- }`,Ee=`console.log('hello')
11
- `;function Mt({value:t}){const{locale:s}=N.useLocaleContext(),i=ve.useUpdate(),o=G.getYjsValue(t).doc;return T.useEffect(()=>{var f;(f=t.renderer)!=null&&f.script||(o.transact(()=>{t.renderer.script=t.renderer.type==="react-component"?_e:Ee}),i())},[t]),e.jsx(r.Box,{sx:{border:1,borderColor:"divider",borderRadius:1,overflow:"hidden"},children:e.jsx(ne.CodeEditor,{keyId:t.id,locale:s,language:"typescript",value:t.renderer.script||"",onChange:f=>t.renderer.script=f,typeScriptNoValidation:!1,fullScreenOptions:{enableEscExit:!0}},t.id)})}function Wt({value:t}){var k,y,l;const{t:s}=N.useLocaleContext(),i=G.getYjsValue(t).doc,{state:{components:o,config:{defaultLocale:f},resources:g},localState:{currentLocale:x}}=A.useStore(),S=A.useAllComponents(),v=((k=o[t.renderer.componentId])==null?void 0:k.data)??((l=(y=g.components)==null?void 0:y[t.renderer.componentId])==null?void 0:l.component),h=U.usePopupState({variant:"dialog"});return e.jsx(q.UploaderProvider,{children:e.jsxs(r.Stack,{gap:1,children:[e.jsx(te,{allComponents:S,excludes:[t.id],value:t.renderer.componentId,onChange:(u,c)=>t.renderer.componentId=c}),v&&e.jsxs(e.Fragment,{children:[e.jsxs(r.Stack,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(r.Typography,{variant:"subtitle2",children:s("parameters")}),e.jsx(r.Button,{sx:{minWidth:32,minHeight:32,p:0},...U.bindTrigger(h),children:e.jsx(E.TranslateRounded,{fontSize:"small"})})]}),v.properties&&V.default(Object.values(v.properties),"index").map(({data:u})=>{var c,d,a,P,n,b,m,j,C,p,w,I,B,R,_,D;return e.jsx(r.Box,{children:e.jsx(L,{allComponents:S,defaultLocale:f,component:v,property:u,fullWidth:!0,size:"small",valueImmutable:ee.default((P=(a=(d=(c=t.renderer.properties)==null?void 0:c[u.id])==null?void 0:d.locales)==null?void 0:a[x])==null?void 0:P.value),value:((j=(m=(b=(n=t.renderer.properties)==null?void 0:n[u.id])==null?void 0:b.locales)==null?void 0:m[x])==null?void 0:j.value)??((I=(w=(p=(C=t.renderer.properties)==null?void 0:C[u.id])==null?void 0:p.locales)==null?void 0:w[f])==null?void 0:I.value)??((R=(B=u.locales)==null?void 0:B[x])==null?void 0:R.defaultValue)??((D=(_=u.locales)==null?void 0:_[f])==null?void 0:D.defaultValue),onChange:z=>{i.transact(()=>{var F,J,H,Y,$;(F=t.renderer).properties??(F.properties={}),(J=t.renderer.properties)[H=u.id]??(J[H]={}),(Y=t.renderer.properties[u.id]).locales??(Y.locales={}),($=t.renderer.properties[u.id].locales)[x]??($[x]={}),t.renderer.properties[u.id].locales[x].value=z})}})},u.id)}),e.jsx(Re,{...U.bindDialog(h),component:t,type:"parameters"})]})]})})}function te({label:t,options:s,excludes:i,value:o,onChange:f,allComponents:g,...x}){var k;const{t:S}=N.useLocaleContext(),v=s??V.default(Object.values(jt.default(g,...i??[])),"index").map(y=>y.data),h=(typeof o=="string"?(k=g[o])==null?void 0:k.data:void 0)??null;return e.jsx(r.Autocomplete,{...x,size:"small",options:v,autoHighlight:!0,isOptionEqualToValue:(y,l)=>y.id===l.id,getOptionKey:y=>y.id,getOptionLabel:y=>y.name||y.id,renderInput:y=>e.jsx(r.TextField,{label:t||S("component"),...y}),value:h,onChange:(y,l)=>{var c,d,a,P,n,b;let u={};l&&(u={blockletId:(c=g[l==null?void 0:l.id])==null?void 0:c.blockletId,blockletTitle:(d=g[l==null?void 0:l.id])==null?void 0:d.blockletTitle,componentName:((P=(a=g[l==null?void 0:l.id])==null?void 0:a.data)==null?void 0:P.name)||((b=(n=g[l==null?void 0:l.id])==null?void 0:n.data)==null?void 0:b.id)}),f==null||f(y,l==null?void 0:l.id,u)}})}function ce({config:t,allComponents:s,defaultLocale:i,propertiesValue:o,currentLocale:f,onChange:g,props:x}){const{t:S}=N.useLocaleContext(),[v,h]=T.useState(t==null?void 0:t.properties),[k,y]=T.useState(null);T.useEffect(()=>{(()=>{var P,n;((P=t==null?void 0:t.renderer)==null?void 0:P.type)==="react-component"&&W.default(t==null?void 0:t.properties)?Z.transpileAndLoadScript((n=t==null?void 0:t.renderer)==null?void 0:n.script).then(b=>{const m=Z.getPropertiesFromCode(b);h(m)}):h(t==null?void 0:t.properties)})()},[JSON.stringify(t)]);const l=T.useCallback(()=>!t||!v?{}:Object.values(v).reduce((a,{data:P})=>{var b,m,j,C,p;const n=P.key||P.id;return a[P.id]={key:n,value:(x==null?void 0:x[n])??((b=o==null?void 0:o[P.id])==null?void 0:b.value)??((j=(m=P.locales)==null?void 0:m[f])==null?void 0:j.defaultValue)??((p=(C=P.locales)==null?void 0:C[i])==null?void 0:p.defaultValue),id:P.id,type:P.type},a},{}),[JSON.stringify(v),t,o,f,i]),u=T.useMemo(()=>{if(!v)return{canUseProperties:[],visibleProperties:[],canUsePropertiesKeys:[]};const a=V.default(Object.values(v),"index"),P=a.filter(({data:m})=>m.key&&le(v,m.id)),n=a.filter(({data:m})=>m.key&&m.type!=="component"),b=n.map(({data:m})=>m.key);return{canUseProperties:n,visibleProperties:P,canUsePropertiesKeys:b}},[JSON.stringify(v)]),c=l(),d=ht.default(c,"key");return e.jsx(q.UploaderProvider,{children:e.jsxs(r.Stack,{gap:2,children:[e.jsx(r.Typography,{variant:"subtitle1",children:S("maker.properties.parameters")}),!t||u.canUsePropertiesKeys.length===0?e.jsx(Q.default,{style:{fontSize:12},children:S("maker.properties.noParameters")}):e.jsxs(e.Fragment,{children:[e.jsx(r.Stack,{gap:2,children:u.visibleProperties.map(({data:a})=>{var P,n;return e.jsx(r.Box,{children:e.jsx(L,{allComponents:s,defaultLocale:i,size:"small",fullWidth:!0,component:t,property:a,valueImmutable:ee.default((P=o==null?void 0:o[a.id])==null?void 0:P.value),value:(x==null?void 0:x[a.key||a.id])??((n=c[a.id])==null?void 0:n.value),onChange:b=>{g({path:["properties",a.id],id:a.id,value:{value:b},shouldSync:ge(a),excludeKeys:[],key:a.key||a.id})}})},a.id)})}),e.jsx(r.Stack,{gap:2,sx:{width:"100%"},children:e.jsx(Z.CustomComponentRenderer,{componentId:(t==null?void 0:t.id)||"",renderType:"setting",locale:f,properties:c,dev:{mode:"draft",components:s,defaultLocale:i},props:{...yt.default(x??{},u.canUsePropertiesKeys),onChange:a=>{const{canUsePropertiesKeys:P}=u;Object.keys(a).filter(b=>{var m;return!ft.default(a[b],(m=d==null?void 0:d[b])==null?void 0:m.value)}).filter(b=>{var m,j,C,p;return!(b==="locale"&&!mt.default(d[b],"locale")||((m=d[b])==null?void 0:m.type)==="component"||(((j=d[b])==null?void 0:j.type)==="yaml"||((C=d[b])==null?void 0:C.type)==="json")&&le(v,(p=d[b])==null?void 0:p.id))}).reduce((b,m)=>b.then(()=>{const j=d[m],C=P.includes(m);if(j!=null&&j.id&&C)return g({path:["properties",j.id],id:j.id,value:{value:a[m]},shouldSync:ge(j),excludeKeys:[],key:j.key||j.id}),Promise.resolve();const p=`propertyNotFound${m}`;if(k===p)return Promise.resolve();ie.default.close(k);const w=ie.default.warning(S("maker.properties.propertyNotFound",{key:m}),{key:p});return y(w),Promise.resolve()}),Promise.resolve())}}})})]})]})})}function Lt({config:t}){const{t:s,locale:i}=N.useLocaleContext(),[o,f]=T.useState(!1),g=x=>{t.llmConfig=x};return e.jsxs(e.Fragment,{children:[e.jsx(r.Tooltip,{title:s("maker.properties.configLLMDescription"),children:e.jsx(r.IconButton,{color:"primary",onClick:()=>f(!0),size:"small",children:e.jsx(E.PsychologyAlt,{})})}),o&&e.jsx(Rt,{open:o,onClose:()=>f(!1),onConfirm:g,component:t,initialConfig:t.llmConfig,locale:i,defaultLocale:"en",title:s("maker.properties.llmConfigTitle")})]})}exports.BasicInfo=Be;exports.CustomComponentAutocomplete=te;exports.CustomComponentSettings=At;exports.DefaultReactComponentScriptTemplate=_e;exports.DefaultWebComponentScriptTemplate=Ee;exports.ParametersConfig=ce;exports.PropertiesConfig=Ne;exports.PropertyValueField=L;
10
+ }`,be=`console.log('hello')
11
+ `;function It({value:t}){const{locale:s}=O.useLocaleContext(),i=te.useUpdate(),l=L.getYjsValue(t).doc;return v.useEffect(()=>{t.renderer?.script||(l.transact(()=>{t.renderer.script=t.renderer.type==="react-component"?he:be}),i())},[t]),e.jsx(r.Box,{sx:{border:1,borderColor:"divider",borderRadius:1,overflow:"hidden"},children:e.jsx(ee.CodeEditor,{keyId:t.id,locale:s,language:"typescript",value:t.renderer.script||"",onChange:f=>t.renderer.script=f,typeScriptNoValidation:!1,fullScreenOptions:{enableEscExit:!0}},t.id)})}function Tt({value:t}){const{t:s}=O.useLocaleContext(),i=L.getYjsValue(t).doc,{state:{components:l,config:{defaultLocale:f},resources:x},localState:{currentLocale:d}}=R.useStore(),b=R.useAllComponents(),m=l[t.renderer.componentId]?.data??x.components?.[t.renderer.componentId]?.component,u=A.usePopupState({variant:"dialog"});return e.jsx(V.UploaderProvider,{children:e.jsxs(r.Stack,{sx:{gap:1},children:[e.jsx(H,{allComponents:b,excludes:[t.id],value:t.renderer.componentId,onChange:(a,c)=>t.renderer.componentId=c}),m&&e.jsxs(e.Fragment,{children:[e.jsxs(r.Stack,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsx(r.Typography,{variant:"subtitle2",children:s("parameters")}),e.jsx(r.Button,{sx:{minWidth:32,minHeight:32,p:0},...A.bindTrigger(u),children:e.jsx(_.TranslateRounded,{fontSize:"small"})})]}),m.properties&&z.default(Object.values(m.properties),"index").map(({data:a})=>e.jsx(r.Box,{children:e.jsx(F,{allComponents:b,defaultLocale:f,component:m,property:a,fullWidth:!0,size:"small",valueImmutable:J.default(t.renderer.properties?.[a.id]?.locales?.[d]?.value),value:t.renderer.properties?.[a.id]?.locales?.[d]?.value??t.renderer.properties?.[a.id]?.locales?.[f]?.value??a.locales?.[d]?.defaultValue??a.locales?.[f]?.defaultValue,onChange:c=>{i.transact(()=>{t.renderer.properties??={},t.renderer.properties[a.id]??={},t.renderer.properties[a.id].locales??={},t.renderer.properties[a.id].locales[d]??={},t.renderer.properties[a.id].locales[d].value=c})}})},a.id)),e.jsx(fe,{...A.bindDialog(u),component:t,type:"parameters"})]})]})})}function H({label:t,options:s,excludes:i,value:l,onChange:f,allComponents:x,...d}){const{t:b}=O.useLocaleContext(),m=s??z.default(Object.values(rt.default(x,...i??[])),"index").map(a=>a.data),u=(typeof l=="string"?x[l]?.data:void 0)??null;return e.jsx(r.Autocomplete,{...d,size:"small",options:m,autoHighlight:!0,isOptionEqualToValue:(a,c)=>a.id===c.id,getOptionKey:a=>a.id,getOptionLabel:a=>a.name||a.id,renderInput:a=>e.jsx(r.TextField,{label:t||b("component"),...a}),value:u,onChange:(a,c)=>{let o={};c&&(o={blockletId:x[c?.id]?.blockletId,blockletTitle:x[c?.id]?.blockletTitle,componentName:x[c?.id]?.data?.name||x[c?.id]?.data?.id}),f?.(a,c?.id,o)}})}function re({config:t,allComponents:s,defaultLocale:i,propertiesValue:l,currentLocale:f,onChange:x,props:d}){const{t:b}=O.useLocaleContext(),[m,u]=v.useState(t?.properties),[a,c]=v.useState(null);v.useEffect(()=>{(()=>{t?.renderer?.type==="react-component"&&D.default(t?.properties)?K.transpileAndLoadScript(t?.renderer?.script).then(y=>{const P=K.getPropertiesFromCode(y);u(P)}):u(t?.properties)})()},[JSON.stringify(t)]);const o=v.useCallback(()=>!t||!m?{}:Object.values(m).reduce((p,{data:y})=>{const P=y.key||y.id;return p[y.id]={key:P,value:d?.[P]??l?.[y.id]?.value??y.locales?.[f]?.defaultValue??y.locales?.[i]?.defaultValue,id:y.id,type:y.type},p},{}),[JSON.stringify(m),t,l,f,i]),n=v.useMemo(()=>{if(!m)return{canUseProperties:[],visibleProperties:[],canUsePropertiesKeys:[]};const p=z.default(Object.values(m),"index"),y=p.filter(({data:S})=>S.key&&Z(m,S.id)),P=p.filter(({data:S})=>S.key&&S.type!=="component"),I=P.map(({data:S})=>S.key);return{canUseProperties:P,visibleProperties:y,canUsePropertiesKeys:I}},[JSON.stringify(m)]),h=o(),g=tt.default(h,"key");return e.jsx(V.UploaderProvider,{children:e.jsxs(r.Stack,{sx:{gap:2},children:[e.jsx(r.Typography,{variant:"subtitle1",children:b("maker.properties.parameters")}),!t||n.canUsePropertiesKeys.length===0?e.jsx(U.default,{style:{fontSize:12},children:b("maker.properties.noParameters")}):e.jsxs(e.Fragment,{children:[e.jsx(r.Stack,{sx:{gap:2},children:n.visibleProperties.map(({data:p})=>e.jsx(r.Box,{children:e.jsx(F,{allComponents:s,defaultLocale:i,size:"small",fullWidth:!0,component:t,property:p,valueImmutable:J.default(l?.[p.id]?.value),value:d?.[p.key||p.id]??h[p.id]?.value,onChange:y=>{x({path:["properties",p.id],id:p.id,value:{value:y},shouldSync:ne(p),excludeKeys:[],key:p.key||p.id})}})},p.id))}),e.jsx(r.Stack,{sx:{gap:2,width:"100%"},children:e.jsx(K.CustomComponentRenderer,{componentId:t?.id||"",renderType:"setting",locale:f,properties:h,dev:{mode:"draft",components:s,defaultLocale:i},props:{...st.default(d??{},n.canUsePropertiesKeys),onChange:p=>{const{canUsePropertiesKeys:y}=n;Object.keys(p).filter(I=>!Ze.default(p[I],g?.[I]?.value)).filter(I=>!(I==="locale"&&!Xe.default(g[I],"locale")||g[I]?.type==="component"||(g[I]?.type==="yaml"||g[I]?.type==="json")&&Z(m,g[I]?.id))).reduce((I,S)=>I.then(()=>{const k=g[S],B=y.includes(S);if(k?.id&&B)return x({path:["properties",k.id],id:k.id,value:{value:p[S]},shouldSync:ne(k),excludeKeys:[],key:k.key||k.id}),Promise.resolve();const j=`propertyNotFound${S}`;if(a===j)return Promise.resolve();Q.default.close(a);const C=Q.default.warning(b("maker.properties.propertyNotFound",{key:S}),{key:j});return c(C),Promise.resolve()}),Promise.resolve())}}})})]})]})})}function Bt({config:t}){const{t:s,locale:i}=O.useLocaleContext(),[l,f]=v.useState(!1),x=d=>{t.llmConfig=d};return e.jsxs(e.Fragment,{children:[e.jsx(r.Tooltip,{title:s("maker.properties.configLLMDescription"),children:e.jsx(r.IconButton,{color:"primary",onClick:()=>f(!0),size:"small",children:e.jsx(_.PsychologyAlt,{})})}),l&&e.jsx(bt,{open:l,onClose:()=>f(!1),onConfirm:x,component:t,initialConfig:t.llmConfig,locale:i,defaultLocale:"en",title:s("maker.properties.llmConfigTitle")})]})}exports.BasicInfo=pe;exports.CustomComponentAutocomplete=H;exports.CustomComponentSettings=yt;exports.DefaultReactComponentScriptTemplate=he;exports.DefaultWebComponentScriptTemplate=be;exports.ParametersConfig=re;exports.PropertiesConfig=me;exports.PropertyValueField=F;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./chunks/site-state-BtZ8o3J2.js"),u=require("@blocklet/pages-kit/utils/common");require("@blocklet/pages-kit/utils/page-model");require("@blocklet/pages-kit/utils/property");require("@blocklet/pages-kit/utils/route");require("@blocklet/sdk/lib/component");require("@blocklet/sdk/lib/config");require("@reactivedata/reactive");require("@syncedstore/core");require("crypto");require("fs");require("glob");require("lib0/decoding");require("lib0/encoding");require("lodash/cloneDeep");require("lodash/debounce");require("lodash/get");require("lodash/isEmpty");require("lodash/pick");require("lodash/set");require("lodash/union");require("lru-cache");require("p-limit");require("path");require("stream/promises");require("tar");require("ufo");require("wait-on");require("y-protocols/awareness");require("y-protocols/sync");require("yaml");require("yjs");const t=require("@blocklet/pages-kit/types/state");exports.PUBLISH_MODES=e.PUBLISH_MODES;exports.SITE_STATE_PATH=e.SITE_STATE_PATH;exports.STATE_MODES=e.STATE_MODES;exports.default=e.SiteState;exports.downloadAsset=e.downloadAsset;exports.downloadAssets=e.downloadAssets;exports.fromPackage=e.fromPackage;exports.getResourceStates=e.getResourceStates;exports.initPackResourceStates=e.initPackResourceStates;exports.mergeState=e.mergeState;exports.toPackage=e.toPackage;exports.triggerReloadAllProjectResource=e.triggerReloadAllProjectResource;Object.defineProperty(exports,"nextId",{enumerable:!0,get:()=>u.nextId});Object.keys(t).forEach(r=>{r!=="default"&&!Object.prototype.hasOwnProperty.call(exports,r)&&Object.defineProperty(exports,r,{enumerable:!0,get:()=>t[r]})});
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./chunks/site-state-gSkcvhcV.js"),u=require("@blocklet/pages-kit/utils/common");require("@blocklet/pages-kit/utils/page-model");require("@blocklet/pages-kit/utils/property");require("@blocklet/pages-kit/utils/route");require("@blocklet/sdk/lib/component");require("@blocklet/sdk/lib/config");require("@reactivedata/reactive");require("@syncedstore/core");require("crypto");require("fs");require("glob");require("lib0/decoding");require("lib0/encoding");require("lodash/cloneDeep");require("lodash/debounce");require("lodash/get");require("lodash/isEmpty");require("lodash/pick");require("lodash/set");require("lodash/union");require("lru-cache");require("p-limit");require("path");require("stream/promises");require("tar");require("ufo");require("wait-on");require("y-protocols/awareness");require("y-protocols/sync");require("yaml");require("yjs");const t=require("@blocklet/pages-kit/types/state");exports.PUBLISH_MODES=e.PUBLISH_MODES;exports.SITE_STATE_PATH=e.SITE_STATE_PATH;exports.STATE_MODES=e.STATE_MODES;exports.default=e.SiteState;exports.downloadAsset=e.downloadAsset;exports.downloadAssets=e.downloadAssets;exports.fromPackage=e.fromPackage;exports.getResourceStates=e.getResourceStates;exports.initPackResourceStates=e.initPackResourceStates;exports.mergeState=e.mergeState;exports.toPackage=e.toPackage;exports.triggerReloadAllProjectResource=e.triggerReloadAllProjectResource;Object.defineProperty(exports,"nextId",{enumerable:!0,get:()=>u.nextId});Object.keys(t).forEach(r=>{r!=="default"&&!Object.prototype.hasOwnProperty.call(exports,r)&&Object.defineProperty(exports,r,{enumerable:!0,get:()=>t[r]})});
package/lib/cjs/theme.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),u=require("@arcblock/ux/lib/Config"),d=require("@iconify-icon/react"),m=require("@iconify-icons/tabler/chevron-down"),e=require("@mui/material"),c=require("react"),x=require("react-router-dom"),b=require("./chunks/session-BA7Qrcia.js"),f=require("./locales.js"),C=s=>s&&s.__esModule?s:{default:s},h=C(m);var r;const i=((r=window.blocklet)==null?void 0:r.prefix)||"/",$=i.endsWith("/")?`${i}admin`:`${i}/admin`,o={fontSize:"5rem","@media (max-width: 1536px)":{fontSize:"5rem"},"@media (max-width: 1200px)":{fontSize:"4rem"},"@media (max-width: 900px)":{fontSize:"3rem"},"@media (max-width: 600px)":{fontSize:"2rem"}};function n(s){return a.jsx(e.Box,{...s,component:d.Icon,icon:h.default})}const g={typography:{big:{...o},button:{textTransform:"none",WebkitTextTransform:"none"},subtitle1:{fontWeight:600,fontSize:"18px",lineHeight:1.5},subtitle2:{fontSize:"14px",lineHeight:"24px",fontWeight:500,marginBottom:"4px"}},palette:{background:{},action:{}},shape:{borderRadius:8},components:{MuiCssBaseline:{},MuiFormLabel:{styleOverrides:{root:{fontSize:"0.875rem"}}},MuiFormControlLabel:{styleOverrides:{root:{marginLeft:0},label:{fontSize:"0.875rem"}}},MuiInputLabel:{styleOverrides:{root:{fontSize:"0.875rem"}}},MuiRadio:{styleOverrides:{root:{padding:4,[`.${e.svgIconClasses.fontSizeMedium}`]:{fontSize:"1.25rem"},[`.${e.svgIconClasses.fontSizeSmall}`]:{fontSize:"1.125rem"}}}},MuiCheckbox:{styleOverrides:{root:{padding:4,[`.${e.svgIconClasses.fontSizeMedium}`]:{fontSize:"1.25rem"},[`.${e.svgIconClasses.fontSizeSmall}`]:{fontSize:"1.125rem"}}}},MuiSwitch:{styleOverrides:{root:{height:28,width:48,padding:8,[`&.${e.switchClasses.sizeSmall}`]:{height:26,width:40,padding:8}},switchBase:{padding:4}}},MuiAutocomplete:{defaultProps:{popupIcon:a.jsx(n,{fontSize:14})},variants:[{props:{},style:({theme:s})=>s.unstable_sx({[`.${e.autocompleteClasses.inputRoot}`]:{pt:1.5,pb:.25,[`.${e.autocompleteClasses.input}.${e.inputBaseClasses.input}`]:{px:0,pt:.5,pb:.25},[`&.${e.inputBaseClasses.sizeSmall}`]:{[`.${e.autocompleteClasses.input}.${e.inputBaseClasses.input}`]:{px:0,py:0,pb:"1px"}}}})}]},MuiTextField:{defaultProps:{variant:"filled"},variants:[{props:{},style:({theme:s,ownerState:t})=>s.unstable_sx({[`.${e.inputBaseClasses.root}`]:{borderRadius:1,lineHeight:"1.5rem",[`.${e.inputBaseClasses.input}`]:{height:"1.5rem"},[`&.${e.inputClasses.multiline}`]:{pl:0,pr:0,pt:t!=null&&t.label?2:1,"& .MuiInputBase-inputMultiline":{py:0}}},[`.${e.inputClasses.root}`]:{mt:1.5,[`&.${e.inputBaseClasses.hiddenLabel}`]:{mt:0,pt:0,[`.${e.selectClasses.select}.${e.inputClasses.input}:focus`]:{bgcolor:"transparent"}}},[`.${e.inputLabelClasses.standard}`]:{transform:"translate(0px, 18px) scale(1)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(0px, 15px) scale(1)"},[`&.${e.inputLabelClasses.shrink}`]:{transform:"translate(0px, -1px) scale(0.8)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(0px, -1px) scale(0.8)"}}},[`.${e.filledInputClasses.root}`]:{":before,:after":{display:"none"},[`.${e.inputBaseClasses.input}`]:{pb:.5,pt:t!=null&&t.label?2:.5,px:1,":focus":{borderRadius:1},[`&.${e.inputBaseClasses.inputSizeSmall}`]:{pb:.25,pt:t!=null&&t.label?1.25:.25,...t!=null&&t.multiline?{pt:0}:{}},[`&.${e.inputBaseClasses.inputHiddenLabel}`]:{py:.5,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:"1px"}}}},[`.${e.inputLabelClasses.filled}`]:{transform:"translate(8px, 11px) scale(1)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(8px, 7px) scale(1)"},[`&.${e.inputLabelClasses.shrink}`]:{transform:"translate(8px, 2px) scale(0.8)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(8px, 0) scale(0.8)"}}},[`.${e.outlinedInputClasses.root}`]:{[`.${e.inputBaseClasses.input}`]:{py:1.25,px:1,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:.875},[`&.${e.inputBaseClasses.inputHiddenLabel}`]:{py:.5,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:"1px"}}}},[`.${e.inputLabelClasses.outlined}`]:{transform:"translate(8px, 10px) scale(1)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(8px, 7px) scale(1)"},[`&.${e.inputLabelClasses.shrink}`]:{transform:"translate(16px, -7px) scale(0.8)"}}})}]},MuiInput:{defaultProps:{disableUnderline:!0},variants:[{props:{disableUnderline:!0},style:({theme:s})=>s.unstable_sx({fontSize:"0.875rem",lineHeight:"1.5rem",[`&.${e.inputBaseClasses.multiline}`]:{py:0},[`.${e.inputBaseClasses.input}`]:{py:.5,height:"1.5rem"},[`&.${e.inputBaseClasses.sizeSmall}`]:{[`.${e.inputBaseClasses.input}`]:{py:"1px"}}})}]},MuiFilledInput:{styleOverrides:{root:({theme:s})=>s.unstable_sx({fontSize:"0.875rem",bgcolor:s.palette.grey[100],"&:hover":{bgcolor:s.palette.grey[100]},"@media (hover: none)":{bgcolor:s.palette.grey[100]}})}},MuiSelect:{styleOverrides:{select:{display:"flex",alignItems:"center",[`.${e.listItemIconClasses.root}`]:{minWidth:20}}},defaultProps:{variant:"filled",IconComponent:n},variants:[{props:{},style:({theme:s})=>s.unstable_sx({fontSize:"0.875rem",borderRadius:1,lineHeight:"1.5rem",[`&.${e.filledInputClasses.root}`]:{":before,:after":{display:"none"},[`.${e.inputBaseClasses.input}`]:{py:.5,borderRadius:1,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:"1px"}}},[`&.${e.outlinedInputClasses.root}`]:{[`.${e.inputBaseClasses.input}`]:{py:.5,borderRadius:1,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:"1px"}}}})}]},MuiSlider:{defaultProps:{},variants:[{props:{},style:({theme:s})=>s.unstable_sx({height:3,[`.${e.sliderClasses.track}`]:{borderWidth:0},[`.${e.sliderClasses.thumb}`]:{width:16,height:16},[`&.${e.sliderClasses.sizeSmall}`]:{height:2,[`.${e.sliderClasses.thumb}`]:{width:12,height:12}}})}]},MuiFormHelperText:{styleOverrides:{root:({theme:s})=>s.unstable_sx({mx:1})}},MuiTypography:{variants:[{props:{variant:"body1"},style:({theme:s})=>s.unstable_sx({fontSize:"0.875rem"})},{props:{variant:"body2"},style:({theme:s})=>s.unstable_sx({fontSize:"0.75rem"})}]},MuiMenuItem:{styleOverrides:{root:({theme:s})=>s.unstable_sx({padding:"6px 12px",fontSize:"0.875rem",borderRadius:1,".MuiListItemIcon-root":{minWidth:0,mr:1}})}},MuiListItemButton:{styleOverrides:{root:{padding:"6px 12px"}}},MuiList:{styleOverrides:{root:{padding:4}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"0.875rem"}}},MuiDialogTitle:{styleOverrides:{root:({theme:s})=>s.unstable_sx({padding:"16px 24px",borderBottom:`1px solid ${s.palette.divider}`})}},MuiDialogActions:{styleOverrides:{root:({theme:s})=>s.unstable_sx({borderTop:`1px solid ${s.palette.divider}`,padding:"16px 24px"})}},MuiDialogContent:{styleOverrides:{root:{padding:"12px 24px !important"}}},MuiButton:{defaultProps:{size:"small"},styleOverrides:{}}}},y={typography:{big:{...o},button:{textTransform:"none",WebkitTextTransform:"none"}}},v=({children:s,isDashboard:t=!1})=>{const l=x.useLocation().pathname.startsWith("/admin/maker")||t,p=c.useMemo(()=>l?g:y,[l]);return a.jsx(u.ConfigProvider,{theme:p,translations:f.translations,fallbackLocale:"en",injectFirst:!0,children:a.jsx(b.SessionProvider,{serviceHost:i,protectedRoutes:[`${$}/*`],children:s})})};exports.PagesKitThemeProvider=v;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),p=require("@arcblock/ux/lib/Config"),u=require("@iconify-icon/react"),d=require("@iconify-icons/tabler/chevron-down"),e=require("@mui/material"),m=require("react"),c=require("react-router-dom"),x=require("./chunks/session-BRtsDvA-.js"),b=require("./locales.js"),f=s=>s&&s.__esModule?s:{default:s},C=f(d),i=window.blocklet?.prefix||"/",h=i.endsWith("/")?`${i}admin`:`${i}/admin`,r={fontSize:"5rem","@media (max-width: 1536px)":{fontSize:"5rem"},"@media (max-width: 1200px)":{fontSize:"4rem"},"@media (max-width: 900px)":{fontSize:"3rem"},"@media (max-width: 600px)":{fontSize:"2rem"}};function l(s){return a.jsx(e.Box,{...s,component:u.Icon,icon:C.default})}const $={typography:{big:{...r},button:{textTransform:"none",WebkitTextTransform:"none"},subtitle1:{fontWeight:600,fontSize:"18px",lineHeight:1.5},subtitle2:{fontSize:"14px",lineHeight:"24px",fontWeight:500,marginBottom:"4px"}},palette:{background:{},action:{}},shape:{borderRadius:8},components:{MuiCssBaseline:{},MuiFormLabel:{styleOverrides:{root:{fontSize:"0.875rem"}}},MuiFormControlLabel:{styleOverrides:{root:{marginLeft:0},label:{fontSize:"0.875rem"}}},MuiInputLabel:{styleOverrides:{root:{fontSize:"0.875rem"}}},MuiRadio:{styleOverrides:{root:{padding:4,[`.${e.svgIconClasses.fontSizeMedium}`]:{fontSize:"1.25rem"},[`.${e.svgIconClasses.fontSizeSmall}`]:{fontSize:"1.125rem"}}}},MuiCheckbox:{styleOverrides:{root:{padding:4,[`.${e.svgIconClasses.fontSizeMedium}`]:{fontSize:"1.25rem"},[`.${e.svgIconClasses.fontSizeSmall}`]:{fontSize:"1.125rem"}}}},MuiSwitch:{styleOverrides:{root:{height:28,width:48,padding:8,[`&.${e.switchClasses.sizeSmall}`]:{height:26,width:40,padding:8}},switchBase:{padding:4}}},MuiAutocomplete:{defaultProps:{popupIcon:a.jsx(l,{fontSize:14})},variants:[{props:{},style:({theme:s})=>s.unstable_sx({[`.${e.autocompleteClasses.inputRoot}`]:{pt:1.5,pb:.25,[`.${e.autocompleteClasses.input}.${e.inputBaseClasses.input}`]:{px:0,pt:.5,pb:.25},[`&.${e.inputBaseClasses.sizeSmall}`]:{[`.${e.autocompleteClasses.input}.${e.inputBaseClasses.input}`]:{px:0,py:0,pb:"1px"}}}})}]},MuiTextField:{defaultProps:{variant:"filled"},variants:[{props:{},style:({theme:s,ownerState:t})=>s.unstable_sx({[`.${e.inputBaseClasses.root}`]:{borderRadius:1,lineHeight:"1.5rem",[`.${e.inputBaseClasses.input}`]:{height:"1.5rem"},[`&.${e.inputClasses.multiline}`]:{pl:0,pr:0,pt:t?.label?2:1,"& .MuiInputBase-inputMultiline":{py:0}}},[`.${e.inputClasses.root}`]:{mt:1.5,[`&.${e.inputBaseClasses.hiddenLabel}`]:{mt:0,pt:0,[`.${e.selectClasses.select}.${e.inputClasses.input}:focus`]:{bgcolor:"transparent"}}},[`.${e.inputLabelClasses.standard}`]:{transform:"translate(0px, 18px) scale(1)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(0px, 15px) scale(1)"},[`&.${e.inputLabelClasses.shrink}`]:{transform:"translate(0px, -1px) scale(0.8)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(0px, -1px) scale(0.8)"}}},[`.${e.filledInputClasses.root}`]:{":before,:after":{display:"none"},[`.${e.inputBaseClasses.input}`]:{pb:.5,pt:t?.label?2:.5,px:1,":focus":{borderRadius:1},[`&.${e.inputBaseClasses.inputSizeSmall}`]:{pb:.25,pt:t?.label?1.25:.25,...t?.multiline?{pt:0}:{}},[`&.${e.inputBaseClasses.inputHiddenLabel}`]:{py:.5,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:"1px"}}}},[`.${e.inputLabelClasses.filled}`]:{transform:"translate(8px, 11px) scale(1)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(8px, 7px) scale(1)"},[`&.${e.inputLabelClasses.shrink}`]:{transform:"translate(8px, 2px) scale(0.8)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(8px, 0) scale(0.8)"}}},[`.${e.outlinedInputClasses.root}`]:{[`.${e.inputBaseClasses.input}`]:{py:1.25,px:1,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:.875},[`&.${e.inputBaseClasses.inputHiddenLabel}`]:{py:.5,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:"1px"}}}},[`.${e.inputLabelClasses.outlined}`]:{transform:"translate(8px, 10px) scale(1)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(8px, 7px) scale(1)"},[`&.${e.inputLabelClasses.shrink}`]:{transform:"translate(16px, -7px) scale(0.8)"}}})}]},MuiInput:{defaultProps:{disableUnderline:!0},variants:[{props:{disableUnderline:!0},style:({theme:s})=>s.unstable_sx({fontSize:"0.875rem",lineHeight:"1.5rem",[`&.${e.inputBaseClasses.multiline}`]:{py:0},[`.${e.inputBaseClasses.input}`]:{py:.5,height:"1.5rem"},[`&.${e.inputBaseClasses.sizeSmall}`]:{[`.${e.inputBaseClasses.input}`]:{py:"1px"}}})}]},MuiFilledInput:{styleOverrides:{root:({theme:s})=>s.unstable_sx({fontSize:"0.875rem",bgcolor:s.palette.grey[100],"&:hover":{bgcolor:s.palette.grey[100]},"@media (hover: none)":{bgcolor:s.palette.grey[100]}})}},MuiSelect:{styleOverrides:{select:{display:"flex",alignItems:"center",[`.${e.listItemIconClasses.root}`]:{minWidth:20}}},defaultProps:{variant:"filled",IconComponent:l},variants:[{props:{},style:({theme:s})=>s.unstable_sx({fontSize:"0.875rem",borderRadius:1,lineHeight:"1.5rem",[`&.${e.filledInputClasses.root}`]:{":before,:after":{display:"none"},[`.${e.inputBaseClasses.input}`]:{py:.5,borderRadius:1,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:"1px"}}},[`&.${e.outlinedInputClasses.root}`]:{[`.${e.inputBaseClasses.input}`]:{py:.5,borderRadius:1,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:"1px"}}}})}]},MuiSlider:{defaultProps:{},variants:[{props:{},style:({theme:s})=>s.unstable_sx({height:3,[`.${e.sliderClasses.track}`]:{borderWidth:0},[`.${e.sliderClasses.thumb}`]:{width:16,height:16},[`&.${e.sliderClasses.sizeSmall}`]:{height:2,[`.${e.sliderClasses.thumb}`]:{width:12,height:12}}})}]},MuiFormHelperText:{styleOverrides:{root:({theme:s})=>s.unstable_sx({mx:1})}},MuiTypography:{variants:[{props:{variant:"body1"},style:({theme:s})=>s.unstable_sx({fontSize:"0.875rem"})},{props:{variant:"body2"},style:({theme:s})=>s.unstable_sx({fontSize:"0.75rem"})}]},MuiMenuItem:{styleOverrides:{root:({theme:s})=>s.unstable_sx({padding:"6px 12px",fontSize:"0.875rem",borderRadius:1,".MuiListItemIcon-root":{minWidth:0,mr:1}})}},MuiListItemButton:{styleOverrides:{root:{padding:"6px 12px"}}},MuiList:{styleOverrides:{root:{padding:4}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"0.875rem"}}},MuiDialogTitle:{styleOverrides:{root:({theme:s})=>s.unstable_sx({padding:"16px 24px",borderBottom:`1px solid ${s.palette.divider}`})}},MuiDialogActions:{styleOverrides:{root:({theme:s})=>s.unstable_sx({borderTop:`1px solid ${s.palette.divider}`,padding:"16px 24px"})}},MuiDialogContent:{styleOverrides:{root:{padding:"12px 24px !important"}}},MuiButton:{defaultProps:{size:"small"},styleOverrides:{}}}},g={typography:{big:{...r},button:{textTransform:"none",WebkitTextTransform:"none"}}},y=({children:s,isDashboard:t=!1})=>{const n=c.useLocation().pathname.startsWith("/admin/maker")||t,o=m.useMemo(()=>n?$:g,[n]);return a.jsx(p.ConfigProvider,{theme:o,translations:b.translations,fallbackLocale:"en",injectFirst:!0,children:a.jsx(x.SessionProvider,{serviceHost:i,protectedRoutes:[`${h}/*`],children:s})})};exports.PagesKitThemeProvider=y;