@blocklet/pages-kit-inner-components 0.4.97 → 0.4.99

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),t=require("./state-oKsa8z3D.js");function n({children:e}){const r=t.useProjectId();return s.jsx(t.StoreProvider,{url:t.getWssURL(r??""),name:"root",waitingSynced:!0,children:s.jsx(o,{children:e})})}function o({children:e}){const{state:r}=t.useStore();return e({state:r})}exports.default=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),t=require("./state-eTpgUKhB.js");function n({children:e}){const r=t.useProjectId();return s.jsx(t.StoreProvider,{url:t.getWssURL(r??""),name:"root",waitingSynced:!0,children:s.jsx(o,{children:e})})}function o({children:e}){const{state:r}=t.useStore();return e({state:r})}exports.default=n;
@@ -1,4 +1,4 @@
1
- "use strict";var Ge=Object.create;var pe=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var Xe=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty;var Qe=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ke(t))!Ye.call(e,i)&&i!==o&&pe(e,i,{get:()=>t[i],enumerable:!(r=Je(t,i))||r.enumerable});return e};var xe=(e,t,o)=>(o=e!=null?Ge(Xe(e)):{},Qe(t||!e||!e.__esModule?pe(o,"default",{value:e,enumerable:!0}):o,e));const n=require("react/jsx-runtime"),w=require("./state-oKsa8z3D.js"),A=require("lodash"),$e=require("@arcblock/ux/lib/Locale/context"),Ze=require("@arcblock/ux/lib/Result"),et=require("@blocklet/pages-kit/builtin/page/header"),tt=require("@blocklet/ui-react/lib/Header"),_=require("@emotion/css"),Q=require("@emotion/react"),nt=require("@emotion/styled"),p=require("@mui/material"),Se=require("ahooks"),ot=require("isomorphic-dompurify"),rt=require("lodash/cloneDeep"),it=require("lodash/isEmpty"),st=require("lodash/isEqual"),g=require("react"),at=require("react-helmet"),B=require("react-router-dom"),U=require("react-use"),P=require("ufo");require("@mui/icons-material");const K=require("@blocklet/ai-runtime/components"),ct=require("@mui/utils"),lt=require("lodash/pick"),dt=require("react-error-boundary"),ee=require("@iconify/react"),ut=require("react-markdown"),mt=require("remark-gfm"),pt=require("@mui/lab"),$=require("@arcblock/ux/lib/Theme"),xt=require("@arcblock/react-hooks/lib/useBrowser"),ft=require("@arcblock/ux/lib/Colors"),re=require("@blocklet/pages-kit/components"),ht=require("@mui/material/useMediaQuery"),gt=require("lodash/omit"),Ce=require("@iconify-icon/react"),bt=require("@arcblock/ux/lib/Screenshot"),yt=require("@arcblock/ux/lib/Button"),jt=require("is-uri"),X=require("pathe"),wt=require("@blocklet/embed/message"),_t=require("@blocklet/embed/react"),vt=require("react-twitter-embed"),kt=require("@blocklet/ui-react/lib/Footer"),$t=require("webfontloader"),St=require("@arcblock/did-connect/lib/Session"),S=e=>e&&e.__esModule?e:{default:e},Be=S(Ze),Ct=S(tt),Ie=S(nt),Bt=S(ot),fe=S(rt),It=S(it),Ne=S(st),Pe=S(g),ie=S(lt),Nt=S(ut),Pt=S(mt),Rt=S(xt),he=S(ft),Re=S(ht),R=S(gt),Tt=S(bt),qt=S(yt),te=S(jt),Et=S(kt),zt=S($t);function Wt(e,t,o,r){e.locales||(e.locales={}),e.locales[o]=A.cloneDeep(e.locales[o]||{}),e.locales[o].title=r.title??e.locales[o].title,e.locales[o].image=r.image??e.locales[o].image,e.locales[o].description=r.description??e.locales[o].description,Object.entries(r.sectionsData).forEach(([i,s])=>{var c,l,d,u;const a=Object.values(e.sections).find(m=>m.id===i||m.name===i);if(a&&a.isTemplateSection)if(a.locales=A.cloneDeep(a.locales||{}),a.locales[o]=A.cloneDeep(a.locales[o]||{}),a.component==="custom-component"){const m=(c=a.config)==null?void 0:c.componentId;if(!m)return;const f=((l=t.components[m])==null?void 0:l.data)||((u=(d=t.resources.components)==null?void 0:d[m])==null?void 0:u.component);if(!f)return;a.locales[o].properties=A.cloneDeep(a.locales[o].properties||{}),Object.entries(s||{}).forEach(([x,y])=>{var h,v;const j=((h=f==null?void 0:f.properties)==null?void 0:h[x])||Object.values((f==null?void 0:f.properties)||{}).find(b=>{var k;return((k=b.data)==null?void 0:k.key)===x});j&&(a.locales[o].properties[(v=j.data)==null?void 0:v.id]={value:y})})}else a.locales[o]={...A.cloneDeep(a.locales[o]),...s||{}}})}const Lt=g.forwardRef(({onClick:e,...t},o)=>{const[r,i]=g.useState(!1),s=g.useCallback(async a=>{try{i(!0),await(e==null?void 0:e(a))}finally{i(!1)}},[e]);return n.jsx(pt.LoadingButton,{ref:o,...t,loading:t.loading||r,onClick:s})});function At({tip:e,tipSucceed:t,title:o,titleSucceed:r,icon:i,iconSucceed:s,autoReset:a,placement:c="top",...l}){const[d,u]=g.useState(!1),[m,f]=g.useState(),x=g.useRef(),y=()=>{f(void 0),a&&(x.current=window.setTimeout(()=>{u(!1)},3e3))},j=()=>{clearTimeout(x.current)},h=d?s:i,v=m?n.jsx(p.Box,{color:"error",children:m.message}):d&&t||e,b=d?r:o;return n.jsx(p.Tooltip,{title:v,disableInteractive:!0,placement:c,onClose:y,onOpen:j,children:n.jsx("span",{children:n.jsx(Lt,{startIcon:h&&(typeof h=="string"?n.jsx(ee.Icon,{icon:h}):h),loadingPosition:h?"start":void 0,...l,onClick:async k=>{if(l.onClick)try{await l.onClick(k),u(!0)}catch(N){f(N)}},children:b})})})}const Ot=Pe.default.lazy(()=>import("react-syntax-highlighter").then(e=>({default:e.Prism}))),Ut=p.styled(e=>n.jsx(Nt.default,{...e,remarkPlugins:[Pt.default],components:{pre:Mt,code:({node:t,inline:o,className:r,children:i,...s})=>{if(!i)return null;const a=/language-(\w+)/.exec(r||"");return o?n.jsx(p.Box,{component:"code",className:r,...s,children:i}):n.jsx(p.Box,{component:Ot,language:a==null?void 0:a[1],...s,sx:{borderRadius:1},children:String(i).replace(/\n$/,"")})},table:({className:t,children:o})=>n.jsx(p.Box,{sx:{overflow:"auto",my:1},children:n.jsx("table",{className:t,children:o})})}}))`
1
+ "use strict";var Ge=Object.create;var pe=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var Xe=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty;var Qe=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ke(t))!Ye.call(e,i)&&i!==o&&pe(e,i,{get:()=>t[i],enumerable:!(r=Je(t,i))||r.enumerable});return e};var xe=(e,t,o)=>(o=e!=null?Ge(Xe(e)):{},Qe(t||!e||!e.__esModule?pe(o,"default",{value:e,enumerable:!0}):o,e));const n=require("react/jsx-runtime"),w=require("./state-eTpgUKhB.js"),A=require("lodash"),$e=require("@arcblock/ux/lib/Locale/context"),Ze=require("@arcblock/ux/lib/Result"),et=require("@blocklet/pages-kit/builtin/page/header"),tt=require("@blocklet/ui-react/lib/Header"),_=require("@emotion/css"),Q=require("@emotion/react"),nt=require("@emotion/styled"),p=require("@mui/material"),Se=require("ahooks"),ot=require("isomorphic-dompurify"),rt=require("lodash/cloneDeep"),it=require("lodash/isEmpty"),st=require("lodash/isEqual"),g=require("react"),at=require("react-helmet"),B=require("react-router-dom"),U=require("react-use"),P=require("ufo");require("@mui/icons-material");const K=require("@blocklet/ai-runtime/components"),ct=require("@mui/utils"),lt=require("lodash/pick"),dt=require("react-error-boundary"),ee=require("@iconify/react"),ut=require("react-markdown"),mt=require("remark-gfm"),pt=require("@mui/lab"),$=require("@arcblock/ux/lib/Theme"),xt=require("@arcblock/react-hooks/lib/useBrowser"),ft=require("@arcblock/ux/lib/Colors"),re=require("@blocklet/pages-kit/components"),ht=require("@mui/material/useMediaQuery"),gt=require("lodash/omit"),Ce=require("@iconify-icon/react"),bt=require("@arcblock/ux/lib/Screenshot"),yt=require("@arcblock/ux/lib/Button"),jt=require("is-uri"),X=require("pathe"),wt=require("@blocklet/embed/message"),_t=require("@blocklet/embed/react"),vt=require("react-twitter-embed"),kt=require("@blocklet/ui-react/lib/Footer"),$t=require("webfontloader"),St=require("@arcblock/did-connect/lib/Session"),S=e=>e&&e.__esModule?e:{default:e},Be=S(Ze),Ct=S(tt),Ie=S(nt),Bt=S(ot),fe=S(rt),It=S(it),Ne=S(st),Pe=S(g),ie=S(lt),Nt=S(ut),Pt=S(mt),Rt=S(xt),he=S(ft),Re=S(ht),R=S(gt),Tt=S(bt),qt=S(yt),te=S(jt),Et=S(kt),zt=S($t);function Wt(e,t,o,r){e.locales||(e.locales={}),e.locales[o]=A.cloneDeep(e.locales[o]||{}),e.locales[o].title=r.title??e.locales[o].title,e.locales[o].image=r.image??e.locales[o].image,e.locales[o].description=r.description??e.locales[o].description,Object.entries(r.sectionsData).forEach(([i,s])=>{var c,l,d,u;const a=Object.values(e.sections).find(m=>m.id===i||m.name===i);if(a&&a.isTemplateSection)if(a.locales=A.cloneDeep(a.locales||{}),a.locales[o]=A.cloneDeep(a.locales[o]||{}),a.component==="custom-component"){const m=(c=a.config)==null?void 0:c.componentId;if(!m)return;const f=((l=t.components[m])==null?void 0:l.data)||((u=(d=t.resources.components)==null?void 0:d[m])==null?void 0:u.component);if(!f)return;a.locales[o].properties=A.cloneDeep(a.locales[o].properties||{}),Object.entries(s||{}).forEach(([x,y])=>{var h,v;const j=((h=f==null?void 0:f.properties)==null?void 0:h[x])||Object.values((f==null?void 0:f.properties)||{}).find(b=>{var k;return((k=b.data)==null?void 0:k.key)===x});j&&(a.locales[o].properties[(v=j.data)==null?void 0:v.id]={value:y})})}else a.locales[o]={...A.cloneDeep(a.locales[o]),...s||{}}})}const Lt=g.forwardRef(({onClick:e,...t},o)=>{const[r,i]=g.useState(!1),s=g.useCallback(async a=>{try{i(!0),await(e==null?void 0:e(a))}finally{i(!1)}},[e]);return n.jsx(pt.LoadingButton,{ref:o,...t,loading:t.loading||r,onClick:s})});function At({tip:e,tipSucceed:t,title:o,titleSucceed:r,icon:i,iconSucceed:s,autoReset:a,placement:c="top",...l}){const[d,u]=g.useState(!1),[m,f]=g.useState(),x=g.useRef(),y=()=>{f(void 0),a&&(x.current=window.setTimeout(()=>{u(!1)},3e3))},j=()=>{clearTimeout(x.current)},h=d?s:i,v=m?n.jsx(p.Box,{color:"error",children:m.message}):d&&t||e,b=d?r:o;return n.jsx(p.Tooltip,{title:v,disableInteractive:!0,placement:c,onClose:y,onOpen:j,children:n.jsx("span",{children:n.jsx(Lt,{startIcon:h&&(typeof h=="string"?n.jsx(ee.Icon,{icon:h}):h),loadingPosition:h?"start":void 0,...l,onClick:async k=>{if(l.onClick)try{await l.onClick(k),u(!0)}catch(N){f(N)}},children:b})})})}const Ot=Pe.default.lazy(()=>import("react-syntax-highlighter").then(e=>({default:e.Prism}))),Ut=p.styled(e=>n.jsx(Nt.default,{...e,remarkPlugins:[Pt.default],components:{pre:Mt,code:({node:t,inline:o,className:r,children:i,...s})=>{if(!i)return null;const a=/language-(\w+)/.exec(r||"");return o?n.jsx(p.Box,{component:"code",className:r,...s,children:i}):n.jsx(p.Box,{component:Ot,language:a==null?void 0:a[1],...s,sx:{borderRadius:1},children:String(i).replace(/\n$/,"")})},table:({className:t,children:o})=>n.jsx(p.Box,{sx:{overflow:"auto",my:1},children:n.jsx("table",{className:t,children:o})})}}))`
2
2
  width: 100%;
3
3
  overflow: hidden;
4
4
  word-break: break-word;
@@ -530,11 +530,11 @@
530
530
  font-family: ${JSON.stringify(t)}, ${ve};
531
531
  }
532
532
  }
533
- `})}const{SessionProvider:po,SessionContext:eo,SessionConsumer:xo,withSession:fo}=St.createAuthServiceSessionContext();function ce(){return g.useContext(eo)}function to(...e){var o;const{session:t}=ce();return e.includes((o=t.user)==null?void 0:o.role)}function no(...e){var r;const{session:t}=ce(),o=to(...e);return((r=window.blocklet)==null?void 0:r.tenantMode)==="multiple"?!!t.user:o}function oo(e){return e!=null}function ro(){const[e]=B.useSearchParams(),{session:t}=ce(),o=no("owner","admin","pagesEditor","member"),r=g.useMemo(()=>{const s=e.get("mode");return Un.includes(s)?s:"production"},[e]),i=r==="production"?r:t.user?o?r:"production":null;return i?n.jsx(Me,{mode:i}):null}function Me({mode:e}){if(e!=="draft"){const t=window.__PAGE_STATE__;return t?n.jsx(Y,{mode:e,state:t}):n.jsx(so,{mode:e,children:({state:o})=>n.jsx(Y,{mode:e,state:o})})}return n.jsx(io,{children:({state:t})=>n.jsx(Y,{mode:e,state:t})})}const io=g.lazy(()=>Promise.resolve().then(()=>require("./draft-data-CE4YeR_n.js")));function so({mode:e,children:t}){const o=document.querySelector('meta[property="pages:version"]'),r=o==null?void 0:o.content,i=w.useProjectId(),s=g.useMemo(()=>{if(r==="{{pagesPublishedAt}}"){const l=localStorage.getItem(w.getProjectPageVersionKey(i??""));return Number(l)?Number(l):new Date().getTime()}return Number(r)},[r]),{loading:a,value:c}=U.useAsync(()=>Oe({mode:e,version:s}),[e,s]);return a?n.jsx(Ue,{}):c?t({state:c}):null}function Y({mode:e,state:t}){var y,j,h,v;const{t:o,locale:r}=$e.useLocaleContext(),{pageIds:i,pages:s,supportedLocales:a,config:{defaultLocale:c},resources:l}=t,d=w.getAllComponents(t),u=g.useMemo(()=>a!=null&&a.some(b=>b.locale===r)?r:void 0,[r,a]),m=Object.values(s).find(b=>(b==null?void 0:b.slug)==="/")?void 0:Object.values(s)[0],f=g.useMemo(()=>i.map(b=>{const k=s[b];return k&&{id:k.id,path:P.joinURL("/",u||"",k.slug,e!=="production"?`?mode=${e}`:"")}}).filter(oo),[i,s,u,e]),x=([...b])=>(e!=="production"&&b.unshift(n.jsx(g.Suspense,{fallback:n.jsx("div",{}),children:n.jsx(co,{mode:"production",state:t})})),b);return n.jsxs(nn,{value:{pages:f},children:[n.jsxs(B.Routes,{children:[m&&n.jsx(B.Route,{index:!0,element:n.jsx(B.Navigate,{to:P.joinURL("/",u||"",m.slug)})}),i.map(b=>{const k=s[b];return k?n.jsx(B.Route,{path:P.joinURL(":projectIdOrSlug?",k.slug),element:n.jsx(Z,{mode:e,components:d,page:k,locale:u,defaultLocale:c,headerAddons:x})},k.id):null}),l.pages&&Object.values(l.pages).map(({blockletId:b,page:k})=>n.jsx(B.Route,{path:P.joinURL("/",`@${b}`,k.slug),element:n.jsx(Z,{mode:e,components:d,page:k,locale:u,defaultLocale:c,headerAddons:x})},k.id)),n.jsx(B.Route,{path:"*",element:n.jsx(p.Box,{width:"100vw",height:"100vh",display:"flex",justifyContent:"center",alignItems:"center",children:n.jsx(Be.default,{status:404,extra:n.jsx(Ve,{href:"/",children:o("common.back")})})})})]}),e!=="production"&&n.jsx(Xn,{sx:{bgcolor:"info.light"},children:e}),n.jsx(Zn,{titleFontFamily:(j=(y=t.config)==null?void 0:y.fontFamily)==null?void 0:j.title,descriptionFontFamily:(v=(h=t.config)==null?void 0:h.fontFamily)==null?void 0:v.description})]})}function ao({mode:e,state:t,path:o,pageData:r}){const{t:i,locale:s}=$e.useLocaleContext(),{pages:a,supportedLocales:c,config:{defaultLocale:l},resources:d}=t,u=Object.values(a).find(h=>(h==null?void 0:h.slug)===o),m=Object.values(d.pages||{}).find(h=>h.page.slug===o),f=g.useMemo(()=>c!=null&&c.some(h=>h.locale===s)?s:void 0,[s,c]),x=Se.useReactive({page:null});g.useEffect(()=>{const h=u||(m==null?void 0:m.page)||null;h?x.page=fe.default(h):x.page=null},[u,m]);const y=g.useRef();if(g.useEffect(()=>{Ne.default(r,y.current)||r&&x.page&&(Wt(x.page,t,f,r),y.current=fe.default(r))},[{}]),!u&&!(m!=null&&m.page))return n.jsx(p.Box,{width:"100vw",height:"100vh",display:"flex",justifyContent:"center",alignItems:"center",children:n.jsx(Be.default,{style:{background:"inherit"},status:404,extra:n.jsx(Ve,{href:"/",children:i("common.back")})})});const j=w.getAllComponents(t);return x.page?n.jsx(Z,{mode:e,components:j,page:x.page,locale:f,defaultLocale:l}):null}function Z({mode:e,components:t,page:o,locale:r,defaultLocale:i,headerAddons:s}){var h,v,b,k,N,W,J,le,de;const a=((h=o.locales)==null?void 0:h[r])??((v=o.locales)==null?void 0:v[i])??{},c=a.title||((b=window.blocklet)==null?void 0:b.appName),l=a.description||((k=window.blocklet)==null?void 0:k.appDescription),d=w.autoResizeImage(w.getImageAbsoluteUrl(a.image),540),{logo:u,brand:m,description:f,...x}=et.useHeaderState(),y=g.useMemo(()=>E=>{var L;let C=(s==null?void 0:s(E))??E;return C=((L=x.addons)==null?void 0:L.call(x,C))??C,C},[x.addons,s]),j=(N=a.header)!=null&&N.translucent?Fe:He;return n.jsxs(n.Fragment,{children:[!!a.backgroundColor&&n.jsx(Q.Global,{styles:Q.css`
533
+ `})}const{SessionProvider:po,SessionContext:eo,SessionConsumer:xo,withSession:fo}=St.createAuthServiceSessionContext();function ce(){return g.useContext(eo)}function to(...e){var o;const{session:t}=ce();return e.includes((o=t.user)==null?void 0:o.role)}function no(...e){var r;const{session:t}=ce(),o=to(...e);return((r=window.blocklet)==null?void 0:r.tenantMode)==="multiple"?!!t.user:o}function oo(e){return e!=null}function ro(){const[e]=B.useSearchParams(),{session:t}=ce(),o=no("owner","admin","pagesEditor","member"),r=g.useMemo(()=>{const s=e.get("mode");return Un.includes(s)?s:"production"},[e]),i=r==="production"?r:t.user?o?r:"production":null;return i?n.jsx(Me,{mode:i}):null}function Me({mode:e}){if(e!=="draft"){const t=window.__PAGE_STATE__;return t?n.jsx(Y,{mode:e,state:t}):n.jsx(so,{mode:e,children:({state:o})=>n.jsx(Y,{mode:e,state:o})})}return n.jsx(io,{children:({state:t})=>n.jsx(Y,{mode:e,state:t})})}const io=g.lazy(()=>Promise.resolve().then(()=>require("./draft-data-Quz8toC_.js")));function so({mode:e,children:t}){const o=document.querySelector('meta[property="pages:version"]'),r=o==null?void 0:o.content,i=w.useProjectId(),s=g.useMemo(()=>{if(r==="{{pagesPublishedAt}}"){const l=localStorage.getItem(w.getProjectPageVersionKey(i??""));return Number(l)?Number(l):new Date().getTime()}return Number(r)},[r]),{loading:a,value:c}=U.useAsync(()=>Oe({mode:e,version:s}),[e,s]);return a?n.jsx(Ue,{}):c?t({state:c}):null}function Y({mode:e,state:t}){var y,j,h,v;const{t:o,locale:r}=$e.useLocaleContext(),{pageIds:i,pages:s,supportedLocales:a,config:{defaultLocale:c},resources:l}=t,d=w.getAllComponents(t),u=g.useMemo(()=>a!=null&&a.some(b=>b.locale===r)?r:void 0,[r,a]),m=Object.values(s).find(b=>(b==null?void 0:b.slug)==="/")?void 0:Object.values(s)[0],f=g.useMemo(()=>i.map(b=>{const k=s[b];return k&&{id:k.id,path:P.joinURL("/",u||"",k.slug,e!=="production"?`?mode=${e}`:"")}}).filter(oo),[i,s,u,e]),x=([...b])=>(e!=="production"&&b.unshift(n.jsx(g.Suspense,{fallback:n.jsx("div",{}),children:n.jsx(co,{mode:"production",state:t})})),b);return n.jsxs(nn,{value:{pages:f},children:[n.jsxs(B.Routes,{children:[m&&n.jsx(B.Route,{index:!0,element:n.jsx(B.Navigate,{to:P.joinURL("/",u||"",m.slug)})}),i.map(b=>{const k=s[b];return k?n.jsx(B.Route,{path:P.joinURL(":projectIdOrSlug?",k.slug),element:n.jsx(Z,{mode:e,components:d,page:k,locale:u,defaultLocale:c,headerAddons:x})},k.id):null}),l.pages&&Object.values(l.pages).map(({blockletId:b,page:k})=>n.jsx(B.Route,{path:P.joinURL("/",`@${b}`,k.slug),element:n.jsx(Z,{mode:e,components:d,page:k,locale:u,defaultLocale:c,headerAddons:x})},k.id)),n.jsx(B.Route,{path:"*",element:n.jsx(p.Box,{width:"100vw",height:"100vh",display:"flex",justifyContent:"center",alignItems:"center",children:n.jsx(Be.default,{status:404,extra:n.jsx(Ve,{href:"/",children:o("common.back")})})})})]}),e!=="production"&&n.jsx(Xn,{sx:{bgcolor:"info.light"},children:e}),n.jsx(Zn,{titleFontFamily:(j=(y=t.config)==null?void 0:y.fontFamily)==null?void 0:j.title,descriptionFontFamily:(v=(h=t.config)==null?void 0:h.fontFamily)==null?void 0:v.description})]})}function ao({mode:e,state:t,path:o,pageData:r}){const{t:i,locale:s}=$e.useLocaleContext(),{pages:a,supportedLocales:c,config:{defaultLocale:l},resources:d}=t,u=Object.values(a).find(h=>(h==null?void 0:h.slug)===o),m=Object.values(d.pages||{}).find(h=>h.page.slug===o),f=g.useMemo(()=>c!=null&&c.some(h=>h.locale===s)?s:void 0,[s,c]),x=Se.useReactive({page:null});g.useEffect(()=>{const h=u||(m==null?void 0:m.page)||null;h?x.page=fe.default(h):x.page=null},[u,m]);const y=g.useRef();if(g.useEffect(()=>{Ne.default(r,y.current)||r&&x.page&&(Wt(x.page,t,f,r),y.current=fe.default(r))},[{}]),!u&&!(m!=null&&m.page))return n.jsx(p.Box,{width:"100vw",height:"100vh",display:"flex",justifyContent:"center",alignItems:"center",children:n.jsx(Be.default,{style:{background:"inherit"},status:404,extra:n.jsx(Ve,{href:"/",children:i("common.back")})})});const j=w.getAllComponents(t);return x.page?n.jsx(Z,{mode:e,components:j,page:x.page,locale:f,defaultLocale:l}):null}function Z({mode:e,components:t,page:o,locale:r,defaultLocale:i,headerAddons:s}){var h,v,b,k,N,W,J,le,de;const a=((h=o.locales)==null?void 0:h[r])??((v=o.locales)==null?void 0:v[i])??{},c=a.title||((b=window.blocklet)==null?void 0:b.appName),l=a.description||((k=window.blocklet)==null?void 0:k.appDescription),d=w.autoResizeImage(w.getImageAbsoluteUrl(a.image),540),{logo:u,brand:m,description:f,...x}=et.useHeaderState(),y=g.useMemo(()=>E=>{var L;let C=(s==null?void 0:s(E))??E;return C=((L=x.addons)==null?void 0:L.call(x,C))??C,C},[x.addons,s]),j=(N=a.header)!=null&&N.translucent?Fe:He;return n.jsxs(n.Fragment,{children:[!!a.backgroundColor&&n.jsx(Q.Global,{styles:Q.css`
534
534
  body {
535
535
  background-color: ${a.backgroundColor} !important;
536
536
  }
537
- `}),n.jsx(j,{hideNavMenu:!!((W=a.header)!=null&&W.hideNavMenus),translucentTextColor:(J=a.header)==null?void 0:J.translucentTextColor,...u?{logo:u}:{},...m?{brand:m}:{},...f?{description:f}:{},className:_.cx(((le=a.header)==null?void 0:le.sticky)&&"sticky","page-header"),maxWidth:!1,addons:y}),n.jsx(B.ScrollRestoration,{}),n.jsxs(at.Helmet,{children:[n.jsx("title",{children:c}),n.jsx("meta",{name:"og:title",content:c}),n.jsx("meta",{name:"og:description",content:l}),n.jsx("meta",{name:"og:image",content:d}),n.jsx("meta",{name:"twitter:image:src",content:d}),n.jsx("meta",{name:"twitter:image",content:d}),n.jsx("meta",{property:"twitter:description",content:l}),n.jsx("meta",{property:"twitter:title",content:c}),n.jsx("meta",{name:"description",content:l})]}),n.jsx(p.Stack,{flexGrow:1,children:o.sectionIds.map(E=>{var ue,me;const C=o.sections[E];if(!C||C.visibility==="hidden")return null;const L=(ue=C.locales)==null?void 0:ue[r],De=((me=C.locales)==null?void 0:me[i])??{};return n.jsx(Gn,{id:E,type:C.component,mode:e,section:C,config:{...It.default(L)?De:L,locale:r,dev:e==="draft"?{mode:e,components:t,defaultLocale:i}:{mode:e}}},E)})}),!((de=a.footer)!=null&&de.hidden)&&n.jsx(Kn,{})]})}const co=g.lazy(()=>Promise.resolve().then(()=>require("./publish-button-BRVXtU3n.js"))),He=Ie.default(Ct.default)`
537
+ `}),n.jsx(j,{hideNavMenu:!!((W=a.header)!=null&&W.hideNavMenus),translucentTextColor:(J=a.header)==null?void 0:J.translucentTextColor,...u?{logo:u}:{},...m?{brand:m}:{},...f?{description:f}:{},className:_.cx(((le=a.header)==null?void 0:le.sticky)&&"sticky","page-header"),maxWidth:!1,addons:y}),n.jsx(B.ScrollRestoration,{}),n.jsxs(at.Helmet,{children:[n.jsx("title",{children:c}),n.jsx("meta",{name:"og:title",content:c}),n.jsx("meta",{name:"og:description",content:l}),n.jsx("meta",{name:"og:image",content:d}),n.jsx("meta",{name:"twitter:image:src",content:d}),n.jsx("meta",{name:"twitter:image",content:d}),n.jsx("meta",{property:"twitter:description",content:l}),n.jsx("meta",{property:"twitter:title",content:c}),n.jsx("meta",{name:"description",content:l})]}),n.jsx(p.Stack,{flexGrow:1,children:o.sectionIds.map(E=>{var ue,me;const C=o.sections[E];if(!C||C.visibility==="hidden")return null;const L=(ue=C.locales)==null?void 0:ue[r],De=((me=C.locales)==null?void 0:me[i])??{};return n.jsx(Gn,{id:E,type:C.component,mode:e,section:C,config:{...It.default(L)?De:L,locale:r,dev:e==="draft"?{mode:e,components:t,defaultLocale:i}:{mode:e}}},E)})}),!((de=a.footer)!=null&&de.hidden)&&n.jsx(Kn,{})]})}const co=g.lazy(()=>Promise.resolve().then(()=>require("./publish-button-6WQRr1s7.js"))),He=Ie.default(Ct.default)`
538
538
  &.sticky {
539
539
  position: sticky;
540
540
  top: 0;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("./state-oKsa8z3D.js"),q=require("@arcblock/ux/lib/Locale/context"),O=require("@arcblock/ux/lib/Toast"),S=require("@mui/icons-material"),E=require("@mui/lab"),s=require("@mui/material"),W=require("immer"),z=require("lodash/difference"),c=require("react"),_=require("react-use"),C=require("./home-BW7VfExi.js"),M=t=>t&&t.__esModule?t:{default:t},A=M(O),D=M(z);function N(t){const[d,b]=c.useState(!1);return e.jsx(E.LoadingButton,{...t,loading:t.loading||d,onClick:i=>{var h;const m=(h=t.onClick)==null?void 0:h.call(t,i);m instanceof Promise&&(b(!0),m.finally(()=>{b(!1)}))}})}const R=s.createSvgIcon(e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M7.75732 16.2426L16.2426 7.75736",stroke:"#4B5563",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M16.2426 16.2426L7.75732 7.75735",stroke:"#4B5563",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Close");function F(){const[t,d]=c.useState(),b=c.useMemo(()=>t?e.jsx(s.Dialog,{...t}):null,[t]),i=c.useCallback(()=>{d(void 0)},[]),m=c.useCallback(({title:h,content:g,cancelText:T="Cancel",okText:p="Ok",onOk:f,onClose:k,okIcon:L,okColor:n="primary",cancelColor:y="primary",DialogContentProps:u,form:x,...I})=>{d({...I,open:!0,children:e.jsxs("form",{onSubmit:P=>P.preventDefault(),children:[h&&e.jsxs(s.DialogTitle,{className:"between",zIndex:"appBar",bgcolor:"background.paper",sx:{borderBottom:"1px solid #E5E7EB"},children:[e.jsx(s.Box,{children:h}),e.jsx(s.IconButton,{size:"small",onClick:async()=>{i(),k==null||k()},children:e.jsx(R,{})})]}),g&&e.jsx(s.DialogContent,{...u,sx:{mt:-3,...u==null?void 0:u.sx},children:e.jsx(s.Box,{pt:3,children:g})}),e.jsxs(s.DialogActions,{children:[e.jsx(s.Button,{variant:"outlined",color:y||"primary",onClick:k??i,children:T}),e.jsx(N,{variant:"contained",color:n||"primary",startIcon:L,loadingPosition:L?"start":"center",onClick:async()=>{await(f==null?void 0:f()),i()},type:"submit",children:p})]})]}),onClose:k??i})},[i]);return{dialog:b,showDialog:m,closeDialog:i}}const H=c.forwardRef(({mode:t,state:d},b)=>{const{t:i}=q.useLocaleContext(),[m,h]=c.useState(!1),{dialog:g,showDialog:T}=F(),p=v.useProjectId(),f=c.useCallback(L=>{let n=[];T({title:i("maker.publishToProduction"),content:e.jsxs(s.Box,{sx:{minWidth:300},children:[e.jsx(s.Alert,{color:"warning",icon:e.jsx(S.Warning,{}),children:i("maker.publishToProductionTip")}),e.jsx(s.Box,{maxHeight:"50vh",overflow:"auto",mt:2,children:e.jsx(J,{state:d,toMode:t,onChange:y=>n=y,defaultPageIds:L})})]}),okText:i("maker.publish"),cancelText:i("common.cancel"),onOk:async()=>{var y,u;if((n==null?void 0:n.length)===0){const x=i("maker.publishSelectPagesMessage");throw A.default.error(x),new Error(x)}for(const x of n??d.pageIds){const I=d.pages[x];if(I){const P=(u=(y=v.checkPage(i,I,d))==null?void 0:y[0])==null?void 0:u.message;if(P)throw A.default.error(P),new Error(P)}}localStorage.setItem(v.getProjectPageVersionKey(p??""),String(new Date().getTime())),h(!0);try{await C.publishPages({mode:t,pages:n}),A.default.success(i("maker.publishSuccessMessage"))}catch(x){throw A.default.error(x.message),x}finally{h(!1)}}})},[t,d,i,p,T]);c.useImperativeHandle(b,()=>({openPublishDialog:f}));const k=c.useCallback(()=>{f()},[f]);return e.jsxs(e.Fragment,{children:[e.jsx(E.LoadingButton,{color:"primary",variant:"contained",size:"small",sx:{mr:1},onClick:k,loading:m,disabled:m,children:i("maker.publishToProduction")}),g]})});function J({state:t,toMode:d,onChange:b,defaultPageIds:i}){const{t:m,locale:h}=q.useLocaleContext(),[g,T]=c.useState(!1),[p,f]=c.useState(()=>i?Object.fromEntries(i.map(r=>[r,!0])):{}),{loading:k,error:L,value:n}=_.useAsync(()=>C.getPages({mode:d}),[d]);if(L)throw L;const y=c.useMemo(()=>JSON.parse(JSON.stringify(t.pageIds)).sort((a,j)=>{const o=t.pages[a],l=t.pages[j];return o!=null&&o.publishedAt&&new Date(o.publishedAt).getTime()<new Date(o.updatedAt).getTime()?-1:l!=null&&l.publishedAt&&new Date(l.publishedAt).getTime()<new Date(l.updatedAt).getTime()?1:new Date((o==null?void 0:o.updatedAt)??"").getTime()-new Date((l==null?void 0:l.updatedAt)??"").getTime()}),[t]),u=c.useMemo(()=>n?D.default(n.pageIds,t.pageIds):[],[t,n]),x=c.useMemo(()=>[...t.pageIds].concat(u),[t,u]),I=c.useCallback(r=>{f(a=>{const j=W.produce(a,o=>{g?(Object.assign(o,Object.fromEntries(x.map(l=>[l,!0]))),delete o[r]):o[r]?(delete o[r],u.includes(r)&&t.pageIds.filter(l=>{var w,B;return((w=t.pages[l])==null?void 0:w.slug)===((B=n==null?void 0:n.pages[r])==null?void 0:B.slug)}).forEach(l=>{delete o[l]})):(o[r]=!0,t.pageIds.includes(r)&&u.filter(l=>{var w,B;return((w=n==null?void 0:n.pages[l])==null?void 0:w.slug)===((B=t.pages[r])==null?void 0:B.slug)}).forEach(l=>{o[l]=!0}))});return T(D.default(x,Object.keys(j)).length===0),j})},[g,x,u,t,n]),P=c.useCallback(()=>{T(r=>(r&&f({}),!r))},[p]);return c.useEffect(()=>{b(g?null:Object.keys(p))},[g,p,b]),k?e.jsx(C.Loading,{sx:{my:4}}):e.jsxs(s.List,{disablePadding:!0,sx:{maxWidth:500},children:[e.jsx(s.ListItem,{sx:{position:"sticky",top:0,bgcolor:"background.paper",zIndex:1},disablePadding:!0,children:e.jsxs(s.ListItemButton,{onClick:P,dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:g,tabIndex:-1})}),e.jsx(s.ListItemText,{primary:m("common.all")})]})}),y.map(r=>{var l,w;const a=t.pages[r];if(!a)return null;const j=v.checkPage(m,a,t),o=!a.publishedAt||a.updatedAt&&new Date(a.updatedAt).getTime()>new Date(a.publishedAt).getTime();return e.jsx(s.ListItem,{disablePadding:!0,secondaryAction:e.jsxs(e.Fragment,{children:[o&&e.jsx(s.Tooltip,{title:m("maker.pages.needPublish"),children:e.jsx(S.Sync,{fontSize:"small",sx:{color:"warning.main",fontSize:16,mr:.35}})}),!a.isPublic&&e.jsx(s.Tooltip,{title:m("maker.pages.notPublic"),children:e.jsx(S.VisibilityOff,{fontSize:"small",sx:{color:"warning.main",fontSize:16,mr:.35}})}),j&&e.jsx(v.PageErrorTip,{errors:j,children:e.jsx(S.Warning,{sx:{color:"error.dark",mr:.35}})})]}),children:e.jsxs(s.ListItemButton,{onClick:()=>I(r),dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:g||!!p[r],tabIndex:-1})}),e.jsx(s.ListItemText,{primary:a.slug,secondary:(w=(l=a.locales)==null?void 0:l[h])==null?void 0:w.title,primaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"},secondaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"}})]})},r)}),u.map(r=>{var j,o;const a=n==null?void 0:n.pages[r];return a?e.jsx(s.ListItem,{disablePadding:!0,secondaryAction:e.jsx(s.Chip,{color:"warning",label:"deleted",size:"small"}),children:e.jsxs(s.ListItemButton,{onClick:()=>I(r),dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:g||!!p[r],tabIndex:-1})}),e.jsx(s.ListItemText,{primary:a.slug,secondary:(o=(j=a.locales)==null?void 0:j[h])==null?void 0:o.title,primaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"},secondaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"}})]})},r):null})]})}exports.default=H;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("./state-eTpgUKhB.js"),q=require("@arcblock/ux/lib/Locale/context"),O=require("@arcblock/ux/lib/Toast"),S=require("@mui/icons-material"),E=require("@mui/lab"),s=require("@mui/material"),W=require("immer"),z=require("lodash/difference"),c=require("react"),_=require("react-use"),C=require("./home-D9IcqQld.js"),M=t=>t&&t.__esModule?t:{default:t},A=M(O),D=M(z);function N(t){const[d,b]=c.useState(!1);return e.jsx(E.LoadingButton,{...t,loading:t.loading||d,onClick:i=>{var h;const m=(h=t.onClick)==null?void 0:h.call(t,i);m instanceof Promise&&(b(!0),m.finally(()=>{b(!1)}))}})}const R=s.createSvgIcon(e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M7.75732 16.2426L16.2426 7.75736",stroke:"#4B5563",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M16.2426 16.2426L7.75732 7.75735",stroke:"#4B5563",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Close");function F(){const[t,d]=c.useState(),b=c.useMemo(()=>t?e.jsx(s.Dialog,{...t}):null,[t]),i=c.useCallback(()=>{d(void 0)},[]),m=c.useCallback(({title:h,content:g,cancelText:T="Cancel",okText:p="Ok",onOk:f,onClose:k,okIcon:L,okColor:n="primary",cancelColor:y="primary",DialogContentProps:u,form:x,...I})=>{d({...I,open:!0,children:e.jsxs("form",{onSubmit:P=>P.preventDefault(),children:[h&&e.jsxs(s.DialogTitle,{className:"between",zIndex:"appBar",bgcolor:"background.paper",sx:{borderBottom:"1px solid #E5E7EB"},children:[e.jsx(s.Box,{children:h}),e.jsx(s.IconButton,{size:"small",onClick:async()=>{i(),k==null||k()},children:e.jsx(R,{})})]}),g&&e.jsx(s.DialogContent,{...u,sx:{mt:-3,...u==null?void 0:u.sx},children:e.jsx(s.Box,{pt:3,children:g})}),e.jsxs(s.DialogActions,{children:[e.jsx(s.Button,{variant:"outlined",color:y||"primary",onClick:k??i,children:T}),e.jsx(N,{variant:"contained",color:n||"primary",startIcon:L,loadingPosition:L?"start":"center",onClick:async()=>{await(f==null?void 0:f()),i()},type:"submit",children:p})]})]}),onClose:k??i})},[i]);return{dialog:b,showDialog:m,closeDialog:i}}const H=c.forwardRef(({mode:t,state:d},b)=>{const{t:i}=q.useLocaleContext(),[m,h]=c.useState(!1),{dialog:g,showDialog:T}=F(),p=v.useProjectId(),f=c.useCallback(L=>{let n=[];T({title:i("maker.publishToProduction"),content:e.jsxs(s.Box,{sx:{minWidth:300},children:[e.jsx(s.Alert,{color:"warning",icon:e.jsx(S.Warning,{}),children:i("maker.publishToProductionTip")}),e.jsx(s.Box,{maxHeight:"50vh",overflow:"auto",mt:2,children:e.jsx(J,{state:d,toMode:t,onChange:y=>n=y,defaultPageIds:L})})]}),okText:i("maker.publish"),cancelText:i("common.cancel"),onOk:async()=>{var y,u;if((n==null?void 0:n.length)===0){const x=i("maker.publishSelectPagesMessage");throw A.default.error(x),new Error(x)}for(const x of n??d.pageIds){const I=d.pages[x];if(I){const P=(u=(y=v.checkPage(i,I,d))==null?void 0:y[0])==null?void 0:u.message;if(P)throw A.default.error(P),new Error(P)}}localStorage.setItem(v.getProjectPageVersionKey(p??""),String(new Date().getTime())),h(!0);try{await C.publishPages({mode:t,pages:n}),A.default.success(i("maker.publishSuccessMessage"))}catch(x){throw A.default.error(x.message),x}finally{h(!1)}}})},[t,d,i,p,T]);c.useImperativeHandle(b,()=>({openPublishDialog:f}));const k=c.useCallback(()=>{f()},[f]);return e.jsxs(e.Fragment,{children:[e.jsx(E.LoadingButton,{color:"primary",variant:"contained",size:"small",sx:{mr:1},onClick:k,loading:m,disabled:m,children:i("maker.publishToProduction")}),g]})});function J({state:t,toMode:d,onChange:b,defaultPageIds:i}){const{t:m,locale:h}=q.useLocaleContext(),[g,T]=c.useState(!1),[p,f]=c.useState(()=>i?Object.fromEntries(i.map(r=>[r,!0])):{}),{loading:k,error:L,value:n}=_.useAsync(()=>C.getPages({mode:d}),[d]);if(L)throw L;const y=c.useMemo(()=>JSON.parse(JSON.stringify(t.pageIds)).sort((a,j)=>{const o=t.pages[a],l=t.pages[j];return o!=null&&o.publishedAt&&new Date(o.publishedAt).getTime()<new Date(o.updatedAt).getTime()?-1:l!=null&&l.publishedAt&&new Date(l.publishedAt).getTime()<new Date(l.updatedAt).getTime()?1:new Date((o==null?void 0:o.updatedAt)??"").getTime()-new Date((l==null?void 0:l.updatedAt)??"").getTime()}),[t]),u=c.useMemo(()=>n?D.default(n.pageIds,t.pageIds):[],[t,n]),x=c.useMemo(()=>[...t.pageIds].concat(u),[t,u]),I=c.useCallback(r=>{f(a=>{const j=W.produce(a,o=>{g?(Object.assign(o,Object.fromEntries(x.map(l=>[l,!0]))),delete o[r]):o[r]?(delete o[r],u.includes(r)&&t.pageIds.filter(l=>{var w,B;return((w=t.pages[l])==null?void 0:w.slug)===((B=n==null?void 0:n.pages[r])==null?void 0:B.slug)}).forEach(l=>{delete o[l]})):(o[r]=!0,t.pageIds.includes(r)&&u.filter(l=>{var w,B;return((w=n==null?void 0:n.pages[l])==null?void 0:w.slug)===((B=t.pages[r])==null?void 0:B.slug)}).forEach(l=>{o[l]=!0}))});return T(D.default(x,Object.keys(j)).length===0),j})},[g,x,u,t,n]),P=c.useCallback(()=>{T(r=>(r&&f({}),!r))},[p]);return c.useEffect(()=>{b(g?null:Object.keys(p))},[g,p,b]),k?e.jsx(C.Loading,{sx:{my:4}}):e.jsxs(s.List,{disablePadding:!0,sx:{maxWidth:500},children:[e.jsx(s.ListItem,{sx:{position:"sticky",top:0,bgcolor:"background.paper",zIndex:1},disablePadding:!0,children:e.jsxs(s.ListItemButton,{onClick:P,dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:g,tabIndex:-1})}),e.jsx(s.ListItemText,{primary:m("common.all")})]})}),y.map(r=>{var l,w;const a=t.pages[r];if(!a)return null;const j=v.checkPage(m,a,t),o=!a.publishedAt||a.updatedAt&&new Date(a.updatedAt).getTime()>new Date(a.publishedAt).getTime();return e.jsx(s.ListItem,{disablePadding:!0,secondaryAction:e.jsxs(e.Fragment,{children:[o&&e.jsx(s.Tooltip,{title:m("maker.pages.needPublish"),children:e.jsx(S.Sync,{fontSize:"small",sx:{color:"warning.main",fontSize:16,mr:.35}})}),!a.isPublic&&e.jsx(s.Tooltip,{title:m("maker.pages.notPublic"),children:e.jsx(S.VisibilityOff,{fontSize:"small",sx:{color:"warning.main",fontSize:16,mr:.35}})}),j&&e.jsx(v.PageErrorTip,{errors:j,children:e.jsx(S.Warning,{sx:{color:"error.dark",mr:.35}})})]}),children:e.jsxs(s.ListItemButton,{onClick:()=>I(r),dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:g||!!p[r],tabIndex:-1})}),e.jsx(s.ListItemText,{primary:a.slug,secondary:(w=(l=a.locales)==null?void 0:l[h])==null?void 0:w.title,primaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"},secondaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"}})]})},r)}),u.map(r=>{var j,o;const a=n==null?void 0:n.pages[r];return a?e.jsx(s.ListItem,{disablePadding:!0,secondaryAction:e.jsx(s.Chip,{color:"warning",label:"deleted",size:"small"}),children:e.jsxs(s.ListItemButton,{onClick:()=>I(r),dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:g||!!p[r],tabIndex:-1})}),e.jsx(s.ListItemText,{primary:a.slug,secondary:(o=(j=a.locales)==null?void 0:j[h])==null?void 0:o.title,primaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"},secondaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"}})]})},r):null})]})}exports.default=H;
@@ -0,0 +1 @@
1
+ "use strict";const j=require("react/jsx-runtime"),b=require("@mui/material"),Q=require("gradient-parser"),X=require("tinycolor2"),y=require("ufo"),Y=require("@blocklet/js-sdk"),Z=require("lodash/isEmpty"),H=require("yaml"),W=require("@syncedstore/core"),ee=require("@syncedstore/react"),te=require("ahooks"),x=require("immer"),ne=require("js-cookie"),oe=require("lodash/debounce"),re=require("nanoid"),d=require("react"),N=require("react-router-dom"),se=require("y-indexeddb"),ie=require("y-websocket"),ce=require("yjs"),C=e=>e&&e.__esModule?e:{default:e};function ae(e){if(e&&e.__esModule)return e;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const u=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,u.get?u:{enumerable:!0,get:()=>e[a]})}}return n.default=e,Object.freeze(n)}const ue=C(Q),de=C(X),le=C(Z),fe=ae(H),me=C(W),pe=C(ne),F=C(oe);function V(){const{pathname:e}=window.location,n=e.match(/\/admin\/(maker|previewer)\/([^/]+)/),a=n==null?void 0:n[2],u=window.__PROJECT_ID__;if(!a&&!u)throw new Error("Unable to get projectId from pathname");return a||u}function Se(e){return`${e}:pages:version`}function we(e,n){return n==="yaml"?le.default(e)?"":fe.stringify(e,{indent:2}):n==="json"?JSON.parse(JSON.stringify(e||"{}")):n==="array"?JSON.parse(JSON.stringify(e||"[]")):e}function he({error:e}){return j.jsx(b.Box,{children:j.jsx(b.Alert,{severity:"error",children:e.message})})}var U;const v=((U=window.blocklet)==null?void 0:U.prefix)||"/",O=Y.createAxios({timeout:200*1e3}),ge=window.location.protocol==="https:"?"wss":"ws",Pe=e=>y.joinURL(`${ge}://${window.location.hostname}`,v,`api/${e}/ws/pages`),je="z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";var $;($=blocklet==null?void 0:blocklet.componentMountPoints.find(e=>e.did===je))!=null&&$.mountPoint||y.joinURL(v,"/image-bin");function ye(e){return e&&!/^(https?:\/\/|\/)/.test(e)?window.location.origin+y.joinURL(v,"uploads",e):e}const Ce=window.innerWidth<=750;function Ie(e,n,a){if(!e||/\.gif/.test(e))return e;const u=(Ce?n/1.5:n)*(a==="quality"?1.5:1);return ke(e,{imageFilter:"resize",w:u,f:"webp"})}function ke(e,n){return!e||!n?e:y.withQuery(e,n)}function z(e){if(e!=null&&e.trim())try{return ue.default.parse(e),!0}catch{return!1}return!1}function be(e){return typeof e!="string"?!1:!!(z(e)||de.default(e).isValid())}async function Ee(e){return O.get(`/api/projects/${e}`).then(n=>n.data)}async function xe(e){return O.post(`/api/projects/${e.id}/update`,e).then(n=>n.data)}const _e=500,_=re.customAlphabet("abcdefghijklmnopqrstuvwxyz0123456789",16),B=d.createContext(null);function ve({url:e,name:n,children:a,waitingSynced:u}){const[f,l]=d.useState(!1),w=L(),I=`${w}:MakerLocalState`,t=`${w}:${n}`,[r,o]=te.useLocalStorageState(I,{defaultValue:{},listenStorageChange:!0}),s=d.useRef(r);s.current=r;const c=d.useMemo(()=>me.default({pages:{},pageIds:[],components:{},supportedLocales:[],config:{},resources:{}}),[]),i=d.useMemo(()=>W.getYjsDoc(c),[c]);d.useMemo(()=>new se.IndexeddbPersistence(t,i),[t,i]);const h=d.useMemo(()=>new ie.WebsocketProvider(e,t,i,{params:{token:pe.default.get("login_token")}}),[e,t,i]),P=d.useMemo(()=>new ce.UndoManager([i.getArray("pageIds"),i.getMap("pages"),i.getArray("supportedLocales"),i.getMap("config")],{doc:i}),[i]),[k,E]=d.useState(null),[A,q]=d.useState(!1),[M,R]=d.useState(void 0),T=d.useCallback(async()=>{if(w){q(!0);try{const m=await Ee(w);E(m)}catch(m){console.error("Failed to fetch project:",m)}finally{q(!1)}}},[w]),D=d.useCallback(async(m,p)=>{var g;if(R(void 0),!!w){p!=null&&p.optimisticUpdate&&k&&E(S=>({...S,...m}));try{const S=await xe({...m});E(S)}catch(S){console.error("Failed to update project:",S),p!=null&&p.optimisticUpdate&&E(k),R((g=S==null?void 0:S.response)==null?void 0:g.data)}}},[w,k]);d.useEffect(()=>{w&&T()},[w,T]);const K=d.useMemo(()=>({doc:i,state:c,localState:r,setLocalState:m=>o(typeof m=="function"?p=>m(p??{}):m),undoManager:P,projectState:{project:k,isLoadingProject:A,error:M},updateProject:D}),[i,c,JSON.stringify(r),o,P,k,A,D,M]);return d.useEffect(()=>{P.on("stack-item-added",({stackItem:m})=>{const{currentPageId:p,currentLocale:g,pages:S}=s.current;m.meta.set("localState",{currentPageId:p,currentLocale:g,pages:S})}),P.on("stack-item-popped",({stackItem:m})=>{const p=m.meta.get("localState");p&&o(g=>({...g,...p}))})},[P,o]),d.useEffect(()=>{h.awareness.setLocalState(r)},[h,r]),d.useEffect(()=>{h.once("synced",()=>l(!0));const m=()=>{o(S=>({...S,networkStatus:void 0}))},p=()=>{o(S=>({...S,networkStatus:"offline"}))},g=F.default(({status:S})=>{S==="connected"?m():S==="disconnected"&&p()},_e);return h.on("status",g),window.addEventListener("online",m),window.addEventListener("offline",p),()=>{h.off("status",g),window.removeEventListener("online",m),window.removeEventListener("offline",p)}},[h,o]),u&&!f?null:j.jsx(B.Provider,{value:K,children:a})}const G=()=>{const e=d.useContext(B);if(!e)throw new Error("Context is null");const n=ee.useSyncedStore(e.state),{setLocalState:a,localState:u}=e,f=N.useNavigate(),l=L(),w=d.useMemo(()=>({setCurrentSectionId:(t,r)=>{var o,s;t===u.currentPageId&&r===((s=(o=u.pages)==null?void 0:o[t])==null?void 0:s.currentSectionId)||(f(y.joinURL("/admin/maker",l??"","pages",t)),a(c=>x.produce(c,i=>{var h;i.currentPageId=t,i.currentComponentId=void 0,i.componentDebugProps={},r!==void 0&&(i.pages??(i.pages={}),(h=i.pages)[t]??(h[t]={}),i.pages[t].currentSectionId=r??void 0),r?window.sessionStorage.setItem("iframe_show_id",`"${r}"`):window.sessionStorage.removeItem("iframe_show_id")})))},setCurrentComponentId:t=>{t!==u.currentComponentId&&(f(y.joinURL("/admin/maker",l??"","components",t)),a(r=>x.produce(r,o=>{o.currentComponentId=t,o.componentDebugProps={}})))},setComponentDebugProps:(()=>{const t={},r=F.default(()=>{a(o=>x.produce(o,s=>{s.componentDebugProps={...s==null?void 0:s.componentDebugProps,...t},Object.keys(t).forEach(c=>delete t[c])}))},5);return o=>{Object.assign(t,o),r()}})()}),[a,f,l]),I=d.useMemo(()=>({addPage:(t,r)=>{var c,i,h,P;const o=(t==null?void 0:t.id)??_(),s={...t,id:o,createdAt:(t==null?void 0:t.createdAt)??new Date().toISOString(),updatedAt:(t==null?void 0:t.updatedAt)??new Date().toISOString(),publishedAt:new Date(0).toISOString(),slug:(t==null?void 0:t.slug)??`/${o}`,sections:(t==null?void 0:t.sections)??{},sectionIds:(t==null?void 0:t.sectionIds)??[],isPublic:(t==null?void 0:t.isPublic)??!0,templateConfig:(t==null?void 0:t.templateConfig)??{isTemplate:((c=t==null?void 0:t.templateConfig)==null?void 0:c.isTemplate)??!0,displayTemplateId:((i=t==null?void 0:t.templateConfig)==null?void 0:i.displayTemplateId)??void 0,dataSourceId:((h=t==null?void 0:t.templateConfig)==null?void 0:h.dataSourceId)??void 0,dataSourceParameters:((P=t==null?void 0:t.templateConfig)==null?void 0:P.dataSourceParameters)??{}}};return e.doc.transact(()=>{n.pages[s.id]=s,n.pageIds.splice(r??n.pageIds.length,0,s.id)}),s},deletePage:t=>{const r=n.pageIds.indexOf(t);r!==-1&&e.doc.transact(()=>{n.pageIds.splice(r,1),delete n.pages[t]})},movePage:(t,r)=>{const{pageIds:o}=n,s=o.indexOf(t);s>=0&&o.splice(r,0,...o.splice(s,1))},addSection:(t,r,o)=>{const s=n.pages[t];if(!s)throw new Error(`Page ${t} is not exists`);const c={...r,id:r.id??_(),isTemplateSection:r.isTemplateSection??!0,llmConfig:r.llmConfig??{}};return e.doc.transact(()=>{s.sections[c.id]=c,s.sectionIds.splice(o??s.sectionIds.length,0,c.id)}),c},deleteSection:(t,r)=>{const o=n.pages[t];if(!o)throw new Error(`Page ${t} is not exists`);const s=o.sectionIds.indexOf(r);s!==-1&&e.doc.transact(()=>{o.sectionIds.splice(s,1),delete o.sections[r]})},toggleSectionVisibility:(t,r,o)=>{const s=n.pages[t];if(!s)throw new Error(`Page ${t} is not exists`);const c=s.sections[r];c&&(c.visibility=o)},moveSection:(t,r,o)=>{const s=n.pages[t];if(!s)throw new Error(`Page ${t} is not exists`);const{sectionIds:c}=s,i=c.indexOf(r);i>=0&&c.splice(o,0,...c.splice(i,1))}}),[n,e.doc]);return{...e,state:n,actions:I,localActions:w,get currentPage(){const{localState:{currentPageId:t}}=e;return t?n.pages[t]:void 0},get currentSection(){var s,c,i;const{localState:{currentPageId:t,...r}}=e;if(!t)return;const o=(c=(s=r.pages)==null?void 0:s[t])==null?void 0:c.currentSectionId;if(o)return(i=n.pages[t])==null?void 0:i.sections[o]}}},L=()=>{const{projectId:e}=N.useParams();return e??V()??""};function Oe(e){var u,f;const{resources:n}=e;if(!n.components)return{};const a={};return(f=(u=window==null?void 0:window.blocklet)==null?void 0:u.componentMountPoints)==null||f.forEach(l=>{a[l.did]=l}),Object.fromEntries(Object.entries(n.components).map(([l,{blockletId:w,component:I}])=>{var t;return[l,{data:I,blockletId:w,blockletTitle:((t=a[w])==null?void 0:t.title)||w}]}))}function Le(e){const{components:n}=e;return n||{}}function J(e){return{...Oe(e),...Le(e)}}const Ae=()=>J(G().state),qe=[/\.\./,/<[^>]*>/,/%[0-9a-f]{2}/i,/[<>'"%;{}()\\]/,/\x00/,/\n|\r|\t|\v|\f/,/[^a-zA-Z0-9-_@/]/];function Me(e,n,a){const u=[];{let f;n.slug?n.slug.startsWith("/")?n.slug!=="/"&&n.slug.endsWith("/")?f=e("maker.properties.pathCheckEndWithoutSlash"):/\/{2,}/.test(n.slug)?f=e("maker.properties.pathCheckConsecutiveSlash"):/\s/.test(n.slug)?f=e("maker.properties.pathCheckWhitespace"):qe.some(l=>l.test(n.slug))?f=e("maker.properties.pathCheckInvalid"):Object.values(a.pages).some(l=>(l==null?void 0:l.id)!==n.id&&(l==null?void 0:l.slug)===n.slug)&&(f=e("maker.properties.pathCheckAlreadyExist")):f=e("maker.properties.pathCheckStartWithSlash"):f=e("maker.properties.pathCheckRequired"),f&&u.push({path:["path"],message:f})}return u.length>0?u:null}function Re({errors:e,...n}){return e!=null&&e.length?j.jsx(b.Tooltip,{...n,title:j.jsx(b.Box,{children:e.map((a,u)=>j.jsx(b.Box,{children:a.message},u))})}):null}exports.ErrorView=he;exports.PageErrorTip=Re;exports.StoreProvider=ve;exports.api=O;exports.autoResizeImage=Ie;exports.checkPage=Me;exports.getAllComponents=J;exports.getImageAbsoluteUrl=ye;exports.getProjectIdFromPathnameOrWindow=V;exports.getProjectPageVersionKey=Se;exports.getWssURL=Pe;exports.isColorString=be;exports.isGradient=z;exports.nextId=_;exports.transformValue=we;exports.useAllComponents=Ae;exports.useProjectId=L;exports.useStore=G;
package/lib/cjs/home.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("react/jsx-runtime");require("./chunks/state-oKsa8z3D.js");const e=require("./chunks/home-BW7VfExi.js");require("@arcblock/ux/lib/Locale/context");require("@arcblock/ux/lib/Result");require("@blocklet/pages-kit/builtin/page/header");require("@blocklet/ui-react/lib/Header");require("@emotion/css");require("@emotion/react");require("@emotion/styled");require("@mui/material");require("ahooks");require("isomorphic-dompurify");require("lodash/cloneDeep");require("lodash/isEmpty");require("lodash/isEqual");require("react");require("react-helmet");require("react-router-dom");require("react-use");require("ufo");exports.HomeView=e.HomeView;exports.PageRoutes=e.PageRoutes;exports.PageView=e.PageView;exports.PageViewByPath=e.PageViewByPath;exports.TranslucentHeader=e.TranslucentHeader;exports.default=e.Home;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("react/jsx-runtime");require("./chunks/state-eTpgUKhB.js");const e=require("./chunks/home-D9IcqQld.js");require("@arcblock/ux/lib/Locale/context");require("@arcblock/ux/lib/Result");require("@blocklet/pages-kit/builtin/page/header");require("@blocklet/ui-react/lib/Header");require("@emotion/css");require("@emotion/react");require("@emotion/styled");require("@mui/material");require("ahooks");require("isomorphic-dompurify");require("lodash/cloneDeep");require("lodash/isEmpty");require("lodash/isEqual");require("react");require("react-helmet");require("react-router-dom");require("react-use");require("ufo");exports.HomeView=e.HomeView;exports.PageRoutes=e.PageRoutes;exports.PageView=e.PageView;exports.PageViewByPath=e.PageViewByPath;exports.TranslucentHeader=e.TranslucentHeader;exports.default=e.Home;
@@ -1,4 +1,4 @@
1
- "use strict";var Ne=Object.create;var ge=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,qe=Object.prototype.hasOwnProperty;var Ue=(e,s,o,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let d of Fe(s))!qe.call(e,d)&&d!==o&&ge(e,d,{get:()=>s[d],enumerable:!(l=Ee(s,d))||l.enumerable});return e};var We=(e,s,o)=>(o=e!=null?Ne(Ve(e)):{},Ue(s||!e||!e.__esModule?ge(o,"default",{value:e,enumerable:!0}):o,e));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),B=require("./chunks/state-oKsa8z3D.js"),Me=require("@arcblock/ux/lib/Empty"),_=require("@arcblock/ux/lib/Locale/context"),ne=require("@blocklet/code-editor"),Ke=require("@mui/icons-material/AddRounded"),Le=require("@mui/icons-material/ArrowDownward"),$e=require("@mui/icons-material/ArrowUpward"),Je=require("@mui/icons-material/DeleteOutline"),r=require("@mui/material"),He=require("lodash/sortBy"),P=require("react"),ce=require("react-use"),Ye=require("@arcblock/ux/lib/Theme"),Ge=require("@emotion/css"),re=require("ahooks"),Qe=require("gradient-parser");require("lodash/without");const Xe=require("tinycolor2"),D=require("@mui/material/colors"),A=require("./uploader.js"),Ze=require("@iconify-icon/react"),et=require("lodash/isEmpty"),tt=require("lodash/set"),rt=require("yaml"),st=require("lodash/cloneDeep"),ot=require("@arcblock/ux/lib/Toast"),Z=require("@blocklet/pages-kit/components"),Pe=require("@mui/base"),z=require("@mui/icons-material"),ve=require("@mui/material/styles"),Y=require("@syncedstore/core"),lt=require("lodash/assign"),it=require("lodash/has"),nt=require("lodash/isNil"),ct=require("lodash/isObject"),at=require("lodash/keyBy"),ut=require("lodash/omit"),dt=require("lodash/pick"),pt=require("lodash/reduce"),F=require("material-ui-popup-state/hooks"),xt=require("react-error-boundary"),se=require("react-dnd"),O=e=>e&&e.__esModule?e:{default:e};function mt(e){if(e&&e.__esModule)return e;const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const l=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(s,o,l.get?l:{enumerable:!0,get:()=>e[o]})}}return s.default=e,Object.freeze(s)}const G=O(Me),ft=O(Ke),ht=O(Le),bt=O($e),jt=O(Je),N=O(He),ke=O(Qe),yt=O(Xe),Ce=O(et),Te=O(tt),oe=mt(rt),gt=O(st),Se=O(ot),vt=O(lt),kt=O(it),ee=O(nt),St=O(ct),wt=O(at),It=O(ut),Pt=O(dt),Ct=O(pt);function Tt({onClick:e,disabled:s,sx:o,...l}){return t.jsx(r.IconButton,{size:"small",color:"warning",variant:"outlined",disabled:s,onClick:e,...l,children:t.jsx(jt.default,{fontSize:"small"})})}function Bt({onClick:e,disabled:s,sx:o,...l}){return t.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:e,...l,children:t.jsx(bt.default,{fontSize:"small"})})}function Ot({onClick:e,disabled:s,sx:o,...l}){return t.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:e,...l,children:t.jsx(ht.default,{fontSize:"small"})})}function Rt({label:e,value:s,onChange:o,disabled:l=!1,itemLabel:d="",emptyHeight:m=40,property:u,renderItem:b,...g}){const{t:f,locale:k}=_.useLocaleContext(),x=ce.useUpdate(),i=P.useCallback(h=>{o(B.transformValue(h,u.type))},[o,u.type]),c=P.useMemo(()=>Array.isArray(s)?s:[],[s]),n=P.useCallback(()=>{const h=[...c,""];i(h),x()},[c,i,x]),p=P.useCallback(()=>{if(!u||!u.subProperties)return n();const h={};N.default(Object.values(u.subProperties),"index").forEach(({data:R})=>{var V,q;if(!R.key)return;const E=((q=(V=R.locales)==null?void 0:V[k])==null?void 0:q.defaultValue)??"";h[R.key]=E});const T=[...c,h];i(T),x()},[c,i,x,u,k,n]),j=P.useCallback(h=>{try{const I=JSON.parse(h);Array.isArray(I)?i(I):console.error("JSON解析结果不是数组")}catch(I){console.error("JSON解析错误:",I)}},[i]),w=P.useCallback(h=>{const I=c.filter((T,R)=>R!==h);i(I),x()},[c,i,x]),a=P.useCallback(h=>{if(h<=0)return;const I=[...c],T=I[h];I[h]=I[h-1],I[h-1]=T,i(I),x()},[c,i,x]),v=P.useCallback(h=>{if(h>=c.length-1)return;const I=[...c],T=I[h];I[h]=I[h+1],I[h+1]=T,i(I),x()},[c,i,x]),y=P.useCallback((h,I)=>{const T=[...c];T[h]=I,i(T)},[c,i]),S=u&&u.subProperties&&Object.keys(u.subProperties).length>0,C=P.useMemo(()=>[{field:"index",headerName:"#",width:40,align:"center",renderCell:({index:h})=>t.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:h+1})},{field:"content",headerName:"",renderCell:({row:h,index:I})=>b&&S?b({item:h,index:I,property:u,onChange:T=>y(I,T)}):t.jsx(r.TextField,{fullWidth:!0,size:"small",disabled:l,value:h,placeholder:d||`${f("item")} ${I+1}`,onChange:T=>y(I,T.target.value),...g})},{field:"actions",headerName:"",width:30,align:"center",renderCell:({index:h})=>t.jsxs(r.Stack,{direction:"column",spacing:.25,children:[t.jsx(Bt,{disabled:l||h===0,onClick:()=>a(h)}),t.jsx(Ot,{disabled:l||h===c.length-1,onClick:()=>v(h)}),t.jsx(Tt,{disabled:l,onClick:()=>w(h)})]})}],[b,S,u,y,d,f,l,g,w,a,v,c.length]);return S?t.jsxs(r.Stack,{width:"100%",gap:1,children:[e&&t.jsx(r.FormLabel,{children:e}),c.length>0?t.jsx(r.TableContainer,{component:r.Paper,variant:"outlined",sx:{borderRadius:1,mb:1},children:t.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:[t.jsx(r.TableHead,{sx:{display:"none"},children:t.jsx(r.TableRow,{children:C.map(h=>t.jsx(r.TableCell,{width:h.width,align:h.align||"left",sx:{fontWeight:"bold"},children:h.renderHeader?h.renderHeader():h.headerName},h.field))})}),t.jsx(r.TableBody,{children:c.map((h,I,T)=>t.jsx(r.TableRow,{sx:{borderBottom:I<T.length-1?"1px solid":"none",borderColor:"divider","&:hover":{backgroundColor:"action.hover"}},children:C.map(R=>t.jsx(r.TableCell,{width:R.width,align:R.align||"left",sx:{borderBottom:"none"},children:R.renderCell({row:h,index:I,onChange:E=>y(I,E)})},`${I}-${R.field}`))},I))})]})}):t.jsx(G.default,{style:{fontSize:12,height:m},children:f("maker.properties.arrayEmpty")}),t.jsx(r.Button,{fullWidth:!0,size:"small",variant:"outlined",disabled:l,startIcon:t.jsx(ft.default,{}),onClick:p,children:f("maker.properties.addArrayItem")})]}):t.jsxs(r.Stack,{width:"100%",gap:1,children:[e&&t.jsx(r.FormLabel,{children:e}),t.jsx(r.Box,{sx:{border:1,borderColor:"divider",borderRadius:1,minHeight:150},children:t.jsx(ne.CodeEditor,{keyId:u.id,locale:k,language:"json",value:JSON.stringify(c,null,2),onChange:h=>j(h||"")},u.id)})]})}D.red[300],D.pink[300],D.purple[300],D.indigo[300],D.blue[300],D.cyan[300],D.teal[300],D.green[300],D.lime[300],D.yellow[300],D.amber[300],D.orange[300],D.brown[300],D.grey[300],D.blueGrey[300];const _t=P.forwardRef(function({showMarkdown:s,markdown:o,onMarkdownChange:l,showUploader:d,value:m,meta:u,onChange:b,...g},f){const[k,x]=P.useState("");P.useEffect(()=>{x(m||"")},[m,x]);const i=async()=>{if(k!==m){const n=B.getImageAbsoluteUrl(k);if(!n){b(k,void 0);return}const p=await A.getImageSize(n).catch(()=>A.getVideoSize(n)).catch(()=>{});b(k,{...p,filename:k})}};ce.useDebounce(()=>{k!==m&&b(k)},300,[k]),P.useImperativeHandle(f,()=>({submit:i}));const c={};return d&&(c.InputProps={sx:{pr:0},endAdornment:t.jsx(r.InputAdornment,{position:"end",sx:{mx:.5},children:t.jsx(A.UploaderButton,{onChange:async({response:n})=>{var a;const p=(a=n==null?void 0:n.data)==null?void 0:a.filename,j=B.getImageAbsoluteUrl(p)||"";let w={};j&&(w=await A.getImageSize(j).catch(()=>A.getVideoSize(j)).catch(()=>{})),b(p,{...w,filename:p})}})})}),t.jsx(r.TextField,{size:"small",fullWidth:!0,...g,label:t.jsxs(r.Stack,{direction:"row",spacing:1,alignItems:"center",children:[g.label,s&&t.jsxs(t.Fragment,{children:[" (",t.jsx(r.FormControlLabel,{checked:o,label:t.jsx(r.Box,{component:Ze.Icon,icon:"tabler:markdown",sx:{verticalAlign:"middle"}}),labelPlacement:"start",control:t.jsx(r.Switch,{size:"small"}),sx:{ml:.25,pr:1},onChange:(n,p)=>l==null?void 0:l(p)}),")"]})]}),InputLabelProps:{shrink:!0,...g.InputLabelProps},value:k,onChange:n=>x(n.target.value),...c,onKeyDown:n=>{n.keyCode!==229&&n.key==="Enter"&&i()}})}),Dt=P.lazy(()=>import("react-best-gradient-color-picker")),At=0,zt=100;function Nt(e){try{const o=ke.default.parse(e).map(d=>{const m=d.colorStops.map((u,b)=>{let{value:g}=u;if(typeof g!="string"&&!Array.isArray(g))throw new Error("Invalid color stop value type");let{type:f}=u;if(f!=="rgba"){const i=yt.default(g).toRgb();g=[`${i.r}`,`${i.g}`,`${i.b}`,`${i.a}`],f="rgba"}if(u.length)return{...u,value:g,type:f};const k=d.colorStops.length;let x;return b===0?x=At:b===k-1?x=zt:x=b/(k-1)*100,{...u,value:g,type:f,length:{value:`${x}`,type:"%"}}});return{...d,colorStops:m}});return ke.default.stringify(o).replace(/NaN/g,"100")}catch{return B.isColorString(e)?`${e}`.replace(/NaN/g,"100"):""}}function Et({color:e,sx:s={},...o}){B.isColorString(e);const l={};return B.isGradient(e)?l.backgroundImage=e:l.backgroundColor=e,t.jsx(r.Box,{sx:{...s,width:"100%",paddingBottom:"100%",cursor:"pointer",transition:"opacity 0.2s",border:"1px solid #ccc",borderRadius:.5,"&:hover":{opacity:.75},...l},...o})}const Ft=P.forwardRef(function({onSave:s},o){const l=re.useReactive({value:""}),{t:d}=_.useLocaleContext(),m={};l.value?B.isGradient(l.value)?m.backgroundImage=l.value:m.backgroundColor=l.value:m.border="1px solid #ccc";const[u,{setFalse:b,setTrue:g}]=re.useBoolean(!1),f=P.useCallback(()=>{b()},[b]),k=()=>{s({value:l.value},f)};return P.useImperativeHandle(o,()=>({open({value:x}={value:""}){l.value=Nt(x),g()},close(){f()}})),t.jsxs(r.Dialog,{disableEnforceFocus:!0,open:u,onClose:f,hideBackdrop:!0,children:[t.jsx(r.DialogTitle,{children:d("maker.configBackground")}),t.jsx(r.DialogContent,{sx:{width:600},children:t.jsxs(r.Box,{width:"100%",display:"flex",children:[t.jsx(r.Box,{flex:1,mr:1,sx:{...m,borderRadius:.5},children:!l.value&&t.jsx(G.default,{children:d("error.notConfig")})}),t.jsx(P.Suspense,{children:t.jsx(Dt,{disableDarkMode:!0,width:240,height:240,value:l.value,onChange:x=>{l.value=x},hidePresets:!0,hideAdvancedSliders:!0,hideColorGuide:!0,hideInputType:!0})})]})}),t.jsxs(r.DialogActions,{children:[t.jsx(r.Button,{variant:"outlined",size:"small",onClick:f,children:d("common.cancel")}),t.jsx(r.Button,{variant:"contained",size:"small",onClick:k,children:d("maker.save")})]})]})});Ye.styled(r.Box)`
1
+ "use strict";var Ne=Object.create;var ge=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,qe=Object.prototype.hasOwnProperty;var Ue=(e,s,o,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let d of Fe(s))!qe.call(e,d)&&d!==o&&ge(e,d,{get:()=>s[d],enumerable:!(l=Ee(s,d))||l.enumerable});return e};var We=(e,s,o)=>(o=e!=null?Ne(Ve(e)):{},Ue(s||!e||!e.__esModule?ge(o,"default",{value:e,enumerable:!0}):o,e));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),B=require("./chunks/state-eTpgUKhB.js"),Me=require("@arcblock/ux/lib/Empty"),_=require("@arcblock/ux/lib/Locale/context"),ne=require("@blocklet/code-editor"),Ke=require("@mui/icons-material/AddRounded"),Le=require("@mui/icons-material/ArrowDownward"),$e=require("@mui/icons-material/ArrowUpward"),Je=require("@mui/icons-material/DeleteOutline"),r=require("@mui/material"),He=require("lodash/sortBy"),P=require("react"),ce=require("react-use"),Ye=require("@arcblock/ux/lib/Theme"),Ge=require("@emotion/css"),re=require("ahooks"),Qe=require("gradient-parser");require("lodash/without");const Xe=require("tinycolor2"),D=require("@mui/material/colors"),A=require("./uploader.js"),Ze=require("@iconify-icon/react"),et=require("lodash/isEmpty"),tt=require("lodash/set"),rt=require("yaml"),st=require("lodash/cloneDeep"),ot=require("@arcblock/ux/lib/Toast"),Z=require("@blocklet/pages-kit/components"),Pe=require("@mui/base"),z=require("@mui/icons-material"),ve=require("@mui/material/styles"),Y=require("@syncedstore/core"),lt=require("lodash/assign"),it=require("lodash/has"),nt=require("lodash/isNil"),ct=require("lodash/isObject"),at=require("lodash/keyBy"),ut=require("lodash/omit"),dt=require("lodash/pick"),pt=require("lodash/reduce"),F=require("material-ui-popup-state/hooks"),xt=require("react-error-boundary"),se=require("react-dnd"),O=e=>e&&e.__esModule?e:{default:e};function mt(e){if(e&&e.__esModule)return e;const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const l=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(s,o,l.get?l:{enumerable:!0,get:()=>e[o]})}}return s.default=e,Object.freeze(s)}const G=O(Me),ft=O(Ke),ht=O(Le),bt=O($e),jt=O(Je),N=O(He),ke=O(Qe),yt=O(Xe),Ce=O(et),Te=O(tt),oe=mt(rt),gt=O(st),Se=O(ot),vt=O(lt),kt=O(it),ee=O(nt),St=O(ct),wt=O(at),It=O(ut),Pt=O(dt),Ct=O(pt);function Tt({onClick:e,disabled:s,sx:o,...l}){return t.jsx(r.IconButton,{size:"small",color:"warning",variant:"outlined",disabled:s,onClick:e,...l,children:t.jsx(jt.default,{fontSize:"small"})})}function Bt({onClick:e,disabled:s,sx:o,...l}){return t.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:e,...l,children:t.jsx(bt.default,{fontSize:"small"})})}function Ot({onClick:e,disabled:s,sx:o,...l}){return t.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:e,...l,children:t.jsx(ht.default,{fontSize:"small"})})}function Rt({label:e,value:s,onChange:o,disabled:l=!1,itemLabel:d="",emptyHeight:m=40,property:u,renderItem:b,...g}){const{t:f,locale:k}=_.useLocaleContext(),x=ce.useUpdate(),i=P.useCallback(h=>{o(B.transformValue(h,u.type))},[o,u.type]),c=P.useMemo(()=>Array.isArray(s)?s:[],[s]),n=P.useCallback(()=>{const h=[...c,""];i(h),x()},[c,i,x]),p=P.useCallback(()=>{if(!u||!u.subProperties)return n();const h={};N.default(Object.values(u.subProperties),"index").forEach(({data:R})=>{var V,q;if(!R.key)return;const E=((q=(V=R.locales)==null?void 0:V[k])==null?void 0:q.defaultValue)??"";h[R.key]=E});const T=[...c,h];i(T),x()},[c,i,x,u,k,n]),j=P.useCallback(h=>{try{const I=JSON.parse(h);Array.isArray(I)?i(I):console.error("JSON解析结果不是数组")}catch(I){console.error("JSON解析错误:",I)}},[i]),w=P.useCallback(h=>{const I=c.filter((T,R)=>R!==h);i(I),x()},[c,i,x]),a=P.useCallback(h=>{if(h<=0)return;const I=[...c],T=I[h];I[h]=I[h-1],I[h-1]=T,i(I),x()},[c,i,x]),v=P.useCallback(h=>{if(h>=c.length-1)return;const I=[...c],T=I[h];I[h]=I[h+1],I[h+1]=T,i(I),x()},[c,i,x]),y=P.useCallback((h,I)=>{const T=[...c];T[h]=I,i(T)},[c,i]),S=u&&u.subProperties&&Object.keys(u.subProperties).length>0,C=P.useMemo(()=>[{field:"index",headerName:"#",width:40,align:"center",renderCell:({index:h})=>t.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:h+1})},{field:"content",headerName:"",renderCell:({row:h,index:I})=>b&&S?b({item:h,index:I,property:u,onChange:T=>y(I,T)}):t.jsx(r.TextField,{fullWidth:!0,size:"small",disabled:l,value:h,placeholder:d||`${f("item")} ${I+1}`,onChange:T=>y(I,T.target.value),...g})},{field:"actions",headerName:"",width:30,align:"center",renderCell:({index:h})=>t.jsxs(r.Stack,{direction:"column",spacing:.25,children:[t.jsx(Bt,{disabled:l||h===0,onClick:()=>a(h)}),t.jsx(Ot,{disabled:l||h===c.length-1,onClick:()=>v(h)}),t.jsx(Tt,{disabled:l,onClick:()=>w(h)})]})}],[b,S,u,y,d,f,l,g,w,a,v,c.length]);return S?t.jsxs(r.Stack,{width:"100%",gap:1,children:[e&&t.jsx(r.FormLabel,{children:e}),c.length>0?t.jsx(r.TableContainer,{component:r.Paper,variant:"outlined",sx:{borderRadius:1,mb:1},children:t.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:[t.jsx(r.TableHead,{sx:{display:"none"},children:t.jsx(r.TableRow,{children:C.map(h=>t.jsx(r.TableCell,{width:h.width,align:h.align||"left",sx:{fontWeight:"bold"},children:h.renderHeader?h.renderHeader():h.headerName},h.field))})}),t.jsx(r.TableBody,{children:c.map((h,I,T)=>t.jsx(r.TableRow,{sx:{borderBottom:I<T.length-1?"1px solid":"none",borderColor:"divider","&:hover":{backgroundColor:"action.hover"}},children:C.map(R=>t.jsx(r.TableCell,{width:R.width,align:R.align||"left",sx:{borderBottom:"none"},children:R.renderCell({row:h,index:I,onChange:E=>y(I,E)})},`${I}-${R.field}`))},I))})]})}):t.jsx(G.default,{style:{fontSize:12,height:m},children:f("maker.properties.arrayEmpty")}),t.jsx(r.Button,{fullWidth:!0,size:"small",variant:"outlined",disabled:l,startIcon:t.jsx(ft.default,{}),onClick:p,children:f("maker.properties.addArrayItem")})]}):t.jsxs(r.Stack,{width:"100%",gap:1,children:[e&&t.jsx(r.FormLabel,{children:e}),t.jsx(r.Box,{sx:{border:1,borderColor:"divider",borderRadius:1,minHeight:150},children:t.jsx(ne.CodeEditor,{keyId:u.id,locale:k,language:"json",value:JSON.stringify(c,null,2),onChange:h=>j(h||"")},u.id)})]})}D.red[300],D.pink[300],D.purple[300],D.indigo[300],D.blue[300],D.cyan[300],D.teal[300],D.green[300],D.lime[300],D.yellow[300],D.amber[300],D.orange[300],D.brown[300],D.grey[300],D.blueGrey[300];const _t=P.forwardRef(function({showMarkdown:s,markdown:o,onMarkdownChange:l,showUploader:d,value:m,meta:u,onChange:b,...g},f){const[k,x]=P.useState("");P.useEffect(()=>{x(m||"")},[m,x]);const i=async()=>{if(k!==m){const n=B.getImageAbsoluteUrl(k);if(!n){b(k,void 0);return}const p=await A.getImageSize(n).catch(()=>A.getVideoSize(n)).catch(()=>{});b(k,{...p,filename:k})}};ce.useDebounce(()=>{k!==m&&b(k)},300,[k]),P.useImperativeHandle(f,()=>({submit:i}));const c={};return d&&(c.InputProps={sx:{pr:0},endAdornment:t.jsx(r.InputAdornment,{position:"end",sx:{mx:.5},children:t.jsx(A.UploaderButton,{onChange:async({response:n})=>{var a;const p=(a=n==null?void 0:n.data)==null?void 0:a.filename,j=B.getImageAbsoluteUrl(p)||"";let w={};j&&(w=await A.getImageSize(j).catch(()=>A.getVideoSize(j)).catch(()=>{})),b(p,{...w,filename:p})}})})}),t.jsx(r.TextField,{size:"small",fullWidth:!0,...g,label:t.jsxs(r.Stack,{direction:"row",spacing:1,alignItems:"center",children:[g.label,s&&t.jsxs(t.Fragment,{children:[" (",t.jsx(r.FormControlLabel,{checked:o,label:t.jsx(r.Box,{component:Ze.Icon,icon:"tabler:markdown",sx:{verticalAlign:"middle"}}),labelPlacement:"start",control:t.jsx(r.Switch,{size:"small"}),sx:{ml:.25,pr:1},onChange:(n,p)=>l==null?void 0:l(p)}),")"]})]}),InputLabelProps:{shrink:!0,...g.InputLabelProps},value:k,onChange:n=>x(n.target.value),...c,onKeyDown:n=>{n.keyCode!==229&&n.key==="Enter"&&i()}})}),Dt=P.lazy(()=>import("react-best-gradient-color-picker")),At=0,zt=100;function Nt(e){try{const o=ke.default.parse(e).map(d=>{const m=d.colorStops.map((u,b)=>{let{value:g}=u;if(typeof g!="string"&&!Array.isArray(g))throw new Error("Invalid color stop value type");let{type:f}=u;if(f!=="rgba"){const i=yt.default(g).toRgb();g=[`${i.r}`,`${i.g}`,`${i.b}`,`${i.a}`],f="rgba"}if(u.length)return{...u,value:g,type:f};const k=d.colorStops.length;let x;return b===0?x=At:b===k-1?x=zt:x=b/(k-1)*100,{...u,value:g,type:f,length:{value:`${x}`,type:"%"}}});return{...d,colorStops:m}});return ke.default.stringify(o).replace(/NaN/g,"100")}catch{return B.isColorString(e)?`${e}`.replace(/NaN/g,"100"):""}}function Et({color:e,sx:s={},...o}){B.isColorString(e);const l={};return B.isGradient(e)?l.backgroundImage=e:l.backgroundColor=e,t.jsx(r.Box,{sx:{...s,width:"100%",paddingBottom:"100%",cursor:"pointer",transition:"opacity 0.2s",border:"1px solid #ccc",borderRadius:.5,"&:hover":{opacity:.75},...l},...o})}const Ft=P.forwardRef(function({onSave:s},o){const l=re.useReactive({value:""}),{t:d}=_.useLocaleContext(),m={};l.value?B.isGradient(l.value)?m.backgroundImage=l.value:m.backgroundColor=l.value:m.border="1px solid #ccc";const[u,{setFalse:b,setTrue:g}]=re.useBoolean(!1),f=P.useCallback(()=>{b()},[b]),k=()=>{s({value:l.value},f)};return P.useImperativeHandle(o,()=>({open({value:x}={value:""}){l.value=Nt(x),g()},close(){f()}})),t.jsxs(r.Dialog,{disableEnforceFocus:!0,open:u,onClose:f,hideBackdrop:!0,children:[t.jsx(r.DialogTitle,{children:d("maker.configBackground")}),t.jsx(r.DialogContent,{sx:{width:600},children:t.jsxs(r.Box,{width:"100%",display:"flex",children:[t.jsx(r.Box,{flex:1,mr:1,sx:{...m,borderRadius:.5},children:!l.value&&t.jsx(G.default,{children:d("error.notConfig")})}),t.jsx(P.Suspense,{children:t.jsx(Dt,{disableDarkMode:!0,width:240,height:240,value:l.value,onChange:x=>{l.value=x},hidePresets:!0,hideAdvancedSliders:!0,hideColorGuide:!0,hideInputType:!0})})]})}),t.jsxs(r.DialogActions,{children:[t.jsx(r.Button,{variant:"outlined",size:"small",onClick:f,children:d("common.cancel")}),t.jsx(r.Button,{variant:"contained",size:"small",onClick:k,children:d("maker.save")})]})]})});Ye.styled(r.Box)`
2
2
  .color-item {
3
3
  position: relative;
4
4
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as e } from "react/jsx-runtime";
2
- import { u as o, S as a, k as s, h as n } from "./state-JDvNqLu1.js";
2
+ import { u as o, S as a, k as s, h as n } from "./state-CYDNg8EG.js";
3
3
  function d({ children: t }) {
4
4
  const r = o();
5
5
  return /* @__PURE__ */ e(a, { url: s(r ?? ""), name: "root", waitingSynced: !0, children: /* @__PURE__ */ e(i, { children: t }) });
@@ -1,5 +1,5 @@
1
1
  import { jsx as o, jsxs as _, Fragment as F } from "react/jsx-runtime";
2
- import { a as T, g as I, i as ce, b as le, E as de, c as lt, d as dt, e as zt, u as me, f as ue } from "./state-JDvNqLu1.js";
2
+ import { a as T, g as I, i as ce, b as le, E as de, c as lt, d as dt, e as zt, u as me, f as ue } from "./state-CYDNg8EG.js";
3
3
  import { cloneDeep as M } from "lodash";
4
4
  import { useLocaleContext as Wt } from "@arcblock/ux/lib/Locale/context";
5
5
  import Lt from "@arcblock/ux/lib/Result";
@@ -2053,7 +2053,7 @@ function Pn({ mode: t }) {
2053
2053
  }
2054
2054
  return /* @__PURE__ */ o(jn, { children: ({ state: e }) => /* @__PURE__ */ o(ot, { mode: t, state: e }) });
2055
2055
  }
2056
- const jn = Jt(() => import("./draft-data-rHmtmftB.js"));
2056
+ const jn = Jt(() => import("./draft-data-B1GJKphX.js"));
2057
2057
  function Bn({
2058
2058
  mode: t,
2059
2059
  children: e
@@ -2269,7 +2269,7 @@ function ct({
2269
2269
  !((yt = a.footer) != null && yt.hidden) && /* @__PURE__ */ o(yn, {})
2270
2270
  ] });
2271
2271
  }
2272
- const Rn = Jt(() => import("./publish-button-DtE5FP5v.js")), ie = At(he)`
2272
+ const Rn = Jt(() => import("./publish-button-BY10Od4q.js")), ie = At(he)`
2273
2273
  &.sticky {
2274
2274
  position: sticky;
2275
2275
  top: 0;
@@ -1,5 +1,5 @@
1
1
  import { jsx as e, jsxs as p, Fragment as H } from "react/jsx-runtime";
2
- import { u as R, l as J, f as q, P as G } from "./state-JDvNqLu1.js";
2
+ import { u as R, l as J, f as q, P as G } from "./state-CYDNg8EG.js";
3
3
  import { useLocaleContext as V } from "@arcblock/ux/lib/Locale/context";
4
4
  import I from "@arcblock/ux/lib/Toast";
5
5
  import { Warning as F, Sync as Q, VisibilityOff as U } from "@mui/icons-material";
@@ -9,7 +9,7 @@ import { produce as oe } from "immer";
9
9
  import N from "lodash/difference";
10
10
  import { useState as D, useMemo as j, useCallback as L, forwardRef as se, useImperativeHandle as le, useEffect as ce } from "react";
11
11
  import { useAsync as ae } from "react-use";
12
- import { p as de, g as ue, L as me } from "./home-DQvcjT5p.js";
12
+ import { p as de, g as ue, L as me } from "./home-Cclj5ETj.js";
13
13
  function ge(r) {
14
14
  const [a, y] = D(!1);
15
15
  return /* @__PURE__ */ e(
@@ -1,8 +1,8 @@
1
- import { jsx as P } from "react/jsx-runtime";
1
+ import { jsx as C } from "react/jsx-runtime";
2
2
  import { Box as x, Alert as B, Tooltip as G } from "@mui/material";
3
3
  import q from "gradient-parser";
4
4
  import K from "tinycolor2";
5
- import { joinURL as I, withQuery as Q } from "ufo";
5
+ import { joinURL as j, withQuery as Q } from "ufo";
6
6
  import { createAxios as X } from "@blocklet/js-sdk";
7
7
  import Z from "lodash/isEmpty";
8
8
  import * as Y from "yaml";
@@ -19,64 +19,64 @@ import { IndexeddbPersistence as ut } from "y-indexeddb";
19
19
  import { WebsocketProvider as lt } from "y-websocket";
20
20
  import { UndoManager as ft } from "yjs";
21
21
  function mt() {
22
- const { pathname: t } = window.location, o = t.match(/\/admin\/(maker|previewer)\/([^/]+)/), u = o == null ? void 0 : o[2], a = window.__PROJECT_ID__;
22
+ const { pathname: e } = window.location, o = e.match(/\/admin\/(maker|previewer)\/([^/]+)/), u = o == null ? void 0 : o[2], a = window.__PROJECT_ID__;
23
23
  if (!u && !a)
24
24
  throw new Error("Unable to get projectId from pathname");
25
25
  return u || a;
26
26
  }
27
- function Gt(t) {
28
- return `${t}:pages:version`;
27
+ function Gt(e) {
28
+ return `${e}:pages:version`;
29
29
  }
30
- function qt(t, o) {
31
- return o === "yaml" ? Z(t) ? "" : Y.stringify(t, { indent: 2 }) : o === "json" ? JSON.parse(JSON.stringify(t || "{}")) : o === "array" ? JSON.parse(JSON.stringify(t || "[]")) : t;
30
+ function qt(e, o) {
31
+ return o === "yaml" ? Z(e) ? "" : Y.stringify(e, { indent: 2 }) : o === "json" ? JSON.parse(JSON.stringify(e || "{}")) : o === "array" ? JSON.parse(JSON.stringify(e || "[]")) : e;
32
32
  }
33
- function Kt({ error: t }) {
34
- return /* @__PURE__ */ P(x, { children: /* @__PURE__ */ P(B, { severity: "error", children: t.message }) });
33
+ function Kt({ error: e }) {
34
+ return /* @__PURE__ */ C(x, { children: /* @__PURE__ */ C(B, { severity: "error", children: e.message }) });
35
35
  }
36
36
  var R;
37
37
  const O = ((R = window.blocklet) == null ? void 0 : R.prefix) || "/", F = X({
38
38
  timeout: 200 * 1e3
39
- }), pt = window.location.protocol === "https:" ? "wss" : "ws", Qt = (t) => I(`${pt}://${window.location.hostname}`, O, `api/${t}/ws/pages`), St = "z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";
39
+ }), pt = window.location.protocol === "https:" ? "wss" : "ws", Qt = (e) => j(`${pt}://${window.location.hostname}`, O, `api/${e}/ws/pages`), St = "z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";
40
40
  var M;
41
- (M = blocklet == null ? void 0 : blocklet.componentMountPoints.find((t) => t.did === St)) != null && M.mountPoint || I(O, "/image-bin");
42
- function Xt(t) {
43
- return t && !/^(https?:\/\/|\/)/.test(t) ? window.location.origin + I(O, "uploads", t) : t;
41
+ (M = blocklet == null ? void 0 : blocklet.componentMountPoints.find((e) => e.did === St)) != null && M.mountPoint || j(O, "/image-bin");
42
+ function Xt(e) {
43
+ return e && !/^(https?:\/\/|\/)/.test(e) ? window.location.origin + j(O, "uploads", e) : e;
44
44
  }
45
45
  const wt = window.innerWidth <= 750;
46
- function Zt(t, o, u) {
47
- if (!t || /\.gif/.test(t)) return t;
46
+ function Zt(e, o, u) {
47
+ if (!e || /\.gif/.test(e)) return e;
48
48
  const a = (wt ? o / 1.5 : o) * (u === "quality" ? 1.5 : 1);
49
- return ht(t, { imageFilter: "resize", w: a, f: "webp" });
49
+ return ht(e, { imageFilter: "resize", w: a, f: "webp" });
50
50
  }
51
- function ht(t, o) {
52
- return !t || !o ? t : Q(t, o);
51
+ function ht(e, o) {
52
+ return !e || !o ? e : Q(e, o);
53
53
  }
54
- function gt(t) {
55
- if (t != null && t.trim())
54
+ function Pt(e) {
55
+ if (e != null && e.trim())
56
56
  try {
57
- return q.parse(t), !0;
57
+ return q.parse(e), !0;
58
58
  } catch {
59
59
  return !1;
60
60
  }
61
61
  return !1;
62
62
  }
63
- function Yt(t) {
64
- return typeof t != "string" ? !1 : !!(gt(t) || K(t).isValid());
63
+ function Yt(e) {
64
+ return typeof e != "string" ? !1 : !!(Pt(e) || K(e).isValid());
65
65
  }
66
- async function Pt(t) {
67
- return F.get(`/api/projects/${t}`).then((o) => o.data);
66
+ async function gt(e) {
67
+ return F.get(`/api/projects/${e}`).then((o) => o.data);
68
68
  }
69
- async function yt(t) {
70
- return F.post(`/api/projects/${t.id}/update`, t).then((o) => o.data);
69
+ async function Ct(e) {
70
+ return F.post(`/api/projects/${e.id}/update`, e).then((o) => o.data);
71
71
  }
72
- const jt = 500, N = rt("abcdefghijklmnopqrstuvwxyz0123456789", 16), J = st(null);
72
+ const yt = 500, N = rt("abcdefghijklmnopqrstuvwxyz0123456789", 16), J = st(null);
73
73
  function Ht({
74
- url: t,
74
+ url: e,
75
75
  name: o,
76
76
  children: u,
77
77
  waitingSynced: a
78
78
  }) {
79
- const [l, d] = E(!1), S = V(), y = `${S}:MakerLocalState`, e = `${S}:${o}`, [r, n] = ot(y, {
79
+ const [l, d] = E(!1), S = V(), y = `${S}:MakerLocalState`, t = `${S}:${o}`, [r, n] = ot(y, {
80
80
  defaultValue: {},
81
81
  listenStorageChange: !0
82
82
  }), s = it(r);
@@ -92,64 +92,64 @@ function Ht({
92
92
  }),
93
93
  []
94
94
  ), i = g(() => tt(c), [c]);
95
- g(() => new ut(e, i), [e, i]);
95
+ g(() => new ut(t, i), [t, i]);
96
96
  const w = g(
97
- () => new lt(t, e, i, { params: { token: nt.get("login_token") } }),
98
- [t, e, i]
99
- ), j = g(
97
+ () => new lt(e, t, i, { params: { token: nt.get("login_token") } }),
98
+ [e, t, i]
99
+ ), P = g(
100
100
  () => new ft(
101
101
  [i.getArray("pageIds"), i.getMap("pages"), i.getArray("supportedLocales"), i.getMap("config")],
102
102
  { doc: i }
103
103
  ),
104
104
  [i]
105
- ), [k, C] = E(null), [A, L] = E(!1), [_, $] = E(void 0), D = U(async () => {
105
+ ), [I, k] = E(null), [A, L] = E(!1), [T, _] = E(void 0), $ = U(async () => {
106
106
  if (S) {
107
107
  L(!0);
108
108
  try {
109
- const f = await Pt(S);
110
- C(f);
109
+ const f = await gt(S);
110
+ k(f);
111
111
  } catch (f) {
112
112
  console.error("Failed to fetch project:", f);
113
113
  } finally {
114
114
  L(!1);
115
115
  }
116
116
  }
117
- }, [S]), T = U(
117
+ }, [S]), D = U(
118
118
  async (f, m) => {
119
119
  var h;
120
- if ($(void 0), !!S) {
121
- m != null && m.optimisticUpdate && k && C((p) => ({
120
+ if (_(void 0), !!S) {
121
+ m != null && m.optimisticUpdate && I && k((p) => ({
122
122
  ...p,
123
123
  ...f
124
124
  }));
125
125
  try {
126
- const p = await yt({
126
+ const p = await Ct({
127
127
  ...f
128
128
  });
129
- C(p);
129
+ k(p);
130
130
  } catch (p) {
131
- console.error("Failed to update project:", p), m != null && m.optimisticUpdate && C(k), $((h = p == null ? void 0 : p.response) == null ? void 0 : h.data);
131
+ console.error("Failed to update project:", p), m != null && m.optimisticUpdate && k(I), _((h = p == null ? void 0 : p.response) == null ? void 0 : h.data);
132
132
  }
133
133
  }
134
134
  },
135
- [S, k]
135
+ [S, I]
136
136
  );
137
137
  v(() => {
138
- S && D();
139
- }, [S, D]);
138
+ S && $();
139
+ }, [S, $]);
140
140
  const z = g(
141
141
  () => ({
142
142
  doc: i,
143
143
  state: c,
144
144
  localState: r,
145
145
  setLocalState: (f) => n(typeof f == "function" ? (m) => f(m ?? {}) : f),
146
- undoManager: j,
146
+ undoManager: P,
147
147
  projectState: {
148
- project: k,
148
+ project: I,
149
149
  isLoadingProject: A,
150
- error: _
150
+ error: T
151
151
  },
152
- updateProject: T
152
+ updateProject: D
153
153
  }),
154
154
  // eslint-disable-next-line react-hooks/exhaustive-deps
155
155
  [
@@ -158,22 +158,22 @@ function Ht({
158
158
  JSON.stringify(r),
159
159
  // resolve the problem of react warning
160
160
  n,
161
- j,
162
- k,
161
+ P,
162
+ I,
163
163
  A,
164
- T,
165
- _
164
+ D,
165
+ T
166
166
  ]
167
167
  );
168
168
  return v(() => {
169
- j.on("stack-item-added", ({ stackItem: f }) => {
169
+ P.on("stack-item-added", ({ stackItem: f }) => {
170
170
  const { currentPageId: m, currentLocale: h, pages: p } = s.current;
171
171
  f.meta.set("localState", { currentPageId: m, currentLocale: h, pages: p });
172
- }), j.on("stack-item-popped", ({ stackItem: f }) => {
172
+ }), P.on("stack-item-popped", ({ stackItem: f }) => {
173
173
  const m = f.meta.get("localState");
174
174
  m && n((h) => ({ ...h, ...m }));
175
175
  });
176
- }, [j, n]), v(() => {
176
+ }, [P, n]), v(() => {
177
177
  w.awareness.setLocalState(r);
178
178
  }, [w, r]), v(() => {
179
179
  w.once("synced", () => d(!0));
@@ -189,154 +189,156 @@ function Ht({
189
189
  }));
190
190
  }, h = W(({ status: p }) => {
191
191
  p === "connected" ? f() : p === "disconnected" && m();
192
- }, jt);
192
+ }, yt);
193
193
  return w.on("status", h), window.addEventListener("online", f), window.addEventListener("offline", m), () => {
194
194
  w.off("status", h), window.removeEventListener("online", f), window.removeEventListener("offline", m);
195
195
  };
196
- }, [w, n]), a && !l ? null : /* @__PURE__ */ P(J.Provider, { value: z, children: u });
196
+ }, [w, n]), a && !l ? null : /* @__PURE__ */ C(J.Provider, { value: z, children: u });
197
197
  }
198
- const kt = () => {
199
- const t = ct(J);
200
- if (!t)
198
+ const It = () => {
199
+ const e = ct(J);
200
+ if (!e)
201
201
  throw new Error("Context is null");
202
- const o = et(t.state), { setLocalState: u, localState: a } = t, l = dt(), d = V(), S = g(
202
+ const o = et(e.state), { setLocalState: u, localState: a } = e, l = dt(), d = V(), S = g(
203
203
  () => ({
204
- setCurrentSectionId: (e, r) => {
204
+ setCurrentSectionId: (t, r) => {
205
205
  var n, s;
206
- e === a.currentPageId && r === ((s = (n = a.pages) == null ? void 0 : n[e]) == null ? void 0 : s.currentSectionId) || (l(I("/admin/maker", d ?? "", "pages", e)), u(
206
+ t === a.currentPageId && r === ((s = (n = a.pages) == null ? void 0 : n[t]) == null ? void 0 : s.currentSectionId) || (l(j("/admin/maker", d ?? "", "pages", t)), u(
207
207
  (c) => b(c, (i) => {
208
208
  var w;
209
- i.currentPageId = e, i.currentComponentId = void 0, i.componentDebugProps = {}, r !== void 0 && (i.pages ?? (i.pages = {}), (w = i.pages)[e] ?? (w[e] = {}), i.pages[e].currentSectionId = r ?? void 0), r ? window.sessionStorage.setItem("iframe_show_id", `"${r}"`) : window.sessionStorage.removeItem("iframe_show_id");
209
+ i.currentPageId = t, i.currentComponentId = void 0, i.componentDebugProps = {}, r !== void 0 && (i.pages ?? (i.pages = {}), (w = i.pages)[t] ?? (w[t] = {}), i.pages[t].currentSectionId = r ?? void 0), r ? window.sessionStorage.setItem("iframe_show_id", `"${r}"`) : window.sessionStorage.removeItem("iframe_show_id");
210
210
  })
211
211
  ));
212
212
  },
213
- setCurrentComponentId: (e) => {
214
- e !== a.currentComponentId && (l(I("/admin/maker", d ?? "", "components", e)), u(
213
+ setCurrentComponentId: (t) => {
214
+ t !== a.currentComponentId && (l(j("/admin/maker", d ?? "", "components", t)), u(
215
215
  (r) => b(r, (n) => {
216
- n.currentComponentId = e, n.componentDebugProps = {};
216
+ n.currentComponentId = t, n.componentDebugProps = {};
217
217
  })
218
218
  ));
219
219
  },
220
220
  setComponentDebugProps: (() => {
221
- const e = {}, r = W(() => {
221
+ const t = {}, r = W(() => {
222
222
  u(
223
223
  (n) => b(n, (s) => {
224
224
  s.componentDebugProps = {
225
225
  ...s == null ? void 0 : s.componentDebugProps,
226
- ...e
227
- }, Object.keys(e).forEach((c) => delete e[c]);
226
+ ...t
227
+ }, Object.keys(t).forEach((c) => delete t[c]);
228
228
  })
229
229
  );
230
230
  }, 5);
231
231
  return (n) => {
232
- Object.assign(e, n), r();
232
+ Object.assign(t, n), r();
233
233
  };
234
234
  })()
235
235
  }),
236
236
  [u, l, d]
237
237
  ), y = g(
238
238
  () => ({
239
- addPage: (e, r) => {
240
- const n = (e == null ? void 0 : e.id) ?? N(), s = {
241
- ...e,
239
+ addPage: (t, r) => {
240
+ var c, i, w, P;
241
+ const n = (t == null ? void 0 : t.id) ?? N(), s = {
242
+ ...t,
242
243
  id: n,
243
- createdAt: (e == null ? void 0 : e.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
244
- updatedAt: (e == null ? void 0 : e.updatedAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
244
+ createdAt: (t == null ? void 0 : t.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
245
+ updatedAt: (t == null ? void 0 : t.updatedAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
245
246
  publishedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
246
- slug: (e == null ? void 0 : e.slug) ?? `/${n}`,
247
- sections: (e == null ? void 0 : e.sections) ?? {},
248
- sectionIds: (e == null ? void 0 : e.sectionIds) ?? [],
249
- isPublic: (e == null ? void 0 : e.isPublic) ?? !0,
250
- templateConfig: (e == null ? void 0 : e.templateConfig) ?? {
251
- isTemplate: !1,
252
- displayTemplateId: void 0,
253
- dataSourceId: void 0,
254
- dataSourceParameters: {}
247
+ slug: (t == null ? void 0 : t.slug) ?? `/${n}`,
248
+ sections: (t == null ? void 0 : t.sections) ?? {},
249
+ sectionIds: (t == null ? void 0 : t.sectionIds) ?? [],
250
+ isPublic: (t == null ? void 0 : t.isPublic) ?? !0,
251
+ templateConfig: (t == null ? void 0 : t.templateConfig) ?? {
252
+ isTemplate: ((c = t == null ? void 0 : t.templateConfig) == null ? void 0 : c.isTemplate) ?? !0,
253
+ displayTemplateId: ((i = t == null ? void 0 : t.templateConfig) == null ? void 0 : i.displayTemplateId) ?? void 0,
254
+ dataSourceId: ((w = t == null ? void 0 : t.templateConfig) == null ? void 0 : w.dataSourceId) ?? void 0,
255
+ dataSourceParameters: ((P = t == null ? void 0 : t.templateConfig) == null ? void 0 : P.dataSourceParameters) ?? {}
255
256
  }
256
257
  };
257
- return t.doc.transact(() => {
258
+ return e.doc.transact(() => {
258
259
  o.pages[s.id] = s, o.pageIds.splice(r ?? o.pageIds.length, 0, s.id);
259
260
  }), s;
260
261
  },
261
- deletePage: (e) => {
262
- const r = o.pageIds.indexOf(e);
263
- r !== -1 && t.doc.transact(() => {
264
- o.pageIds.splice(r, 1), delete o.pages[e];
262
+ deletePage: (t) => {
263
+ const r = o.pageIds.indexOf(t);
264
+ r !== -1 && e.doc.transact(() => {
265
+ o.pageIds.splice(r, 1), delete o.pages[t];
265
266
  });
266
267
  },
267
- movePage: (e, r) => {
268
- const { pageIds: n } = o, s = n.indexOf(e);
268
+ movePage: (t, r) => {
269
+ const { pageIds: n } = o, s = n.indexOf(t);
269
270
  s >= 0 && n.splice(r, 0, ...n.splice(s, 1));
270
271
  },
271
- addSection: (e, r, n) => {
272
- const s = o.pages[e];
272
+ addSection: (t, r, n) => {
273
+ const s = o.pages[t];
273
274
  if (!s)
274
- throw new Error(`Page ${e} is not exists`);
275
+ throw new Error(`Page ${t} is not exists`);
275
276
  const c = {
276
277
  ...r,
277
278
  id: r.id ?? N(),
278
- isTemplateSection: r.isTemplateSection ?? !1
279
+ isTemplateSection: r.isTemplateSection ?? !0,
280
+ llmConfig: r.llmConfig ?? {}
279
281
  };
280
- return t.doc.transact(() => {
282
+ return e.doc.transact(() => {
281
283
  s.sections[c.id] = c, s.sectionIds.splice(n ?? s.sectionIds.length, 0, c.id);
282
284
  }), c;
283
285
  },
284
- deleteSection: (e, r) => {
285
- const n = o.pages[e];
286
+ deleteSection: (t, r) => {
287
+ const n = o.pages[t];
286
288
  if (!n)
287
- throw new Error(`Page ${e} is not exists`);
289
+ throw new Error(`Page ${t} is not exists`);
288
290
  const s = n.sectionIds.indexOf(r);
289
- s !== -1 && t.doc.transact(() => {
291
+ s !== -1 && e.doc.transact(() => {
290
292
  n.sectionIds.splice(s, 1), delete n.sections[r];
291
293
  });
292
294
  },
293
- toggleSectionVisibility: (e, r, n) => {
294
- const s = o.pages[e];
295
+ toggleSectionVisibility: (t, r, n) => {
296
+ const s = o.pages[t];
295
297
  if (!s)
296
- throw new Error(`Page ${e} is not exists`);
298
+ throw new Error(`Page ${t} is not exists`);
297
299
  const c = s.sections[r];
298
300
  c && (c.visibility = n);
299
301
  },
300
- moveSection: (e, r, n) => {
301
- const s = o.pages[e];
302
+ moveSection: (t, r, n) => {
303
+ const s = o.pages[t];
302
304
  if (!s)
303
- throw new Error(`Page ${e} is not exists`);
305
+ throw new Error(`Page ${t} is not exists`);
304
306
  const { sectionIds: c } = s, i = c.indexOf(r);
305
307
  i >= 0 && c.splice(n, 0, ...c.splice(i, 1));
306
308
  }
307
309
  }),
308
- [o, t.doc]
310
+ [o, e.doc]
309
311
  );
310
312
  return {
311
- ...t,
313
+ ...e,
312
314
  state: o,
313
315
  actions: y,
314
316
  localActions: S,
315
317
  get currentPage() {
316
318
  const {
317
- localState: { currentPageId: e }
318
- } = t;
319
- return e ? o.pages[e] : void 0;
319
+ localState: { currentPageId: t }
320
+ } = e;
321
+ return t ? o.pages[t] : void 0;
320
322
  },
321
323
  get currentSection() {
322
324
  var s, c, i;
323
325
  const {
324
- localState: { currentPageId: e, ...r }
325
- } = t;
326
- if (!e)
326
+ localState: { currentPageId: t, ...r }
327
+ } = e;
328
+ if (!t)
327
329
  return;
328
- const n = (c = (s = r.pages) == null ? void 0 : s[e]) == null ? void 0 : c.currentSectionId;
330
+ const n = (c = (s = r.pages) == null ? void 0 : s[t]) == null ? void 0 : c.currentSectionId;
329
331
  if (n)
330
- return (i = o.pages[e]) == null ? void 0 : i.sections[n];
332
+ return (i = o.pages[t]) == null ? void 0 : i.sections[n];
331
333
  }
332
334
  };
333
335
  }, V = () => {
334
- const { projectId: t } = at();
335
- return t ?? mt();
336
+ const { projectId: e } = at();
337
+ return e ?? mt() ?? "";
336
338
  };
337
- function It(t) {
339
+ function jt(e) {
338
340
  var a, l;
339
- const { resources: o } = t;
341
+ const { resources: o } = e;
340
342
  if (!o.components)
341
343
  return {};
342
344
  const u = {};
@@ -344,25 +346,25 @@ function It(t) {
344
346
  u[d.did] = d;
345
347
  }), Object.fromEntries(
346
348
  Object.entries(o.components).map(([d, { blockletId: S, component: y }]) => {
347
- var e;
349
+ var t;
348
350
  return [
349
351
  d,
350
- { data: y, blockletId: S, blockletTitle: ((e = u[S]) == null ? void 0 : e.title) || S }
352
+ { data: y, blockletId: S, blockletTitle: ((t = u[S]) == null ? void 0 : t.title) || S }
351
353
  ];
352
354
  })
353
355
  );
354
356
  }
355
- function Ct(t) {
356
- const { components: o } = t;
357
+ function kt(e) {
358
+ const { components: o } = e;
357
359
  return o || {};
358
360
  }
359
- function Et(t) {
361
+ function Et(e) {
360
362
  return {
361
- ...It(t),
362
- ...Ct(t)
363
+ ...jt(e),
364
+ ...kt(e)
363
365
  };
364
366
  }
365
- const te = () => Et(kt().state), vt = [
367
+ const te = () => Et(It().state), vt = [
366
368
  /\.\./,
367
369
  // Directory traversal
368
370
  /<[^>]*>/,
@@ -379,20 +381,20 @@ const te = () => Et(kt().state), vt = [
379
381
  /[^a-zA-Z0-9-_@/]/
380
382
  // Disallow any characters except alphanumeric, dash, underscore and forward slash
381
383
  ];
382
- function ee(t, o, u) {
384
+ function ee(e, o, u) {
383
385
  const a = [];
384
386
  {
385
387
  let l;
386
- o.slug ? o.slug.startsWith("/") ? o.slug !== "/" && o.slug.endsWith("/") ? l = t("maker.properties.pathCheckEndWithoutSlash") : /\/{2,}/.test(o.slug) ? l = t("maker.properties.pathCheckConsecutiveSlash") : /\s/.test(o.slug) ? l = t("maker.properties.pathCheckWhitespace") : vt.some((d) => d.test(o.slug)) ? l = t("maker.properties.pathCheckInvalid") : Object.values(u.pages).some((d) => (d == null ? void 0 : d.id) !== o.id && (d == null ? void 0 : d.slug) === o.slug) && (l = t("maker.properties.pathCheckAlreadyExist")) : l = t("maker.properties.pathCheckStartWithSlash") : l = t("maker.properties.pathCheckRequired"), l && a.push({ path: ["path"], message: l });
388
+ o.slug ? o.slug.startsWith("/") ? o.slug !== "/" && o.slug.endsWith("/") ? l = e("maker.properties.pathCheckEndWithoutSlash") : /\/{2,}/.test(o.slug) ? l = e("maker.properties.pathCheckConsecutiveSlash") : /\s/.test(o.slug) ? l = e("maker.properties.pathCheckWhitespace") : vt.some((d) => d.test(o.slug)) ? l = e("maker.properties.pathCheckInvalid") : Object.values(u.pages).some((d) => (d == null ? void 0 : d.id) !== o.id && (d == null ? void 0 : d.slug) === o.slug) && (l = e("maker.properties.pathCheckAlreadyExist")) : l = e("maker.properties.pathCheckStartWithSlash") : l = e("maker.properties.pathCheckRequired"), l && a.push({ path: ["path"], message: l });
387
389
  }
388
390
  return a.length > 0 ? a : null;
389
391
  }
390
- function oe({ errors: t, ...o }) {
391
- return t != null && t.length ? /* @__PURE__ */ P(
392
+ function oe({ errors: e, ...o }) {
393
+ return e != null && e.length ? /* @__PURE__ */ C(
392
394
  G,
393
395
  {
394
396
  ...o,
395
- title: /* @__PURE__ */ P(x, { children: t.map((u, a) => /* @__PURE__ */ P(x, { children: u.message }, a)) })
397
+ title: /* @__PURE__ */ C(x, { children: e.map((u, a) => /* @__PURE__ */ C(x, { children: u.message }, a)) })
396
398
  }
397
399
  ) : null;
398
400
  }
@@ -407,8 +409,8 @@ export {
407
409
  Et as e,
408
410
  Gt as f,
409
411
  Xt as g,
410
- kt as h,
411
- gt as i,
412
+ It as h,
413
+ Pt as i,
412
414
  te as j,
413
415
  Qt as k,
414
416
  ee as l,
package/lib/es/home.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import "react/jsx-runtime";
2
- import "./chunks/state-JDvNqLu1.js";
3
- import { a as h, P as x, c as y, b as B, T as R, H as j } from "./chunks/home-DQvcjT5p.js";
2
+ import "./chunks/state-CYDNg8EG.js";
3
+ import { a as h, P as x, c as y, b as B, T as R, H as j } from "./chunks/home-Cclj5ETj.js";
4
4
  import "@arcblock/ux/lib/Locale/context";
5
5
  import "@arcblock/ux/lib/Result";
6
6
  import "@blocklet/pages-kit/builtin/page/header";
package/lib/es/setting.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as t, jsxs as S, Fragment as H } from "react/jsx-runtime";
2
- import { t as ge, g as oe, i as Fe, b as Je, h as de, E as yt, n as Me, j as xe } from "./chunks/state-JDvNqLu1.js";
2
+ import { t as ge, g as oe, i as Fe, b as Je, h as de, E as yt, n as Me, j as xe } from "./chunks/state-CYDNg8EG.js";
3
3
  import Z from "@arcblock/ux/lib/Empty";
4
4
  import { useLocaleContext as D } from "@arcblock/ux/lib/Locale/context";
5
5
  import { CodeEditor as we } from "@blocklet/code-editor";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/pages-kit-inner-components",
3
- "version": "0.4.97",
3
+ "version": "0.4.99",
4
4
  "description": "Pages Kit inner components library",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -67,13 +67,13 @@
67
67
  "dependencies": {
68
68
  "@arcblock/did-auth": "^1.19.15",
69
69
  "@arcblock/did-auth-storage-nedb": "^1.7.1",
70
- "@arcblock/did-connect": "^2.12.53",
71
- "@arcblock/react-hooks": "^2.12.53",
72
- "@arcblock/ux": "^2.12.53",
70
+ "@arcblock/did-connect": "^2.12.54",
71
+ "@arcblock/react-hooks": "^2.12.54",
72
+ "@arcblock/ux": "^2.12.54",
73
73
  "@blocklet/ai-kit": "^0.1.72",
74
74
  "@blocklet/ai-runtime": "^0.4.254",
75
75
  "@blocklet/code-editor": "^0.4.254",
76
- "@blocklet/crawler": "^2.2.8",
76
+ "@blocklet/crawler": "^2.2.12",
77
77
  "@blocklet/embed": "^0.2.3",
78
78
  "@blocklet/js-sdk": "^1.16.41",
79
79
  "@blocklet/logger": "1.16.36",
@@ -81,9 +81,9 @@
81
81
  "@blocklet/sdk": "^1.16.41",
82
82
  "@blocklet/studio-ui": "^0.4.254",
83
83
  "@blocklet/tracker": "^1.16.41",
84
- "@blocklet/ui-react": "^2.12.53",
85
- "@blocklet/uploader": "^0.1.81",
86
- "@blocklet/uploader-server": "^0.1.92",
84
+ "@blocklet/ui-react": "^2.12.54",
85
+ "@blocklet/uploader": "^0.1.82",
86
+ "@blocklet/uploader-server": "^0.1.93",
87
87
  "@emotion/cache": "^11.13.1",
88
88
  "@emotion/css": "^11.13.0",
89
89
  "@emotion/react": "^11.13.0",
@@ -202,8 +202,8 @@
202
202
  "yaml": "^2.5.0",
203
203
  "yjs": "^13.6.18",
204
204
  "zustand": "^4.5.5",
205
- "@blocklet/pages-kit-block-studio": "^0.4.97",
206
- "@blocklet/pages-kit": "^0.4.97"
205
+ "@blocklet/pages-kit": "^0.4.99",
206
+ "@blocklet/pages-kit-block-studio": "^0.4.99"
207
207
  },
208
208
  "devDependencies": {
209
209
  "@trivago/prettier-plugin-sort-imports": "^5.2.1",
@@ -1 +0,0 @@
1
- "use strict";const P=require("react/jsx-runtime"),C=require("@mui/material"),Q=require("gradient-parser"),X=require("tinycolor2"),j=require("ufo"),Y=require("@blocklet/js-sdk"),Z=require("lodash/isEmpty"),H=require("yaml"),W=require("@syncedstore/core"),ee=require("@syncedstore/react"),te=require("ahooks"),x=require("immer"),ne=require("js-cookie"),oe=require("lodash/debounce"),re=require("nanoid"),d=require("react"),N=require("react-router-dom"),se=require("y-indexeddb"),ce=require("y-websocket"),ie=require("yjs"),y=e=>e&&e.__esModule?e:{default:e};function ae(e){if(e&&e.__esModule)return e;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const i in e)if(i!=="default"){const u=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,u.get?u:{enumerable:!0,get:()=>e[i]})}}return n.default=e,Object.freeze(n)}const ue=y(Q),de=y(X),le=y(Z),fe=ae(H),me=y(W),pe=y(ne),F=y(oe);function V(){const{pathname:e}=window.location,n=e.match(/\/admin\/(maker|previewer)\/([^/]+)/),i=n==null?void 0:n[2],u=window.__PROJECT_ID__;if(!i&&!u)throw new Error("Unable to get projectId from pathname");return i||u}function ge(e){return`${e}:pages:version`}function Se(e,n){return n==="yaml"?le.default(e)?"":fe.stringify(e,{indent:2}):n==="json"?JSON.parse(JSON.stringify(e||"{}")):n==="array"?JSON.parse(JSON.stringify(e||"[]")):e}function we({error:e}){return P.jsx(C.Box,{children:P.jsx(C.Alert,{severity:"error",children:e.message})})}var T;const v=((T=window.blocklet)==null?void 0:T.prefix)||"/",O=Y.createAxios({timeout:200*1e3}),he=window.location.protocol==="https:"?"wss":"ws",Pe=e=>j.joinURL(`${he}://${window.location.hostname}`,v,`api/${e}/ws/pages`),je="z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";var $;($=blocklet==null?void 0:blocklet.componentMountPoints.find(e=>e.did===je))!=null&&$.mountPoint||j.joinURL(v,"/image-bin");function ye(e){return e&&!/^(https?:\/\/|\/)/.test(e)?window.location.origin+j.joinURL(v,"uploads",e):e}const ke=window.innerWidth<=750;function Ie(e,n,i){if(!e||/\.gif/.test(e))return e;const u=(ke?n/1.5:n)*(i==="quality"?1.5:1);return be(e,{imageFilter:"resize",w:u,f:"webp"})}function be(e,n){return!e||!n?e:j.withQuery(e,n)}function z(e){if(e!=null&&e.trim())try{return ue.default.parse(e),!0}catch{return!1}return!1}function Ce(e){return typeof e!="string"?!1:!!(z(e)||de.default(e).isValid())}async function Ee(e){return O.get(`/api/projects/${e}`).then(n=>n.data)}async function xe(e){return O.post(`/api/projects/${e.id}/update`,e).then(n=>n.data)}const _e=500,_=re.customAlphabet("abcdefghijklmnopqrstuvwxyz0123456789",16),B=d.createContext(null);function ve({url:e,name:n,children:i,waitingSynced:u}){const[f,l]=d.useState(!1),S=L(),k=`${S}:MakerLocalState`,t=`${S}:${n}`,[r,o]=te.useLocalStorageState(k,{defaultValue:{},listenStorageChange:!0}),s=d.useRef(r);s.current=r;const a=d.useMemo(()=>me.default({pages:{},pageIds:[],components:{},supportedLocales:[],config:{},resources:{}}),[]),c=d.useMemo(()=>W.getYjsDoc(a),[a]);d.useMemo(()=>new se.IndexeddbPersistence(t,c),[t,c]);const w=d.useMemo(()=>new ce.WebsocketProvider(e,t,c,{params:{token:pe.default.get("login_token")}}),[e,t,c]),I=d.useMemo(()=>new ie.UndoManager([c.getArray("pageIds"),c.getMap("pages"),c.getArray("supportedLocales"),c.getMap("config")],{doc:c}),[c]),[b,E]=d.useState(null),[A,q]=d.useState(!1),[M,R]=d.useState(void 0),D=d.useCallback(async()=>{if(S){q(!0);try{const m=await Ee(S);E(m)}catch(m){console.error("Failed to fetch project:",m)}finally{q(!1)}}},[S]),U=d.useCallback(async(m,p)=>{var h;if(R(void 0),!!S){p!=null&&p.optimisticUpdate&&b&&E(g=>({...g,...m}));try{const g=await xe({...m});E(g)}catch(g){console.error("Failed to update project:",g),p!=null&&p.optimisticUpdate&&E(b),R((h=g==null?void 0:g.response)==null?void 0:h.data)}}},[S,b]);d.useEffect(()=>{S&&D()},[S,D]);const K=d.useMemo(()=>({doc:c,state:a,localState:r,setLocalState:m=>o(typeof m=="function"?p=>m(p??{}):m),undoManager:I,projectState:{project:b,isLoadingProject:A,error:M},updateProject:U}),[c,a,JSON.stringify(r),o,I,b,A,U,M]);return d.useEffect(()=>{I.on("stack-item-added",({stackItem:m})=>{const{currentPageId:p,currentLocale:h,pages:g}=s.current;m.meta.set("localState",{currentPageId:p,currentLocale:h,pages:g})}),I.on("stack-item-popped",({stackItem:m})=>{const p=m.meta.get("localState");p&&o(h=>({...h,...p}))})},[I,o]),d.useEffect(()=>{w.awareness.setLocalState(r)},[w,r]),d.useEffect(()=>{w.once("synced",()=>l(!0));const m=()=>{o(g=>({...g,networkStatus:void 0}))},p=()=>{o(g=>({...g,networkStatus:"offline"}))},h=F.default(({status:g})=>{g==="connected"?m():g==="disconnected"&&p()},_e);return w.on("status",h),window.addEventListener("online",m),window.addEventListener("offline",p),()=>{w.off("status",h),window.removeEventListener("online",m),window.removeEventListener("offline",p)}},[w,o]),u&&!f?null:P.jsx(B.Provider,{value:K,children:i})}const G=()=>{const e=d.useContext(B);if(!e)throw new Error("Context is null");const n=ee.useSyncedStore(e.state),{setLocalState:i,localState:u}=e,f=N.useNavigate(),l=L(),S=d.useMemo(()=>({setCurrentSectionId:(t,r)=>{var o,s;t===u.currentPageId&&r===((s=(o=u.pages)==null?void 0:o[t])==null?void 0:s.currentSectionId)||(f(j.joinURL("/admin/maker",l??"","pages",t)),i(a=>x.produce(a,c=>{var w;c.currentPageId=t,c.currentComponentId=void 0,c.componentDebugProps={},r!==void 0&&(c.pages??(c.pages={}),(w=c.pages)[t]??(w[t]={}),c.pages[t].currentSectionId=r??void 0),r?window.sessionStorage.setItem("iframe_show_id",`"${r}"`):window.sessionStorage.removeItem("iframe_show_id")})))},setCurrentComponentId:t=>{t!==u.currentComponentId&&(f(j.joinURL("/admin/maker",l??"","components",t)),i(r=>x.produce(r,o=>{o.currentComponentId=t,o.componentDebugProps={}})))},setComponentDebugProps:(()=>{const t={},r=F.default(()=>{i(o=>x.produce(o,s=>{s.componentDebugProps={...s==null?void 0:s.componentDebugProps,...t},Object.keys(t).forEach(a=>delete t[a])}))},5);return o=>{Object.assign(t,o),r()}})()}),[i,f,l]),k=d.useMemo(()=>({addPage:(t,r)=>{const o=(t==null?void 0:t.id)??_(),s={...t,id:o,createdAt:(t==null?void 0:t.createdAt)??new Date().toISOString(),updatedAt:(t==null?void 0:t.updatedAt)??new Date().toISOString(),publishedAt:new Date(0).toISOString(),slug:(t==null?void 0:t.slug)??`/${o}`,sections:(t==null?void 0:t.sections)??{},sectionIds:(t==null?void 0:t.sectionIds)??[],isPublic:(t==null?void 0:t.isPublic)??!0,templateConfig:(t==null?void 0:t.templateConfig)??{isTemplate:!1,displayTemplateId:void 0,dataSourceId:void 0,dataSourceParameters:{}}};return e.doc.transact(()=>{n.pages[s.id]=s,n.pageIds.splice(r??n.pageIds.length,0,s.id)}),s},deletePage:t=>{const r=n.pageIds.indexOf(t);r!==-1&&e.doc.transact(()=>{n.pageIds.splice(r,1),delete n.pages[t]})},movePage:(t,r)=>{const{pageIds:o}=n,s=o.indexOf(t);s>=0&&o.splice(r,0,...o.splice(s,1))},addSection:(t,r,o)=>{const s=n.pages[t];if(!s)throw new Error(`Page ${t} is not exists`);const a={...r,id:r.id??_(),isTemplateSection:r.isTemplateSection??!1};return e.doc.transact(()=>{s.sections[a.id]=a,s.sectionIds.splice(o??s.sectionIds.length,0,a.id)}),a},deleteSection:(t,r)=>{const o=n.pages[t];if(!o)throw new Error(`Page ${t} is not exists`);const s=o.sectionIds.indexOf(r);s!==-1&&e.doc.transact(()=>{o.sectionIds.splice(s,1),delete o.sections[r]})},toggleSectionVisibility:(t,r,o)=>{const s=n.pages[t];if(!s)throw new Error(`Page ${t} is not exists`);const a=s.sections[r];a&&(a.visibility=o)},moveSection:(t,r,o)=>{const s=n.pages[t];if(!s)throw new Error(`Page ${t} is not exists`);const{sectionIds:a}=s,c=a.indexOf(r);c>=0&&a.splice(o,0,...a.splice(c,1))}}),[n,e.doc]);return{...e,state:n,actions:k,localActions:S,get currentPage(){const{localState:{currentPageId:t}}=e;return t?n.pages[t]:void 0},get currentSection(){var s,a,c;const{localState:{currentPageId:t,...r}}=e;if(!t)return;const o=(a=(s=r.pages)==null?void 0:s[t])==null?void 0:a.currentSectionId;if(o)return(c=n.pages[t])==null?void 0:c.sections[o]}}},L=()=>{const{projectId:e}=N.useParams();return e??V()};function Oe(e){var u,f;const{resources:n}=e;if(!n.components)return{};const i={};return(f=(u=window==null?void 0:window.blocklet)==null?void 0:u.componentMountPoints)==null||f.forEach(l=>{i[l.did]=l}),Object.fromEntries(Object.entries(n.components).map(([l,{blockletId:S,component:k}])=>{var t;return[l,{data:k,blockletId:S,blockletTitle:((t=i[S])==null?void 0:t.title)||S}]}))}function Le(e){const{components:n}=e;return n||{}}function J(e){return{...Oe(e),...Le(e)}}const Ae=()=>J(G().state),qe=[/\.\./,/<[^>]*>/,/%[0-9a-f]{2}/i,/[<>'"%;{}()\\]/,/\x00/,/\n|\r|\t|\v|\f/,/[^a-zA-Z0-9-_@/]/];function Me(e,n,i){const u=[];{let f;n.slug?n.slug.startsWith("/")?n.slug!=="/"&&n.slug.endsWith("/")?f=e("maker.properties.pathCheckEndWithoutSlash"):/\/{2,}/.test(n.slug)?f=e("maker.properties.pathCheckConsecutiveSlash"):/\s/.test(n.slug)?f=e("maker.properties.pathCheckWhitespace"):qe.some(l=>l.test(n.slug))?f=e("maker.properties.pathCheckInvalid"):Object.values(i.pages).some(l=>(l==null?void 0:l.id)!==n.id&&(l==null?void 0:l.slug)===n.slug)&&(f=e("maker.properties.pathCheckAlreadyExist")):f=e("maker.properties.pathCheckStartWithSlash"):f=e("maker.properties.pathCheckRequired"),f&&u.push({path:["path"],message:f})}return u.length>0?u:null}function Re({errors:e,...n}){return e!=null&&e.length?P.jsx(C.Tooltip,{...n,title:P.jsx(C.Box,{children:e.map((i,u)=>P.jsx(C.Box,{children:i.message},u))})}):null}exports.ErrorView=we;exports.PageErrorTip=Re;exports.StoreProvider=ve;exports.api=O;exports.autoResizeImage=Ie;exports.checkPage=Me;exports.getAllComponents=J;exports.getImageAbsoluteUrl=ye;exports.getProjectIdFromPathnameOrWindow=V;exports.getProjectPageVersionKey=ge;exports.getWssURL=Pe;exports.isColorString=Ce;exports.isGradient=z;exports.nextId=_;exports.transformValue=Se;exports.useAllComponents=Ae;exports.useProjectId=L;exports.useStore=G;