@blocklet/pages-kit-inner-components 0.6.75 → 0.6.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/add-component.js +1 -1
- package/lib/cjs/chunks/{draft-data-1hI-ev3X.js → draft-data-CkVvOh60.js} +1 -1
- package/lib/cjs/chunks/{home-ymdnbwRQ.js → home-CjhOAEa7.js} +2 -2
- package/lib/cjs/chunks/html-xfTPTsl5.js +1 -0
- package/lib/cjs/chunks/{index-BAiZumV7.js → index-CiYwdeK9.js} +24 -24
- package/lib/cjs/chunks/index-CkEcLDOZ.js +1 -0
- package/lib/cjs/chunks/{publish-button-45a3egG-.js → publish-button-DV23sfgB.js} +1 -1
- package/lib/cjs/chunks/site-state-CtiXHtSX.js +1 -0
- package/lib/cjs/chunks/state-BdtFHk36.js +1 -0
- package/lib/cjs/home.js +1 -1
- package/lib/cjs/locales.js +2 -2
- package/lib/cjs/project-html.js +1 -1
- package/lib/cjs/resources.js +1 -1
- package/lib/cjs/setting.js +2 -2
- package/lib/cjs/site-state.js +1 -1
- package/lib/es/add-component.js +2 -2
- package/lib/es/chunks/{draft-data--WtLtXxy.js → draft-data-BOoVhbon.js} +1 -1
- package/lib/es/chunks/{home-BIH-BNIG.js → home-BZB9zOlO.js} +3 -3
- package/lib/es/chunks/{html-DfzaaIYa.js → html-DOgzvdOd.js} +11 -10
- package/lib/es/chunks/{index-Cj977HLf.js → index-Bggolyu_.js} +192 -240
- package/lib/es/chunks/index-D6o0hPHg.js +48 -0
- package/lib/es/chunks/{publish-button-Dn3ikSo5.js → publish-button-Dm2Nce-b.js} +3 -3
- package/lib/es/chunks/{site-state-BXM-5tZw.js → site-state-D4wvb7PN.js} +300 -300
- package/lib/es/chunks/{state-DS2djQbR.js → state-DNdwHwty.js} +173 -165
- package/lib/es/home.js +3 -3
- package/lib/es/locales.js +2 -0
- package/lib/es/project-html.js +1 -1
- package/lib/es/resources.js +1 -1
- package/lib/es/setting.js +680 -670
- package/lib/es/site-state.js +1 -1
- package/package.json +3 -3
- package/lib/cjs/chunks/html-JOhPskS4.js +0 -1
- package/lib/cjs/chunks/site-state-CcYU6tKv.js +0 -1
- package/lib/cjs/chunks/state-BAjDjwwp.js +0 -1
package/lib/cjs/setting.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),r=require("@mui/material"),A=require("./chunks/state-BAjDjwwp.js"),ve=require("@arcblock/ux/lib/Empty"),R=require("@arcblock/ux/lib/Locale/context"),re=require("@blocklet/code-editor"),Ce=require("@mui/icons-material/AddRounded"),ke=require("@mui/icons-material/ArrowDownward"),Se=require("@mui/icons-material/ArrowUpward"),Pe=require("@mui/icons-material/DeleteOutline"),we=require("lodash/sortBy"),P=require("react"),se=require("react-use"),oe=require("@blocklet/pages-kit/builtin/color-picker"),V=require("@blocklet/pages-kit/builtin/uploader"),Ie=require("@iconify-icon/react"),Te=require("lodash/isEmpty"),Be=require("lodash/set"),Oe=require("yaml"),Re=require("lodash/cloneDeep"),Ne=require("@arcblock/ux/lib/Toast"),J=require("@blocklet/pages-kit/components"),ze=require("@blocklet/pages-kit/utils/property"),ae=require("@mui/base"),N=require("@mui/icons-material"),U=require("@syncedstore/core"),Ve=require("ahooks"),Ae=require("lodash/assign"),_e=require("lodash/get"),Ee=require("lodash/has"),De=require("lodash/isEqual"),Fe=require("lodash/isNil"),qe=require("lodash/isObject"),Le=require("lodash/keyBy"),Ue=require("lodash/omit"),Me=require("lodash/pick"),We=require("lodash/reduce"),E=require("material-ui-popup-state/hooks"),Ke=require("react-error-boundary"),L=require("@dnd-kit/core"),Q=require("@dnd-kit/sortable"),Je=require("@dnd-kit/utilities"),ce=require("@blocklet/pages-kit/utils/common"),O=t=>t&&t.__esModule?t:{default:t};function He(t){if(t&&t.__esModule)return t;const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const a=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(s,o,a.get?a:{enumerable:!0,get:()=>t[o]})}}return s.default=t,Object.freeze(s)}const M=O(ve),$e=O(Ce),Ge=O(ke),Ye=O(Se),Qe=O(Pe),_=O(we),D=O(Te),de=O(Be),X=He(Oe),Z=O(Re),ee=O(Ne),Xe=O(Ae),Ze=O(_e),et=O(Ee),tt=O(De),$=O(Fe),rt=O(qe),st=O(Le),nt=O(Ue),ot=O(Me),it=O(We);function lt({error:t}){return e.jsx(r.Box,{children:e.jsx(r.Alert,{severity:"error",children:t.message})})}function at({onClick:t,disabled:s,sx:o,...a}){return e.jsx(r.IconButton,{size:"small",color:"warning",variant:"outlined",disabled:s,onClick:t,...a,children:e.jsx(Qe.default,{fontSize:"small"})})}function ct({onClick:t,disabled:s,sx:o,...a}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...a,children:e.jsx(Ye.default,{fontSize:"small"})})}function dt({onClick:t,disabled:s,sx:o,...a}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...a,children:e.jsx(Ge.default,{fontSize:"small"})})}function ut({label:t,value:s,onChange:o,disabled:a=!1,itemLabel:h="",emptyHeight:x=40,property:p,renderItem:j,...f}){const{t:c,locale:u}=R.useLocaleContext(),l=se.useUpdate(),i=P.useCallback(g=>{o(A.transformValue(g,p.type))},[o,p.type]),n=P.useMemo(()=>Array.isArray(s)?s:[],[s]),m=P.useCallback(()=>{const g=[...n,""];i(g),l()},[n,i,l]),b=P.useCallback(()=>{if(!p||!p.subProperties)return m();const g={};_.default(Object.values(p.subProperties),"index").forEach(({data:B})=>{if(!B.key)return;const z=B.locales?.[u]?.defaultValue??"";g[B.key]=z});const w=[...n,g];i(w),l()},[n,i,l,p,u,m]),d=P.useCallback(g=>{try{const v=JSON.parse(g);Array.isArray(v)?i(v):console.error("JSON解析结果不是数组")}catch(v){console.error("JSON解析错误:",v)}},[i]),y=P.useCallback(g=>{const v=n.filter((w,B)=>B!==g);i(v),l()},[n,i,l]),C=P.useCallback(g=>{if(g<=0)return;const v=[...n],w=v[g];v[g]=v[g-1],v[g-1]=w,i(v),l()},[n,i,l]),I=P.useCallback(g=>{if(g>=n.length-1)return;const v=[...n],w=v[g];v[g]=v[g+1],v[g+1]=w,i(v),l()},[n,i,l]),k=P.useCallback((g,v)=>{const w=[...n];w[g]=v,i(w)},[n,i]),S=p&&p.subProperties&&Object.keys(p.subProperties).length>0,T=P.useMemo(()=>[{field:"index",headerName:"#",width:40,align:"center",renderCell:({index:g})=>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:g+1})},{field:"content",headerName:"",renderCell:({row:g,index:v})=>j&&S?j({item:g,index:v,property:p,onChange:w=>k(v,w)}):e.jsx(r.TextField,{fullWidth:!0,size:"small",disabled:a,value:g,placeholder:h||`${c("item")} ${v+1}`,onChange:w=>k(v,w.target.value),...f})},{field:"actions",headerName:"",width:30,align:"center",renderCell:({index:g})=>e.jsxs(r.Stack,{direction:"column",spacing:.25,children:[e.jsx(ct,{disabled:a||g===0,onClick:()=>C(g)}),e.jsx(dt,{disabled:a||g===n.length-1,onClick:()=>I(g)}),e.jsx(at,{disabled:a,onClick:()=>y(g)})]})}],[j,S,p,k,h,c,a,f,y,C,I,n.length]);return S?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:T.map(g=>e.jsx(r.TableCell,{width:g.width,align:g.align||"left",sx:{fontWeight:"bold"},children:g.renderHeader?g.renderHeader():g.headerName},g.field))})}),e.jsx(r.TableBody,{children:n.map((g,v,w)=>e.jsx(r.TableRow,{sx:{borderBottom:v<w.length-1?"1px solid":"none",borderColor:"divider","&:hover":{backgroundColor:"action.hover"}},children:T.map(B=>e.jsx(r.TableCell,{width:B.width,align:B.align||"left",sx:{borderBottom:"none"},children:B.renderCell({row:g,index:v,onChange:z=>k(v,z)})},`${v}-${B.field}`))},v))})]})}):e.jsx(M.default,{style:{fontSize:12,height:x},children:c("maker.properties.arrayEmpty")}),e.jsx(r.Button,{fullWidth:!0,size:"small",variant:"outlined",disabled:a,startIcon:e.jsx($e.default,{}),onClick:b,children:c("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(re.CodeEditor,{keyId:p.id,locale:u,language:"json",value:JSON.stringify(n,null,2),onChange:g=>d(g||""),fullScreenOptions:{enableEscExit:!0,targetContainer:()=>document.getElementById("parameters-config-dialog")||null}},p.id)})]})}function pt({ref:t,showMarkdown:s,markdown:o,onMarkdownChange:a,showUploader:h,value:x,meta:p,onChange:j,...f}){const[c,u]=P.useState("");P.useEffect(()=>{u(x||"")},[x,u]);const l=async()=>{if(c!==x){const n=A.getImageAbsoluteUrl(c);if(!n){j(c,void 0);return}const m=await V.getImageSize(n).catch(()=>V.getVideoSize(n)).catch(()=>{});j(c,{...m,filename:c})}};se.useDebounce(()=>{c!==x&&j(c)},300,[c]),P.useImperativeHandle(t,()=>({submit:l}));const i={};return h&&(i.InputProps={sx:{pr:0},endAdornment:e.jsx(r.InputAdornment,{position:"end",sx:{mx:.5},children:e.jsx(V.UploaderButton,{onChange:async({response:n})=>{const m=n?.data?.filename,b=A.getImageAbsoluteUrl(m)||"";let d={};b&&(d=await V.getImageSize(b).catch(()=>V.getVideoSize(b)).catch(()=>{})),j(m,{...d,filename:m})}})})}),e.jsx(r.TextField,{size:"small",fullWidth:!0,...f,label:e.jsxs(r.Stack,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[f.label,s&&e.jsxs(e.Fragment,{children:[" (",e.jsx(r.FormControlLabel,{checked:o,label:e.jsx(r.Box,{component:Ie.Icon,icon:"tabler:markdown",sx:{verticalAlign:"middle"}}),labelPlacement:"start",control:e.jsx(r.Switch,{size:"small"}),sx:{ml:.25,pr:1},onChange:(n,m)=>a?.(m)}),")"]})]}),value:c,onChange:n=>u(n.target.value),...i,onKeyDown:n=>{n.keyCode!==229&&n.key==="Enter"&&l()},slotProps:{inputLabel:{shrink:!0,...f.InputLabelProps}}})}function xt({value:t,onChange:s,disableGradient:o=!1,...a}){const h=P.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(pt,{...a,value:t,onChange:s,InputProps:{endAdornment:e.jsx(r.InputAdornment,{position:"end",children:e.jsx(oe.ColorItem,{color:t??"",style:{width:"1.5rem",height:"1.5rem",padding:0},onClick:()=>{h.current?.open({value:t??""})}})})}}),e.jsx(oe.ConfigColorDialog,{ref:h,onSave:({value:x},p)=>{s(x),p()},disableGradient:o})]})}function mt({label:t,value:s,onChange:o,property:a,component:h,defaultLocale:x,allComponents:p,PropertyValueField:j,onUpload:f}){const{locale:c}=R.useLocaleContext(),u=P.useRef(null);if(!D.default(a.subProperties)){const i=_.default(Object.values(a.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:i.map((n,m)=>{const{data:b}=n,d=b.key??b.id,y=m===i.length-1;let C=null;try{s&&typeof s=="object"?C=s[d]:typeof s=="string"&&(C=(a.type==="yaml"?X.parse(s||""):JSON.parse(s||"{}"))[d])}catch{}C==null&&(b.locales&&c&&b.locales[c]?C=b.locales[c].defaultValue:b.locales&&x&&b.locales[x]&&(C=b.locales[x].defaultValue));const I=S=>{try{let T={};if(typeof s=="string")try{T=a.type==="yaml"?X.parse(s||""):JSON.parse(s||"{}")}catch{}else typeof s=="object"&&s!==null&&(T={...s});de.default(T,d,S);const g=A.transformValue(T,a.type);o?.(g)}catch(T){console.error("Error updating property:",T)}},k=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:k,top:0,height:16,width:0,borderLeft:"1px dashed",borderColor:"divider"}}),e.jsx(r.Box,{sx:{position:"absolute",left:k,top:16,width:12,height:0,borderTop:"1px dashed",borderColor:"divider"}}),!y&&e.jsx(r.Box,{sx:{position:"absolute",left:k,top:16,bottom:-8,width:0,borderLeft:"1px dashed",borderColor:"divider"}})]}),e.jsx(r.Box,{sx:{flexGrow:1},children:e.jsx(j,{component:h,property:b,value:C,onChange:I,size:"small",fullWidth:!0,defaultLocale:x,allComponents:p})})]},b.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(re.CodeEditor,{keyId:a.id,locale:c,language:a.type==="yaml"?"yaml":"json",value:typeof s=="string"?s:"",onChange:i=>{o?.(i)},onUpload:i=>{u.current=i,f&&f(i)},fullScreenOptions:{enableEscExit:!0,targetContainer:()=>document.getElementById("parameters-config-dialog")||null}},a.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})})})]})})}function ie(t){return!!t.shared}const ft={setActivatorNodeRef:()=>{},attributes:{},listeners:{}};function ue({disabled:t,list:s,renderItem:o,...a}){const h=_.default(Object.entries(s),([,m])=>m.index),x=h.map(([m])=>m),[p,j]=P.useState(null),[f,c]=P.useState(null),u=L.useSensors(L.useSensor(L.PointerSensor,{activationConstraint:{distance:8}})),l=m=>{const{active:b}=m,d=s[b.id];d&&(c(b.id),j(d.data))},i=()=>{},n=m=>{const{active:b,over:d}=m;if(c(null),j(null),!d||b.id===d.id)return;const y=b.id,C=d.id;if(s[y]&&s[C]){const I=()=>{const T=Object.entries(s).sort(([,B],[,z])=>B.index-z.index),g=T.findIndex(([B])=>B===y),v=T.findIndex(([B])=>B===C),[w]=T.splice(g,1);w&&T.splice(v,0,w),T.forEach(([,B],z)=>{B.index=z})},k=U.getYjsValue(s)?.doc;k?k.transact(()=>{I()}):I()}};return e.jsxs(L.DndContext,{sensors:u,collisionDetection:L.closestCorners,onDragStart:l,onDragOver:i,onDragEnd:n,children:[e.jsx(Q.SortableContext,{items:x,strategy:Q.verticalListSortingStrategy,children:e.jsx(r.Stack,{...a,children:h.map(([m,b],d)=>e.jsx(ht,{id:m,disabled:t,isDragging:f===m,children:({dragHandle:y})=>o(b.data,d,{isDragging:f===m,dragHandle:y,drag:null,drop:null,preview:null})},m))})}),e.jsx(L.DragOverlay,{children:p&&f?e.jsx(r.Box,{sx:{opacity:.8,backgroundColor:"background.paper",border:"1px solid",borderColor:"primary.main",borderRadius:1,boxShadow:2,maxWidth:400},children:o(p,0,{isDragging:!0,dragHandle:ft,drag:null,drop:null,preview:null})}):null})]})}function ht({id:t,disabled:s,isDragging:o,children:a}){const{attributes:h,listeners:x,setNodeRef:p,setActivatorNodeRef:j,transform:f,transition:c}=Q.useSortable({id:t,disabled:s}),u={transform:Je.CSS.Transform.toString(f),transition:c,opacity:o?.5:1};return e.jsx(r.Box,{ref:p,style:u,children:a({dragHandle:{setActivatorNodeRef:j,attributes:h??{},listeners:{...x??{}}}})})}function bt({disabled:t,isDragging:s,children:o,onDelete:a,onVisibilityChange:h,visible:x=!0,onSharedChange:p,shared:j=!1,actions:f,alwaysShowActions:c=!1,dragHandle:u}){const{t:l}=R.useLocaleContext(),i=u?.attributes??{},n=u?.listeners??{},m=u?.setActivatorNodeRef;return e.jsx(r.Box,{sx:{":hover .hover-visible":{maxWidth:"100%"},opacity:x?1:.5},children:e.jsxs(r.Box,{sx:{position:"relative"},children:[e.jsx(r.Box,{sx:{flex:1,borderRadius:.5,bgcolor:s?"action.hover":"background.paper",opacity:.9999},children:o}),!t&&e.jsx(r.Box,{className:c?"":"hover-visible",sx:{maxWidth:c?"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:b=>r.alpha(b.palette.grey[200],.9),borderRadius:1,p:.5,[`.${r.buttonClasses.root}`]:{minWidth:24,width:24,height:24,p:0}},children:[f,p&&e.jsx(r.Tooltip,{title:l(j?"disableSharing":"enableSharing"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:()=>p(!j),children:j?e.jsx(N.SyncRounded,{sx:{fontSize:"1.25rem",color:"primary.main"}}):e.jsx(N.SyncDisabledRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),h&&e.jsx(r.Tooltip,{title:l(x?"hideParameter":"showParameter"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:()=>h(!x),children:x?e.jsx(N.VisibilityOffRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}}):e.jsx(N.VisibilityRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),a&&e.jsx(r.Tooltip,{title:l("delete"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:a,children:e.jsx(N.DeleteOutlineRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),e.jsx(r.Tooltip,{title:l("dragSort"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{ref:m,...i,...n,children:e.jsx(N.DragIndicatorRounded,{sx:{color:"grey.500"}})})})]})})]})})}function gt(t){const s=["string","json","array","url","multiline"],o=["style","fontSize","color","content","type"];return!!(s.includes(t.type||"")&&!o.includes(t.key||""))}function jt(t,s,o){return t.locales&&t.locales[s]&&t.locales[s].name?t.locales[s].name:o&&t.locales&&t.locales[o]&&t.locales[o].name?t.locales[o].name:t.key?t.key:t.id}const pe=(t,s,o,a)=>{const h={};return _.default(Object.entries(t),([,p])=>p.index).forEach(([p,j])=>{const f=j.data;if(!f)return;const c=f.key||f.id,u=o?jt(f,o,a||""):c,l=s?.[f.id],i={key:c,isNeedGenerate:l?.isNeedGenerate??gt(f),describe:l?.describe??"",displayName:u};f.subProperties&&!D.default(f.subProperties)&&(i.subProperties=pe(f.subProperties,l?.subProperties,o,a)),h[f.id]=i}),h};function yt({open:t,onClose:s,onConfirm:o,component:a,initialConfig:h,locale:x,defaultLocale:p,title:j,loading:f=!1}){const{t:c}=R.useLocaleContext(),[u,l]=P.useState(null);P.useEffect(()=>{if(t&&a){const d={properties:{}};if(a.properties){const y=h?.properties;d.properties=pe(a.properties,y,x,p)}l(d)}},[t,a,h,x,p]);const i=()=>{s()},n=()=>{u&&(o(u),s())},m=(d,y,C)=>{if(!u||!d.length)return;const I=JSON.parse(JSON.stringify(u));let k=I.properties,S=null;for(let g=0;g<d.length-1;g++){const v=d[g];if(!v||!k[v])return;S=k;const w=k[v];w.subProperties||(w.subProperties={}),k=w.subProperties}const T=d[d.length-1];if(T){if("isNeedGenerate"in C){const g=C.isNeedGenerate,v={...y,...C};if(y.subProperties&&!D.default(y.subProperties)){const w=(B,z)=>{const q={};return Object.entries(B).forEach(([ye,W])=>{const Y={...W};z!==null&&(Y.isNeedGenerate=z),W.subProperties&&!D.default(W.subProperties)&&(Y.subProperties=w(W.subProperties,z!==null?z:null)),q[ye]=Y}),q};v.subProperties=w(y.subProperties,g===!1?!1:null)}if(d.length===1)I.properties[T]=v;else if(S&&d.length>=2){const w=d[d.length-2];w&&S[w]&&(S[w].subProperties||(S[w].subProperties={}),S[w].subProperties[T]=v)}}else if(d.length===1)I.properties[T]={...y,...C};else if(S&&d.length>=2){const g=d[d.length-2];g&&S[g]&&S[g].subProperties&&(S[g].subProperties[T]={...y,...C})}l(I)}},b=(d,y=[],C=!0)=>{if(!d||D.default(d))return e.jsx(M.default,{children:c("maker.properties.noProperties")});const I=_.default(Object.entries(d),([,k])=>k.displayName);return e.jsx(r.Stack,{spacing:1.5,children:I.map(([k,S],T)=>{const g=[...y,k],v=T===I.length-1,w=S.subProperties&&!D.default(S.subProperties),B=S.displayName||k,z=!C;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"}}),!v&&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:S.isNeedGenerate,disabled:z,onChange:q=>{m(g,S,{isNeedGenerate:q.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:c("maker.properties.llmPropertyDescribe"),value:S.describe,onChange:q=>{m(g,S,{describe:q.target.value})},disabled:!S.isNeedGenerate})]}),w&&e.jsx(r.Box,{sx:{ml:3},children:b(S.subProperties,g,S.isNeedGenerate&&C)})]})]})},k)})})};return e.jsxs(r.Dialog,{open:t,onClose:i,maxWidth:"lg",fullWidth:!0,children:[e.jsx(r.DialogTitle,{children:j||c("maker.properties.llmConfigTitle")}),e.jsx(r.DialogContent,{children:e.jsx(r.Box,{sx:{my:3},children:f?e.jsx(r.Typography,{children:c("maker.properties.loading")}):a?u?e.jsxs(r.Stack,{spacing:3,children:[e.jsx(r.Typography,{variant:"subtitle2",children:c("maker.properties.llmConfigInstructions")}),b(u.properties)]}):e.jsx(r.Typography,{children:c("maker.properties.loading")}):e.jsx(r.Typography,{color:"error",children:c("maker.properties.componentNotFound")})})}),e.jsxs(r.DialogActions,{children:[e.jsx(r.Button,{onClick:i,children:c("common.cancel")}),e.jsx(r.Button,{variant:"contained",onClick:n,disabled:!u||f,children:c("common.confirm")})]})]})}function vt({label:t,value:s,onChange:o}){const[a,h]=P.useState(!1);return e.jsxs(r.Stack,{sx:{gap:1},children:[e.jsx(r.TextField,{label:t,size:"small",value:s,onChange:x=>o?.(x.target.value),slotProps:{input:{sx:{pr:0},endAdornment:e.jsx(r.InputAdornment,{position:"end",children:e.jsx(V.UploaderButton,{onChange:({response:x})=>{const p=x?.data?.filename;p&&o?.(p)}})})}}}),s&&e.jsx(r.Box,{component:"img",src:A.getImageAbsoluteUrl(s),alt:t,onClick:()=>h(!0),sx:{maxWidth:100,maxHeight:100,width:"100%",objectFit:"contain",borderRadius:1,cursor:"pointer"}}),e.jsx(r.Dialog,{open:a,onClose:()=>h(!1),children:e.jsx(r.Box,{component:"img",sx:{objectFit:"contain"},src:A.getImageAbsoluteUrl(s),alt:t})})]})}function te(t,s=""){return it.default(t,(o,a,h)=>{const x=s?`${s}.${h}`:h;return rt.default(a)?Xe.default(o,te(a,x)):o[x]=a,o},{})}const Ct=[{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 K(t,s,o){return!t||!o?!1:Object.values(t).some(({data:a})=>a.id!==s&&a.key===o)}function H(t,s){return!t||!s?!1:t[s]?.data.visible??!0}function xe(t,s){return!t||!s?!1:t[s]?.data.shared??!1}function kt({componentId:t}){const{state:{components:s}}=A.useStore(),a=s[t]?.data;return a?e.jsx(r.Stack,{sx:{maxHeight:"100%",overflow:"auto"},children:e.jsx(r.Box,{sx:{p:2},children:e.jsx(Ke.ErrorBoundary,{FallbackComponent:lt,resetKeys:[t],children:e.jsx(St,{value:a,componentId:t})})})}):null}function St({value:t,componentId:s}){const{t:o}=R.useLocaleContext(),{localState:{currentLocale:a,customComponentPreviewerProperties:h},state:{config:{defaultLocale:x}},localActions:{setCustomComponentPreviewerProperties:p}}=A.useStore(),j=U.getYjsValue(t).doc,f=A.useAllComponents(),c=P.useMemo(()=>h?.[s]??{},[s,h]),u=t.renderer?.type||"react-component",l=u==="component-template",i=Ve.useReactive({componentId:s,propertiesValue:{...c}});return P.useEffect(()=>{i.componentId!==s&&(i.componentId=s,i.propertiesValue={...c})},[s,c,i]),P.useEffect(()=>{if(i.componentId!==s)return;const n=Object.fromEntries(Object.values(t.properties??{}).map(({data:m})=>[m.id,{value:i.propertiesValue[m.id]?.value??ze.parsePropertyValue(m,m.locales?.[a]?.defaultValue??m.locales?.[x]?.defaultValue,{locale:a,defaultLocale:x})}]));p(s,n)},[JSON.stringify(i.propertiesValue),s,i.componentId]),e.jsx(r.Stack,{sx:{height:"100%"},children:e.jsxs(r.Stack,{sx:{gap:2},children:[e.jsx(me,{config:t}),!l&&e.jsxs(e.Fragment,{children:[e.jsx(he,{config:t,currentLocale:a,defaultLocale:x,allComponents:f,onUpdateConfig:n=>{j.transact(()=>{n(t)})}}),e.jsxs(r.Stack,{direction:"row",sx:{gap:2,justifyContent:"space-between",alignItems:"center"},children:[e.jsx(r.Typography,{variant:"subtitle1",children:o("renderer")}),e.jsxs(r.TextField,{hiddenLabel:!0,size:"small",select:!0,value:u,disabled:l,onChange:n=>{j.transact(()=>{const m=n.target.value;t.renderer??={type:m},t.renderer.type=m})},slotProps:{select:{autoWidth:!0}},children:[e.jsx(r.MenuItem,{value:"component-template",disabled:!0,children:o("maker.components.componentTemplate")}),e.jsx(r.MenuItem,{value:"react-component",children:"React Component"}),e.jsx(r.MenuItem,{value:"component",children:"Custom Component"})]})]}),u==="component"&&e.jsx(Rt,{value:t}),u==="react-component"&&e.jsx(Ot,{value:t}),e.jsx(ne,{config:t,currentLocale:a,defaultLocale:x,allComponents:f,propertiesValue:i.propertiesValue,onChange:({value:n,id:m,path:b})=>{const d=[...b,"data"];if(!Ze.default(t,d)){ee.default.warning(o("cannotFindPropertyKey",{key:d.join(".")}));return}i.propertiesValue[m]={value:n.value}}})]}),l&&e.jsxs(r.Stack,{direction:"column",spacing:1,sx:{mt:1},children:[e.jsx(r.Typography,{variant:"subtitle1",children:o("renderer")}),e.jsx(r.TextField,{hiddenLabel:!0,size:"small",value:o("maker.components.componentTemplate"),disabled:!0})]})]})})}function me({config:t}){const{t:s}=R.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:o=>t.name=o.target.value}),e.jsx(r.TextField,{label:s("description"),size:"small",multiline:!0,minRows:2,maxRows:10,value:t.description||"",onChange:o=>t.description=o.target.value,slotProps:{input:{endAdornment:e.jsx(r.InputAdornment,{position:"end",sx:{mt:-1.5},children:e.jsx(Nt,{config:t})})},htmlInput:{maxLength:200}}}),e.jsx(r.Autocomplete,{size:"small",options:[],multiple:!0,freeSolo:!0,value:t.tags??[],onChange:(o,a)=>t.tags=a,renderInput:o=>e.jsx(r.TextField,{label:s("tags"),...o})}),e.jsx(vt,{label:s("previewImage"),value:t.previewImage||"",onChange:o=>t.previewImage=o})]})})}function fe({data:t,params:s,visible:o,shared:a,config:h,currentLocale:x,defaultLocale:p,allComponents:j,onUpdateConfig:f}){const{t:c}=R.useLocaleContext(),u=P.useMemo(()=>t.type==="json"||t.type==="yaml"||t.type==="array"?Tt:F,[t.type]);return e.jsx(bt,{preview:s.preview,drop:s.drop,drag:s.drag,isDragging:s.isDragging,dragHandle:s.dragHandle,onDelete:()=>{f(l=>{if(l.properties){const n=Object.entries(l.properties).sort(([,b],[,d])=>b.index-d.index);delete l.properties[t.id],n.filter(([b])=>b!==t.id).forEach(([,b],d)=>{b.index=d})}})},visible:o,onVisibilityChange:l=>{f(i=>{const n=i.properties[t.id].data;n.visible=l})},shared:a,onSharedChange:l=>{f(i=>{const n=i.properties[t.id].data;n.shared=l})},alwaysShowActions:!0,children:e.jsxs(r.Stack,{direction:"column",sx:{gap:2},children:[e.jsx(r.TextField,{label:c("key"),size:"small",required:!0,sx:{width:"calc(100% - 104px - 8px)",flex:1,"& .MuiOutlinedInput-root":{borderColor:t.key?K(h.properties,t.id,t.key)?"warning.main":void 0:"error.main"},"& .MuiFormLabel-root":{color:t.key?K(h.properties,t.id,t.key)?"warning.main":"text.secondary":"error.main"},"& .MuiFormLabel-root.Mui-focused":{color:t.key?K(h.properties,t.id,t.key)?"warning.main":"primary.main":"error.main"}},value:t.key||"",onChange:l=>{f(i=>{const n=i.properties[t.id].data;n.key=l.target.value.trim()})},slotProps:{input:{endAdornment:!t.key||t.key&&K(h.properties,t.id,t.key)?e.jsx(r.InputAdornment,{position:"end",sx:{width:16,ml:0},children:e.jsx(r.Tooltip,{title:t.key?c("duplicateKey"):c("requiredKey"),children:e.jsx(N.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:c("label"),size:"small",sx:{flex:1},value:(t.locales?.[x]?.name??t.locales?.[p]?.name)||"",onChange:l=>{f(i=>{const n=i.properties[t.id].data;n.locales??={},n.locales[x]??={},n.locales[x].name=l.target.value})}}),e.jsx(r.TextField,{label:c("type"),size:"small",select:!0,sx:{flex:1},value:t.type==="string"&&t.multiline?"multiline":t.type||"string",onChange:l=>{f(i=>{const n=i.properties[t.id].data;if(n.locales)for(const b of Object.keys(n.locales))n.locales[b].defaultValue=void 0;const m=l.target.value;m==="multiline"?(n.type="string",n.multiline=!0):(typeof n.multiline<"u"&&delete n.multiline,n.type=m)})},children:Ct.map(l=>e.jsx(r.MenuItem,{value:l.value,children:l.label},l.value))})]}),e.jsxs(r.Stack,{direction:"row",sx:{gap:1},children:[e.jsx(u,{allComponents:j,defaultLocale:p,component:h,property:t,label:c("defaultValue"),size:"small",fullWidth:!0,value:t.locales?.[x]?.defaultValue,onChange:(l,i)=>{f(n=>{const m=n.properties[t.id].data;if(i?.forceUpdateProperty){const b=te(m),d=te(l);Object.keys(d).forEach(y=>{b[y]||de.default(m,y,d[y])})}else m.locales??={},m.locales[x]??={},m.locales[x].defaultValue=l})}}),t.type==="custom"?e.jsx(r.Box,{children:e.jsx(wt,{property:t,allComponents:j})}):null]})]})})}function Pt(t,s){const[o,a]=P.useState(0);return P.useEffect(()=>{const x=setTimeout(()=>{if(t.current){let p=t.current.parentElement,j=0;for(;p;)p.classList.contains("property-container")&&j++,p=p.parentElement;a(j)}},100);return()=>clearTimeout(x)},[t,s]),o}function he({config:t,currentLocale:s,defaultLocale:o,allComponents:a,onUpdateConfig:h,useI18nEditor:x=!0}){const{t:p}=R.useLocaleContext(),j=E.usePopupState({variant:"dialog"}),f=t.properties&&_.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:p("properties")}),e.jsx(r.Box,{sx:{flex:1}}),x&&e.jsx(r.Button,{sx:{minWidth:32,minHeight:32,p:0},...E.bindTrigger(j),children:e.jsx(N.TranslateRounded,{fontSize:"small"})})]}),t.properties&&Object.keys(t.properties).length>0?e.jsx(ue,{component:r.Stack,gap:2,list:t.properties,renderItem:(c,u,l)=>{const i=H(t.properties,c.id),n=xe(t.properties,c.id);return e.jsx(r.Paper,{elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:i?"1px solid":"1px dashed",borderColor:"divider"},children:e.jsx(r.Stack,{sx:{gap:2},children:e.jsx(fe,{data:c,params:l,visible:i,shared:n,config:t,currentLocale:s,defaultLocale:o,allComponents:a,onUpdateConfig:h})})},c.id)}}):e.jsx(M.default,{style:{fontSize:12},children:p("maker.properties.noProperties")}),e.jsx(r.Button,{fullWidth:!0,variant:"outlined",className:"ignore-style-override",onClick:()=>{h(c=>{const u=ce.nextId();c.properties??={},c.properties[u]??={index:f?.length||0,data:{id:u,shared:!1}}})},startIcon:e.jsx(N.AddRounded,{}),children:p("addObject",{object:p("property")})}),x&&e.jsx(be,{...E.bindDialog(j),component:t})]})})}function wt({property:t,allComponents:s}){const o=E.usePopupState({variant:"popper"});return e.jsxs(e.Fragment,{children:[e.jsx(r.Button,{sx:{minWidth:0},...E.bindTrigger(o),children:e.jsx(N.SettingsRounded,{fontSize:"small"})}),e.jsx(r.Popper,{...E.bindPopper(o),children:e.jsx(ae.ClickAwayListener,{onClickAway:o.close,children:e.jsx(r.Paper,{children:e.jsx(r.Box,{sx:{width:500,p:2},children:e.jsx(G,{value:t.componentId,onChange:(a,h)=>t.componentId=h,allComponents:s})})})})})]})}function It({value:t,valueImmutable:s,onChange:o,defaultLocale:a,allComponents:h}){const[x,p]=P.useState(!1),{t:j,locale:f}=R.useLocaleContext(),c=typeof t?.componentId=="string"?h[t.componentId]?.data:void 0;return c?e.jsxs(r.Box,{sx:{width:"100%",position:"relative"},children:[e.jsx(r.IconButton,{sx:{minWidth:0},disabled:!c,size:"small",onClick:()=>p(!x),color:x?"primary":"default",children:e.jsx(N.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(ne,{config:c,currentLocale:f,defaultLocale:a,allComponents:h,propertiesValue:t?.properties,onChange:({id:u,value:l})=>{const i=Z.default(l.value),n=JSON.parse(JSON.stringify(t));n?.componentId&&(s?o?.({...n,properties:{...n.properties,[u]:{value:i}}}):(n.properties=n.properties??{},n.properties[u]={value:i},o?.(n)))}})}),e.jsx(r.Button,{size:"small",onClick:()=>p(!1),sx:{mt:1},children:j("close")})]})})]}):null}function be({type:t="properties",component:s,...o}){const{t:a}=R.useLocaleContext(),{state:{components:h,supportedLocales:x,config:{defaultLocale:p}}}=A.useStore(),j=A.useAllComponents(),f=U.getYjsValue(s).doc,c=t==="properties"?s.properties:t==="parameters"&&s.renderer?.type==="component"?h[s.renderer.componentId]?.data.properties:void 0,u=s.renderer?.type==="component"?s:void 0;return e.jsxs(r.Dialog,{...o,fullWidth:!0,maxWidth:"lg",children:[e.jsx(r.DialogTitle,{children:a("i18nEditorTitle")}),e.jsx(r.DialogContent,{children:c&&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:l,name:i})=>e.jsx(r.TableCell,{children:e.jsxs(r.Typography,{sx:{color:"text.primary"},children:[i,p===l&&e.jsx(N.StarRounded,{sx:{fontSize:12}})]})},l))})}),e.jsx(r.TableBody,{children:_.default(Object.values(c),"index").map(({data:l})=>e.jsx(r.TableRow,{children:x.map(({locale:i})=>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:l.key||"",onChange:n=>{f.transact(()=>{l.key=n.target.value.trim()})}}),e.jsx(r.TextField,{size:"small",label:a("label"),value:(l.locales?.[i]?.name??l.locales?.[p]?.name)||"",onChange:n=>{f.transact(()=>{l.locales??={},l.locales[i]??={},l.locales[i].name=n.target.value})}}),e.jsx(r.Box,{children:e.jsx(F,{allComponents:j,defaultLocale:p,component:s,property:l,size:"small",fullWidth:!0,label:"Default Value",valueImmutable:$.default(l.locales?.[i]?.defaultValue),value:l.locales?.[i]?.defaultValue??l.locales?.[p]?.defaultValue,onChange:n=>{f.transact(()=>{l.locales??={},l.locales[i]??={},l.locales[i].defaultValue=n})}})})]}):t==="parameters"&&u?e.jsx(r.Box,{children:e.jsx(F,{allComponents:j,defaultLocale:p,component:s,property:l,size:"small",fullWidth:!0,valueImmutable:$.default(u.renderer.properties?.[l.id]?.locales?.[i]?.value),value:u.renderer.properties?.[l.id]?.locales?.[i]?.value??u.renderer.properties?.[l.id]?.locales?.[p]?.value??l.locales?.[i]?.defaultValue??l.locales?.[p]?.defaultValue,onChange:n=>{f.transact(()=>{u.renderer.properties??={},u.renderer.properties[l.id]??={},u.renderer.properties[l.id].locales??={},u.renderer.properties[l.id].locales[i]??={},u.renderer.properties[l.id].locales[i].value=n})}})}):null},l.id)},i))},l.id))})]})})}),e.jsx(r.DialogActions,{children:e.jsx(r.Button,{onClick:l=>o.onClose?.(l,"escapeKeyDown"),children:a("close")})})]})}const le=(t,s)=>o=>{const a=[o.palette.info.main,o.palette.primary.main,o.palette.secondary.main,o.palette.success.main,o.palette.warning.main],h=Math.min(a.length-1,t),x=a[h],p=r.alpha(x,.5),j=r.alpha(x,1);return{borderColor:`${p} !important`,borderLeft:"3px solid !important",borderLeftColor:p,color:j,...s}};function Tt({property:t,onChange:s,defaultLocale:o,allComponents:a}){const{t:h,locale:x}=R.useLocaleContext(),p=P.useRef(null),j=Pt(p,t),f=P.useCallback(()=>{if(!(t.type!=="json"&&t.type!=="yaml"&&t.type!=="array")&&t.subProperties)try{let c={};_.default(Object.values(t.subProperties),"index").filter(i=>i.data.visible!==!1&&i.data.key).forEach(({data:i})=>{if(!i.key)return;let n=i.locales?.[x]?.defaultValue??i.locales?.[o]?.defaultValue;if(i.type==="number")n=Number(n);else if(i.type==="boolean")n=n===!0||n==="true";else if((i.type==="json"||i.type==="yaml")&&typeof n=="string")try{i.type==="json"?n=JSON.parse(n):n=X.parse(n)}catch(m){console.error("Error parsing nested value",n,m),n={}}c[i.key]=n}),t.type==="array"&&!Array.isArray(c)&&(c=D.default(c)?[]:[c]);const l=A.transformValue(c,t.type);s?.(l)}catch(c){console.error("Error converting structure to text:",c)}},[t,x,o,s]);return t.type!=="json"&&t.type!=="yaml"&&t.type!=="array"?null:e.jsxs(r.Stack,{direction:"column",ref:p,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:h("maker.properties.subProperties")})}),t.subProperties&&Object.keys(t.subProperties).length>0?e.jsx(ue,{component:r.Stack,gap:2,list:t.subProperties,renderItem:(c,u,l)=>{const i=c.visible!==!1,n=c.shared??!1;return e.jsx(r.Paper,{elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:i?"1px solid":"1px dashed","&":le(j)},children:e.jsx(r.Stack,{sx:{gap:2},children:e.jsx(fe,{data:c,params:l,visible:i,shared:n,config:{properties:t.subProperties},currentLocale:x,defaultLocale:o,allComponents:a,onUpdateConfig:m=>{try{const b={properties:t.subProperties||{}};m(b);const d={...t,subProperties:b.properties};s?.(d,{forceUpdateProperty:!0}),f()}catch(b){console.error("Error updating property:",b)}}})})},c.id)}}):e.jsx(M.default,{style:{fontSize:12,height:100},children:h("maker.properties.noSubProperties")}),e.jsx(r.Button,{fullWidth:!0,variant:"outlined",className:"ignore-style-override",size:"small",startIcon:e.jsx(N.AddRounded,{}),onClick:()=>{try{const c=t.subProperties||{},u=ce.nextId(),i={index:Object.values(c).length,data:{id:u,key:"",type:"string",visible:!0,shared:!1,locales:{[x]:{name:"",defaultValue:""}},subProperties:{}}},n={...t,subProperties:{...c,[u]:i}};s?.(n,{forceUpdateProperty:!0}),f()}catch(c){console.error("Error adding property:",c)}},sx:{"&":le(j,{})},children:h("maker.properties.addSubProperty")})]})}function F({component:t,property:s,value:o,onChange:a,valueImmutable:h,defaultLocale:x,allComponents:p,...j}){const{locale:f}=R.useLocaleContext(),c=V.useUploader(),u=P.useRef(null),l=()=>{const n=c?.current?.getUploader();n?.open(),u.current&&n.onceUploadSuccess(({response:m})=>{let b=m?.data?.filename||"";b&&(b=`mediakit://${b}`,o&&!o.includes("mediakit://")&&(b+=" # please use < import { getMediaKitAbsoluteUrl } from '@blocklet/pages-kit/builtin/utils' > to get the full address")),u.current?.(b)})},i=j.label??(s.locales?.[f]?.name||s.locales?.[x]?.name||s.key||s.id);if(s.type==="number")return e.jsx(Bt,{...j,label:i,NumberProps:{value:["number","string"].includes(typeof o)?o:null,onChange:(n,m)=>a?.(m)}});if(s.type==="decimal")return e.jsx(r.TextField,{...j,label:i,type:"text",value:o??"",onChange:n=>{const m=n.target.value;if(m===""||m==="-"){a?.(m);return}if(/^-?(?!.*\..*\.)[0-9]*(\.[0-9]{0,9})?$/.test(m)){let d=m;/^-?[1-9]+[0-9]*(\.[0-9]{1,9})?$/.test(d)&&(d=Number(d)),a?.(d)}}});if(s.type==="boolean")return e.jsx(r.FormControlLabel,{label:i,labelPlacement:"start",control:e.jsx(r.Switch,{checked:o===!0,onChange:(n,m)=>a?.(m)})});if(s.type==="color")return e.jsx(xt,{label:i,value:o,onChange:n=>{a?.(n)}});if(s.type==="json"||s.type==="yaml")return e.jsx(mt,{label:i,value:o,onChange:n=>{a?.(n)},property:s,component:t,defaultLocale:x,allComponents:p,PropertyValueField:F,onUpload:n=>{u.current=n,l()}});if(s.type==="custom"){const n=p[s.componentId]?.data;return n?e.jsx(r.Box,{sx:{width:"100%"},children:e.jsx(J.CustomComponentRenderer,{componentId:n.id,props:{label:i,value:o,onChange:a},locale:f,dev:{mode:"draft",components:p,defaultLocale:x}})}):e.jsx(r.TextField,{...j,label:i,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(G,{allComponents:p,label:i,value:o?.componentId,onChange:(n,m)=>{h||!o?a?.({...o&&JSON.parse(JSON.stringify(o)),componentId:m}):typeof o=="object"&&(o.componentId=m,a?.({...o&&JSON.parse(JSON.stringify(o)),componentId:m}))}}),o?.componentId&&e.jsx(It,{value:o,valueImmutable:h,onChange:a,defaultLocale:x,allComponents:p})]});if(!s.type||["string","url","multiline"].includes(s.type)){let n=s.type==="string"?s.multiline:void 0;s.type==="multiline"&&(n=!0);const m=s.type==="url"?o?.url:o;return e.jsx(r.TextField,{...j,label:i,value:typeof m=="string"?m:"",multiline:n,minRows:n?2:void 0,maxRows:n?10:void 0,onChange:b=>a?.(s.type==="url"?{...o,url:b.target.value,mediaKitUrl:b.target.value}:b.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:b})=>{const d=b?.data?.url||b?.data?.fileUrl;let y;d&&(y=await V.getImageSize(d).catch(()=>V.getVideoSize(d)).catch(()=>{}));let C=b?.data?.filename||"";C&&(C=`mediakit://${C}`),a?.({url:d,mediaKitUrl:C,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(N.InfoRounded,{sx:{cursor:"default",mr:1},fontSize:"small"})})]})}:void 0}})}return s.type==="array"?e.jsx(ut,{label:i,value:Array.isArray(o)?o:[],onChange:n=>a?.(n),property:s,renderItem:({item:n,index:m,onChange:b})=>s.subProperties&&Object.keys(s.subProperties).length>0?e.jsx(r.Stack,{sx:{gap:1,width:"100%"},children:_.default(Object.values(s.subProperties),"index").filter(d=>d.data.visible!==!1).map(({data:d})=>d.key?e.jsx(F,{component:t,property:d,value:n[d.key],onChange:y=>{const C={...n,[d.key]:y};b(C)},size:"small",fullWidth:!0,defaultLocale:x,allComponents:p},d.id):null)},m):e.jsx(r.TextField,{size:j.size,fullWidth:!0,value:n,onChange:d=>b(d.target.value)})}):(console.error("Unsupported property type",s.type),null)}function Bt({NumberProps:t,...s}){const{getInputProps:o}=ae.unstable_useNumberInput(t),a=o();return e.jsx(r.TextField,{...s,slotProps:{htmlInput:a}})}const ge=`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("@mui/material"),V=require("./chunks/state-BdtFHk36.js"),ve=require("@arcblock/ux/lib/Empty"),R=require("@arcblock/ux/lib/Locale/context"),re=require("@blocklet/code-editor"),Ce=require("@mui/icons-material/AddRounded"),Se=require("@mui/icons-material/ArrowDownward"),ke=require("@mui/icons-material/ArrowUpward"),Pe=require("@mui/icons-material/DeleteOutline"),we=require("lodash/sortBy"),P=require("react"),se=require("react-use"),oe=require("@blocklet/pages-kit/builtin/color-picker"),z=require("@blocklet/pages-kit/builtin/uploader"),Ie=require("@iconify-icon/react"),Te=require("lodash/isEmpty"),Be=require("lodash/set"),Oe=require("yaml"),Re=require("lodash/cloneDeep"),Ne=require("@arcblock/ux/lib/Toast"),J=require("@blocklet/pages-kit/components"),Ae=require("@blocklet/pages-kit/utils/property"),ae=require("@mui/base"),N=require("@mui/icons-material"),U=require("@syncedstore/core"),ze=require("ahooks"),Ve=require("lodash/assign"),_e=require("lodash/get"),Ee=require("lodash/has"),De=require("lodash/isEqual"),Fe=require("lodash/isNil"),Le=require("lodash/isObject"),qe=require("lodash/keyBy"),Ue=require("lodash/omit"),Me=require("lodash/pick"),We=require("lodash/reduce"),E=require("material-ui-popup-state/hooks"),Ke=require("react-error-boundary"),q=require("@dnd-kit/core"),Q=require("@dnd-kit/sortable"),Je=require("@dnd-kit/utilities"),ce=require("@blocklet/pages-kit/utils/common"),O=t=>t&&t.__esModule?t:{default:t};function He(t){if(t&&t.__esModule)return t;const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const l=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(s,o,l.get?l:{enumerable:!0,get:()=>t[o]})}}return s.default=t,Object.freeze(s)}const M=O(ve),$e=O(Ce),Ge=O(Se),Ye=O(ke),Qe=O(Pe),_=O(we),D=O(Te),de=O(Be),X=He(Oe),Z=O(Re),ee=O(Ne),Xe=O(Ve),Ze=O(_e),et=O(Ee),tt=O(De),$=O(Fe),rt=O(Le),st=O(qe),nt=O(Ue),ot=O(Me),it=O(We);function lt({error:t}){return e.jsx(r.Box,{children:e.jsx(r.Alert,{severity:"error",children:t.message})})}function at({onClick:t,disabled:s,sx:o,...l}){return e.jsx(r.IconButton,{size:"small",color:"warning",variant:"outlined",disabled:s,onClick:t,...l,children:e.jsx(Qe.default,{fontSize:"small"})})}function ct({onClick:t,disabled:s,sx:o,...l}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...l,children:e.jsx(Ye.default,{fontSize:"small"})})}function dt({onClick:t,disabled:s,sx:o,...l}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...l,children:e.jsx(Ge.default,{fontSize:"small"})})}function ut({label:t,value:s,onChange:o,disabled:l=!1,itemLabel:f="",emptyHeight:p=40,property:u,renderItem:j,...m}){const{t:c,locale:d}=R.useLocaleContext(),a=se.useUpdate(),i=P.useCallback(b=>{o(V.transformValue(b,u.type))},[o,u.type]),n=P.useMemo(()=>Array.isArray(s)?s:[],[s]),x=P.useCallback(()=>{const b=[...n,""];i(b),a()},[n,i,a]),g=P.useCallback(()=>{if(!u||!u.subProperties)return x();const b={};_.default(Object.values(u.subProperties),"index").forEach(({data:B})=>{if(!B.key)return;const A=B.locales?.[d]?.defaultValue??"";b[B.key]=A});const w=[...n,b];i(w),a()},[n,i,a,u,d,x]),h=P.useCallback(b=>{try{const v=JSON.parse(b);Array.isArray(v)?i(v):console.error("JSON解析结果不是数组")}catch(v){console.error("JSON解析错误:",v)}},[i]),S=P.useCallback(b=>{const v=n.filter((w,B)=>B!==b);i(v),a()},[n,i,a]),y=P.useCallback(b=>{if(b<=0)return;const v=[...n],w=v[b];v[b]=v[b-1],v[b-1]=w,i(v),a()},[n,i,a]),I=P.useCallback(b=>{if(b>=n.length-1)return;const v=[...n],w=v[b];v[b]=v[b+1],v[b+1]=w,i(v),a()},[n,i,a]),T=P.useCallback((b,v)=>{const w=[...n];w[b]=v,i(w)},[n,i]),C=u&&u.subProperties&&Object.keys(u.subProperties).length>0,k=P.useMemo(()=>[{field:"index",headerName:"#",width:40,align:"center",renderCell:({index:b})=>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:b+1})},{field:"content",headerName:"",renderCell:({row:b,index:v})=>j&&C?j({item:b,index:v,property:u,onChange:w=>T(v,w)}):e.jsx(r.TextField,{fullWidth:!0,size:"small",disabled:l,value:b,placeholder:f||`${c("item")} ${v+1}`,onChange:w=>T(v,w.target.value),...m})},{field:"actions",headerName:"",width:30,align:"center",renderCell:({index:b})=>e.jsxs(r.Stack,{direction:"column",spacing:.25,children:[e.jsx(ct,{disabled:l||b===0,onClick:()=>y(b)}),e.jsx(dt,{disabled:l||b===n.length-1,onClick:()=>I(b)}),e.jsx(at,{disabled:l,onClick:()=>S(b)})]})}],[j,C,u,T,f,c,l,m,S,y,I,n.length]);return C?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:k.map(b=>e.jsx(r.TableCell,{width:b.width,align:b.align||"left",sx:{fontWeight:"bold"},children:b.renderHeader?b.renderHeader():b.headerName},b.field))})}),e.jsx(r.TableBody,{children:n.map((b,v,w)=>e.jsx(r.TableRow,{sx:{borderBottom:v<w.length-1?"1px solid":"none",borderColor:"divider","&:hover":{backgroundColor:"action.hover"}},children:k.map(B=>e.jsx(r.TableCell,{width:B.width,align:B.align||"left",sx:{borderBottom:"none"},children:B.renderCell({row:b,index:v,onChange:A=>T(v,A)})},`${v}-${B.field}`))},v))})]})}):e.jsx(M.default,{style:{fontSize:12,height:p},children:c("maker.properties.arrayEmpty")}),e.jsx(r.Button,{fullWidth:!0,size:"small",variant:"outlined",disabled:l,startIcon:e.jsx($e.default,{}),onClick:g,children:c("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(re.CodeEditor,{keyId:u.id,locale:d,language:"json",value:JSON.stringify(n,null,2),onChange:b=>h(b||""),fullScreenOptions:{enableEscExit:!0,targetContainer:()=>document.getElementById("parameters-config-dialog")||null}},u.id)})]})}function pt({ref:t,showMarkdown:s,markdown:o,onMarkdownChange:l,showUploader:f,value:p,meta:u,onChange:j,...m}){const[c,d]=P.useState("");P.useEffect(()=>{d(p||"")},[p,d]);const a=async()=>{if(c!==p){const n=V.getImageAbsoluteUrl(c);if(!n){j(c,void 0);return}const x=await z.getImageSize(n).catch(()=>z.getVideoSize(n)).catch(()=>{});j(c,{...x,filename:c})}};se.useDebounce(()=>{c!==p&&j(c)},300,[c]),P.useImperativeHandle(t,()=>({submit:a}));const i={};return f&&(i.InputProps={sx:{pr:0},endAdornment:e.jsx(r.InputAdornment,{position:"end",sx:{mx:.5},children:e.jsx(z.UploaderButton,{onChange:async({response:n})=>{const x=n?.data?.filename,g=V.getImageAbsoluteUrl(x)||"";let h={};g&&(h=await z.getImageSize(g).catch(()=>z.getVideoSize(g)).catch(()=>{})),j(x,{...h,filename:x})}})})}),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:o,label:e.jsx(r.Box,{component:Ie.Icon,icon:"tabler:markdown",sx:{verticalAlign:"middle"}}),labelPlacement:"start",control:e.jsx(r.Switch,{size:"small"}),sx:{ml:.25,pr:1},onChange:(n,x)=>l?.(x)}),")"]})]}),value:c,onChange:n=>d(n.target.value),...i,onKeyDown:n=>{n.keyCode!==229&&n.key==="Enter"&&a()},slotProps:{inputLabel:{shrink:!0,...m.InputLabelProps}}})}function xt({value:t,onChange:s,disableGradient:o=!1,...l}){const f=P.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(pt,{...l,value:t,onChange:s,InputProps:{endAdornment:e.jsx(r.InputAdornment,{position:"end",children:e.jsx(oe.ColorItem,{color:t??"",style:{width:"1.5rem",height:"1.5rem",padding:0},onClick:()=>{f.current?.open({value:t??""})}})})}}),e.jsx(oe.ConfigColorDialog,{ref:f,onSave:({value:p},u)=>{s(p),u()},disableGradient:o})]})}function mt({label:t,value:s,onChange:o,property:l,component:f,defaultLocale:p,allComponents:u,PropertyValueField:j,onUpload:m}){const{locale:c}=R.useLocaleContext(),d=P.useRef(null);if(!D.default(l.subProperties)){const i=_.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:i.map((n,x)=>{const{data:g}=n,h=g.key??g.id,S=x===i.length-1;let y=null;try{s&&typeof s=="object"?y=s[h]:typeof s=="string"&&(y=(l.type==="yaml"?X.parse(s||""):JSON.parse(s||"{}"))[h])}catch{}y==null&&(g.locales&&c&&g.locales[c]?y=g.locales[c].defaultValue:g.locales&&p&&g.locales[p]&&(y=g.locales[p].defaultValue));const I=C=>{try{let k={};if(typeof s=="string")try{k=l.type==="yaml"?X.parse(s||""):JSON.parse(s||"{}")}catch{}else typeof s=="object"&&s!==null&&(k={...s});de.default(k,h,C);const b=V.transformValue(k,l.type);o?.(b)}catch(k){console.error("Error updating property:",k)}},T=8;return e.jsxs(r.Box,{sx:{mb:S?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:T,top:0,height:16,width:0,borderLeft:"1px dashed",borderColor:"divider"}}),e.jsx(r.Box,{sx:{position:"absolute",left:T,top:16,width:12,height:0,borderTop:"1px dashed",borderColor:"divider"}}),!S&&e.jsx(r.Box,{sx:{position:"absolute",left:T,top:16,bottom:-8,width:0,borderLeft:"1px dashed",borderColor:"divider"}})]}),e.jsx(r.Box,{sx:{flexGrow:1},children:e.jsx(j,{component:f,property:g,value:y,onChange:I,size:"small",fullWidth:!0,defaultLocale:p,allComponents:u})})]},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(re.CodeEditor,{keyId:l.id,locale:c,language:l.type==="yaml"?"yaml":"json",value:typeof s=="string"?s:"",onChange:i=>{o?.(i)},onUpload:i=>{d.current=i,m&&m(i)},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})})})]})})}function ie(t){return!!t.shared}const ft={setActivatorNodeRef:()=>{},attributes:{},listeners:{}};function ue({disabled:t,list:s,renderItem:o,...l}){const f=_.default(Object.entries(s),([,x])=>x.index),p=f.map(([x])=>x),[u,j]=P.useState(null),[m,c]=P.useState(null),d=q.useSensors(q.useSensor(q.PointerSensor,{activationConstraint:{distance:8}})),a=x=>{const{active:g}=x,h=s[g.id];h&&(c(g.id),j(h.data))},i=()=>{},n=x=>{const{active:g,over:h}=x;if(c(null),j(null),!h||g.id===h.id)return;const S=g.id,y=h.id;if(s[S]&&s[y]){const I=()=>{const k=Object.entries(s).sort(([,B],[,A])=>B.index-A.index),b=k.findIndex(([B])=>B===S),v=k.findIndex(([B])=>B===y),[w]=k.splice(b,1);w&&k.splice(v,0,w),k.forEach(([,B],A)=>{B.index=A})},T=U.getYjsValue(s)?.doc;T?T.transact(()=>{I()}):I()}};return e.jsxs(q.DndContext,{sensors:d,collisionDetection:q.closestCorners,onDragStart:a,onDragOver:i,onDragEnd:n,children:[e.jsx(Q.SortableContext,{items:p,strategy:Q.verticalListSortingStrategy,children:e.jsx(r.Stack,{...l,children:f.map(([x,g],h)=>e.jsx(ht,{id:x,disabled:t,isDragging:m===x,children:({dragHandle:S})=>o(g.data,h,{isDragging:m===x,dragHandle:S,drag:null,drop:null,preview:null})},x))})}),e.jsx(q.DragOverlay,{children:u&&m?e.jsx(r.Box,{sx:{opacity:.8,backgroundColor:"background.paper",border:"1px solid",borderColor:"primary.main",borderRadius:1,boxShadow:2,maxWidth:400},children:o(u,0,{isDragging:!0,dragHandle:ft,drag:null,drop:null,preview:null})}):null})]})}function ht({id:t,disabled:s,isDragging:o,children:l}){const{attributes:f,listeners:p,setNodeRef:u,setActivatorNodeRef:j,transform:m,transition:c}=Q.useSortable({id:t,disabled:s}),d={transform:Je.CSS.Transform.toString(m),transition:c,opacity:o?.5:1};return e.jsx(r.Box,{ref:u,style:d,children:l({dragHandle:{setActivatorNodeRef:j,attributes:f??{},listeners:{...p??{}}}})})}function bt({disabled:t,isDragging:s,children:o,onDelete:l,onVisibilityChange:f,visible:p=!0,onSharedChange:u,shared:j=!1,actions:m,alwaysShowActions:c=!1,dragHandle:d}){const{t:a}=R.useLocaleContext(),i=d?.attributes??{},n=d?.listeners??{},x=d?.setActivatorNodeRef;return e.jsx(r.Box,{sx:{":hover .hover-visible":{maxWidth:"100%"},opacity:p?1:.5},children:e.jsxs(r.Box,{sx:{position:"relative"},children:[e.jsx(r.Box,{sx:{flex:1,borderRadius:.5,bgcolor:s?"action.hover":"background.paper",opacity:.9999},children:o}),!t&&e.jsx(r.Box,{className:c?"":"hover-visible",sx:{maxWidth:c?"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:g=>r.alpha(g.palette.grey[200],.9),borderRadius:1,p:.5,[`.${r.buttonClasses.root}`]:{minWidth:24,width:24,height:24,p:0}},children:[m,u&&e.jsx(r.Tooltip,{title:a(j?"disableSharing":"enableSharing"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:()=>u(!j),children:j?e.jsx(N.SyncRounded,{sx:{fontSize:"1.25rem",color:"primary.main"}}):e.jsx(N.SyncDisabledRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),f&&e.jsx(r.Tooltip,{title:a(p?"hideParameter":"showParameter"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:()=>f(!p),children:p?e.jsx(N.VisibilityOffRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}}):e.jsx(N.VisibilityRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),l&&e.jsx(r.Tooltip,{title:a("delete"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:l,children:e.jsx(N.DeleteOutlineRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),e.jsx(r.Tooltip,{title:a("dragSort"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{ref:x,...i,...n,children:e.jsx(N.DragIndicatorRounded,{sx:{color:"grey.500"}})})})]})})]})})}function gt(t){const s=["string","json","array","url","multiline"],o=["style","fontSize","color","content","type"];return!!(s.includes(t.type||"")&&!o.includes(t.key||""))}function jt(t,s,o){return t.locales&&t.locales[s]&&t.locales[s].name?t.locales[s].name:o&&t.locales&&t.locales[o]&&t.locales[o].name?t.locales[o].name:t.key?t.key:t.id}const pe=(t,s,o,l)=>{const f={};return _.default(Object.entries(t),([,u])=>u.index).forEach(([u,j])=>{const m=j.data;if(!m)return;const c=m.key||m.id,d=o?jt(m,o,l||""):c,a=s?.[m.id],i={key:c,isNeedGenerate:a?.isNeedGenerate??gt(m),describe:a?.describe??"",displayName:d};m.subProperties&&!D.default(m.subProperties)&&(i.subProperties=pe(m.subProperties,a?.subProperties,o,l)),f[m.id]=i}),f};function yt({open:t,onClose:s,onConfirm:o,component:l,initialConfig:f,locale:p,defaultLocale:u,title:j,loading:m=!1}){const{t:c}=R.useLocaleContext(),[d,a]=P.useState(null);P.useEffect(()=>{if(t&&l){const h={properties:{}};if(l.properties){const S=f?.properties;h.properties=pe(l.properties,S,p,u)}a(h)}},[t,l,f,p,u]);const i=()=>{s()},n=()=>{d&&(o(d),s())},x=(h,S,y)=>{if(!d||!h.length)return;const I=JSON.parse(JSON.stringify(d));let T=I.properties,C=null;for(let b=0;b<h.length-1;b++){const v=h[b];if(!v||!T[v])return;C=T;const w=T[v];w.subProperties||(w.subProperties={}),T=w.subProperties}const k=h[h.length-1];if(k){if("isNeedGenerate"in y){const b=y.isNeedGenerate,v={...S,...y};if(S.subProperties&&!D.default(S.subProperties)){const w=(B,A)=>{const L={};return Object.entries(B).forEach(([ye,W])=>{const Y={...W};A!==null&&(Y.isNeedGenerate=A),W.subProperties&&!D.default(W.subProperties)&&(Y.subProperties=w(W.subProperties,A!==null?A:null)),L[ye]=Y}),L};v.subProperties=w(S.subProperties,b===!1?!1:null)}if(h.length===1)I.properties[k]=v;else if(C&&h.length>=2){const w=h[h.length-2];w&&C[w]&&(C[w].subProperties||(C[w].subProperties={}),C[w].subProperties[k]=v)}}else if(h.length===1)I.properties[k]={...S,...y};else if(C&&h.length>=2){const b=h[h.length-2];b&&C[b]&&C[b].subProperties&&(C[b].subProperties[k]={...S,...y})}a(I)}},g=(h,S=[],y=!0)=>{if(!h||D.default(h))return e.jsx(M.default,{children:c("maker.properties.noProperties")});const I=_.default(Object.entries(h),([,T])=>T.displayName);return e.jsx(r.Stack,{spacing:1.5,children:I.map(([T,C],k)=>{const b=[...S,T],v=k===I.length-1,w=C.subProperties&&!D.default(C.subProperties),B=C.displayName||T,A=!y;return e.jsx(r.Box,{sx:{position:"relative"},children:e.jsxs(r.Stack,{direction:"row",children:[S.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"}}),!v&&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:C.isNeedGenerate,disabled:A,onChange:L=>{x(b,C,{isNeedGenerate:L.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:c("maker.properties.llmPropertyDescribe"),value:C.describe,onChange:L=>{x(b,C,{describe:L.target.value})},disabled:!C.isNeedGenerate})]}),w&&e.jsx(r.Box,{sx:{ml:3},children:g(C.subProperties,b,C.isNeedGenerate&&y)})]})]})},T)})})};return e.jsxs(r.Dialog,{open:t,onClose:i,maxWidth:"lg",fullWidth:!0,children:[e.jsx(r.DialogTitle,{children:j||c("maker.properties.llmConfigTitle")}),e.jsx(r.DialogContent,{children:e.jsx(r.Box,{sx:{my:3},children:m?e.jsx(r.Typography,{children:c("maker.properties.loading")}):l?d?e.jsxs(r.Stack,{spacing:3,children:[e.jsx(r.Typography,{variant:"subtitle2",children:c("maker.properties.llmConfigInstructions")}),g(d.properties)]}):e.jsx(r.Typography,{children:c("maker.properties.loading")}):e.jsx(r.Typography,{color:"error",children:c("maker.properties.componentNotFound")})})}),e.jsxs(r.DialogActions,{children:[e.jsx(r.Button,{onClick:i,children:c("common.cancel")}),e.jsx(r.Button,{variant:"contained",onClick:n,disabled:!d||m,children:c("common.confirm")})]})]})}function vt({label:t,value:s,onChange:o}){const[l,f]=P.useState(!1);return e.jsxs(r.Stack,{sx:{gap:1},children:[e.jsx(r.TextField,{label:t,size:"small",value:s,onChange:p=>o?.(p.target.value),slotProps:{input:{sx:{pr:0},endAdornment:e.jsx(r.InputAdornment,{position:"end",children:e.jsx(z.UploaderButton,{onChange:({response:p})=>{const u=p?.data?.filename;u&&o?.(u)}})})}}}),s&&e.jsx(r.Box,{component:"img",src:V.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:V.getImageAbsoluteUrl(s),alt:t})})]})}function te(t,s=""){return it.default(t,(o,l,f)=>{const p=s?`${s}.${f}`:f;return rt.default(l)?Xe.default(o,te(l,p)):o[p]=l,o},{})}const Ct=[{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 K(t,s,o){return!t||!o?!1:Object.values(t).some(({data:l})=>l.id!==s&&l.key===o)}function H(t,s){return!t||!s?!1:t[s]?.data.visible??!0}function xe(t,s){return!t||!s?!1:t[s]?.data.shared??!1}function St({componentId:t}){const{state:{components:s}}=V.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(Ke.ErrorBoundary,{FallbackComponent:lt,resetKeys:[t],children:e.jsx(kt,{value:l,componentId:t})})})}):null}function kt({value:t,componentId:s}){const{t:o}=R.useLocaleContext(),{localState:{currentLocale:l,customComponentPreviewerProperties:f},state:{config:{defaultLocale:p}},localActions:{setCustomComponentPreviewerProperties:u}}=V.useStore(),j=U.getYjsValue(t).doc,m=V.useAllComponents(),c=P.useMemo(()=>f?.[s]??{},[s,f]),d=t.renderer?.type||"react-component",a=d==="component-template",i=ze.useReactive({componentId:s,propertiesValue:{...c}});return P.useEffect(()=>{i.componentId!==s&&(i.componentId=s,i.propertiesValue={...c})},[s,c,i]),P.useEffect(()=>{if(i.componentId!==s)return;const n=Object.fromEntries(Object.values(t.properties??{}).map(({data:x})=>[x.id,{value:i.propertiesValue[x.id]?.value??Ae.parsePropertyValue(x,x.locales?.[l]?.defaultValue??x.locales?.[p]?.defaultValue,{locale:l,defaultLocale:p})}]));u(s,n)},[JSON.stringify(i.propertiesValue),s,i.componentId]),e.jsx(r.Stack,{sx:{height:"100%"},children:e.jsxs(r.Stack,{sx:{gap:2},children:[e.jsx(me,{config:t}),e.jsxs(e.Fragment,{children:[e.jsx(he,{config:t,currentLocale:l,defaultLocale:p,allComponents:m,onUpdateConfig:n=>{j.transact(()=>{n(t)})}}),e.jsxs(r.Stack,{direction:"row",sx:{gap:2,justifyContent:"space-between",alignItems:"center"},children:[e.jsx(r.Typography,{variant:"subtitle1",children:o("renderer")}),e.jsxs(r.TextField,{hiddenLabel:!0,size:"small",select:!0,value:d,disabled:a,onChange:n=>{j.transact(()=>{const x=n.target.value;t.renderer??={type:x},t.renderer.type=x})},slotProps:{select:{autoWidth:!0}},children:[e.jsx(r.MenuItem,{value:"component-template",disabled:!0,children:o("maker.components.componentTemplate")}),e.jsx(r.MenuItem,{value:"react-component",children:"React Component"}),e.jsx(r.MenuItem,{value:"component",children:"Custom Component"})]})]}),d==="component"&&e.jsx(Rt,{value:t}),d==="react-component"&&e.jsx(Ot,{value:t}),e.jsx(ne,{config:t,currentLocale:l,defaultLocale:p,allComponents:m,propertiesValue:i.propertiesValue,onChange:({value:n,id:x,path:g})=>{const h=[...g,"data"];if(!Ze.default(t,h)){ee.default.warning(o("cannotFindPropertyKey",{key:h.join(".")}));return}i.propertiesValue[x]={value:n.value}}})]})]})})}function me({config:t}){const{t:s}=R.useLocaleContext();return e.jsx(z.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:o=>t.name=o.target.value}),e.jsx(r.TextField,{label:s("description"),size:"small",multiline:!0,minRows:2,maxRows:10,value:t.description||"",onChange:o=>t.description=o.target.value,slotProps:{input:{endAdornment:e.jsx(r.InputAdornment,{position:"end",sx:{mt:-1.5},children:e.jsx(Nt,{config:t})})},htmlInput:{maxLength:200}}}),e.jsx(r.Autocomplete,{size:"small",options:[],multiple:!0,freeSolo:!0,value:t.tags??[],onChange:(o,l)=>t.tags=l,renderInput:o=>e.jsx(r.TextField,{label:s("tags"),...o})}),e.jsx(vt,{label:s("previewImage"),value:t.previewImage||"",onChange:o=>t.previewImage=o})]})})}function fe({data:t,params:s,visible:o,shared:l,config:f,currentLocale:p,defaultLocale:u,allComponents:j,onUpdateConfig:m}){const{t:c}=R.useLocaleContext(),d=P.useMemo(()=>t.type==="json"||t.type==="yaml"||t.type==="array"?Tt:F,[t.type]);return e.jsx(bt,{preview:s.preview,drop:s.drop,drag:s.drag,isDragging:s.isDragging,dragHandle:s.dragHandle,onDelete:()=>{m(a=>{if(a.properties){const n=Object.entries(a.properties).sort(([,g],[,h])=>g.index-h.index);delete a.properties[t.id],n.filter(([g])=>g!==t.id).forEach(([,g],h)=>{g.index=h})}})},visible:o,onVisibilityChange:a=>{m(i=>{const n=i.properties[t.id].data;n.visible=a})},shared:l,onSharedChange:a=>{m(i=>{const n=i.properties[t.id].data;n.shared=a})},alwaysShowActions:!0,children:e.jsxs(r.Stack,{direction:"column",sx:{gap:2},children:[e.jsx(r.TextField,{label:c("key"),size:"small",required:!0,sx:{width:"calc(100% - 104px - 8px)",flex:1,"& .MuiOutlinedInput-root":{borderColor:t.key?K(f.properties,t.id,t.key)?"warning.main":void 0:"error.main"},"& .MuiFormLabel-root":{color:t.key?K(f.properties,t.id,t.key)?"warning.main":"text.secondary":"error.main"},"& .MuiFormLabel-root.Mui-focused":{color:t.key?K(f.properties,t.id,t.key)?"warning.main":"primary.main":"error.main"}},value:t.key||"",onChange:a=>{m(i=>{const n=i.properties[t.id].data;n.key=a.target.value.trim()})},slotProps:{input:{endAdornment:!t.key||t.key&&K(f.properties,t.id,t.key)?e.jsx(r.InputAdornment,{position:"end",sx:{width:16,ml:0},children:e.jsx(r.Tooltip,{title:t.key?c("duplicateKey"):c("requiredKey"),children:e.jsx(N.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:c("label"),size:"small",sx:{flex:1},value:(t.locales?.[p]?.name??t.locales?.[u]?.name)||"",onChange:a=>{m(i=>{const n=i.properties[t.id].data;n.locales??={},n.locales[p]??={},n.locales[p].name=a.target.value})}}),e.jsx(r.TextField,{label:c("type"),size:"small",select:!0,sx:{flex:1},value:t.type==="string"&&t.multiline?"multiline":t.type||"string",onChange:a=>{m(i=>{const n=i.properties[t.id].data;if(n.locales)for(const g of Object.keys(n.locales))n.locales[g].defaultValue=void 0;const x=a.target.value;x==="multiline"?(n.type="string",n.multiline=!0):(typeof n.multiline<"u"&&delete n.multiline,n.type=x)})},children:Ct.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(d,{allComponents:j,defaultLocale:u,component:f,property:t,label:c("defaultValue"),size:"small",fullWidth:!0,value:t.locales?.[p]?.defaultValue,onChange:(a,i)=>{m(n=>{const x=n.properties[t.id].data;if(i?.forceUpdateProperty){const g=te(x),h=te(a);Object.keys(h).forEach(S=>{g[S]||de.default(x,S,h[S])})}else x.locales??={},x.locales[p]??={},x.locales[p].defaultValue=a})}}),t.type==="custom"?e.jsx(r.Box,{children:e.jsx(wt,{property:t,allComponents:j})}):null]})]})})}function Pt(t,s){const[o,l]=P.useState(0);return P.useEffect(()=>{const p=setTimeout(()=>{if(t.current){let u=t.current.parentElement,j=0;for(;u;)u.classList.contains("property-container")&&j++,u=u.parentElement;l(j)}},100);return()=>clearTimeout(p)},[t,s]),o}function he({config:t,currentLocale:s,defaultLocale:o,allComponents:l,onUpdateConfig:f,useI18nEditor:p=!0}){const{t:u}=R.useLocaleContext(),j=E.usePopupState({variant:"dialog"}),m=t.properties&&_.default(Object.values(t.properties),"index");return e.jsx(z.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:u("properties")}),e.jsx(r.Box,{sx:{flex:1}}),p&&e.jsx(r.Button,{sx:{minWidth:32,minHeight:32,p:0},...E.bindTrigger(j),children:e.jsx(N.TranslateRounded,{fontSize:"small"})})]}),t.properties&&Object.keys(t.properties).length>0?e.jsx(ue,{component:r.Stack,gap:2,list:t.properties,renderItem:(c,d,a)=>{const i=H(t.properties,c.id),n=xe(t.properties,c.id);return e.jsx(r.Paper,{elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:i?"1px solid":"1px dashed",borderColor:"divider"},children:e.jsx(r.Stack,{sx:{gap:2},children:e.jsx(fe,{data:c,params:a,visible:i,shared:n,config:t,currentLocale:s,defaultLocale:o,allComponents:l,onUpdateConfig:f})})},c.id)}}):e.jsx(M.default,{style:{fontSize:12},children:u("maker.properties.noProperties")}),e.jsx(r.Button,{fullWidth:!0,variant:"outlined",className:"ignore-style-override",onClick:()=>{f(c=>{const d=ce.nextId();c.properties??={},c.properties[d]??={index:m?.length||0,data:{id:d,shared:!1}}})},startIcon:e.jsx(N.AddRounded,{}),children:u("addObject",{object:u("property")})}),p&&e.jsx(be,{...E.bindDialog(j),component:t})]})})}function wt({property:t,allComponents:s}){const o=E.usePopupState({variant:"popper"});return e.jsxs(e.Fragment,{children:[e.jsx(r.Button,{sx:{minWidth:0},...E.bindTrigger(o),children:e.jsx(N.SettingsRounded,{fontSize:"small"})}),e.jsx(r.Popper,{...E.bindPopper(o),children:e.jsx(ae.ClickAwayListener,{onClickAway:o.close,children:e.jsx(r.Paper,{children:e.jsx(r.Box,{sx:{width:500,p:2},children:e.jsx(G,{value:t.componentId,onChange:(l,f)=>t.componentId=f,allComponents:s})})})})})]})}function It({value:t,valueImmutable:s,onChange:o,defaultLocale:l,allComponents:f}){const[p,u]=P.useState(!1),{t:j,locale:m}=R.useLocaleContext(),c=typeof t?.componentId=="string"?f[t.componentId]?.data:void 0;return c?e.jsxs(r.Box,{sx:{width:"100%",position:"relative"},children:[e.jsx(r.IconButton,{sx:{minWidth:0},disabled:!c,size:"small",onClick:()=>u(!p),color:p?"primary":"default",children:e.jsx(N.SettingsRounded,{fontSize:"small"})}),p&&e.jsx(r.Collapse,{in:p,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(ne,{config:c,currentLocale:m,defaultLocale:l,allComponents:f,propertiesValue:t?.properties,onChange:({id:d,value:a})=>{const i=Z.default(a.value),n=JSON.parse(JSON.stringify(t));n?.componentId&&(s?o?.({...n,properties:{...n.properties,[d]:{value:i}}}):(n.properties=n.properties??{},n.properties[d]={value:i},o?.(n)))}})}),e.jsx(r.Button,{size:"small",onClick:()=>u(!1),sx:{mt:1},children:j("close")})]})})]}):null}function be({type:t="properties",component:s,...o}){const{t:l}=R.useLocaleContext(),{state:{components:f,supportedLocales:p,config:{defaultLocale:u}}}=V.useStore(),j=V.useAllComponents(),m=U.getYjsValue(s).doc,c=t==="properties"?s.properties:t==="parameters"&&s.renderer?.type==="component"?f[s.renderer.componentId]?.data.properties:void 0,d=s.renderer?.type==="component"?s:void 0;return e.jsxs(r.Dialog,{...o,fullWidth:!0,maxWidth:"lg",children:[e.jsx(r.DialogTitle,{children:l("i18nEditorTitle")}),e.jsx(r.DialogContent,{children:c&&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:p.map(({locale:a,name:i})=>e.jsx(r.TableCell,{children:e.jsxs(r.Typography,{sx:{color:"text.primary"},children:[i,u===a&&e.jsx(N.StarRounded,{sx:{fontSize:12}})]})},a))})}),e.jsx(r.TableBody,{children:_.default(Object.values(c),"index").map(({data:a})=>e.jsx(r.TableRow,{children:p.map(({locale:i})=>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:a.key||"",onChange:n=>{m.transact(()=>{a.key=n.target.value.trim()})}}),e.jsx(r.TextField,{size:"small",label:l("label"),value:(a.locales?.[i]?.name??a.locales?.[u]?.name)||"",onChange:n=>{m.transact(()=>{a.locales??={},a.locales[i]??={},a.locales[i].name=n.target.value})}}),e.jsx(r.Box,{children:e.jsx(F,{allComponents:j,defaultLocale:u,component:s,property:a,size:"small",fullWidth:!0,label:"Default Value",valueImmutable:$.default(a.locales?.[i]?.defaultValue),value:a.locales?.[i]?.defaultValue??a.locales?.[u]?.defaultValue,onChange:n=>{m.transact(()=>{a.locales??={},a.locales[i]??={},a.locales[i].defaultValue=n})}})})]}):t==="parameters"&&d?e.jsx(r.Box,{children:e.jsx(F,{allComponents:j,defaultLocale:u,component:s,property:a,size:"small",fullWidth:!0,valueImmutable:$.default(d.renderer.properties?.[a.id]?.locales?.[i]?.value),value:d.renderer.properties?.[a.id]?.locales?.[i]?.value??d.renderer.properties?.[a.id]?.locales?.[u]?.value??a.locales?.[i]?.defaultValue??a.locales?.[u]?.defaultValue,onChange:n=>{m.transact(()=>{d.renderer.properties??={},d.renderer.properties[a.id]??={},d.renderer.properties[a.id].locales??={},d.renderer.properties[a.id].locales[i]??={},d.renderer.properties[a.id].locales[i].value=n})}})}):null},a.id)},i))},a.id))})]})})}),e.jsx(r.DialogActions,{children:e.jsx(r.Button,{onClick:a=>o.onClose?.(a,"escapeKeyDown"),children:l("close")})})]})}const le=(t,s)=>o=>{const l=[o.palette.info.main,o.palette.primary.main,o.palette.secondary.main,o.palette.success.main,o.palette.warning.main],f=Math.min(l.length-1,t),p=l[f],u=r.alpha(p,.5),j=r.alpha(p,1);return{borderColor:`${u} !important`,borderLeft:"3px solid !important",borderLeftColor:u,color:j,...s}};function Tt({property:t,onChange:s,defaultLocale:o,allComponents:l}){const{t:f,locale:p}=R.useLocaleContext(),u=P.useRef(null),j=Pt(u,t),m=P.useCallback(()=>{if(!(t.type!=="json"&&t.type!=="yaml"&&t.type!=="array")&&t.subProperties)try{let c={};_.default(Object.values(t.subProperties),"index").filter(i=>i.data.visible!==!1&&i.data.key).forEach(({data:i})=>{if(!i.key)return;let n=i.locales?.[p]?.defaultValue??i.locales?.[o]?.defaultValue;if(i.type==="number")n=Number(n);else if(i.type==="boolean")n=n===!0||n==="true";else if((i.type==="json"||i.type==="yaml")&&typeof n=="string")try{i.type==="json"?n=JSON.parse(n):n=X.parse(n)}catch(x){console.error("Error parsing nested value",n,x),n={}}c[i.key]=n}),t.type==="array"&&!Array.isArray(c)&&(c=D.default(c)?[]:[c]);const a=V.transformValue(c,t.type);s?.(a)}catch(c){console.error("Error converting structure to text:",c)}},[t,p,o,s]);return t.type!=="json"&&t.type!=="yaml"&&t.type!=="array"?null:e.jsxs(r.Stack,{direction:"column",ref:u,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:(c,d,a)=>{const i=c.visible!==!1,n=c.shared??!1;return e.jsx(r.Paper,{elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:i?"1px solid":"1px dashed","&":le(j)},children:e.jsx(r.Stack,{sx:{gap:2},children:e.jsx(fe,{data:c,params:a,visible:i,shared:n,config:{properties:t.subProperties},currentLocale:p,defaultLocale:o,allComponents:l,onUpdateConfig:x=>{try{const g={properties:t.subProperties||{}};x(g);const h={...t,subProperties:g.properties};s?.(h,{forceUpdateProperty:!0}),m()}catch(g){console.error("Error updating property:",g)}}})})},c.id)}}):e.jsx(M.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(N.AddRounded,{}),onClick:()=>{try{const c=t.subProperties||{},d=ce.nextId(),i={index:Object.values(c).length,data:{id:d,key:"",type:"string",visible:!0,shared:!1,locales:{[p]:{name:"",defaultValue:""}},subProperties:{}}},n={...t,subProperties:{...c,[d]:i}};s?.(n,{forceUpdateProperty:!0}),m()}catch(c){console.error("Error adding property:",c)}},sx:{"&":le(j,{})},children:f("maker.properties.addSubProperty")})]})}function F({component:t,property:s,value:o,onChange:l,valueImmutable:f,defaultLocale:p,allComponents:u,...j}){const{locale:m}=R.useLocaleContext(),c=z.useUploader(),d=P.useRef(null),a=()=>{const n=c?.current?.getUploader();n?.open(),d.current&&n.onceUploadSuccess(({response:x})=>{let g=x?.data?.filename||"";g&&(g=`mediakit://${g}`,o&&!o.includes("mediakit://")&&(g+=" # please use < import { getMediaKitAbsoluteUrl } from '@blocklet/pages-kit/builtin/utils' > to get the full address")),d.current?.(g)})},i=j.label??(s.locales?.[m]?.name||s.locales?.[p]?.name||s.key||s.id);if(s.type==="number")return e.jsx(Bt,{...j,label:i,NumberProps:{value:["number","string"].includes(typeof o)?o:null,onChange:(n,x)=>l?.(x)}});if(s.type==="decimal")return e.jsx(r.TextField,{...j,label:i,type:"text",value:o??"",onChange:n=>{const x=n.target.value;if(x===""||x==="-"){l?.(x);return}if(/^-?(?!.*\..*\.)[0-9]*(\.[0-9]{0,9})?$/.test(x)){let h=x;/^-?[1-9]+[0-9]*(\.[0-9]{1,9})?$/.test(h)&&(h=Number(h)),l?.(h)}}});if(s.type==="boolean")return e.jsx(r.FormControlLabel,{label:i,labelPlacement:"start",control:e.jsx(r.Switch,{checked:o===!0,onChange:(n,x)=>l?.(x)})});if(s.type==="color")return e.jsx(xt,{label:i,value:o,onChange:n=>{l?.(n)}});if(s.type==="json"||s.type==="yaml")return e.jsx(mt,{label:i,value:o,onChange:n=>{l?.(n)},property:s,component:t,defaultLocale:p,allComponents:u,PropertyValueField:F,onUpload:n=>{d.current=n,a()}});if(s.type==="custom"){const n=u[s.componentId]?.data;return n?e.jsx(r.Box,{sx:{width:"100%"},children:e.jsx(J.CustomComponentRenderer,{componentId:n.id,props:{label:i,value:o,onChange:l},locale:m,dev:{mode:"draft",components:u,defaultLocale:p}})}):e.jsx(r.TextField,{...j,label:i,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(G,{allComponents:u,label:i,value:o?.componentId,onChange:(n,x)=>{f||!o?l?.({...o&&JSON.parse(JSON.stringify(o)),componentId:x}):typeof o=="object"&&(o.componentId=x,l?.({...o&&JSON.parse(JSON.stringify(o)),componentId:x}))}}),o?.componentId&&e.jsx(It,{value:o,valueImmutable:f,onChange:l,defaultLocale:p,allComponents:u})]});if(!s.type||["string","url","multiline"].includes(s.type)){let n=s.type==="string"?s.multiline:void 0;s.type==="multiline"&&(n=!0);const x=s.type==="url"?o?.url:o;return e.jsx(r.TextField,{...j,label:i,value:typeof x=="string"?x:"",multiline:n,minRows:n?2:void 0,maxRows:n?10:void 0,onChange:g=>l?.(s.type==="url"?{...o,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(z.UploaderButton,{onChange:async({response:g})=>{const h=g?.data?.url||g?.data?.fileUrl;let S;h&&(S=await z.getImageSize(h).catch(()=>z.getVideoSize(h)).catch(()=>{}));let y=g?.data?.filename||"";y&&(y=`mediakit://${y}`),l?.({url:h,mediaKitUrl:y,width:S?.naturalWidth,height:S?.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(N.InfoRounded,{sx:{cursor:"default",mr:1},fontSize:"small"})})]})}:void 0}})}return s.type==="array"?e.jsx(ut,{label:i,value:Array.isArray(o)?o:[],onChange:n=>l?.(n),property:s,renderItem:({item:n,index:x,onChange:g})=>s.subProperties&&Object.keys(s.subProperties).length>0?e.jsx(r.Stack,{sx:{gap:1,width:"100%"},children:_.default(Object.values(s.subProperties),"index").filter(h=>h.data.visible!==!1).map(({data:h})=>h.key?e.jsx(F,{component:t,property:h,value:n[h.key],onChange:S=>{const y={...n,[h.key]:S};g(y)},size:"small",fullWidth:!0,defaultLocale:p,allComponents:u},h.id):null)},x):e.jsx(r.TextField,{size:j.size,fullWidth:!0,value:n,onChange:h=>g(h.target.value)})}):(console.error("Unsupported property type",s.type),null)}function Bt({NumberProps:t,...s}){const{getInputProps:o}=ae.unstable_useNumberInput(t),l=o();return e.jsx(r.TextField,{...s,slotProps:{htmlInput:l}})}const ge=`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 () {
|
|
@@ -8,4 +8,4 @@ export default function () {
|
|
|
8
8
|
</Box>
|
|
9
9
|
)
|
|
10
10
|
}`,je=`console.log('hello')
|
|
11
|
-
`;function Ot({value:t}){const{locale:s}=R.useLocaleContext(),o=se.useUpdate(),
|
|
11
|
+
`;function Ot({value:t}){const{locale:s}=R.useLocaleContext(),o=se.useUpdate(),l=U.getYjsValue(t).doc;return P.useEffect(()=>{t.renderer?.script||(l.transact(()=>{t.renderer.script=t.renderer.type==="react-component"?ge:je}),o())},[t]),e.jsx(r.Box,{sx:{border:1,borderColor:"divider",borderRadius:1,overflow:"hidden"},children:e.jsx(re.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 Rt({value:t}){const{t:s}=R.useLocaleContext(),o=U.getYjsValue(t).doc,{state:{components:l,config:{defaultLocale:f},resources:p},localState:{currentLocale:u}}=V.useStore(),j=V.useAllComponents(),m=l[t.renderer.componentId]?.data??p.components?.[t.renderer.componentId]?.component,c=E.usePopupState({variant:"dialog"});return e.jsx(z.UploaderProvider,{children:e.jsxs(r.Stack,{sx:{gap:1},children:[e.jsx(G,{allComponents:j,excludes:[t.id],value:t.renderer.componentId,onChange:(d,a)=>t.renderer.componentId=a}),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},...E.bindTrigger(c),children:e.jsx(N.TranslateRounded,{fontSize:"small"})})]}),m.properties&&_.default(Object.values(m.properties),"index").map(({data:d})=>e.jsx(r.Box,{children:e.jsx(F,{allComponents:j,defaultLocale:f,component:m,property:d,fullWidth:!0,size:"small",valueImmutable:$.default(t.renderer.properties?.[d.id]?.locales?.[u]?.value),value:t.renderer.properties?.[d.id]?.locales?.[u]?.value??t.renderer.properties?.[d.id]?.locales?.[f]?.value??d.locales?.[u]?.defaultValue??d.locales?.[f]?.defaultValue,onChange:a=>{o.transact(()=>{t.renderer.properties??={},t.renderer.properties[d.id]??={},t.renderer.properties[d.id].locales??={},t.renderer.properties[d.id].locales[u]??={},t.renderer.properties[d.id].locales[u].value=a})}})},d.id)),e.jsx(be,{...E.bindDialog(c),component:t,type:"parameters"})]})]})})}function G({label:t,options:s,excludes:o,value:l,onChange:f,allComponents:p,...u}){const{t:j}=R.useLocaleContext(),m=s??_.default(Object.values(nt.default(p,...o??[])),"index").map(d=>d.data),c=(typeof l=="string"?p[l]?.data:void 0)??null;return e.jsx(r.Autocomplete,{...u,size:"small",options:m,autoHighlight:!0,isOptionEqualToValue:(d,a)=>d.id===a.id,getOptionKey:d=>d.id,getOptionLabel:d=>d.name||d.id,renderInput:d=>e.jsx(r.TextField,{label:t||j("component"),...d}),value:c,onChange:(d,a)=>{let i={};a&&(i={blockletId:p[a?.id]?.blockletId,blockletTitle:p[a?.id]?.blockletTitle,componentName:p[a?.id]?.data?.name||p[a?.id]?.data?.id}),f?.(d,a?.id,i)}})}function ne({config:t,allComponents:s,defaultLocale:o,propertiesValue:l,currentLocale:f,onChange:p,props:u}){const{t:j}=R.useLocaleContext(),[m,c]=P.useState(Z.default(t?.properties)),[d,a]=P.useState(null),[i,n]=P.useState(!1);P.useEffect(()=>{(()=>{t?.renderer?.type==="react-component"&&D.default(t?.properties)?J.transpileAndLoadScript(t?.renderer?.script).then(I=>{const T=J.getPropertiesFromCode(I);c(T)}):c(Z.default(t?.properties))})()},[JSON.stringify(t)]);const x=P.useCallback(()=>!t||!m?{}:Object.values(m).reduce((y,{data:I})=>{const T=I.key||I.id;return y[I.id]={key:T,value:u?.[T]??l?.[I.id]?.value??I.locales?.[f]?.defaultValue??I.locales?.[o]?.defaultValue,id:I.id,type:I.type,visible:H(m,I.id),shared:xe(m,I.id)},y},{}),[JSON.stringify(m),t,l,f,o]),g=P.useMemo(()=>{if(!m)return{canUseProperties:[],visibleProperties:[],canUsePropertiesKeys:[]};const y=_.default(Object.values(m),"index"),I=y.filter(({data:k})=>k.key&&H(m,k.id)),T=y.filter(({data:k})=>k.key&&k.type!=="component"),C=T.map(({data:k})=>k.key);return{canUseProperties:T,visibleProperties:I,canUsePropertiesKeys:C}},[JSON.stringify(m)]),h=x(),S=st.default(h,"key");return e.jsx(z.UploaderProvider,{children:e.jsxs(r.Stack,{sx:{gap:2},children:[e.jsxs(r.Typography,{variant:"subtitle1",sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[j("maker.properties.parameters"),e.jsx(r.FormControlLabel,{control:e.jsx(r.Switch,{size:"small",checked:i,onChange:y=>n(y.target.checked)}),label:e.jsx(r.Typography,{variant:"caption",children:j("maker.properties.forceSyncToAllLanguages")}),sx:{mr:0}})]}),!t||g.canUsePropertiesKeys.length===0?e.jsx(M.default,{style:{fontSize:12},children:j("maker.properties.noParameters")}):e.jsxs(e.Fragment,{children:[e.jsx(r.Stack,{sx:{gap:2},children:g.visibleProperties.map(({data:y})=>e.jsx(r.Box,{children:e.jsx(F,{allComponents:s,defaultLocale:o,size:"small",fullWidth:!0,component:t,property:y,valueImmutable:$.default(l?.[y.id]?.value),value:u?.[y.key||y.id]??h[y.id]?.value,onChange:I=>{p({path:["properties",y.id],id:y.id,value:{value:I},shouldSync:i?!0:ie(y),excludeKeys:[],key:y.key||y.id})}})},y.id))}),e.jsx(r.Stack,{sx:{gap:2,width:"100%"},children:e.jsx(J.CustomComponentRenderer,{componentId:t?.id||"",renderType:"setting",locale:f,properties:h,dev:{mode:"draft",components:s,defaultLocale:o},props:{...ot.default(u??{},g.canUsePropertiesKeys),onChange:y=>{const{canUsePropertiesKeys:I}=g;Object.keys(y).filter(C=>!tt.default(y[C],S?.[C]?.value)).filter(C=>!(C==="locale"&&!et.default(S[C],"locale")||S[C]?.type==="component"||(S[C]?.type==="yaml"||S[C]?.type==="json")&&H(m,S[C]?.id))).reduce((C,k)=>C.then(()=>{const b=S[k],v=I.includes(k);if(b?.id&&v)return p({path:["properties",b.id],id:b.id,value:{value:y[k]},shouldSync:i?!0:ie(b),excludeKeys:[],key:b.key||b.id}),Promise.resolve();const w=`propertyNotFound${k}`;if(d===w)return Promise.resolve();ee.default.close(d);const B=ee.default.warning(j("maker.properties.propertyNotFound",{key:k}),{key:w});return a(B),Promise.resolve()}),Promise.resolve())}}})})]})]},f)})}function Nt({config:t}){const{t:s,locale:o}=R.useLocaleContext(),[l,f]=P.useState(!1),p=u=>{t.llmConfig=u};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(N.PsychologyAlt,{})})}),l&&e.jsx(yt,{open:l,onClose:()=>f(!1),onConfirm:p,component:t,initialConfig:t.llmConfig,locale:o,defaultLocale:"en",title:s("maker.properties.llmConfigTitle")})]})}exports.BasicInfo=me;exports.CustomComponentAutocomplete=G;exports.CustomComponentSettings=St;exports.DefaultReactComponentScriptTemplate=ge;exports.DefaultWebComponentScriptTemplate=je;exports.ParametersConfig=ne;exports.PropertiesConfig=he;exports.PropertyValueField=F;
|
package/lib/cjs/site-state.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("./chunks/components-DLLpFRy5.js");const e=require("./chunks/site-state-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("./chunks/components-DLLpFRy5.js");const e=require("./chunks/site-state-CtiXHtSX.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("fs");require("glob");require("lib0/decoding");require("lib0/encoding");require("lodash/cloneDeep");require("lodash/debounce");require("lodash/get");require("lodash/isEmpty");require("lodash/set");require("lodash/union");require("lru-cache");require("p-limit");require("path");require("sequelize");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.getDefaultState=e.getDefaultState;exports.getResourceStates=e.getResourceStates;exports.initPackResourceStates=e.initPackResourceStates;exports.mergeState=e.mergeState;exports.toPackage=e.toPackage;exports.triggerReloadAllProjectResource=e.triggerReloadAllProjectResource;exports.updateResourceStatesByProjectId=e.updateResourceStatesByProjectId;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/es/add-component.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as o, jsxs as w } from "react/jsx-runtime";
|
|
2
|
-
import { i as D, a as G, h as J, j as Z, k as ee, l as oe, m as te, f as re } from "./chunks/state-
|
|
2
|
+
import { i as D, a as G, h as J, j as Z, k as ee, l as oe, m as te, f as re } from "./chunks/state-DNdwHwty.js";
|
|
3
3
|
import $ from "@arcblock/ux/lib/Empty";
|
|
4
4
|
import { useLocaleContext as F } from "@arcblock/ux/lib/Locale/context";
|
|
5
5
|
import { Icon as L } from "@iconify-icon/react";
|
|
@@ -7,7 +7,7 @@ import ie from "@mui/icons-material/Check";
|
|
|
7
7
|
import { Box as n, styled as H, alpha as ne, Stack as ae, Dialog as se, DialogTitle as le, TextField as pe, IconButton as ce, DialogContent as de, Tabs as me, Tab as ue, Grid as O, Card as fe, CardMedia as be, CardContent as ge, Typography as W, DialogActions as xe, Button as N, Skeleton as he } from "@mui/material";
|
|
8
8
|
import { useReactive as Q } from "ahooks";
|
|
9
9
|
import { createContext as _, useMemo as P, useEffect as M, useRef as E } from "react";
|
|
10
|
-
import { a as ye, R as ve, B as V, c as Ce, T as ke, I as we } from "./chunks/index-
|
|
10
|
+
import { a as ye, R as ve, B as V, c as Ce, T as ke, I as we } from "./chunks/index-Bggolyu_.js";
|
|
11
11
|
import { styled as g } from "@arcblock/ux/lib/Theme";
|
|
12
12
|
import "@blocklet/pages-kit/builtin/color-picker";
|
|
13
13
|
import "@blocklet/pages-kit/utils/style";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { u as a, S as o, g as s, a as n } from "./state-
|
|
2
|
+
import { u as a, S as o, g as s, a as n } from "./state-DNdwHwty.js";
|
|
3
3
|
function d({ children: t }) {
|
|
4
4
|
const r = a();
|
|
5
5
|
return /* @__PURE__ */ e(o, { url: s(r ?? ""), name: "root", waitingSynced: !0, children: /* @__PURE__ */ e(i, { children: t }) });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e, jsxs as T } from "react/jsx-runtime";
|
|
2
|
-
import { u as N, c as U, d as se, e as ie, f as le, b as ce } from "./state-
|
|
2
|
+
import { u as N, c as U, d as se, e as ie, f as le, b as ce } from "./state-DNdwHwty.js";
|
|
3
3
|
import { useLocaleContext as W } from "@arcblock/ux/lib/Locale/context";
|
|
4
4
|
import V from "@arcblock/ux/lib/Result";
|
|
5
5
|
import { styled as M, useTheme as ue } from "@arcblock/ux/lib/Theme";
|
|
@@ -21,7 +21,7 @@ import { Helmet as Se } from "react-helmet";
|
|
|
21
21
|
import { useSearchParams as Z, Routes as Ce, Route as S, Navigate as Ie, ScrollRestoration as Te } from "react-router-dom";
|
|
22
22
|
import { useAsync as ee } from "react-use";
|
|
23
23
|
import { joinURL as P } from "ufo";
|
|
24
|
-
import { u as Re, S as je, i as D, P as Me, a as Oe, R as Ee, B as Le, b as te, g as Ae } from "./index-
|
|
24
|
+
import { u as Re, S as je, i as D, P as Me, a as Oe, R as Ee, B as Le, b as te, g as Ae } from "./index-Bggolyu_.js";
|
|
25
25
|
import Be from "@blocklet/ui-react/lib/Footer";
|
|
26
26
|
import "webfontloader";
|
|
27
27
|
import { u as _e, a as Fe } from "./session-Dx5M-1r2.js";
|
|
@@ -149,7 +149,7 @@ function Ge({ mode: t }) {
|
|
|
149
149
|
}
|
|
150
150
|
return /* @__PURE__ */ e(Ke, { children: ({ state: o }) => /* @__PURE__ */ e(L, { mode: t, state: o }) });
|
|
151
151
|
}
|
|
152
|
-
const qe = X(() => import("./publish-button-
|
|
152
|
+
const qe = X(() => import("./publish-button-Dm2Nce-b.js")), Ke = X(() => import("./draft-data-BOoVhbon.js"));
|
|
153
153
|
function Ye({
|
|
154
154
|
mode: t,
|
|
155
155
|
children: o
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createHash as a } from "crypto";
|
|
2
|
+
import "ufo";
|
|
2
3
|
const s = async () => await import("cheerio"), o = {};
|
|
3
4
|
function u(t, e) {
|
|
4
5
|
const n = JSON.stringify([t, e]);
|
|
5
6
|
return a("md5").update(n).digest("hex");
|
|
6
7
|
}
|
|
7
|
-
async function
|
|
8
|
+
async function i(t, e) {
|
|
8
9
|
{
|
|
9
10
|
let n = await s();
|
|
10
11
|
try {
|
|
@@ -17,33 +18,33 @@ async function l(t, e) {
|
|
|
17
18
|
n = null;
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
return
|
|
21
|
+
return l(t, e);
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
+
function l(t, e) {
|
|
23
24
|
let n = t;
|
|
24
25
|
return e.forEach((r) => {
|
|
25
26
|
const c = typeof r.selector.pattern == "string" ? new RegExp(r.selector.pattern, "gis") : r.selector.pattern;
|
|
26
27
|
n = n.replace(c, r.value);
|
|
27
28
|
}), n;
|
|
28
29
|
}
|
|
29
|
-
async function
|
|
30
|
+
async function f(t, e) {
|
|
30
31
|
if (!e || e.length === 0)
|
|
31
32
|
return t;
|
|
32
33
|
const n = u(t, e);
|
|
33
|
-
return o[n] ??=
|
|
34
|
+
return o[n] ??= i(t, e).finally(() => {
|
|
34
35
|
setTimeout(() => {
|
|
35
36
|
delete o[n];
|
|
36
37
|
}, 10 * 1e3);
|
|
37
38
|
}), o[n];
|
|
38
39
|
}
|
|
39
|
-
function
|
|
40
|
+
function p(t) {
|
|
40
41
|
return t.match(/<body[^>]*>(.*?)<\/body>/s)?.[1] || "";
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
+
function g(t, e) {
|
|
43
44
|
return !e || Object.keys(e).length === 0 ? !0 : Object.entries(e).every(([n, r]) => t.includes(`${n}=${r}`));
|
|
44
45
|
}
|
|
45
46
|
export {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
p as e,
|
|
48
|
+
f as i,
|
|
49
|
+
g as m
|
|
49
50
|
};
|