@blocklet/pages-kit-inner-components 0.4.84 → 0.4.86

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.
@@ -0,0 +1,542 @@
1
+ "use strict";var Ge=Object.create;var me=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var Ke=Object.getPrototypeOf,Xe=Object.prototype.hasOwnProperty;var Ye=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Je(t))!Xe.call(e,i)&&i!==o&&me(e,i,{get:()=>t[i],enumerable:!(r=De(t,i))||r.enumerable});return e};var pe=(e,t,o)=>(o=e!=null?Ge(Ke(e)):{},Ye(t||!e||!e.__esModule?me(o,"default",{value:e,enumerable:!0}):o,e));const n=require("react/jsx-runtime"),w=require("./state-BjeG4kYg.js"),ke=require("@arcblock/ux/lib/Locale/context"),Qe=require("@arcblock/ux/lib/Result"),Ze=require("@blocklet/pages-kit/builtin/page/header"),et=require("@blocklet/ui-react/lib/Header"),_=require("@emotion/css"),Y=require("@emotion/react"),tt=require("@emotion/styled"),p=require("@mui/material"),$e=require("ahooks"),nt=require("isomorphic-dompurify"),ot=require("lodash/cloneDeep"),rt=require("lodash/isEmpty"),it=require("lodash/isEqual"),g=require("react"),st=require("react-helmet"),B=require("react-router-dom"),O=require("react-use"),P=require("ufo");require("@mui/icons-material");const J=require("@blocklet/ai-runtime/components"),at=require("@mui/utils"),ct=require("lodash/pick"),lt=require("react-error-boundary"),Z=require("@iconify/react"),dt=require("react-markdown"),ut=require("remark-gfm"),mt=require("@mui/lab"),$=require("@arcblock/ux/lib/Theme"),pt=require("@arcblock/react-hooks/lib/useBrowser"),xt=require("@arcblock/ux/lib/Colors"),oe=require("@blocklet/pages-kit/components"),ft=require("@mui/material/useMediaQuery"),ht=require("lodash/omit"),Se=require("@iconify-icon/react"),gt=require("@arcblock/ux/lib/Screenshot"),bt=require("@arcblock/ux/lib/Button"),yt=require("is-uri"),K=require("pathe"),jt=require("@blocklet/embed/message"),wt=require("@blocklet/embed/react"),_t=require("react-twitter-embed"),vt=require("@blocklet/ui-react/lib/Footer"),kt=require("webfontloader"),$t=require("@arcblock/did-connect/lib/Session"),S=e=>e&&e.__esModule?e:{default:e},Ce=S(Qe),St=S(et),Be=S(tt),Ct=S(nt),xe=S(ot),Bt=S(rt),Ie=S(it),Ne=S(g),re=S(ct),It=S(dt),Nt=S(ut),Pt=S(pt),fe=S(xt),Pe=S(ft),R=S(ht),Rt=S(gt),Tt=S(bt),ee=S(yt),qt=S(vt),Et=S(kt);function zt(e,t,o,r){e.locales||(e.locales={}),e.locales[o]=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.locales||{},a.locales[o]=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.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.locales[o],...s||{}}})}const Wt=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(mt.LoadingButton,{ref:o,...t,loading:t.loading||r,onClick:s})});function Lt({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(Wt,{startIcon:h&&(typeof h=="string"?n.jsx(Z.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 At=Ne.default.lazy(()=>import("react-syntax-highlighter").then(e=>({default:e.Prism}))),Ot=p.styled(e=>n.jsx(It.default,{...e,remarkPlugins:[Nt.default],components:{pre:Ut,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:At,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
+ width: 100%;
3
+ overflow: hidden;
4
+ word-break: break-word;
5
+
6
+ > * {
7
+ &:first-child /* emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason */ {
8
+ margin-top: 0;
9
+ }
10
+ &:last-child /* emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason */ {
11
+ margin-bottom: 0;
12
+ }
13
+ }
14
+
15
+ pre {
16
+ overflow: auto;
17
+ }
18
+
19
+ li {
20
+ margin: 0;
21
+ padding: 0;
22
+ }
23
+
24
+ li p {
25
+ display: inline-block;
26
+ vertical-align: top;
27
+ margin: 0;
28
+ padding: 0;
29
+ }
30
+
31
+ table {
32
+ border-collapse: collapse;
33
+ white-space: nowrap;
34
+
35
+ th,
36
+ td {
37
+ border: 1px solid grey;
38
+ padding: 4px 8px;
39
+ }
40
+ }
41
+
42
+ a {
43
+ color: ${({theme:e})=>e.palette.primary.main};
44
+
45
+ :hover {
46
+ text-decoration: underline;
47
+ }
48
+ }
49
+
50
+ &.writing > *:last-child {
51
+ &:after {
52
+ content: '';
53
+ display: inline-block;
54
+ vertical-align: middle;
55
+ height: 1.2em;
56
+ margin-top: -0.2em;
57
+ margin-left: 0.1em;
58
+ border-right: 0.2em solid orange;
59
+ border-radius: 10px;
60
+ animation: blink-caret 0.75s step-end infinite;
61
+
62
+ @keyframes blink-caret {
63
+ from,
64
+ to {
65
+ border-color: transparent;
66
+ }
67
+ 50% {
68
+ border-color: ${({theme:e})=>e.palette.secondary.main};
69
+ }
70
+ }
71
+ }
72
+ }
73
+ `;function Ut({children:e}){const t=e==null?void 0:e.props;if(!(t!=null&&t.children))return null;const o=/language-(\w+)/.exec(t.className||""),r=o==null?void 0:o[1];return n.jsxs(p.Box,{component:"div",sx:{fontSize:14,borderRadius:1,bgcolor:"rgb(245, 242, 240)","> pre":{mt:"0 !important"}},children:[n.jsxs(p.Stack,{direction:"row",alignItems:"center",p:.5,pl:1.5,borderBottom:1,borderColor:"grey.200",children:[n.jsx(p.Box,{children:r}),n.jsx(p.Box,{flex:1}),n.jsx(Lt,{autoReset:!0,title:n.jsx(Z.Icon,{icon:"tabler:copy"}),titleSucceed:n.jsx(Z.Icon,{icon:"tabler:copy-check"}),sx:{minWidth:32,minHeight:32,p:0,fontSize:18},onClick:()=>{window.navigator.clipboard.writeText(t.children)}})]}),e]})}function z({actions:e,center:t,className:o,align:r}){return e&&(e!=null&&e.length)?n.jsx(p.Box,{className:_.cx("flex gap-4 flex-wrap","lg:flex-row lg:gap-8",(t||r==="center")&&"justify-center",!t&&r==="right"&&"justify-end",!t&&r==="left"&&"justify-start",o),sx:{alignItems:"center"},children:e}):null}const Mt="section",Ht=p.styled(p.Box)`
74
+ overflow: hidden;
75
+
76
+ .section__title {
77
+ margin-top: 0;
78
+ font-weight: 700;
79
+ }
80
+ .section__title_non_big {
81
+ font-size: 32px;
82
+ @media (max-width: 600px) {
83
+ font-size: 24px;
84
+ }
85
+ }
86
+ &.base-info .section__tag {
87
+ margin-top: 0;
88
+ margin-bottom: 2vw;
89
+ background-color: ${({theme:e})=>e.palette.primary.main};
90
+ white-space: nowrap;
91
+ max-width: 100%;
92
+ display: inline-block;
93
+ padding: 0 10px;
94
+ justify-content: flex-start;
95
+ overflow: hidden;
96
+ text-overflow: ellipsis;
97
+ font-size: 12px;
98
+ color: #fff;
99
+ border-radius: 4px;
100
+ line-height: 20px;
101
+ }
102
+ .section__title {
103
+ a {
104
+ color: ${({theme:e})=>e.palette.primary.main};
105
+ }
106
+ p {
107
+ margin-top: 0;
108
+ margin-bottom: 0;
109
+ }
110
+ }
111
+ .section__description {
112
+ margin-bottom: 4vw;
113
+ margin-top: 0;
114
+ a {
115
+ color: ${({theme:e})=>e.palette.primary.main};
116
+ }
117
+ p {
118
+ margin-top: 0;
119
+ margin-bottom: 0.5rem;
120
+ }
121
+ }
122
+ @media (min-width: ${({theme:e})=>e.breakpoints.values[Mt]}px) {
123
+ .section__tag {
124
+ margin-bottom: 32px;
125
+ }
126
+ .section__title {
127
+ margin-bottom: 32px;
128
+ }
129
+ .section__description {
130
+ margin-bottom: 40px;
131
+ }
132
+ }
133
+ `;function U({title:e,description:t,descriptionMarkdown:o,actions:r,className:i="",classes:s={},prepend:a,append:c,level:l=2,tag:d,badge:u,center:m,logo:f,titleAppearance:x,descriptionAppearance:y,...j}){if(!e&&!t&&!r&&!u&&!d&&!a&&!c&&!f)return null;const h=Math.max(Math.min(5,l+1),1),v={1:"xl:!text-3xl lg:!text-2xl md:!text-xl",2:"xl:!text-2xl lg:!text-xl md:!text-lg",3:"xl:!text-2xl lg:!text-xl md:!text-lg",4:"xl:!text-xl lg:!text-lg md:!text-md",5:"xl:!text-lg md:!text-md sm:!text-sm",6:"!text-sm"},b=l===0?"big":`h${h}`,k=l===0;return n.jsxs(Ht,{className:_.cx("base-info","lg:text-left",m&&"!text-center",i),...j,children:[a&&n.jsx("div",{children:a}),(d||u)&&n.jsx("div",{className:_.cx("section__tag",(s==null?void 0:s.tag)||(s==null?void 0:s.badge)),children:d||u}),f&&n.jsx("img",{className:"w-[120px] m-auto mb-8",src:f,alt:"info",loading:"lazy"}),e&&n.jsx(p.Typography,{sx:{whiteSpace:"pre-wrap",mb:t?"2vw":0,...(x==null?void 0:x.color)&&{color:`${x.color} !important`}},className:_.cx("section__title","text-gray-800","dark:text-gray-50",s.title,"page-kit-section__title",k?"":"section__title_non_big"),component:`h${Math.max(l,1)}`,variant:b,children:e}),t&&(o?n.jsx(p.Box,{sx:{...(y==null?void 0:y.color)&&{color:`${y.color} !important`}},component:Ot,className:_.cx("section__description","text-gray-800","dark:text-gray-100",v[h],s.description,"page-kit-section__description"),children:t}):n.jsx(p.Typography,{sx:{whiteSpace:"pre-wrap",...(y==null?void 0:y.color)&&{color:`${y.color} !important`}},className:_.cx("section__description","text-gray-800","dark:text-gray-100",v[h],s.description,"page-kit-section__description"),component:"div",variant:"body1",gutterBottom:!0,children:t})),n.jsx(z,{actions:r,center:m,className:"mt-8"}),c&&n.jsx("div",{children:c})]})}const M=["actions","append","badge","tag","center","description","descriptionMarkdown","level","logo","prepend","title","titleAppearance","descriptionAppearance"];function Re(e){if(e.type===g.Fragment){const o=(e.props.children||[]).filter(r=>g.isValidElement(r));return o.length===1?Re(o[0]):o.length>1}return Array.isArray(e)}const T="&>*";function ie({children:e,col:t,gap:o,className:r,align:i,sx:s,type:a,...c}={children:null,className:"",col:3,gap:void 0,sx:{},align:"center",type:"default"}){const l=$.useTheme(),d=Number(Math.floor(100/t*100)/100),u={center:"justify-center items-center",left:"justify-start items-center",right:"justify-end items-center",top:"justify-center items-start",bottom:"justify-center items-end","top-left":"justify-start items-start","top-right":"justify-end items-start","bottom-left":"justify-start items-end","bottom-right":"justify-end items-end"},m=u[i]||u.center;let x=o??({2:6,3:4,4:4,5:3,6:3}[t]||0);Re(e)||(x=0);const j=(t-1)*x/t;let h={...s,gap:`${x}rem`};const v={[T]:{width:"100%"}},b={},k={},N={};switch(v.gap="1rem",b.gap=`${x/2}rem`,t){case 3:case 4:b[T]={width:`calc(50% - ${x/2}rem)`};break;case 5:case 6:v[T]={width:`calc(50% - ${x/2/2}rem)`},b[T]={width:`calc(50% - ${x/2/2}rem)`},k[T]={width:`calc(33.33% - ${x*2/3}rem)`};break}return h[T]={width:`calc(${d}% - ${j}rem)`},h[`@media (max-width: ${l.breakpoints.values.xl}px)`]=N,h[`@media (max-width: ${l.breakpoints.values.lg}px)`]=k,h[`@media (max-width: ${l.breakpoints.values.md}px)`]=b,h[`@media (max-width: ${l.breakpoints.values.sm}px)`]=v,a==="wall"&&(h={...s,gap:`${x}rem`},h[T]={width:`calc(${d}% - ${j}rem)`},v[T]={width:`calc(45% - ${x/2/2}rem)`},h[`@media (max-width: ${l.breakpoints.values.sm}px)`]=v),n.jsx(p.Box,{className:_.cx("flex flex-wrap flex-row h-full",m,r),sx:h,...c,children:e})}function Ft(){const e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")}function Vt(e=""){if(e.startsWith("data:image/svg+xml,"))return!0;const t=/^(((ht|f)tps?):\/\/)?([^!@#$%^&*?.\s-]([^!@#$%^&*?.\s]{0,63}[^!@#$%^&*?.\s])?\.)+[a-z]{2,6}\/?/,o=/^(\/|\.\/|\.\.\/)(?:[^/]+\/)*[^/]+$/;return t.test(e)||o.test(e)}function te(e){return(e==null?void 0:e.endsWith(".mp4"))||(e==null?void 0:e.endsWith(".m4v"))||(e==null?void 0:e.endsWith(".webm"))}function Gt(e){return e!=null&&e.endsWith(".mp4")||e!=null&&e.endsWith(".m4v")?"video/mp4":e!=null&&e.endsWith(".webm")?"video/webm":void 0}function Dt(e){let t={};return typeof e=="string"?w.isGradient(e)?t.image=e:(t.image=w.getImageAbsoluteUrl(e),w.isColorString(e)&&(t.color=e,t.image="")):t=e,t}function Jt(){const[e,t]=g.useState(Date.now());return g.useEffect(()=>{const o=()=>{t(Date.now())};return document.addEventListener("visibilitychange",o),()=>{document.removeEventListener("visibilitychange",o)}},[]),e}function he(e,t,o,r,i){let s=null;const{color:a="",image:c}=Dt(t);return c&&Vt(c)?(delete o.backgroundColor,!(e.mobile.apple.device||Ft())&&te(c)?s=n.jsx(p.Box,{component:"video",className:"section-bg",width:"100%",autoPlay:!0,loop:!0,muted:!0,controls:!1,playsInline:!0,poster:w.autoResizeImage(w.getImageAbsoluteUrl(r),1200,"quality"),src:te(c)?c:w.autoResizeImage(c,1200,"quality"),sx:{position:"absolute",zIndex:-9999,right:0,left:0,top:0,width:"100%",height:"100%",objectFit:"cover"}},c):s=n.jsx(oe.ResponsiveImage,{src:c,sizesAttr:{sm:600,md:900,lg:1200},className:"section-bg",alt:"",width:"100%",loading:"lazy",sx:{position:"absolute",zIndex:-9999,right:0,left:0,top:0,width:"100%",height:"100%",objectFit:"cover"}},i||c)):c?o.backgroundImage=`${c} !important`:a&&(o.backgroundColor=`${a} !important`),s}function Kt({autoWidth:e,children:t,...o}){return e?n.jsx(p.Box,{display:"flex",...o,children:t}):n.jsx(p.Container,{...o,children:t})}function H({dark:e=!1,children:t,className:o,sx:r={},boxed:i={show:!1},padding:s="normal",boxProps:a,type:c,...l}){const d={...r},u=Pe.default(x=>x.breakpoints.down("md"));e&&(d.color=fe.default.common.white,d.backgroundColor=`${fe.default.grey[900]} !important`);const m={none:"py-0",small:"py-5 md:py-8 lg:py-8 xl:py-12",normal:"py-10 md:py-15 lg:py-20 xl:py-25",large:"py-15 md:py-20 lg:py-25 xl:py-30"};i.show&&(d.display="flex");const f=g.useMemo(()=>!Number(l.boxMaxWidth)||u?{width:"100%"}:c==="wall"&&l.boxMaxWidth?{maxWidth:`${l.boxMaxWidth}px !important`,width:"100%"}:{width:"100%"},[l.boxMaxWidth,u,c]);return n.jsx(Xt,{component:"section",styles:{...d},className:_.cx("base-section","px-2 md:px-5 lg:px-5 xl:px-10",m[s],o,{dark:e}),...R.default(l,"hoverStyle","boxMaxWidth","embedUrl","autoWidth","paddingXY","iframeHeight","titleAppearance","descriptionAppearance"),children:n.jsx(Kt,{autoWidth:l==null?void 0:l.autoWidth,className:_.cx("section-content h-full"),sx:f,children:i.show?n.jsx(Te,{...a,boxed:i,children:t}):t})})}function Te({background:e="",backgroundVideoPoster:t,children:o,sx:r={},boxed:i={show:!1},className:s="",styles:a={},...c}){const l={...a,...r};let d=null;const u=Pe.default(x=>x.breakpoints.up("sm")),m=Pt.default(),f=Jt();return e&&(d=he(m,e,l,t,f)),i.show&&(l.borderRadius="10px",l.padding===void 0&&(l.padding=u?"50px":"20px"),i!=null&&i.border&&(l.border="1px solid #c0c0c0"),i!=null&&i.background&&(d=he(m,i==null?void 0:i.background,l,i==null?void 0:i.backgroundVideoPoster,f))),n.jsxs(p.Box,{...c,sx:{...l,...d?{position:"relative",overflow:"hidden",zIndex:0}:{}},className:_.cx(s,(i==null?void 0:i.boxShadow)&&"shadow-xl"),children:[d,o]})}const Xt=$.styled(Te)`
134
+ &:nth-of-type(even) {
135
+ background: #f8f8f8;
136
+ }
137
+
138
+ @media (max-width: 600px) {
139
+ .section__title {
140
+ font-size: 24px;
141
+ }
142
+
143
+ .base-info {
144
+ > *:last-child {
145
+ margin-bottom: 0;
146
+ }
147
+ }
148
+ }
149
+ `;function qe({icon:e,...t}){return n.jsx(Se.Icon,{icon:e,...t,ref:null})}function I(e,t){const o=re.default(e,t),r=R.default(e,t);return[o,r]}const Ee=["title","description","actions","badge","tag","prepend","append","logo"];function Yt({image:e,imageBorder:t,imageShadow:o,className:r,reverse:i=!1,fullSizeImage:s,...a}){const[c,l]=I(a,M),d=Object.keys(c).length>0&&Object.values(re.default(c,Ee)).filter(Boolean).length>0&&n.jsx(U,{...c}),u=g.isValidElement(e)?e:n.jsx(p.Box,{component:"img",src:e,alt:"",className:"block"}),m=["phone","macbook"].includes(t),f=e&&n.jsx(p.Box,{className:_.cx("section__image","m-auto, leading-[1] text-center",o&&"shadow-xl",c!=null&&c.center?"flex justify-center items-center":""),sx:{border:t===!0?"1px solid #c0c0c0":void 0,borderRadius:2,overflow:"hidden","> div":m?{width:"100%",video:{borderRadius:"0 !important"}}:void 0},children:m?n.jsx(Rt.default,{type:t,sx:{width:"100%"},children:u}):u});return n.jsx(H,{className:_.cx("section--block",r,s&&!i&&_.css`
150
+ .section-bg {
151
+ height: 80%;
152
+ }
153
+ `),...l,boxProps:s?{sx:{padding:0,overflow:"hidden"}}:void 0,children:n.jsx(ie,{col:e?2:1,className:s?_.css`
154
+ display: flex;
155
+ flex-direction: column;
156
+
157
+ > .base-info,
158
+ > .section__image {
159
+ width: 100%;
160
+
161
+ > img,
162
+ > video {
163
+ width: 100%;
164
+ }
165
+ }
166
+ `:void 0,children:i?n.jsxs(n.Fragment,{children:[f,d]}):n.jsxs(n.Fragment,{children:[d,f]})})})}const F=["editing","height","locale","dev","sx"];function Qt(e){return n.jsx(Zt,{...e})}const Zt=$.styled(p.Box)`
167
+ position: relative;
168
+ `;function en({widget:e,reverse:t,projectId:o,assistantId:r,working:i,submitTitle:s,submitIcon:a,submitColor:c,placeholder:l,loadingIndicator:d,section:u,...m}){const[{editing:f},x]=I(m,F),[y,j]=I(x,M),h=o&&r?{projectId:o,gitRef:"main",assistantId:r,working:!0}:void 0,v={children:s,endIcon:a?n.jsx(qe,{icon:a}):void 0,sx:{background:c||void 0,":hover":{background:c||void 0,opacity:.8}}},b=[],k=l&&n.jsx(p.Typography,{variant:"caption",color:"text.disabled",children:l}),N=d&&n.jsx(p.Typography,{variant:"caption",color:"text.disabled",children:d});Object.keys(y).length>0&&Object.values(re.default(y,Ee)).filter(Boolean).length>0&&b.push(n.jsx(U,{...y},"base-info")),h&&(e==="form"?b.push(n.jsx(J.AIForm,{identifier:h,SubmitProps:v},"form")):e==="result"?b.push(n.jsx(J.AIFormResult,{identifier:h,placeholder:k,loadingIndicator:N},"result")):b.push(n.jsxs(p.Stack,{width:"100%",gap:2,direction:"row",children:[n.jsx(J.AIForm,{identifier:h,BoxProps:{flex:1},SubmitProps:v}),n.jsx(J.AIFormResult,{identifier:h,BoxProps:{flex:1},placeholder:k,loadingIndicator:N})]},"form-result"))),t&&b.reverse();const W=p.useTheme(),D=g.useMemo(()=>p.createTheme(at.deepmerge(W,{palette:{primary:c?{main:c}:void 0}})),[c,W]);return n.jsx(lt.ErrorBoundary,{fallbackRender:w.ErrorView,children:n.jsx(p.ThemeProvider,{theme:D,children:n.jsx(H,{...j,sx:f?{pointerEvents:"none"}:{},children:n.jsx(ie,{col:b.length,children:b})})})})}const ze=g.createContext({pages:[],project:void 0}),{Provider:tn,Consumer:uo}=ze;function We(){return g.useContext(ze)}function nn({icon:e,className:t="",size:o="1rem",...r}){return n.jsx(on,{component:qe,className:_.cx("css-icon",t),size:o,...r,icon:e})}const on=$.styled(p.Box)`
169
+ &.css-icon {
170
+ display: inline-block;
171
+ width: ${({size:e})=>e};
172
+ height: ${({size:e})=>e};
173
+ }
174
+ `;function rn({icon:e,className:t="",size:o="1rem",imageMeta:r,...i}){const s=w.autoResizeImage(w.getImageAbsoluteUrl(e),540),[a,c]=g.useState(!1),l=$.useTheme();return a?n.jsx(nn,{icon:"i-mdi:image",color:l.palette.grey[500],size:o,className:t,...i}):n.jsx(sn,{className:_.cx("image-icon",t),size:o,...i,children:n.jsx("img",{className:"image-icon__image",src:s,onError:()=>c(!0),width:r==null?void 0:r.naturalWidth,height:r==null?void 0:r.naturalHeight,alt:(r==null?void 0:r.filename)||"card-icon",loading:"lazy"})})}const sn=$.styled(p.Box)`
175
+ display: inline-block;
176
+ width: ${({size:e})=>e};
177
+ height: ${({size:e})=>e};
178
+ .image-icon__image {
179
+ object-fit: contain;
180
+ height: 100%;
181
+ width: 100%;
182
+ }
183
+ `,se=e=>typeof e=="string"&&/^[\w-_]+:[\w-_]+$/.test(e);function ne({icon:e,size:t="1rem",imageMeta:o,...r}){const i=window.isNaN(t)?t:`${t}px`;return se(e)?n.jsx(Se.Icon,{icon:e}):n.jsx(an,{component:rn,imageMeta:o,className:"base-icon",icon:e,size:i,...r})}const an=$.styled(p.Box)`
184
+ flex-shrink: 0;
185
+ `;function A({text:e,children:t,icon:o="",endIcon:r,color:i="primary",link:s="",href:a="",...c}){const l=o?n.jsx(ne,{icon:o}):null,d=r?n.jsx(ne,{icon:r}):null,u=s||a,m={...c};return u&&(m.href=u,ee.default(u)&&(m.target=m.target||"_blank")),n.jsx(Tt.default,{startIcon:l,endIcon:d,color:i,...m,children:e||t})}function Le({editing:e,text:t,...o}){const{pages:r=[]}=We(),i=r.find(s=>s.id===(o.link||o.linkId));if(e)return n.jsx(A,{...R.default(o,["link","linkId"]),children:t});if(i){const s=i.path||"/";return n.jsx(B.Link,{to:s,children:n.jsx(A,{...R.default(o,["link","linkId"]),children:t})})}return n.jsx(A,{...R.default(o,"linkId"),children:t})}function q({type:e="",icon:t="",size:o="3rem",className:r="",...i}){return n.jsx(ne,{icon:t||e,size:o,className:_.cx("content-icon",r),...i})}q.propTypes={};q.defaultProps={type:"",icon:"",size:"3rem",color:"inherit",className:""};function cn({to:e,base:t,children:o,className:r,activeClassName:i="active",target:s="auto",autoExternalMark:a=!1,useRouterLink:c,...l}){const{pages:d=[],locale:u=""}={},m=t?K.join("/",t):t||"";let f=s==="auto"?"_self":s,x=K.join(m,e);const y=a?ee.default(x):!1;if(t)return x=K.join(m,u,e),n.jsx("a",{className:`no-underline ${r}`,href:P.withoutTrailingSlash(x),rel:"noreferrer noopener",target:f,...l,children:o});if(ee.default(e))s==="auto"&&(f="_blank"),x=e;else{P.isRelative(x)&&(x=K.join(window.location.pathname,x));const j=P.parseURL(`${window.location.origin}${x}`),h=d.some(v=>v.pathname===j.pathname);if(c||h)return n.jsx(B.NavLink,{end:!0,to:P.withoutTrailingSlash(x),className:({isActive:v})=>_.cx(r,v?i:""),...l,children:o})}return n.jsxs("a",{className:`no-underline ${r}`,href:P.withoutTrailingSlash(x),rel:"noreferrer noopener",target:f,...l,children:[o,y&&n.jsx(q,{icon:"i-mdi:arrow-top-right",size:"0.9em",className:"smart-link__mark",style:{marginLeft:5}})]})}function V({prepend:e,append:t,children:o,className:r="",dark:i=!1,border:s=!0,...a}){let c={};const{pages:l=[]}=We(),d=l.find(f=>f.id===a.link),u=!o||Ne.default.Children.toArray(o).every(f=>f===null);a.link&&(c={component:cn,to:(d==null?void 0:d.path)||a.link,useRouterLink:!0});const m=i&&s;return n.jsxs(ln,{className:_.cx("base-card card",{"border-gray-200":s},{"dark:border-gray-500":m},{dark:i,"border-transparent":!s},r),...c,...R.default(a,["listType","dark","iconColor","link","hoverStyle","imageSize"]),children:[e,!u&&n.jsx("div",{className:"card__body",children:o}),t]})}const ln=$.styled(p.Box)`
186
+ &.base-card {
187
+ text-align: left;
188
+ border-width: 1px;
189
+ border-style: solid;
190
+ border-radius: 12px;
191
+ overflow: hidden;
192
+ &,
193
+ &:hover {
194
+ text-decoration: none;
195
+ }
196
+ }
197
+ .card__body {
198
+ padding: 15px 15px;
199
+ }
200
+ `;function G({align:e="left",title:t,titleProps:o={},description:r,descriptionProps:i={}}){return n.jsxs(n.Fragment,{children:[t&&n.jsx(p.Typography,{className:_.cx("card__title text-gray-800","dark:text-gray-50"),component:"h5",variant:"h5",gutterBottom:!0,align:e,...o,children:t}),r&&n.jsx(p.Typography,{className:_.cx("card__description","text-gray-500","dark:text-gray-400"),component:"div",variant:"body1",gutterBottom:!0,align:e,...i,children:r})]})}function dn({image:e,title:t,description:o,imageProps:r={},imageMeta:i,imageSize:s,titleProps:a={},descriptionProps:c={},actions:l,align:d,...u}){const m=se(e),f=w.autoResizeImage(w.getImageAbsoluteUrl(e),540);return n.jsxs(un,{className:"card-article",...u,prepend:n.jsx("div",{className:"card__image__wrap",children:m&&e?n.jsx(p.Box,{sx:{position:"absolute",left:0,top:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center"},children:n.jsx(q,{icon:e,color:"primary.main"})}):f&&n.jsx("img",{className:"card__image",src:f,...r,alt:r.alt||(i==null?void 0:i.filename)||"card-image",width:i==null?void 0:i.naturalWidth,height:i==null?void 0:i.naturalHeight,style:{width:"100%",height:"100%",objectFit:s||"cover",objectPosition:"center"},loading:"lazy"})}),children:[t||o?n.jsx(G,{align:d,title:t,titleProps:a,description:o,descriptionProps:c}):null,l!=null&&l.length?n.jsx(z,{align:d,actions:l,className:"mt-4"}):null]})}const un=$.styled(V)`
201
+ ${e=>e.hoverStyle==="none"?"":e.link?`transition: box-shadow ease .3s;
202
+ &:hover {
203
+ box-shadow: 0 0 10px rgba(95, 142, 244, 0.42);
204
+ }`:""}
205
+
206
+ .card__image__wrap {
207
+ padding-top: 61.8%;
208
+ width: 100%;
209
+ position: relative;
210
+ }
211
+ .card__image {
212
+ position: absolute;
213
+ top: 0;
214
+ left: 0;
215
+ bottom: 0;
216
+ right: 0;
217
+ width: 100%;
218
+ height: 100%;
219
+ object-position: top center;
220
+ }
221
+ `,ge="section";function be({title:e,image:t,imageMeta:o,description:r,actions:i,align:s,listType:a="",className:c="",...l}){return n.jsxs(mn,{className:_.cx("card",`list-type-${a}`,c),align:s,...l,children:[t&&n.jsx(q,{icon:t,color:"primary.main",size:a==="icon-title"?"1.2rem":"3rem",imageMeta:o}),e||r?n.jsx(G,{align:s,title:e,description:r}):null,i!=null&&i.length?n.jsx(z,{align:s,actions:i,className:"mt-4"}):null]})}const mn=$.styled(V)`
222
+ padding: 5vw 4vw;
223
+ box-sizing: border-box;
224
+ /* min-height: 320px; */
225
+ color: inherit !important;
226
+ border-radius: 0.5rem;
227
+ /* ${({dark:e,theme:t})=>`background-color:${e?t.palette.grey[900]:t.palette.common.white};`} */
228
+ @media (max-width: ${({theme:e})=>e.breakpoints.values[ge]}px) {
229
+ padding: 1.5rem 2rem;
230
+ }
231
+ @media (max-width: ${({theme:e})=>e.breakpoints.values.sm}px) {
232
+ height: auto;
233
+ min-height: unset;
234
+ }
235
+
236
+ ${e=>e.hoverStyle==="none"?"":e.link?`transition: box-shadow ease .3s;
237
+ &:hover {
238
+ box-shadow: 0 0 10px rgba(95, 142, 244, 0.42);
239
+ }`:""}
240
+
241
+ .card__title {
242
+ font-weight: 700;
243
+ margin-top: 24px;
244
+ margin-bottom: 12px;
245
+ a {
246
+ color: ${({theme:e})=>e.palette.primary.main};
247
+ }
248
+ }
249
+ .card__description {
250
+ a {
251
+ color: ${({theme:e})=>e.palette.primary.main};
252
+ }
253
+ }
254
+ .card__body {
255
+ padding: 0;
256
+ ${({align:e})=>`text-align:${e||"left"};`}
257
+ }
258
+
259
+ &.list-type-icon-title {
260
+ padding: 1.2rem;
261
+ .title-line {
262
+ display: flex;
263
+ }
264
+ .card__title {
265
+ margin: 0;
266
+ font-size: 1em;
267
+ }
268
+ .css-icon {
269
+ margin-right: 0.5rem;
270
+ }
271
+ }
272
+
273
+ @media (min-width: ${({theme:e})=>e.breakpoints.values[ge]}px) {
274
+ padding: 2rem 2rem;
275
+ text-align: left;
276
+ box-sizing: border-box;
277
+ }
278
+ `;function pn({image:e,title:t,description:o,imageProps:r={},imageMeta:i,imageSize:s,titleProps:a={},descriptionProps:c={},actions:l,align:d,...u}){const m=se(e),f=w.autoResizeImage(w.getImageAbsoluteUrl(e),540);return n.jsxs(xn,{className:"card-article",...u,prepend:n.jsx("div",{className:"card__image__wrap",children:m&&e?n.jsx(p.Box,{sx:{position:"absolute",left:0,top:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center"},children:n.jsx(q,{icon:e,color:"primary.main"})}):f&&n.jsx(p.Box,{component:"img",className:"card__image",src:f,...r,alt:r.alt||(i==null?void 0:i.filename)||"card-image",width:i==null?void 0:i.naturalWidth,height:i==null?void 0:i.naturalHeight,style:{width:"100%",height:"100%",objectFit:s||"contain",objectPosition:"center"},loading:"lazy"})}),children:[t||o?n.jsx(G,{align:d,title:t,titleProps:a,description:o,descriptionProps:c}):null,l!=null&&l.length?n.jsx(z,{align:d,actions:l,className:"mt-4"}):null]})}const xn=$.styled(V)`
279
+ ${e=>e.hoverStyle==="none"?"":e.link?`transition: box-shadow ease .3s;
280
+ &:hover {
281
+ box-shadow: 0 0 10px rgba(95, 142, 244, 0.42);
282
+ }`:""}
283
+
284
+ border-radius: 0 !important;
285
+
286
+ .card__body {
287
+ ${({align:e})=>`text-align:${e||"left"};`}
288
+ }
289
+
290
+ .card__image__wrap {
291
+ width: 100%;
292
+ height: 100%;
293
+ position: relative;
294
+ display: flex;
295
+ justify-content: center;
296
+ align-items: center;
297
+ }
298
+
299
+ .card__image {
300
+ max-height: 60px;
301
+ }
302
+ `,ye="section";function fn({title:e,image:t,imageMeta:o,iconSize:r=100,description:i,actions:s,align:a,className:c="",...l}){return n.jsx(hn,{className:_.cx("card",c),...l,children:n.jsxs(p.Box,{className:"flex items-center",children:[t&&n.jsx(q,{icon:t,color:"primary.main",size:r,imageMeta:o}),n.jsxs(p.Box,{className:"flex-1 ml-4",children:[n.jsx(G,{align:a,title:e,description:i}),n.jsx(z,{align:a,actions:s,className:"mt-4"})]})]})})}const hn=$.styled(V)`
303
+ padding: 5vw 4vw;
304
+ text-align: left;
305
+ box-sizing: border-box;
306
+ /* min-height: 320px; */
307
+ color: inherit !important;
308
+ border-radius: 0.5rem;
309
+ /* ${({dark:e,theme:t})=>`background-color:${e?t.palette.grey[900]:t.palette.common.white};`} */
310
+ @media (max-width: ${({theme:e})=>e.breakpoints.values[ye]}px) {
311
+ padding: 1.5rem 2rem;
312
+ }
313
+ @media (max-width: ${({theme:e})=>e.breakpoints.values.sm}px) {
314
+ height: auto;
315
+ min-height: unset;
316
+ }
317
+
318
+ ${e=>e.hoverStyle==="none"?"":e.link?`transition: box-shadow ease .3s;
319
+ &:hover {
320
+ box-shadow: 0 0 10px rgba(95, 142, 244, 0.42);
321
+ }`:""}
322
+
323
+ .card__title {
324
+ font-weight: 700;
325
+ margin-bottom: 12px;
326
+ a {
327
+ color: ${({theme:e})=>e.palette.primary.main};
328
+ }
329
+ }
330
+ .card__description {
331
+ a {
332
+ color: ${({theme:e})=>e.palette.primary.main};
333
+ }
334
+ }
335
+ .card__body {
336
+ padding: 0;
337
+ }
338
+
339
+ &.list-type-icon-title {
340
+ padding: 1.2rem;
341
+ .title-line {
342
+ display: flex;
343
+ }
344
+ .card__title {
345
+ margin: 0;
346
+ font-size: 1em;
347
+ }
348
+ .css-icon {
349
+ margin-right: 0.5rem;
350
+ }
351
+ }
352
+
353
+ @media (min-width: ${({theme:e})=>e.breakpoints.values[ye]}px) {
354
+ padding: 2rem 2rem;
355
+ text-align: left;
356
+ box-sizing: border-box;
357
+ }
358
+ `;function gn({title:e,titleProps:t={},description:o,descriptionProps:r={},image:i,imageMeta:s,className:a="",align:c,hoverStyle:l,...d}){return n.jsxs(bn,{className:_.cx("card-simple",a,`hover-style__${l}`),align:c,...d,children:[i&&n.jsx(q,{icon:i,color:"primary.main",imageMeta:s}),e||o?n.jsx(G,{align:c,title:e,titleProps:t,description:o,descriptionProps:r}):null]})}const bn=$.styled(V)`
359
+ ${({dark:e,theme:t})=>`background-color:${e?t.palette.grey[900]:t.palette.common.white};`}
360
+
361
+ &.hover-style__default {
362
+ &.card-simple {
363
+ &:hover {
364
+ border-top-right-radius: 36px;
365
+ }
366
+ }
367
+ .card__body {
368
+ &:hover {
369
+ &::before {
370
+ width: 42px;
371
+ height: 42px;
372
+ transform: translate(50%, -50%) rotate(45deg);
373
+ }
374
+ &::after {
375
+ transform: none;
376
+ }
377
+ }
378
+ }
379
+ }
380
+
381
+ &.card-simple {
382
+ border-radius: 8px;
383
+ border-top-right-radius: 26px;
384
+
385
+ .card__body {
386
+ ${({align:e})=>`text-align:${e||"left"};`}
387
+ }
388
+
389
+ ${e=>e.link?`
390
+ cursor: pointer;
391
+ `:""}
392
+ /* cursor: pointer; */
393
+ /* &:hover {
394
+ border-top-right-radius: 36px;
395
+ } */
396
+ transition: all 180ms ease 0s;
397
+ overflow: visible;
398
+ .card__title {
399
+ margin: 12px 0;
400
+ }
401
+ .card__body {
402
+ position: relative;
403
+ padding: 20px 16px 18px;
404
+ overflow: hidden;
405
+ transition: all 180ms ease 0s;
406
+ /* &:hover {
407
+ &::before {
408
+ width: 42px;
409
+ height: 42px;
410
+ transform: translate(50%, -50%) rotate(45deg);
411
+ }
412
+ &::after {
413
+ transform: none;
414
+ }
415
+ } */
416
+ &::before,
417
+ &::after {
418
+ content: ${({border:e})=>e?'""':""};
419
+ transition: inherit;
420
+ position: absolute;
421
+ top: 0px;
422
+ right: 0px;
423
+ }
424
+ &::before {
425
+ z-index: 3;
426
+ background: #fff;
427
+ width: 30px;
428
+ height: 30px;
429
+ transform: translate(50%, -50%) rotate(45deg);
430
+ box-shadow: 0 1px 0 0 #e9eaec;
431
+ }
432
+ &::after {
433
+ z-index: 2;
434
+ width: 28px;
435
+ height: 28px;
436
+ border-bottom-left-radius: 6px;
437
+ background: #fcfcfd;
438
+ box-shadow: -1px 1px 0 0 #e9eaec;
439
+ transform: translate(8px, -8px);
440
+ }
441
+ }
442
+ }
443
+ `;function yn({type:e="default",...t}){const r={article:dn,simple:gn,news:fn,default:be,wall:pn}[e]||be;return n.jsx(r,{...e==="news"?t:R.default(t,"iconSize")})}function jn({list:e=[],align:t="top",cards:o,listBorder:r=!0,listType:i="",col:s=3,gap:a,iconColor:c,className:l="",type:d="default",dark:u=!1,textAlign:m="left",hoverStyle:f,...x}){return n.jsx(ie,{type:d,className:_.cx("card-list py-1",l,"items-stretch"),col:s,gap:a,align:t,...x,children:o||e.map(y=>n.jsx(yn,{borderColor:r,iconColor:c,type:d,listType:i,dark:u,...y,align:m,sx:{bgcolor:d==="wall"?void 0:u?"grey.900":"common.white"},style:a===0&&e.length>1?{borderRadius:0,marginRight:"-1px",marginBottom:"-1px"}:{}},y.id))})}const wn=["align","cards","list","listBorder","listType","col","gap","iconColor","type","textAlign"],_n=$.styled(H)`
444
+ a .card {
445
+ color: #404040;
446
+ cursor: pointer;
447
+ }
448
+ a:not(.MuiButton-root) {
449
+ color: ${({theme:e})=>e.palette.primary.main};
450
+ &:hover,
451
+ &:active {
452
+ color: ${({theme:e})=>e.palette.primary.main};
453
+ }
454
+ }
455
+ a:hover .card {
456
+ color: #404040;
457
+ }
458
+ `;function vn({className:e,...t}){const[o,r]=I(t,M),[i,s]=I(r,wn);return n.jsxs(_n,{className:_.cx("section--card-list",e),type:t.type,...s,children:[Object.keys(o).length>0&&n.jsx(U,{center:!0,...o,className:"mb-[2.5vw]"}),n.jsx(jn,{...i,dark:!!t.dark})]})}const kn=$.styled(vn)`
459
+ .card__description {
460
+ white-space: pre-wrap;
461
+ }
462
+ .section__description {
463
+ }
464
+ .card {
465
+ /* background: inherit !important; */
466
+ }
467
+ &.dark .card-simple .card__body::before {
468
+ background: #212121 !important;
469
+ }
470
+ .card-simple .card__body::after {
471
+ background: inherit !important;
472
+ }
473
+ `;function $n({section:e,...t}){const[{editing:o},r]=I(t,F),i=g.useMemo(()=>{var s;return{...R.default(r,["listBorder","list","iconSize","imageSize"]),list:(s=r.list)==null?void 0:s.map(a=>{var c,l;return{...R.default(a,"icon","iconColor"),image:["news","simple","default"].includes(r.type)&&a.icon?a.icon:a.image,actions:(l=(c=a.actions)==null?void 0:c.map)==null?void 0:l.call(c,d=>n.jsx(Le,{...d,editing:o},d.id)),border:r.listBorder,iconSize:r.iconSize,imageSize:r.imageSize,hoverStyle:r.hoverStyle}})}},[r]);return n.jsx(kn,{style:o?{pointerEvents:"none"}:{},...i})}function Sn({properties:e,section:t,locale:o,dev:r}){var i;return(i=t==null?void 0:t.config)!=null&&i.componentId?n.jsx(oe.CustomComponentRenderer,{instanceId:t.id,componentId:t.config.componentId,blockletId:t.config.blockletId,blockletTitle:t.config.blockletTitle,componentName:t.config.componentName,locale:o,properties:e,dev:r}):n.jsx(p.Box,{textAlign:"center",py:2,children:n.jsx(p.Typography,{variant:"caption",color:"text.secondary",children:"Please select component to render"})})}function Cn({src:e,dataId:t,isEdit:o=!1,height:r="100%",onLoad:i=()=>{}}){return n.jsx(wt.EmbedIframe,{isEdit:o,embedId:t,src:e,height:r,onLoad:()=>{i()}})}function Bn({dataId:e,src:t,actions:o,center:r,onLoad:i,...s}){const[a,c]=I(s,M);return n.jsxs(H,{...c,children:[Object.keys(a).length>0&&n.jsx(U,{center:r,...a}),n.jsx(Cn,{dataId:e,src:t,onLoad:i,height:s.iframeHeight?`${s.iframeHeight}px`:"100%"}),n.jsx(z,{actions:o,center:r})]})}function In({section:e,id:t,src:o,...r}){const i=`${t}-${r.locale}`,[{editing:s},a]=I(r,F),c=g.useRef({}),l=JSON.parse(JSON.stringify(a)),{message:d}=jt.useMessage(i,"server"),u=$e.useLatest(JSON.parse(JSON.stringify(a.config)||"{}"));return g.useEffect(()=>{d&&d.onInit(()=>u.current)},[d]),g.useEffect(()=>{const m=JSON.parse(JSON.stringify(a.config)||"{}");Ie.default(c.current,m)||(c.current=m,d==null||d.send("config-set",m))},[d,a.config]),o?n.jsx(Bn,{...l,dataId:i,src:o,style:s?{pointerEvents:"none"}:{}}):n.jsx(Nn,{children:'Please set the "src" attribute for this block'})}const Nn=$.styled("div")`
474
+ user-select: none;
475
+ color: #999;
476
+ padding: 8px;
477
+ height: 200px;
478
+ `,Pn=[/youtu\.be\/([^#&?]{11})/,/\?v=([^#&?]{11})/,/&v=([^#&?]{11})/,/embed\/([^#&?]{11})/,/\/v\/([^#&?]{11})/];function Rn(e){var t;if(/youtu\.?be/.test(e))for(const o of Pn){const r=(t=o.exec(e))==null?void 0:t[1];if(r)return r}}function Tn(e){const t=Rn(e);if(t)return`https://youtube.com/embed/${t}`}function qn({src:e}){return g.useEffect(()=>{import("@lottiefiles/lottie-player")},[]),n.jsx("lottie-player",{autoplay:!0,loop:!0,mode:"normal",src:e})}function En(e){return n.jsx(p.Box,{maxHeight:400,overflow:"hidden auto",children:n.jsx(_t.TwitterTimelineEmbed,{...e})})}function zn({url:e}){const t=g.useRef(null),o=495,[r,i]=g.useState(t.current?t.current.offsetWidth*.5625:o),s=g.useCallback(()=>{const a=window.innerWidth>990?1:window.innerWidth>522?1.2:window.innerWidth>400?1.45:1.85,c=t.current?t.current.offsetWidth*.5625:o;return i(Math.floor(c*a))},[]);return g.useEffect(()=>{window.addEventListener("resize",s);const a=window.innerWidth>990?1:window.innerWidth>522?1.2:window.innerWidth>400?1.45:1.85,c=t.current?t.current.offsetWidth*.5625:o;return i(Math.floor(c*a)),function(){window.removeEventListener("resize",s)}},[r,s]),n.jsx(p.Box,{component:"iframe",ref:t,title:"youtube",width:"100%",height:`${r}px`,src:e,frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sx:{display:"block"}})}const Wn=$.styled(Yt)`
479
+ .section__description {
480
+ }
481
+ `;function Ln({hasImage:e,fullSizeImage:t,boxed:o,videoPoster:r,imageMeta:i,imageOptimization:s,imageSize:a,section:c,...l}){var x,y;const[{editing:d},u]=I({...l,boxed:t?void 0:o},F);let m=An(u.image,r,t,i,s,a);e||(m=null);let f=null;return u.actions&&(f=(y=(x=u.actions)==null?void 0:x.map)==null?void 0:y.call(x,(j,h)=>n.jsx(Le,{...j,editing:d},h))),n.jsx(Wn,{...u,style:d?{pointerEvents:"none"}:{},image:m,fullSizeImage:e&&t,actions:f})}function An(e,t,o,r,i,s){if(e){if(e.endsWith(".json"))return n.jsx(qn,{src:e});if(e.indexOf("twitter.com")!==-1)return n.jsx(En,{sourceType:"url",url:e});const a=Tn(e);if(a)return n.jsx(zn,{url:a});const{naturalWidth:c,naturalHeight:l,filename:d}=r||{};if(te(e))return n.jsx("video",{width:c&&`${c}px`,height:l&&`${l}px`,controls:!0,autoPlay:!0,muted:!0,style:{display:"block",objectFit:s||"contain",borderRadius:"8px",width:"100%",height:"100%"},poster:w.autoResizeImage(w.getImageAbsoluteUrl(t),o?1200:540,i),children:n.jsx("source",{src:w.getImageAbsoluteUrl(e),type:Gt(e)})},e);const u=i==="quality"?1:.6;return n.jsx(oe.ResponsiveImage,{src:w.getImageAbsoluteUrl(e),sizesAttr:{sm:600*u,md:450*u,lg:540*u,...o&&{md:900*u,lg:1200*u}},width:c&&`${c}px`,height:l&&`${l}px`,alt:d??e,style:{objectFit:s||"contain",display:"block",width:"100%",height:"100%"},loading:"lazy"})}return null}const On=["production","draft"];function Ae({mode:e,version:t}={}){const o=t&&typeof t=="number"?{mode:e,version:t}:{mode:e};return w.api.get(`/api/${w.getProjectIdFromPathnameOrWindow()}/pages`,{params:o}).then(r=>r.data)}function Un({mode:e,pages:t}){return w.api.post(`/api/${w.getProjectIdFromPathnameOrWindow()}/pages/publish`,{mode:e,pages:t}).then(o=>o.data)}function Mn({locale:e,sort:t,page:o,limit:r,mode:i}={}){return w.api.get(`/api/${w.getProjectIdFromPathnameOrWindow()}/pages/toc`,{params:{locale:e,sort:t,page:o,limit:r,mode:i}}).then(s=>s.data)}const je=20;function Hn({style:e,sort:t,section:o,...r}){const[{editing:i,locale:s},a]=I(r,F),[c,l]=I(a,M),[d,u]=g.useState(),m=g.useRef(!1),f=O.useUpdate(),x=B.useNavigate(),y=g.useCallback(async()=>{if(!m.current){m.current=!0,f();try{const j=d?Math.floor(d.list.length/je)+1:1,{list:h,total:v}=await Mn({locale:s,sort:t,page:j,limit:je});u(b=>({list:((b==null?void 0:b.list)??[]).concat(h),total:v}))}finally{m.current=!1,f()}}},[d,s,t,f]);return O.useMount(()=>{y()}),n.jsxs(H,{...l,sx:i?{pointerEvents:"none"}:{},children:[Object.keys(c).length>0&&n.jsx(U,{...c}),d?n.jsxs(n.Fragment,{children:[n.jsx(p.Grid,{container:!0,spacing:2,justifyContent:"center",children:d==null?void 0:d.list.map(j=>n.jsx(p.Grid,{item:!0,xs:12,sm:e==="card"?6:12,md:e==="card"?3:12,children:n.jsxs(Fn,{elevation:0,className:_.cx(e==="card"&&"style-card"),onClick:i?void 0:()=>x(j.slug),children:[!!j.image&&n.jsx(p.CardMedia,{component:"img",alt:"",image:w.autoResizeImage(w.getImageAbsoluteUrl(j.image),540),loading:"lazy"}),n.jsxs(p.CardContent,{children:[n.jsx(p.Typography,{variant:"h6",component:"div",className:we,children:j.title||j.id}),n.jsx(p.Typography,{variant:"body2",className:we,children:j.description})]})]})},j.id))}),n.jsx(p.Box,{textAlign:"center",mt:2,children:d.total>d.list.length?n.jsx(A,{variant:"outlined",color:"secondary",onClick:y,loading:m.current,children:"More"}):n.jsx(A,{variant:"outlined",color:"secondary",disabled:!0,children:"No More"})})]}):n.jsx(p.Box,{p:2,textAlign:"center",children:n.jsx(p.CircularProgress,{size:24})})]})}const we=_.css`
482
+ display: -webkit-box;
483
+ -webkit-box-orient: vertical;
484
+ -webkit-line-clamp: 2;
485
+ overflow: hidden;
486
+ text-overflow: ellipsis;
487
+ `,Fn=$.styled(p.Card)`
488
+ border: 1px solid #e0e0e0;
489
+ background-color: transparent;
490
+ cursor: pointer;
491
+ display: flex;
492
+ color: inherit;
493
+
494
+ > .MuiCardMedia-root {
495
+ width: 30vw;
496
+ max-height: 50vw;
497
+ }
498
+
499
+ &.style-card {
500
+ display: block;
501
+
502
+ > .MuiCardMedia-root {
503
+ width: 100%;
504
+ max-height: 50vw;
505
+ }
506
+ }
507
+ `,Vn={iframe:In,section:Ln,"section-card-list":$n,toc:Hn,"ai-runtime":en,"custom-component":Sn};function Gn({id:e,type:t,mode:o,config:r,section:i,...s}){const a=Vn[t],c=g.useMemo(()=>{const{sx:u,height:m,...f}=r;return f},[r]),l=g.useMemo(()=>{const u={sx:r.sx};return t!=="custom-component"&&(u.height=r.height),u},[r.sx,r.height,t]),d=a&&n.jsx(a,{mode:o,...c,id:e,section:i});return n.jsx(Qt,{...s,...l,children:d})}const Dn=$.styled(qt.default,{shouldForwardProp:e=>!!e})`
508
+ & > div > .MuiContainer-root {
509
+ max-width: unset;
510
+ }
511
+ `;function Jn({meta:e,...t}){const o=$.useTheme();return n.jsx(Dn,{...t,meta:e,theme:o||{}})}function Oe(e){return n.jsx(p.Box,{display:"flex",flex:1,height:"100%",alignItems:"center",justifyContent:"center",...e,children:n.jsx(p.CircularProgress,{size:30})})}function Kn(e){return n.jsx(Xn,{...e})}const Xn=$.styled(p.Box)`
512
+ position: fixed;
513
+ left: 0;
514
+ top: 0;
515
+ z-index: 999999999999;
516
+ width: 80px;
517
+ font-size: 12px;
518
+ text-align: center;
519
+ opacity: 0.7;
520
+ transform: translateX(-23%) translateY(70%) rotate(-45deg);
521
+ pointer-events: none;
522
+ `,Yn=e=>new Promise((t,o)=>{(e==null?void 0:e.length)>0?Et.default.load({google:{families:e},fontactive:()=>{t("success")},fontinactive:()=>{o(new Error("load font fail"))}}):t("success")}),_e=`Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
523
+ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'`,ve={};function Qn({titleFontFamily:e,descriptionFontFamily:t}){const o=async r=>{if(r&&!document.querySelectorAll(`link[href*="${r}" i]`).length)try{ve[r]||(await Yn([r]),ve[r]=!0)}catch(i){console.error(i)}};return g.useEffect(()=>{e&&o(e),t&&o(t)},[e,t]),n.jsx(Y.Global,{styles:Y.css`
524
+ #app {
525
+ .page-kit-section__title {
526
+ font-family: ${JSON.stringify(e)}, ${_e};
527
+ }
528
+
529
+ .page-kit-section__description {
530
+ font-family: ${JSON.stringify(t)}, ${_e};
531
+ }
532
+ }
533
+ `})}const{SessionProvider:mo,SessionContext:Zn,SessionConsumer:po,withSession:xo}=$t.createAuthServiceSessionContext();function ae(){return g.useContext(Zn)}function eo(...e){var o;const{session:t}=ae();return e.includes((o=t.user)==null?void 0:o.role)}function to(...e){var r;const{session:t}=ae(),o=eo(...e);return((r=window.blocklet)==null?void 0:r.tenantMode)==="multiple"?!!t.user:o}function no(e){return e!=null}function oo(){const[e]=B.useSearchParams(),{session:t}=ae(),o=to("owner","admin","pagesEditor","member"),r=g.useMemo(()=>{const s=e.get("mode");return On.includes(s)?s:"production"},[e]),i=r==="production"?r:t.user?o?r:"production":null;return i?n.jsx(Ue,{mode:i}):null}function Ue({mode:e}){if(e!=="draft"){const t=window.__PAGE_STATE__;return t?n.jsx(X,{mode:e,state:t}):n.jsx(io,{mode:e,children:({state:o})=>n.jsx(X,{mode:e,state:o})})}return n.jsx(ro,{children:({state:t})=>n.jsx(X,{mode:e,state:t})})}const ro=g.lazy(()=>Promise.resolve().then(()=>require("./draft-data-CMqq2YH1.js")));function io({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}=O.useAsync(()=>Ae({mode:e,version:s}),[e,s]);return a?n.jsx(Oe,{}):c?t({state:c}):null}function X({mode:e,state:t}){var y,j,h,v;const{t:o,locale:r}=ke.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(no),[i,s,u,e]),x=([...b])=>(e!=="production"&&b.unshift(n.jsx(g.Suspense,{fallback:n.jsx("div",{}),children:n.jsx(ao,{mode:"production",state:t})})),b);return n.jsxs(tn,{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(Q,{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(Q,{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(Ce.default,{style:{background:"inherit"},status:404,extra:n.jsx(Fe,{href:"/",children:o("common.back")})})})})]}),e!=="production"&&n.jsx(Kn,{sx:{bgcolor:"info.light"},children:e}),n.jsx(Qn,{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 so({mode:e,state:t,path:o,pageData:r}){const{t:i,locale:s}=ke.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=$e.useReactive({page:null});g.useEffect(()=>{const h=u||(m==null?void 0:m.page)||null;h?x.page=xe.default(h):x.page=null},[u,m]);const y=g.useRef();if(g.useEffect(()=>{Ie.default(r,y.current)||r&&x.page&&(zt(x.page,t,f,r),y.current=xe.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(Ce.default,{style:{background:"inherit"},status:404,extra:n.jsx(Fe,{href:"/",children:i("common.back")})})});const j=w.getAllComponents(t);return x.page?n.jsx(Q,{mode:e,components:j,page:x.page,locale:f,defaultLocale:l}):null}function Q({mode:e,components:t,page:o,locale:r,defaultLocale:i,headerAddons:s}){var h,v,b,k,N,W,D,ce,le;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}=Ze.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?He:Me;return n.jsxs(n.Fragment,{children:[!!a.backgroundColor&&n.jsx(Y.Global,{styles:Y.css`
534
+ body {
535
+ background-color: ${a.backgroundColor} !important;
536
+ }
537
+ `}),n.jsx(j,{hideNavMenu:!!((W=a.header)!=null&&W.hideNavMenus),translucentTextColor:(D=a.header)==null?void 0:D.translucentTextColor,...u?{logo:u}:{},...m?{brand:m}:{},...f?{description:f}:{},className:_.cx(((ce=a.header)==null?void 0:ce.sticky)&&"sticky","page-header"),maxWidth:!1,addons:y}),n.jsx(B.ScrollRestoration,{}),n.jsxs(st.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 de,ue;const C=o.sections[E];if(!C||C.visibility==="hidden")return null;const L=(de=C.locales)==null?void 0:de[r],Ve=((ue=C.locales)==null?void 0:ue[i])??{};return n.jsx(Gn,{id:E,type:C.component,mode:e,section:C,config:{...Bt.default(L)?Ve:L,locale:r,dev:e==="draft"?{mode:e,components:t,defaultLocale:i}:{mode:e}}},E)})}),!((le=a.footer)!=null&&le.hidden)&&n.jsx(Jn,{})]})}const ao=g.lazy(()=>Promise.resolve().then(()=>require("./publish-button-DEx0XGBW.js"))),Me=Be.default(St.default)`
538
+ &.sticky {
539
+ position: sticky;
540
+ top: 0;
541
+ }
542
+ `;function co({logo:e}){const[t,o]=g.useState(),{value:r}=O.useAsync(()=>new Promise(i=>{fetch("/.well-known/service/blocklet/logo-rect").then(s=>{const a=s.headers.get("content-type");a!=null&&a.includes("svg")&&s.text().then(c=>{o(c),i(null)}),i(s.url)})}),[]);if(e)return e;if(t)return n.jsx(p.Box,{sx:{filter:"initial !important"},dangerouslySetInnerHTML:{__html:Ct.default.sanitize(t)}});if(r){const i=new URL(r);i.searchParams.set("imageFilter","convert"),i.searchParams.set("f","png"),i.searchParams.set("h","80");const s=i.toString();return n.jsx("img",{src:s,alt:"logo"})}return null}function He({logo:e,translucentTextColor:t,...o}){const{y:r}=O.useWindowScroll();let i=Math.min(r/800,1),s="";if(i>.1){i=Math.max(i,.6);const a=Math.round(255*Math.min(1-i,.2));s=`rgb(${a}, ${a}, ${a})`}else s=t||"#EEEEEE";return n.jsx(Me,{logo:n.jsx(co,{logo:e}),...o,className:_.cx(i<=.7&&"reverse-color"),style:{backgroundColor:`rgba(255,255,255,${i})`,"--logo-invert":i<=.7?1-i/6:1-i},sx:{backdropFilter:i>=.6?"blur(10px)":"blur(0px)",transition:"all 0.3s ease",position:"fixed !important",left:0,top:0,right:0,bgcolor:"transparent","&.reverse-color":{".navmenu-root>.navmenu-sub>span,\n .navmenu-root>.navmenu-item,\n .header-addons>button,\n .header-addons>a,\n .header-addons>div>button":{color:`${s} !important`}},".header-logo > div":{filter:"invert(var(--logo-invert))"},".header-logo":{color:s}}})}const Fe=Be.default(p.Button)``;exports.Home=oo;exports.HomeView=Ue;exports.Loading=Oe;exports.PageRoutes=X;exports.PageView=Q;exports.PageViewByPath=so;exports.TranslucentHeader=He;exports.getPages=Ae;exports.publishPages=Un;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("./state-BjeG4kYg.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-D0r5jd24.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:2},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-BjeG4kYg.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-O1tb16Jn.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:2},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;