You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
225 KiB
JavaScript

(()=>{"use strict";var e,t,a,r={58979:(e,t,a)=>{a.d(t,{useKeyDownEffect:()=>i});a(67294),a(41792);var r=a(69845),n=a(65583),l=a(90180);function o(e,t,a,o,i){const{keys:s}=(0,r.useContext)(n.default),c=(0,r.useBatchingCallback)(o,i||[]);(0,r.useEffect)((()=>{const r=(0,l.getNodeFromRefOrNode)(e);if(!r)return;if(r.nodeType!==Node.ELEMENT_NODE&&r.nodeType!==Node.DOCUMENT_NODE)throw new Error("only an element or a document node can be used");const n=(0,l.resolveKeySpec)(s,t);if(1===n.key.length&&""===n.key[0])return;const o=(0,l.getOrCreateMousetrap)(r),i=(0,l.createKeyHandler)(r,n,c);return o.bind(n.key,i,a),()=>{o.unbind(n.key,a)}}),[c,s])}function i(e,t,a,r){o(e,t,"keydown",a,r)}},90180:(e,t,a)=>{a.d(t,{createKeyHandler:()=>u,getNodeFromRefOrNode:()=>c,getOrCreateMousetrap:()=>s,prettifyShortcut:()=>f,resolveKeySpec:()=>d});a(41792);var r=a(42441),n=a.n(r);const l="__WEB_STORIES_MT__",o=["submit","button","checkbox","radio","image","file","range","reset","hidden"],i=["submit","button","checkbox","radio","image","file","reset"];function s(e){return e[l]||(e[l]=new(n())(e))}function c(e){return e&&"current"in e?e.current:e}function d(e,t){const a="string"==typeof t||Array.isArray(t)?{key:t}:t,{key:r,shift:n=!1,repeat:l=!0,clickable:o=!0,editable:i=!1,dialog:s=!1,allowDefault:c=!1}=a,d=function(e,t){if(!t)return e;return e.concat(e.map((e=>`shift+${e}`)))}((new Array).concat(r).map((t=>e[t]||t)).flat(),n);return{key:d,shift:n,clickable:o,repeat:l,editable:i,dialog:s,allowDefault:c}}function u(e,t,a){let{repeat:r,editable:n,clickable:l,dialog:s,allowDefault:c=!1}=t;return t=>{const{repeat:d,target:u}=t;if((r||!d)&&(n||!function(e){let{tagName:t,isContentEditable:a,type:r,...n}=e;if("readOnly"in n&&!0===n.readOnly)return!1;if(a||"TEXTAREA"===t)return!0;if("INPUT"===t)return!o.includes(r);return!1}(u))&&(l||!function(e){let{tagName:t,type:a}=e;if(["BUTTON","A"].includes(t))return!0;if("INPUT"===t)return i.includes(a);return!1}(u))&&(s||!function(e,t){if(1!==e.nodeType)return!1;const a=e.closest('dialog,[role="dialog"]');return a&&t!==a&&t.contains(a)}(u,e)))return a(t),c}}function p(){const{platform:e}=window.navigator;return e.includes("Mac")||["iPad","iPhone"].includes(e)}function m(e){const t=p();return{alt:t?"⌥":"Alt",ctrl:t?"^":"Ctrl",mod:t?"⌘":"Ctrl",cmd:"⌘",shift:t?"⇧":"Shift"}[e]||e}function f(e){const t=p()?"":"+";return e.toLowerCase().replace("alt",m("alt")).replace("ctrl",m("ctrl")).replace("mod",m("mod")).replace("cmd",m("cmd")).replace("shift",m("shift")).replace("left","←").replace("up","↑").replace("right","→").replace("down","↓").replace("delete","⌫").replace("enter","⏎").split("+").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(t)}},28395:(e,t,a)=>{a.d(t,{Placement:()=>n,PopupContainer:()=>o,RTL_PLACEMENT:()=>l});var r=a(12788);let n=function(e){return e.Top="top",e.TopStart="top-start",e.TopEnd="top-end",e.Bottom="bottom",e.BottomStart="bottom-start",e.BottomEnd="bottom-end",e.Right="right",e.RightStart="right-start",e.RightEnd="right-end",e.Left="left",e.LeftStart="left-start",e.LeftEnd="left-end",e}({});const l={[n.Top]:n.Top,[n.TopStart]:n.TopStart,[n.TopEnd]:n.TopEnd,[n.Bottom]:n.Bottom,[n.BottomEnd]:n.BottomEnd,[n.BottomStart]:n.BottomStart,[n.Right]:n.Left,[n.RightStart]:n.LeftStart,[n.RightEnd]:n.LeftEnd,[n.Left]:n.Right,[n.LeftStart]:n.RightStart,[n.LeftEnd]:n.RightEnd},o=r.default.div.withConfig({displayName:"constants__PopupContainer",componentId:"sc-1f3rwe8-0"})(["/*! @noflip */ "," /*! @noflip */ left:0px;top:0px;position:fixed;",";max-height:",";"],(e=>{let{$offset:{x:t,y:a,width:r},fillWidth:n,transforms:l="",zIndex:o,maxWidth:i}=e;const s={};return n&&(i?s.minWidth=`${r}px`:s.width=`${r}px`),i&&!s.width&&(s.maxWidth=`${i}px`),{transform:`translate(${t}px, ${a}px) ${l}`,...s,zIndex:o}}),(e=>{let{noOverFlow:t}=e;return t?"":"overflow-y: auto;"}),(e=>{let{topOffset:t=0}=e;return`calc(100vh - ${t}px)`}))},1782:(e,t,a)=>{a.d(t,{DEFAULT_ARIA_CLEAR_LABEL:()=>o,DEFAULT_ARIA_INPUT_LABEL:()=>i,DEFAULT_PLACEHOLDER:()=>l,DEFAULT_POPUP_FILL_WIDTH:()=>n,Z_INDEX:()=>s});var r=a(36823
(0,l._n)("Viewing <strong>%d</strong> story","Viewing all <strong>%d</strong> stories",e,"web-stories"),String(e)),[ce.DRAFT]:e=>(0,X.default)(/* translators: %d: number of draft stories in view */
(0,l._n)("Viewing <strong>%d</strong> draft","Viewing <strong>%d</strong> drafts",e,"web-stories"),String(e)),[ce.PUBLISH]:e=>(0,X.default)(/* translators: %d: number of stories */
(0,l._n)("Viewing <strong>%d</strong> published story","Viewing <strong>%d</strong> published stories",e,"web-stories"),String(e)),[ce.FUTURE]:e=>(0,X.default)(/* translators: %d: number of stories */
(0,l._n)("Viewing <strong>%d</strong> scheduled story","Viewing <strong>%d</strong> scheduled stories",e,"web-stories"),String(e)),[ce.PENDING]:e=>(0,X.default)(/* translators: %d: number of stories */
(0,l._n)("Viewing <strong>%d</strong> pending story","Viewing <strong>%d</strong> pending stories",e,"web-stories"),String(e)),[ce.PRIVATE]:e=>(0,X.default)(/* translators: %d: number of stories */
(0,l._n)("Viewing <strong>%d</strong> private story","Viewing <strong>%d</strong> private stories",e,"web-stories"),String(e))},me={filters:{status:ce.ALL},sort:{orderby:ne.LAST_MODIFIED,order:oe[ne.LAST_MODIFIED]}},fe="diy_crafts",ge="movies_tv",he="beauty_style",be="fitness_wellbeing",_e="food",ye="travel",Ee="music",Se="sports",we=((0,l._x)("DIY & Crafts","template vertical","web-stories"),(0,l._x)("Movies & TV","template vertical","web-stories"),(0,l._x)("Beauty & Style","template vertical","web-stories"),(0,l._x)("Fitness & Wellbeing","template vertical","web-stories"),(0,l._x)("Food","template vertical","web-stories"),(0,l._x)("Travel","template vertical","web-stories"),(0,l._x)("Music","template vertical","web-stories"),(0,l._x)("Sports","template vertical","web-stories"),"white"),ve="black",Te="gray",Ce="brown",Ie="red",ke="orange",Le="yellow",Ae="green",xe="blue",Oe="pink",De="purple",Ne=((0,l._x)("White","color","web-stories"),(0,l._x)("Black","color","web-stories"),(0,l._x)("Gray","color","web-stories"),(0,l._x)("Brown","color","web-stories"),(0,l._x)("Red","color","web-stories"),(0,l._x)("Orange","color","web-stories"),(0,l._x)("Yellow","color","web-stories"),(0,l._x)("Green","color","web-stories"),(0,l._x)("Blue","color","web-stories"),(0,l._x)("Pink","color","web-stories"),(0,l._x)("Purple","color","web-stories"),{ALL:"template"}),Pe={[Ne.ALL]:e=>(0,X.default)(/* translators: %d: number of templates in view */
(0,l._n)("Viewing <strong>%d</strong> template","Viewing all <strong>%d</strong> templates",e,"web-stories"),String(e))},Re={POPULAR:"popular",RECENT:"recent"},Be={orderby:Re,order:{ASC:"asc",DESC:"desc"}},Me={filters:{status:Ne.ALL},sort:{orderby:Re.POPULAR}},Ue=[{label:(0,l.__)("Popular","web-stories"),value:Re.POPULAR},{label:(0,l.__)("Recent","web-stories"),value:Re.RECENT}],Fe={template:(0,l.__)("See details","web-stories")},ze={MENU:"menu",PANEL:"panel",COLOR_PANEL:"color_panel"},Ge=[".jpg",".jpeg",".png",".gif"],He=288,je=1098,Ve={TABLET:"tablet",DESKTOP:"desktop",THUMBNAIL:"thumbnail"},$e={[Ve.TABLET]:200,[Ve.DESKTOP]:232,[Ve.THUMBNAIL]:33},We=24,Ke=32,qe=52,Xe=5,Ye={DASHBOARD:"/",TEMPLATES_GALLERY:"/templates-gallery",TEMPLATE_DETAIL:"template-detail"},Ze={[Ye.DASHBOARD]:(0,l.__)("Dashboard","web-stories"),[Ye.TEMPLATES_GALLERY]:(0,l.__)("Explore Templates","web-stories"),[`${Ye.TEMPLATES_GALLERY}/${Ye.TEMPLATE_DETAIL}`]:(0,l.__)("Template Details","web-stories"),DEFAULT:(0,l.__)("Dashboard","web-stories")},Je=[{value:Ye.DASHBOARD,label:Ze[Ye.DASHBOARD],Icon:H},{value:Ye.TEMPLATES_GALLERY,label:Ze[Ye.TEMPLATES_GALLERY],Icon:U}],Qe={GRID:"grid",LIST:"list"},et={[Qe.GRID]:(0,l.__)("Switch to List View","web-stories"),[Qe.LIST]:(0,l.__)("Switch to Grid View","web-stories")},tt="DASHBOARD",at="TEMPLATES_GALLERY",rt={[tt]:{...pe},[at]:{...Pe}},nt=24,lt=300,ot=853,it=640;const st=function(e,t){switch(t.type){case C:case w:return{...e,isLoading:t.payload};case T:case k:case A:case O:case N:return{...e,error:{...t.payload,id:Date.now()}};case v:return{...e,error:{}};case L:return{...e,error:{},stories:{...e.stories,[t.payload.id]:t.payload}};case x:{const a=t.payload.storyStatus===ce.DRAFT?ce.DRAFT:ce.PUBLISH;return{...e,error:{},storiesOrderById:e.storiesOrderById.filter((e=>e!==t.payload.id)),totalStoriesByStatus:{...e.totalStoriesByStatus,all:e.totalStoriesByStatus.all-1,[a]:e.totalStoriesByStatus[a]-1},stories:Object.keys(e.stories).reduce(((a,r)=>(parseInt(r)!==t.payload.id&&(a[r]=e.stories[r]),a)),{})}}case D:return{...e,error:{},storiesOrderById:[t.payload.id,...e.storiesOrderById],totalStoriesByStatus:{...e.totalStoriesByStatus,all:e.totalStoriesByStatus.all+1,[t.payload.status]:e.totalStoriesByStatus[t.payload.status]+1},stories:{...e.stories,[t.payload.id]:t.payload}};case I:{const{fetchedStoryIds:a,totalStoriesByStatus:r,totalPages:n,page:l,stories:o}=t.payload,{storiesOrderById:i,stories:s}=e,c=1===l?a:[...i,...a],d=[...new Set(c)];return{...e,error:{},storiesOrderById:d,stories:{...s,...o},totalPages:n||1,totalStoriesByStatus:r,allPagesFetched:l>=n}}default:return e}},ct={LOAD_STORIES:{MESSAGE:(0,l.__)("Unable to load stories","web-stories")},UPDATE_STORY:{MESSAGE:(0,l.__)("Unable to update story","web-stories")},DELETE_STORY:{MESSAGE:(0,l.__)("Unable to delete story","web-stories")},CREATE_STORY_FROM_TEMPLATE:{MESSAGE:(0,l.__)("Unable to create story from template","web-stories")},DUPLICATE_STORY:{MESSAGE:(0,l.__)("Unable to duplicate story","web-stories")},LOAD_TEMPLATES:{DEFAULT_MESSAGE:(0,l.__)("Cannot connect to data source","web-stories"),MESSAGE:(0,l.__)("Unable to load templates","web-stories")},RENDER_PREVIEW:{MESSAGE:(0,l.__)("Unable to render preview","web-stories")},LOAD_TEMPLATE:{DEFAULT_MESSAGE:(0,l.__)("Could not load the template","web-stories")}},dt=`${S.SESSION_STORAGE_PREFIX.LOCAL_AUTOSAVE_PREFIX}_auto-draft`,ut=()=>{const e=(0,h.useRef)(!0),t=(0,h.useMemo)((()=>new Map),[]),[a,r]=(0,h.useReducer)(st,P),{apiCallbacks:n}=y(),l=(0,h.useRef)(!1);(0,h.useEffect)((()=>(l.current=!0,()=>{l.current=!1})),[]);const o=(0,h.useCallback)((async a=>{r({type:C,payload:!0});const o=(0,E.getTimeTracker)("load_stories");try{const{stories:o,fetchedStoryIds:i,totalPages:s,totalStoriesByStatus:c}=await n.fetchStories(a);if(!l.current)return;e.current&&t.forEach((e=>{e(c)})),e.current=!1,r({type:I,payload:{stories:o,totalPages:s,totalStoriesByStatus:c,fetchedStoryIds:i,page:a.page}})}catch(e){r({type:k,payload:{message:ct.LOAD_STORIES.MESSAGE,code:e.code}})}finally{r({type:C,payload:!1}),o()}}),[n,t]),i=(0,
(0,l.__)("Poster of template page %s","web-stories"),e)}Ht.propTypes={$isSelected:Rt().bool};const Vt=function CardGallery(e){let{galleryPosters:t,isRTL:a,galleryLabel:r}=e;const[o,i]=(0,h.useState)(0),[s,c]=(0,h.useState)(),d=(0,h.useRef)(),u=(0,h.useRef)(),p=(0,h.useRef)({}),m=(0,h.useCallback)((e=>{i(e),c(e)}),[]),f=(0,h.useCallback)((e=>{c(e)}),[]);(0,h.useEffect)((()=>{t&&(i(0),c())}),[t]),(0,Nt.default)({containerRef:d,gridRef:u,itemRefs:p,isRTL:a,currentItemId:s,items:t});const g=(0,h.useMemo)((()=>t.map(((e,t)=>{const a=`gallery_item_${t}`,r=t+1,i=s?s===t:o===t;return n.createElement("div",{key:a,ref:e=>{p.current[t]=e},onFocus:()=>f(t)},n.createElement(Ht,{$isSelected:o===t,tabIndex:i?0:-1,onClick:()=>m(t),"aria-label":o===t?(0,X.default)(/* translators: %s: page number. */
(0,l.__)("Page %s (current page)","web-stories"),r):(0,X.default)(/* translators: %s: page number. */
(0,l.__)("Page %s","web-stories"),r)},n.createElement("picture",null,n.createElement("source",{srcSet:e.webp,type:"image/webp"}),n.createElement("source",{srcSet:e.png,type:"image/png"}),n.createElement("img",{src:e.png,decoding:"async",alt:jt(r),width:it,height:ot}))))}))),[t,o,s,f,m]);return n.createElement(Ft,{ref:d},n.createElement(Gt,{ref:u,role:"group","aria-label":r,"data-testid":"mini-cards-container"},g),n.createElement(zt,null,t[o]&&n.createElement("picture",null,n.createElement("source",{srcSet:t[o].webp,type:"image/webp"}),n.createElement("source",{srcSet:t[o].png,type:"image/png"}),n.createElement("img",{src:t[o].png,decoding:"async",alt:(0,X.default)(/* translators: %s: active preview page number */
(0,l.__)("Active Page Preview - Page %s","web-stories"),o+1),width:it,height:ot}))))};var $t=a(41708);const Wt=Rt().oneOf([...Object.values(ce),...Object.values(Ne)]),Kt=Rt().shape({id:Rt().number.isRequired,status:Wt,title:Rt().string.isRequired,modified:Rt().oneOfType([Rt().object,Rt().string]),author:Rt().object,capabilities:Rt().shape({hasDeleteAction:Rt().bool,hasEditAction:Rt().bool})}),qt=Rt().shape({id:Rt().number.isRequired,status:Wt,title:Rt().string.isRequired,pages:Rt().array,modified:Rt().object,colors:Rt().arrayOf(Rt().shape({label:Rt().string.isRequired,color:Rt().string.isRequired})),description:Rt().string,tags:Rt().arrayOf(Rt().string),createdBy:Rt().string,postersByPage:Rt().arrayOf(Rt().shape({webp:Rt().string,png:Rt().string,type:Rt().string}))}),Xt=(Rt().arrayOf(Kt),Rt().arrayOf(qt).isRequired,Rt().shape({duplicateStory:Rt().func,trashStory:Rt().func,updateStory:Rt().func}),Rt().shape({createStoryFromTemplate:Rt().func,handleDetailsToggle:Rt().func,switchToTemplateByOffset:Rt().func}),Rt().shape({all:Rt().number,draft:Rt().number,publish:Rt().number}),Rt().shape({width:Rt().number,height:Rt().number})),Yt=(Rt().shape({handleMenuToggle:Rt().func.isRequired,contextMenuId:Rt().number.isRequired,menuItems:Rt().arrayOf(Rt().shape({label:Rt().string,value:Rt().oneOfType([Rt().string,Rt().bool]),url:Rt().string,isEnabled:Rt().func,action:Rt().func}))}),Rt().shape({handleOnRenameStory:Rt().func,id:Rt().number,handleCancelRename:Rt().func}),m.default.div.withConfig({displayName:"cardGrid__DashboardGrid",componentId:"sc-1kbl74q-0"})(["display:grid;width:100%;grid-column-gap:","px;grid-row-gap:","px;grid-template-columns:",";grid-template-rows:",";scroll-margin-top:30vh;",";"],We,Ke,(e=>{let{columnWidth:t}=e;return`\n repeat(auto-fill, ${t}px)`}),(e=>{let{columnHeight:t}=e;return`minmax(${t}px, auto)`}),(e=>{let{theme:t}=e;return(0,m.css)(["&:focus-visible{",";}"],$t.focusCSS(t.colors.border.focus))})));Yt.propTypes={columnHeight:Rt().number,columnWidth:Rt().number};const Zt=(0,h.forwardRef)((function CardGrid(e,t){let{ariaLabel:a,children:r,pageSize:l}=e;return n.createElement(Yt,{ref:t,role:"list","data-testid":"dashboard-grid-list",tabIndex:0,"aria-label":a,columnWidth:l.width,columnHeight:l.height},r)}));var Jt=a(46710),Qt=a(67745),ea=a(18275),ta=a(8921),aa=a(16330);function ra(){return ra=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},ra.apply(this,arguments)}const na=(0,m.default)(ea.Link).withConfig({displayName:"link__StyledLink",componentId:"sc-7h28r8-0"})(["",";background-color:transparent;text-decoration:none;:active,:hover,:focus,:active *,:hover *,:focus *{color:"," !important;}:hover{background-color:",";}:active{background-color:",";}"],aa.menuItemStyles,(e=>{let{theme:t}=e;return t.colors.fg.primary}),(e=>{let{theme:t}=e;return t.colors.interactiveBg.secondaryHover}),(e=>{let{theme:t}=e;return t.colors.interactiveBg.secondaryPress}));const la=function Link(e){let{id:t,onBlur:a,onClick:r,onFocus:l,openNewTab:o,...i}=e;const{focusedId:s,onDismiss:c,onMenuItemBlur:d,onMenuItemFocus:u}=(0,ta.default)((e=>{let{state:t,actions:a}=e;return{focusedId:t.focusedId,onDismiss:a.onDismiss,onMenuItemBlur:a.onMenuItemBlur,onMenuItemFocus:a.onMenuItemFocus}})),p=(0,h.useMemo)(Qt.default,[]),m=t||p,f=o?{target:"_blank",rel:"noreferrer"}:{};return n.createElement(na,ra({id:m,tabIndex:s===m?0:-1,role:"menuitem",onBlur:e=>{d(),a?.(e)},onClick:e=>{r?.(e),c(e.nativeEvent)},onFocus:e=>{u(m),l?.(e)}},f,i))};var oa=a(48652),ia=a(22728);const sa=m.default.button.withConfig({displayName:"storyMenu__MoreVerticalButton",componentId:"sc-1vaaobv-0"})(["display:flex;background:transparent;padding:0 8px;opacity:",";transition:opacity ease-in-out 300ms;cursor:pointer;color:",";& > svg{width:4px;max-height:100%;}border:0;border-radius:",";",";"],(e=>{let{menuOpen:t,isVisible:a}=e;return t||a?1:0}),(e=>{let{theme:t,$isInverted:a}=e;return a?t.colors.inverted.fg.primary:t.colors.interactiveFg.b
(0,l.__)("%s (active view)","web-stories"),r.label):r.label},r.isExternal&&{rel:"noreferrer",target:"_blank",onClick:e=>g(e,r)}),n.createElement(gr,null,a&&n.createElement(a,{width:"22px"})),n.createElement(pr,{size:Ya.TextSize.Small,isBold:!0},r.label)))}))))),n.createElement(or,null,r&&n.createElement(sr,null,r.map((t=>n.createElement(cr,{key:t.value},n.createElement(ur,fr({active:e===t.value,href:tr(t.value),size:Ya.TextSize.Small,"aria-label":e===t.value?(0,X.default)(/* translators: %s: the current page, for example "Dashboard". */
(0,l.__)("%s (active view)","web-stories"),t.label):t.label},t.isExternal&&{rel:"noreferrer",target:"_blank",onClick:e=>g(e,t)}),n.createElement(Sa.Text.Span,{size:Ya.TextSize.Small,isBold:!0},t.label)))))),n.createElement(mr,{size:Ya.TextSize.XSmall},(0,X.default)(/* translators: 1: Current Year, 2: App Version */
(0,l.__)("© %1$s Google Version %2$s","web-stories"),(new Date).getFullYear(),a))))},br=(0,m.default)($).attrs({width:24,height:24}).withConfig({displayName:"menuButton__MenuIcon",componentId:"sc-ov12l5-0"})(["display:block;color:",";"],(e=>{let{theme:t}=e;return t.colors.interactiveFg.brandNormal})),_r=m.default.button.withConfig({displayName:"menuButton__TransparentButton",componentId:"sc-ov12l5-1"})(["display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;margin-right:16px;background:transparent;border:0;border-radius:",";"," ",""],(e=>{let{theme:t}=e;return t.borders.radius.small}),$t.focusableOutlineCSS,(e=>{let{showOnlyOnSmallViewport:t}=e;return t&&(0,m.css)(["display:none;@media screen and (max-width:","px){display:inline-block;}"],je)}));const yr=function NavMenuButton(e){let{showOnlyOnSmallViewport:t}=e;const{actions:a}=nr();return n.createElement(_r,{onClick:a.toggleSideBar,showOnlyOnSmallViewport:t,"aria-label":(0,l.__)("Toggle main navigation","web-stories")},n.createElement(br,{"aria-hidden":!0}))};var Er=a(99832);const Sr=(0,m.default)(Bt.Button).withConfig({displayName:"scrollToTop__StyledButton",componentId:"sc-o0u22z-0"})((e=>{let{$isVisible:t,theme:a}=e;return(0,m.css)(["position:fixed;right:40px;bottom:40px;height:50px;width:50px;display:flex;align-self:center;justify-content:space-around;align-items:center;contain:content;padding:8px;background-color:",";pointer-events:",";box-shadow:0px 4px 14px rgba(0,0,0,0.25);opacity:",";transition:opacity 300ms ease-in-out;"],a.colors.opacity.white64,t?"auto":"none",Number(t))})),wr=(0,m.default)(Er.default).withConfig({displayName:"scrollToTop__DropUpArrowIcon",componentId:"sc-o0u22z-1"})(["position:relative;transform:scale(2.4);"]),vr=()=>{const[e,t]=(0,h.useState)(!1),{actions:{scrollToTop:a}}=Pa(),r=(0,h.useDebouncedCallback)((()=>t(window.scrollY>0)),100);return(0,h.useEffect)((()=>(window.addEventListener("scroll",r,{passive:!0}),function(){window.removeEventListener("scroll",r,{passive:!0})})),[r]),n.createElement(Sr,{disabled:!e,"aria-label":(0,l.__)("Scroll back to top","web-stories"),"data-testid":"scroll-to-top-button",$isVisible:e,onClick:a,variant:Mt.ButtonVariant.Circle},n.createElement(wr,{"aria-hidden":!0}))};var Tr=a(38668);const Cr=m.default.table.withConfig({displayName:"table__Table",componentId:"sc-16y5cap-0"})([""," border-collapse:collapse;width:inherit;"],Tr.expandTextPreset(((e,t)=>{let{paragraph:a}=e,{Small:r}=t;return a[r]}))),Ir=m.default.tbody.withConfig({displayName:"table__TableBody",componentId:"sc-16y5cap-1"})([""]),kr=m.default.thead.withConfig({displayName:"table__TableHeader",componentId:"sc-16y5cap-2"})(["background:",";"],(e=>{let{theme:t}=e;return t.colors.bg.secondary})),Lr=(0,m.default)(kr).withConfig({displayName:"table__StickyTableHeader",componentId:"sc-16y5cap-3"})(["width:100%;border-top:0;border-bottom:0;th{height:100%;background:",";position:sticky;z-index:2;top:",";:first-child{border-top-left-radius:",";border-bottom-left-radius:",";}:last-child{border-top-right-radius:",";border-bottom-right-radius:",";}}"],(e=>{let{theme:t}=e;return t.colors.bg.secondary}),(e=>{let{topOffset:t}=e;return`${t}px`}),(e=>{let{theme:t}=e;return t.borders.radius.small}),(e=>{let{theme:t}=e;return t.borders.radius.small}),(e=>{let{theme:t}=e;return t.borders.radius.small}),(e=>{let{theme:t}=e;return t.borders.radius.small})),Ar=m.default.th.withConfig({displayName:"table__TableHeaderCell",componentId:"sc-16y5cap-4"})(["padding:16px;text-align:left;white-space:nowrap;"]),xr=(0,m.default)(Ar).withConfig({displayName:"table__TablePreviewHeaderCell",componentId:"sc-16y5cap-5"})(["padding-right:0;"]),Or=(0,m.default)(Ar).withConfig({displayName:"table__TableDateHeaderCell",componentId:"sc-16y5cap-6"})(["min-width:160px;"]),Dr=(0,m.default)(Ar).withConfig({displayName:"table__TableStatusHeaderCell",componentId:"sc-16y5cap-7"})(["display:table-cell;min-width:100px;@media ","{display:none;}"],(e=>{let{theme:t}=e;return t.breakpoint.tabletMax})),Nr=(0,m.default)(Ar).withConfig({displayName:"table__Tabl
(0,l._n)("%s result","%s results",e,"web-stories"),(0,X.default)("<strong>%s</strong>",e)):i}),[t,r,n,a])}const en=e=>Math.round(e/.6666666666666666),tn=e=>e<=je?Ve.TABLET:Ve.DESKTOP,an=(e,t)=>{let{bp:a,respectSetWidth:r,availableContainerSpace:n}=t;if(r){return{width:e,height:en(e)}}a===Ve.DESKTOP&&(n-=He);const l=Math.floor(n/e),o=e+(n-(e*l+We*(l-1)+2*qe))/l;return{width:o,height:en(o)}},rn=e=>window.innerWidth<je?je:e;function nn(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{thumbnailMode:t=!1,isGrid:a}=e,{containerId:r}=y(),n=(0,h.useRef)(document.getElementById(r)),[l,o]=(0,h.useState)(window.innerWidth),[i,s]=(0,h.useState)(tn(l)),[c,d]=(0,h.useState)(rn(n.current?.offsetWidth||window.innerWidth)),u=(0,h.useDebouncedCallback)((e=>{o(e)}),500);return(0,h.useEffect)((()=>{s(tn(l))}),[l]),(0,h.useResizeEffect)(n,(e=>{let{width:t}=e;d(rn(t)),window.innerWidth!==l&&u(window.innerWidth)}),[d,l,u]),(0,h.useMemo)((()=>({pageSize:an($e[t?Ve.THUMBNAIL:i],{respectSetWidth:!a||t,availableContainerSpace:c,bp:i})})),[i,a,t,c])}const ln=(e,t)=>{let{MIN:a,MAX:r}=t;return Math.min(Math.max(e,a),r)};Rt().shape({style:Rt().oneOf(Object.values(Qe)),toggleStyle:Rt().func,pageSize:Xt}),Rt().shape({filterId:Rt().number,toggleFilterId:Rt().func,queriedAuthors:Rt().arrayOf(Rt().shape({id:Rt().number,name:Rt().string})).isRequired,setQueriedAuthors:Rt().func}),Rt().shape({value:Rt().oneOfType([Rt().number,Rt().string]),set:Rt().func}),Rt().shape({value:Rt().oneOf(Object.values(ne)),set:Rt().func,direction:Rt().oneOf(Object.values(re)),setDirection:Rt().func}),Rt().shape({value:Rt().number,set:Rt().func,requestNextPage:Rt().func}),Rt().shape({keyword:Rt().string,setKeyword:Rt().func}),Rt().shape({current:Rt().bool});Rt().shape({style:Rt().oneOf(Object.values(Qe)),pageSize:Xt}),Rt().shape({value:Rt().oneOfType([Rt().number,Rt().string]),set:Rt().func}),Rt().shape({value:Rt().number,set:Rt().func,requestNextPage:Rt().func}),Rt().shape({keyword:Rt().string,setKeyword:Rt().func}),Rt().shape({value:Rt().oneOf(Object.values(Re)),set:Rt().func});const on=()=>{},sn=()=>({isRTL:!1,userId:1,locale:{locale:"en-US",dateFormat:"F j, Y",timeFormat:"g:i a",gmtOffset:"0",timezone:"",months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],weekdaysInitials:["S","M","T","W","T","F","S"],weekStartsOn:1},newStoryURL:"",cdnURL:"https://wp.stories.google/static/main/",version:"",capabilities:{canManageSettings:!1,canUploadFiles:!1},canViewDefaultTemplates:!1,flags:{},apiCallbacks:{},leftRailSecondaryNavigation:[],styleConstants:{topOffset:0,leftOffset:0}});Object.defineProperty(f.default,"name",{value:"stylisRTLPlugin"});const cn=function Dashboard(e){let{config:t,children:a}=e;const r=(0,o.default)(sn(),t),l={...i.theme,colors:s.light},{isRTL:h,flags:b,styleConstants:{leftOffset:y,topOffset:E}={}}=r;return n.createElement(g.FlagsProvider,{features:b},n.createElement(m.StyleSheetManager,{stylisPlugins:h?[f.default]:[]},n.createElement(m.ThemeProvider,{theme:l},n.createElement(c.Styles,null),n.createElement(d.ModalGlobalStyle,null),n.createElement(_,{config:r},n.createElement(ApiProvider,null,n.createElement(NavProvider,null,n.createElement(Qa,null,n.createElement(u.default,null,n.createElement(p.default,{value:{isRTL:h,leftOffset:y,topOffset:E}},n.createElement(qr,null),n.createElement(Jr,null),a)))))))))};var dn=a(13013),un=a(80125);a(70928);const pn="UPDATE_FILTER",mn="UPDATE_SORT",fn="REGISTER_FILTERS",gn=(e,t)=>{let{type:a,payload:r={}}=t;switch(a){case pn:{const t=["search","status"],{key:a,value:n}=r,l=e.filters.find((e=>e.key===a));if(!l)return e;if(n.filterId&&l?.filterId===n.filterId){if(t.includes(a))return e;n.filterId=null}const o=e.filters.indexOf(l),i=[...e.filters];i[o]={...l,...n};const s={};for(const e of i)e.filterId&&(s[e.key]=e.filter
(0,l._n)("%d result found.","%d results found.",n.length,"web-stories"),String(n.length)):(0,l.__)("No results found.","web-stories");o(e)}}),[b,i,n.length,o]),{activeOption:g,getActiveOption:f,groups:m,inputState:b,setInputState:y,isMenuFocused:d,setIsMenuFocused:p,isOpen:i,setIsOpen:c}}({options:p,selectedValue:_,searchValue:y,handleSearchValueChange:o}),R=(0,h.useMemo)((()=>Boolean(r||!L?.length)),[r,L]),B=(0,h.useCallback)((()=>{N(!0),O(!1)}),[N,O]),M=(0,h.useCallback)((e=>{e.preventDefault(),N(!0)}),[N]),U=(0,h.useCallback)((e=>{v&&e?.currentTarget instanceof HTMLElement&&e.currentTarget.id===v||N(!1)}),[v,N]),F=(0,h.useCallback)(((e,t)=>{N(!1);const a=k(t)||{label:String(t),value:t};A(String(a.label)),d?.(e,a)}),[k,A,N,d]),z=(0,h.useCallback)((()=>T?.current?.focus()),[]),G=(0,h.useCallback)((e=>{let{target:t}=e;A(t.value),N(t.value.length>0)}),[A,N]),H=(0,h.useCallback)((()=>{A(""),u?.(),z?.()}),[z,A,u]),j=(0,h.useCallback)((()=>{N(!1),O(!1)}),[N,O]),V=(0,h.useCallback)((()=>O(!0)),[O]),$=(0,h.useCallback)((()=>{(R||0===L?.trim().length)&&(O(!1),N(!1))}),[L,O,R,N]),W=(0,h.useCallback)((e=>{const{key:t}=e;"Escape"===t?R||O(!1):"Tab"===t?$():"ArrowDown"===t?V():"Enter"===t&&L&&L.trim().length>0&&F(e.nativeEvent,String(L))}),[R,O,$,V,L,F]);return(0,h.useFocusOut)(C,$,[$]),n.createElement($n,null,c&&n.createElement(Wn,{size:Ya.TextSize.Small,disabled:r,isBold:!0},c),n.createElement(Qn,{ref:C},n.createElement(Xn.default,Jn({"aria-label":t,hasError:i,id:w,onChange:G,onClick:M,onFocus:B,onKeyDown:W,placeholder:m,ariaClearLabel:a,clearId:v,disabled:r,handleClearInput:H,handleTabClear:j,inputValue:L||"",isOpen:D,listId:S,ref:T},E))),!R&&n.createElement(Vn.default,{anchor:T,isOpen:D,placement:f,fillWidth:g,zIndex:b,ignoreMaxOffsetY:!0},n.createElement(jn.default,Jn({activeValue:I?.value,handleReturnToParent:z,isMenuFocused:x,listId:S,menuAriaLabel:(0,X.default)(/* translators: %s: dropdown aria label or general dropdown label if there is no specific aria label. */
(0,l.__)("%s Option List Selector","web-stories"),t),onDismissMenu:U,handleMenuItemSelect:F,groups:P,parentId:w},E))),s&&n.createElement(Kn,{hasError:i,size:Ya.TextSize.Small},s))},tl=(0,m.default)(ha).withConfig({displayName:"pageHeading__HeadingContainer",componentId:"sc-1ln7suo-0"})(["display:flex;align-items:center;flex-wrap:wrap;justify-content:space-between;margin-bottom:16px;padding-top:48px;border-bottom:1px solid ",";"],(e=>{let{theme:t}=e;return t.colors.divider.secondary})),al=(0,m.default)(Gn).withConfig({displayName:"pageHeading__StyledHeadline",componentId:"sc-1ln7suo-1"})(["display:flex;align-items:center;margin-right:28px;padding-bottom:24px;white-space:nowrap;"]),rl=m.default.div.withConfig({displayName:"pageHeading__HeadlineFilters",componentId:"sc-1ln7suo-2"})(["display:flex;align-items:center;margin:auto 0 auto 0;padding-bottom:24px;"]),nl=m.default.div.withConfig({displayName:"pageHeading__HeaderSearch",componentId:"sc-1ln7suo-3"})(["width:208px;max-width:208px;min-width:208px;margin:auto 0;padding-bottom:24px;"]),ll=e=>{let{children:t,heading:a,searchPlaceholder:r,searchOptions:o=[],showSearch:i,handleSearchChange:s,searchValue:c,onClear:d=Hn.noop}=e;return n.createElement(tl,null,n.createElement(al,{as:"h2",size:Ya.TextSize.Small},n.createElement(yr,{showOnlyOnSmallViewport:!0}),a),t&&n.createElement(rl,null,t),i&&n.createElement(nl,null,n.createElement(el,{placeholder:r,searchValue:c,options:o,handleSearchValueChange:s,onClear:d,emptyText:(0,l.__)("No options available","web-stories")})))};var ol,il=a(71028),sl=a(26707),cl=a(61736),dl=a(92414);function ul(){return ul=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},ul.apply(this,arguments)}const SvgArrowDown=e=>{let{title:t,titleId:a,...r}=e;return n.createElement("svg",ul({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 32 32","aria-labelledby":a},r),t?n.createElement("title",{id:a},t):null,ol||(ol=n.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"m16.5 21.282 4.645-4.704a.5.5 0 0 1 .711.702l-5.5 5.571a.5.5 0 0 1-.712 0l-5.5-5.57a.5.5 0 0 1 .712-.703l4.644 4.704V9.5a.5.5 0 0 1 1 0v11.782Z",clipRule:"evenodd"})))},pl=(0,n.memo)(SvgArrowDown),ml=e=>{let{menuItems:t,story:a,isLocked:r}=e;const n=t.default?()=>t.default(a):on;return t.filter((e=>void 0===e.isEnabled||e.isEnabled(a))).map((e=>{let{capability:l,value:o,...i}=e;const s=(e=>t.find((t=>t?.value===e)))(o),c={onClick:s?()=>s.action(a):n};switch(o){case Y:c.href=a.bottomTargetAction,c.openNewTab=!1;break;case te:c.href=a.previewLink,c.openNewTab=!0;break;case Z:case Q:c.disabled=r}return delete i?.action,{...i,...c}}))};var fl=a(37233);const gl=m.default.div.withConfig({displayName:"storyListItem__PreviewImage",componentId:"sc-1w22569-0"})(["display:inline-block;background:",";width:","px;height:","px;object-fit:contain;border-radius:",";"],(e=>{let{theme:t}=e;return t.colors.gradient.placeholder}),$e[Ve.THUMBNAIL],$e[Ve.THUMBNAIL]/(3/4),(e=>{let{theme:t}=e;return t.borders.radius.small})),hl=m.default.div.withConfig({displayName:"storyListItem__PreviewWrapper",componentId:"sc-1w22569-1"})(["position:relative;"]),bl=(0,m.default)(fl.default).withConfig({displayName:"storyListItem__LockIcon",componentId:"sc-1w22569-2"})(["position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);height:24px;display:block;margin:auto;background-color:",";color:",";border-radius:",";"],(e=>{let{theme:t}=e;return t.colors.interactiveBg.brandNormal}),(e=>{let{theme:t}=e;return t.colors.standard.white}),(e=>{let{theme:t}=e;return t.borders.radius.round})),_l=(0,m.default)(Rr).withConfig({displayName:"storyListItem__StyledTableRow",componentId:"sc-1w22569-3"})(["&:hover ",",&:focus-within ","{opacity:1;}"],sa,sa),yl=m.default.div.withConfig({displayName:"storyListItem__TitleTableCellContainer",componentId:"sc-1w22569-4"})(["display:flex;align-items:center;justify-content:flex-start;","{margin:10px auto;}&:hover ",",&:active ","{opacity:1;}"],sa,sa,
(0,l.__)("Context menu for %s","web-stories"),c),onMoreButtonSelected:(e,t)=>o.handleMenuToggle(t),contextMenuId:o.contextMenuId,storyId:t.id,menuItems:d,verticalAlign:"center"}):null),[d,c,o,t]);return n.createElement(_l,{"data-testid":`story-list-item-${t.id}`},n.createElement(Ur,null,n.createElement(Tooltip,{title:s&&t?.lockUser.name?(0,X.default)(/* translators: %s: user name */
(0,l.__)("%s is currently editing this story","web-stories"),t?.lockUser.name):""},n.createElement(hl,null,n.createElement(gl,t.featuredMediaUrl?{src:t.featuredMediaUrl,alt:(0,X.default)(/* translators: %s: Story title. */
(0,l.__)("%s Poster image","web-stories"),c),as:"img",decoding:"async"}:null),s&&n.createElement(bl,null)))),n.createElement(Br,null,n.createElement(yl,null,a.id===t.id?n.createElement(Oa,{onEditComplete:e=>a.handleOnRenameStory(t,e),onEditCancel:a.handleCancelRename,value:t.title,id:t.id,label:(0,l.__)("Rename story","web-stories")}):n.createElement(n.Fragment,null,n.createElement(lr.Headline,{tabIndex:0,onFocus:El,onBlur:Sl,size:Ya.TextSize.XXXSmall,as:"h3","aria-label":s?(0,X.default)(/* translators: 1: story title. 2: user currently editing the story. */
(0,l.__)("%1$s (locked by %2$s)","web-stories"),c,t?.lockUser.name):c},c),u))),n.createElement(Br,null,n.createElement(Sa.Text.Span,{size:Ya.TextSize.Small},t.author?.name||"—")),n.createElement(Br,null,n.createElement(Sa.Text.Span,{size:Ya.TextSize.Small},Et(t.createdGmt))),n.createElement(Br,null,n.createElement(Sa.Text.Span,{size:Ya.TextSize.Small},Et(t.modifiedGmt))),i!==ce.DRAFT&&n.createElement(Mr,null,n.createElement(Sa.Text.Span,{size:Ya.TextSize.Small},de[t?.status])))};var wl=a(75097);const{focusableOutlineCSS:vl}=wl,Tl=m.default.div.withConfig({displayName:"listView__ListView",componentId:"sc-15nl0r5-0"})(["width:100%;"]),Cl=m.default.div.withConfig({displayName:"listView__ArrowIcon",componentId:"sc-15nl0r5-1"})(["width:32px;height:100%;display:inline-grid;color:",";vertical-align:middle;svg{visibility:",";transition:transform 0.15s;",";}"],(e=>{let{theme:t}=e;return t.colors.fg.primary}),(e=>{let{active:t}=e;return t?"visible":"hidden"}),(e=>{let{asc:t}=e;return t&&(0,m.css)(["transform:rotate(180deg);"])})),Il=m.default.div.withConfig({displayName:"listView__EmptyIconSpace",componentId:"sc-15nl0r5-2"})(["height:32px;width:32px;"]),kl=(0,m.default)(Cl).withConfig({displayName:"listView__ArrowIconWithTitle",componentId:"sc-15nl0r5-3"})([""," position:absolute;top:16px;@media ","{margin-left:4px;}"],(e=>{let{active:t}=e;return!t&&"display: none;"}),(e=>{let{theme:t}=e;return t.breakpoint.mobile})),Ll=(0,m.default)(Sa.Text.Span).attrs({tabIndex:0,isBold:!0}).withConfig({displayName:"listView__SelectableTitle",componentId:"sc-15nl0r5-4"})(["color:",";cursor:pointer;",";"],(e=>{let{theme:t}=e;return t.colors.blue[70]}),(e=>{let{theme:t}=e;return vl(t.colors.border.focus,t.colors.bg.secondary)})),Al={[re.DESC]:re.ASC,[re.ASC]:re.DESC};function StoryListView(e){let{hideStoryList:t,renameStory:a,stories:r,storyMenu:o}=e;const{userId:i,styleConstants:{topOffset:s}}=y(),{filters:c,sortObject:d,updateSort:u}=wn((e=>{let{state:{filters:t,sortObject:a},actions:{updateSort:r}}=e;return{filters:t,sortObject:a,updateSort:r}})),[p,m]=(0,h.useMemo)((()=>[d?.orderby,d?.order]),[d]),f=(0,h.useMemo)((()=>c.filter((e=>{let{key:t}=e;return"status"===t})).filterId),[c]),g=(0,h.useCallback)((e=>{u(e!==p?{orderby:e,order:oe[e]}:{order:Al[m]})}),[u,p,m]),b=(0,h.useCallback)(((e,t)=>{let{key:a}=e;"Enter"===a&&g(t)}),[g]),_=(0,h.useMemo)((()=>!t&&r.map((e=>n.createElement(StoryListItem,{key:`story-${e.id}`,story:e,userId:i,renameStory:a,storyStatus:f,storyMenu:o})))),[t,a,r,f,o,i]);return n.createElement(Tl,{"data-testid":"story-list-view"},n.createElement(Cr,{"aria-label":(0,l.__)("List view of created stories","web-stories")},n.createElement(Lr,{topOffset:s},n.createElement(Rr,null,n.createElement(xr,{onClick:()=>g(ne.NAME),onKeyDown:e=>b(e,ne.NAME)},n.createElement(Ll,{"aria-label":(0,l.__)("Title, select to sort table by story title","web-stories"),size:Ya.TextSize.Small,isBold:!0},(0,l.__)("Title","web-stories"))),n.createElement(Pr,{onClick:()=>g(ne.NAME),onKeyDown:e=>b(e,ne.NAME)},n.createElement(Ll,{"aria-hidden":!0,active:p===ne.NAME,size:Ya.TextSize.Small,isBold:!0},(0,l.__)("Title","web-stories")),n.createElement(Cl,{active:p===ne.NAME,asc:m===re.ASC},n.createElement(pl,null))),n.createElement(Nr,null,n.createElement(Ll,{"aria-label":(0,l.__)("Author, select to sort table by story author","web-stories"),onClick:()=>g(ne.CREATED_BY),onKeyDown:e=>b(e,ne.CREATED_BY),active:p===ne.CREATED_BY,size:Ya.TextSize.Small,isBold:!0},(0,l.__)("Author","web-stories")),n.createElement(kl,{"aria-hidden":!0,active:p===ne.CREATED_BY,asc:m===re.ASC},p===ne.CREATED_BY?n.createElement(pl,null):n.createElement(Il,null))),n.createElement(Or,null,n.createElement(Ll,{"aria-label":(0,l.__)("Creation date, select to sort table by date story was created","web-stories"),onClick:()=>g(ne.DATE_CREATED),onKeyDown:e=>b(e,ne.DATE_CREATED),active:p===ne.DATE_CREATED,size:Ya.TextSize.Small,isBold:!0},(0,l.__)("Date Created","web-stories")),n.createElement(kl,{"aria-hidden":!0,active:p===ne.DATE_CREATED,asc:m===re.ASC},n.createElement(pl,null))),n.createElemen
(0,l.__)("Published %s","web-stories"),r);case ce.FUTURE:return(0,X.default)(/* translators: %s: future publish date */
(0,l.__)("Scheduled %s","web-stories"),r);default:return(0,X.default)(/* translators: %s: last modified date */
(0,l.__)("Modified %s","web-stories"),r)}}),[m,r]),{name:b,avatar:_}=d,y=c&&_&&n.createElement(zl,null,n.createElement(Tooltip,{position:zr.Placement.BottomStart,title:b&&(0,X.default)(/* translators: %s: user name */
(0,l.__)("%s is currently editing this story","web-stories"),b)},n.createElement($l,{src:_,alt:b,decoding:"async",height:24,width:24,"data-test-id":"lock-user-avatar"})));return n.createElement(Ul,null,y,o?n.createElement(Oa,{onEditComplete:u,onEditCancel:p,value:f,id:s,label:(0,l.__)("Rename story","web-stories"),isInverted:!0}):n.createElement(Fl,null,c&&n.createElement(Wl,null),n.createElement(jl,null,i)),n.createElement(Gl,null,n.createElement(Hl,null,m===ce.DRAFT&&n.createElement(Vl,{isBold:!0},(0,l.__)("Draft","web-stories")),m===ce.PENDING&&n.createElement(Vl,{isBold:!0},(0,l.__)("Pending","web-stories")),t?.name&&n.createElement(Vl,null,t?.name),n.createElement(Vl,{className:"dashboard-grid-item-date"},g)),n.createElement(Hl,null,a)))};function ql(){return ql=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},ql.apply(this,arguments)}const Xl=(0,h.forwardRef)(((e,t)=>{let{onFocus:a,isActive:r,pageSize:o,renameStory:i,story:s,storyMenu:c}=e;const{userId:d}=y(),u=r?0:-1,p=i?{editMode:i?.id===s?.id,onEditComplete:e=>i?.handleOnRenameStory(s,e),onEditCancel:i?.handleCancelRename}:{},f=(0,h.useMemo)((()=>s?.locked&&d!==s?.lockUser.id),[s,d]),g=(0,h.useMemo)((()=>ml({menuItems:c.menuItems,story:s,isLocked:f})),[c,s,f]),b=Et(s?.status===ce.DRAFT?s?.modifiedGmt:s?.createdGmt),_=Xr(s.title),E=(0,h.useMemo)((()=>g.length?n.createElement(StoryMenu,{menuLabel:f?(0,X.default)(/* translators: 1: story title. 2: user currently editing the story. */
(0,l.__)("Context menu for %1$s (locked by %2$s)","web-stories"),_,s?.lockUser.name):(0,X.default)(/* translators: %s: story title.*/
(0,l.__)("Context menu for %s","web-stories"),_),itemActive:r,tabIndex:u,onMoreButtonSelected:c.handleMenuToggle,contextMenuId:c.contextMenuId,storyId:s.id,isInverted:!0,menuItems:g,menuStyleOverrides:(0,m.css)(["margin:0 0 0 auto;"])}):null),[f,_,s?.lockUser?.name,s.id,r,u,c,g]);return n.createElement(Rl,{"data-testid":`story-grid-item-${s.id}`,onFocus:a,$posterHeight:o.height,ref:t,"aria-label":(0,X.default)(/* translators: %s: story title.*/
(0,l.__)("Details about %s","web-stories"),_)},n.createElement(Nl,null,n.createElement(Bl,null,n.createElement(Pl,ql({},s.featuredMediaUrl?{alt:(0,X.default)(/* translators: %s: Story title. */
(0,l.__)("%s Poster image","web-stories"),_),as:"img",src:s.featuredMediaUrl,decoding:"async"}:null,{width:it,height:ot})),n.createElement(Ol,null),n.createElement(Dl,null,s?.capabilities?.hasEditAction&&n.createElement(Ml,{className:"grid-item-anchor","data-testid":"story-editor-grid-link",tabIndex:u,href:s.editStoryLink},n.createElement(xl.VisuallyHidden,null,(0,X.default)(/* translators: %s: Story title. */
(0,l.__)("Open %s in Editor","web-stories"),_))),n.createElement(Kl,ql({author:s.author,contextMenu:E,displayDate:b,formattedTitle:_,id:s.id,isLocked:f,lockUser:s?.lockUser,status:s?.status,title:s.title},p))))))}));Xl.displayName="StoryGridItem";const Yl=Xl,Zl=(0,m.default)(Zt).withConfig({displayName:"storyGridView__StoryGrid",componentId:"sc-1fwq7hb-0"})(["width:calc(100% - ","px);"],qe),Jl=e=>{let{stories:t,pageSize:a,storyMenu:r,renameStory:o,returnStoryFocusId:i}=e;const{isRTL:s}=y(),c=(0,h.useRef)(),d=(0,h.useRef)(),u=(0,h.useRef)({}),[p,m]=(0,h.useState)(),f=(0,h.useRef)(),g=(0,h.useMemo)((()=>t.map((e=>{let{id:t}=e;return t}))),[t]);(0,Nt.default)({containerRef:c,gridRef:d,itemRefs:u,isRTL:s,currentItemId:p,items:t}),(0,h.useEffect)((()=>{if(!p&&i?.value&&!f.current){const e=i?.value;m(e);const t=u.current?.[e]?.querySelectorAll(["button","a"])?.[0];t?.focus()}}),[p,i]),(0,h.useEffect)((()=>{p&&(f.current=p)}),[p]);const b=(0,h.useCallback)(((e,t)=>{if(r.handleMenuToggle(t),t<0&&9===e?.keyCode){const t=!e?.shiftKey?g[g.indexOf(p)+1]:p;i.set(t),f.current=null,m(null)}}),[p,g,i,r]),_=(0,h.useCallback)((()=>{f.current=null,m(null),i.set(null)}),[i]);(0,h.useFocusOut)(c,(()=>m(null)),[]);const E=(0,h.useMemo)((()=>{const e=[Q,Z,J],t=r.menuItems.map((t=>{const a={...t};return e.includes(t?.value)&&(a.action=e=>{_(),t.action(e)}),a}));return{...r,handleMenuToggle:b,menuItems:t}}),[b,r,_]),S=(0,h.useMemo)((()=>t.map((e=>n.createElement(Yl,{onFocus:()=>m(e.id),isActive:p===e.id,ref:t=>{u.current[e.id]=t},key:e.id,pageSize:a,renameStory:o,story:e,storyMenu:E})))),[p,E,a,o,t]);return n.createElement("div",{ref:c},n.createElement(Zl,{pageSize:a,ref:d,role:"list",ariaLabel:(0,l.__)("Viewing stories","web-stories")},S))},Ql="DELETE_STORY";const eo=function StoriesView(e){let{loading:t,storyActions:a,stories:r,view:o}=e;const[i,s]=(0,h.useState)(-1),[c,d]=(0,h.useState)(-1),[u,p]=(0,h.useState)(""),[m,f]=(0,h.useState)(null),[g,b]=(0,h.useState)({}),[_,y]=(0,h.useState)(null),{showSnackbar:S}=(0,il.useSnackbar)(),w=u===Ql&&m,v=(0,h.useMemo)((()=>r.map((e=>{let{id:t}=e;return t}))),[r]);(0,h.useEffect)((()=>{if(g.id&&!_){const e=v.indexOf(g.id),t=e>0?-1:1,a=g.isDeleted?t:0,r=v[e+a];r&&y(r)}}),[g,_,v]),(0,h.useEffect)((()=>{u||f(null)}),[u,f]),(0,h.useEffect)((()=>{u&&(b({}),y(null))}),[u]);const T=(0,h.useCallback)(((e,t)=>{d(-1),(0,E.trackEvent)("rename_story"),a.updateStory({...e,title:{raw:t}})}),[a]),C=(0,h.useCallback)((()=>{(0,E.trackEvent)("delete_story"),a.trashStory(m),b({id:m.id,isDeleted:!0}),p("")}),[a,m]),I=(0,h.useCallback)((()=>{s(-1),(0,E.trackEvent)("open_in_editor")}),[]),k=(0,h.useCallback)((e=>{s(-1),d(e.id)}),[]),L=(0,h.useCallback)((e=>{s(-1),(0,E.trackEvent)("duplicate_story"),a.duplicateStory(e),b({id:e.id})}),[a]),A=(0,h.useCallback)((e=>{s(-1),f(e),p(Ql)}),[]),x=(0,h.useCallback)((e=>{s(-1),window.navigator.clipboard.writeText(e.link),S({message:(0,X.default)(/* translators: %s: story title. */
(0,l.__)("%s has been copied to your clipboard.","web-stories"),Xr(e.title)),dismissible:!0}),b({id:e.id})}),[S]),O=ae.map((e=>{switch(e?.value){case ee:e.action=x;break;case Q:e.action=A;break;case J:e.action=L;break;case te:e.action=I;break;case Z:e.action=k;break;default:e.action=()=>s(-1)}return e})),D=(0,h.useMemo)((()=>({handleMenuToggle:s,contextMenuId:i,menuItems:O})),[i,O,s]),N=(0,h.useMemo)((()=>({id:c,handleOnRenameStory:T,handleCancelRename:()=>d(-1)})),[T,d,c]),P=(0,h.useMemo)((()=>o.style===Qe.LIST?n.createElement(StoryListView,{hideStoryList:t?.isLoading&&!t?.showStoriesWhileLoading.current,pageSize:o.pageSize,renameStory:N,stories:r,storyMenu:D}):!t?.isLoading||t?.isLoading&&t?.showStoriesWhileLoading.current?n.createElement(Jl,{isLoading:t?.isLoading,pageSize:o.pageSize,renameStory:N,storyMenu:D,stories:r,returnStoryFocusId:{value:_,set:y}}):null),[t,N,_,r,D,o]);return n.createElement(n.Fragment,null,P,t?.isLoading&&!t?.showStoriesWhileLoading.current&&n.createElement(ja,null,n.createElement(dl.default,null)),w&&n.createElement(ya,{isOpen:!0,contentLabel:(0,l.__)("Dialog to confirm deleting a story","web-stories"),title:(0,l.__)("Delete Story","web-stories"),onClose:()=>{b({id:m.id}),p("")},secondaryText:(0,l.__)("Cancel","web-stories"),secondaryRest:{"aria-label":(0,X.default)(/* translators: %s: story title. */
(0,l.__)('Cancel deleting story "%s"',"web-stories"),Xr(m.title))},primaryText:(0,l.__)("Delete","web-stories"),onPrimary:C,primaryRest:{"aria-label":(0,X.default)(/* translators: %s: story title. */
(0,l.__)('Confirm deleting story "%s"',"web-stories"),Xr(m.title))}},n.createElement(Sa.Text.Paragraph,{size:Ya.TextSize.Small},(0,X.default)(/* translators: %s: story title. */
(0,l.__)('Are you sure you want to delete "%s"?',"web-stories"),Xr(m.title)))))};function NoAvailableContent(e){let{filtersObject:t}=e;const{search:a}=t;return a?(0,X.default)(/* translators: %s: search term. */
(0,l.__)('Sorry, we couldn\'t find any results matching "%s"',"web-stories"),a):0!==Object.keys(t).length?(0,l.__)("Sorry, we couldn't find any results","web-stories"):(0,l.__)("Start telling Stories.","web-stories")}NoAvailableContent.propTypes={filtersObject:Rt().object};const to=function(e){let{allPagesFetched:t,canViewDefaultTemplates:a,filtersObject:r={},loading:o,page:i,stories:s,storyActions:c,view:d}=e;return n.createElement(Ua.Scrollable,null,n.createElement(ha,null,s.length>0?n.createElement(n.Fragment,null,n.createElement(eo,{storyActions:c,stories:s,view:d,loading:o}),n.createElement(cl.default,{canLoadMore:!t,isLoading:o?.isLoading,allDataLoadedMessage:(0,l.__)("No more stories","web-stories"),allDataLoadedAriaMessage:(0,l.__)("All stories are loaded","web-stories"),loadingAriaMessage:(0,l.__)("Loading more stories","web-stories"),onLoadMore:i.requestNextPage})):!o?.isLoading&&n.createElement(Fn,null,n.createElement(lr.Headline,{size:Ya.TextSize.Small,as:"h3"},n.createElement(NoAvailableContent,{filtersObject:r})),0===Object.keys(r).length&&a&&n.createElement(Bt.ButtonAsLink,{type:Mt.ButtonType.Primary,size:Mt.ButtonSize.Medium,href:tr(Ye.TEMPLATES_GALLERY)},(0,l.__)("Explore Templates","web-stories")))))};const ao=function(e){return e.reduce(((e,t)=>!t.title||t?.title.trim().length<=0?e:[...e,{label:t.title,value:t.title}]),[])};var ro=a(85934);const no="VERTICAL",lo="COLOR",oo="TAG",io="TITLE";const so=function(e){const t=Object.values(e),a=t.flatMap((e=>e.colors)).map((e=>({label:e.family,value:e.family,type:lo}))),r=t.flatMap((e=>e.tags)).map((e=>({label:e,value:e,type:oo}))),n=t.map((e=>e.vertical)).map((e=>({label:e,value:e,type:no}))),l=t.map((e=>({label:e.title,value:e.title,type:io})));return[...(0,ro.default)(r,"label"),...(0,ro.default)(a,"label"),...(0,ro.default)(n,"label"),...(0,ro.default)(l,"label")]};a(28244);const co=function(e){return t=>!e||e.some((e=>{switch(e?.type){case oo:return t.tags.map((e=>e.toLowerCase())).includes(e.value.toLowerCase());case lo:return t.colors.map((e=>e.label.toLowerCase())).includes(e.value.toLowerCase());case no:return t.vertical.toLowerCase().includes(e.value.toLowerCase());case io:return t.title.toLowerCase().includes(e.value.toLowerCase());default:return!0}}))};var uo=a(50212);const po=(0,m.default)(uo.default).withConfig({displayName:"storyStatusToggle__StyledPill",componentId:"sc-141pqd7-0"})(["margin:0 2px;white-space:nowrap;& > span{padding-left:8px;color:",";}"],(e=>{let{theme:t,isActive:a}=e;return a?t.colors.gray[20]:t.colors.fg.tertiary}));const mo=function StoryStatusToggle(e){let{initialPageReady:t,totalStoriesByStatus:a,currentStatus:r}=e;const{updateFilter:o,registerFilters:i}=wn((e=>{let{actions:{updateFilter:t,registerFilters:a}}=e;return{updateFilter:t,registerFilters:a}})),s=(0,h.useCallback)((e=>{o("status",{filterId:e})}),[o]);(0,h.useEffect)((()=>{i([{key:"status",filterId:me.filters.status}])}),[i]);const c=(0,h.useMemo)((()=>Object.keys(a).reduce(((e,t)=>e+a[t]),0)),[a]),d=(0,h.useMemo)((()=>ue.filter((e=>{let{status:t}=e;return Boolean(t in a)&&a[t]>0||t===r})).map((e=>{let{label:t,status:n,value:o}=e;const i=a[n],s=Boolean(!i);return{ariaLabel:(0,X.default)(/* translators: %s is story status */
(0,l.__)("Filter stories by %s","web-stories"),t),disabled:s,isActive:r===o,value:o,label:t,count:i}}))),[a,r]);return!t||!c||a&&0===Object.keys(a).length?null:n.createElement(n.Fragment,null,d.map((e=>{let{ariaLabel:t,disabled:a,isActive:r,value:l,label:o,count:i}=e;return n.createElement(po,{key:l,onClick:()=>s(l),isActive:r,disabled:a,"aria-label":t},o,n.createElement("span",null,i))})))};const fo=(0,h.memo)((function(e){let{initialPageReady:t,stories:a,totalStoriesByStatus:r,view:o}=e;const i=(0,h.useMemo)((()=>ao(a)),[a]),{filters:s,sortObject:c,updateFilter:d,updateSort:u,registerFilters:p}=wn((e=>{let{state:{filters:t,sortObject:a},actions:{updateFilter:r,updateSort:n,registerFilters:l}}=e;return{filters:t,updateFilter:r,sortObject:a,updateSort:n,registerFilters:l}})),[m,f,g]=(0,h.useMemo)((()=>{const e=s.find((e=>{let{key:t}=e;return"status"===t})),t=s.find((e=>{let{key:t}=e;return"search"===t}));return[s.filter((e=>{let{key:t}=e;return!["status","search"].includes(t)})),e?.filterId,t?.filterId]}),[s]),b=(0,h.useMemo)((()=>(f?.split(",")||[]).reduce(((e,t)=>e+(r[t]||0)),0)),[f,r]),_=Qr({currentFilter:f,isActiveSearch:Boolean(g),totalResults:b,view:tt}),y=(0,h.useDebouncedCallback)((async e=>{await(0,E.trackEvent)("search",{search_type:"dashboard",search_term:e}),d("search",{filterId:e})}),lt);(0,h.useEffect)((()=>{p([{key:"search"}])}),[p]);const S=(0,h.useCallback)((()=>d("search",{filterId:null})),[d]);return n.createElement(n.Fragment,null,n.createElement(ll,{heading:(0,l.__)("Dashboard","web-stories"),searchPlaceholder:(0,l.__)("Search Stories","web-stories"),searchOptions:i,handleSearchChange:y,showSearch:t,searchValue:g,onClear:S},n.createElement(mo,{initialPageReady:t,totalStoriesByStatus:r,currentStatus:f})),n.createElement(BodyViewOptions,{showGridToggle:!0,filters:m,showSortDropdown:!0,resultsLabel:_,layoutStyle:o.style,handleLayoutSelect:o.toggleStyle,pageSortOptions:ie,pageSortDefaultOption:ne.LAST_MODIFIED,handleSortChange:u,currentSort:c}))}));function MyStoriesView(){const{duplicateStory:e,fetchStories:t,trashStory:a,updateStory:r,allPagesFetched:l,isLoading:o,stories:i,storiesOrderById:s,totalPages:c,totalStoriesByStatus:d}=hn((e=>{let{actions:{storyApi:{duplicateStory:t,fetchStories:a,trashStory:r,updateStory:n}},state:{stories:{allPagesFetched:l,isLoading:o,stories:i,storiesOrderById:s,totalPages:c,totalStoriesByStatus:d}}}=e;return{duplicateStory:t,fetchStories:a,trashStory:r,updateStory:n,allPagesFetched:l,isLoading:o,stories:i,storiesOrderById:s,totalPages:c,totalStoriesByStatus:d}})),{filtersObject:u,sortObject:p}=wn((e=>{let{state:{filtersObject:t,sortObject:a}}=e;return{filtersObject:t,sortObject:a}})),{apiCallbacks:m,canViewDefaultTemplates:f}=y(),g=(0,h.useRef)(!1);(0,h.useEffect)((()=>(g.current=!0,()=>{g.current=!1})),[]);const{page:b,view:_,showStoriesWhileLoading:S,initialPageReady:w}=function(e){let{filtersObject:t=me.filters,sortObject:a=me.sort,isLoading:r=!1,totalPages:n}=e;const[l,o]=(0,h.useState)(Qe.GRID),[i,s]=(0,h.useState)(a),[c,d]=(0,h.useState)(t),[u,p]=(0,h.useState)(1),m=(0,h.useRef)(!1),[f,g]=(0,h.useState)(!1),{pageSize:b}=nn({thumbnailMode:l===Qe.LIST,isGrid:l===Qe.GRID}),_=(0,h.useCallback)((e=>{p(ln(e,{MIN:1,MAX:n}))}),[n]),y=(0,h.useCallback)((e=>{s(e),_(1)}),[_]),S=(0,h.useCallback)((e=>{d(e),_(1)}),[_]),w=(0,h.useCallback)((()=>{const e=l===Qe.LIST?Qe.GRID:Qe.LIST;o(e)}),[l,o]),v=(0,h.useCallback)((()=>{m.current=!0,_(u+1)}),[u,_]);return(0,h.useEffect)((()=>{c?.search?.length&&(0,E.trackEvent)("search",{search_type:"dashboard_stories",search_term:c.search,search_filter:c.status,search_author_filter:c.author,search_order:i.order,search_orderby:i.orderby,search_view:l})}),[c,i,l]),(0,h.useEffect)((()=>{r||(m.current=!1)}),[r]),(0,h.useEffect)((()=>{n&&!f&&g(!0)}),[n,f]),(0,h.useEffect)((()=>{f&&S(t)}),[S,f,t]),(0,h.useEffect)((()=>{f&&y(a)}),[y,f,a]),(0,h.useMemo)((()=>({view:{style:l,toggleStyle:w,pageSize:b},sort:{value:i.orderby,direction:i.order,set:y},filters:{value:c,set:S},page:{value:u,set:p,requestNextPage:v},initialPageReady:f,showStoriesWhileLoading:m
(0,l.__)("First page of %s template","web-stories"),u);return n.createElement(ua,{ref:t,id:`template-grid-item-${i}`,className:"templateGridItem","data-testid":`template-grid-item-${i}`,$posterHeight:o,onFocus:r},n.createElement(Nl,null,n.createElement(yo,{$isSelected:s},n.createElement(So,null,n.createElement("source",{srcSet:c?.webp,type:"image/webp"}),n.createElement("source",{srcSet:c?.png,type:"image/png"}),n.createElement("img",{src:c?.png,alt:g,decoding:"async",width:it,height:ot})),n.createElement(Ol,null),n.createElement(Dl,{"data-testid":"card-action-container","data-template-slug":d},n.createElement(Eo,null,n.createElement(vo,{ariaLabel:(0,X.default)(/* translators: %s: template title.*/
(0,l.__)("Go to detail view of %s","web-stories"),u),onClick:()=>m(i,u),className:wo,tabIndex:f},Fe[p]),a&&n.createElement(Bt.Button,{size:Mt.ButtonSize.Small,type:Mt.ButtonType.Primary,onClick:a,tabIndex:f,ariaLabel:(0,X.default)(/* translators: %s: template title.*/
(0,l.__)("Create new story from %s","web-stories"),u)},(0,l.__)("Use template","web-stories")))))))}));To.displayName="TemplateGridItem";const Co=To;const Io=function TemplateGridView(e){let{pageSize:t,templates:a,templateActions:r}=e;const{isRTL:o,apiCallbacks:i}=y(),s=(0,h.useRef)(),c=(0,h.useRef)(),d=(0,h.useRef)({}),[u,p]=(0,h.useState)(null),{handleDetailsToggle:m,createStoryFromTemplate:f}=r||{},g=Boolean(i?.createStoryFromTemplate);(0,Nt.default)({containerRef:s,gridRef:c,itemRefs:d,isRTL:o,currentItemId:u,items:a}),(0,h.useEffect)((()=>{u&&d.current?.[u]?.querySelector(`.${wo}`)?.focus()}),[u]),(0,h.useFocusOut)(s,(()=>p(null)),[]);const b=(0,h.useMemo)((()=>a.map((e=>{let{id:a,slug:r,status:l,title:o,postersByPage:i}=e;const s=u===a,c=i?.[0];return n.createElement(Co,{onCreateStory:g?()=>f(a):on,onFocus:()=>{p(a)},onSeeDetailsClick:m,height:t.height,id:a,isActive:s,key:r,posterSrc:c,ref:e=>{d.current[a]=e},slug:r,status:l,title:o})}))),[a,u,g,m,t.height,f]);return n.createElement("div",{ref:s},n.createElement(Zt,{pageSize:t,role:"list",ref:c,ariaLabel:(0,l.__)("Viewing available templates","web-stories")},b))};const ko=function(e){let{allPagesFetched:t,isLoading:a,page:r,templates:o,view:i,totalTemplates:s,search:c,templateActions:d}=e;const{newStoryURL:u}=y(),p=(0,h.useMemo)((()=>a?n.createElement(ja,null,n.createElement(dl.default,null)):s>0?n.createElement(n.Fragment,null,n.createElement(Io,{templates:o,pageSize:i.pageSize,templateActions:d}),n.createElement(cl.default,{canLoadMore:!t,isLoading:a,allDataLoadedMessage:(0,l.__)("No more templates","web-stories"),allDataLoadedAriaMessage:(0,l.__)("All templates are loaded","web-stories"),loadingAriaMessage:(0,l.__)("Loading more templates","web-stories"),onLoadMore:r.requestNextPage})):n.createElement(Fn,null,n.createElement(lr.Headline,{size:Ya.TextSize.Small,as:"h3"},c?(0,X.default)(/* translators: %s: search term. */
(0,l.__)('Sorry, we couldn\'t find any results matching "%s"',"web-stories"),c):(0,l.__)("No templates currently available.","web-stories")),!c&&n.createElement(Bt.ButtonAsLink,{type:Mt.ButtonType.Primary,size:Mt.ButtonSize.Medium,href:u},(0,l.__)("Create New Story","web-stories")))),[t,a,u,r.requestNextPage,d,c,o,s,i.pageSize]);return n.createElement(Ua.Scrollable,null,n.createElement(ha,null,p))};const Lo=function(e){let{isLoading:t,totalTemplates:a,view:r,searchOptions:o=[]}=e;const i=(0,g.useFeature)("enableInProgressTemplateActions"),{filters:s,sortObject:c,updateFilter:d,updateSort:u,registerFilters:p}=_o((e=>{let{state:{filters:t,sortObject:a},actions:{updateFilter:r,updateSort:n,registerFilters:l}}=e;return{filters:t,sortObject:a,updateFilter:r,updateSort:n,registerFilters:l}})),[m,f]=(0,h.useMemo)((()=>{const e=s.find((e=>{let{key:t}=e;return"status"===t})),t=s.find((e=>{let{key:t}=e;return"search"===t}));return[e?.filterId,t?.filterId]}),[s]),b=(0,h.useDebouncedCallback)((e=>{d("search",{filterId:e})}),lt);(0,h.useEffect)((()=>{p([{key:"search"}]),p([{key:"status",filterId:Me.filters.status}])}),[p]);const _=(0,h.useCallback)((()=>d("search",{filterId:null})),[d]),y=Qr({totalResults:a,currentFilter:m,view:at});return n.createElement(n.Fragment,null,n.createElement(ll,{heading:(0,l.__)("Explore Templates","web-stories"),searchPlaceholder:(0,l.__)("Search Templates","web-stories"),showSearch:!0,searchOptions:o,searchValue:f,handleSearchChange:b,onClear:_}),n.createElement(BodyViewOptions,{resultsLabel:y,layoutStyle:r.style,handleLayoutSelect:r.toggleStyle,isLoading:t,pageSortOptions:Ue,pageSortDefaultOption:Re.POPULAR,currentSort:c,handleSortChange:u,showSortDropdown:i,sortDropdownAriaLabel:(0,l.__)("Choose sort option for display","web-stories")}))};var Ao,xo=a(95735);function Oo(){return Oo=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},Oo.apply(this,arguments)}const SvgCrossLarge=e=>{let{title:t,titleId:a,...r}=e;return n.createElement("svg",Oo({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 32 32","aria-labelledby":a},r),t?n.createElement("title",{id:a},t):null,Ao||(Ao=n.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M25.146 25.854a.5.5 0 0 0 .708-.708L16.707 16l9.147-9.146a.5.5 0 0 0-.708-.708L16 15.293 6.854 6.146a.5.5 0 1 0-.708.708L15.293 16l-9.147 9.146a.5.5 0 0 0 .708.708L16 16.707l9.146 9.147Z",clipRule:"evenodd"})))},Do=(0,n.memo)(SvgCrossLarge),No=m.default.nav.withConfig({displayName:"header__Nav",componentId:"sc-1wko3r4-0"})(["justify-content:space-between;align-items:center;display:flex;margin:48px auto;width:calc(76% + 121px);"]),Po=(0,m.default)(Bt.Button).attrs({type:Mt.ButtonType.Primary,size:Mt.ButtonSize.Small}).withConfig({displayName:"header__CTAButton",componentId:"sc-1wko3r4-1"})(["padding:10px 16px;"]);const Ro=function(e){let{templateTitle:t,templateId:a,templateActions:r,canCreateStory:o}=e;const{createStoryFromTemplate:i,handleDetailsToggle:s}=r||{};return n.createElement(No,null,n.createElement(Bt.Button,{type:Mt.ButtonType.Tertiary,variant:Mt.ButtonVariant.Square,size:Mt.ButtonSize.Small,"aria-label":(0,l.__)("Close","web-stories"),onClick:s},n.createElement(Do,null)),o&&n.createElement(Po,{onClick:()=>i(a),"aria-label":(0,X.default)(/* translators: %s: template title */
(0,l.__)("Use %s template to create new story","web-stories"),t)},(0,l.__)("Use template","web-stories")))};var Bo,Mo=a(63094),Uo=a(2039);function Fo(){return Fo=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},Fo.apply(this,arguments)}const SvgArrowRightLarge=e=>{let{title:t,titleId:a,...r}=e;return n.createElement("svg",Fo({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 32 32","aria-labelledby":a},r),t?n.createElement("title",{id:a},t):null,Bo||(Bo=n.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M16.355 6.146a.5.5 0 1 0-.707.708l8.647 8.647H6.5a.5.5 0 1 0 0 1h17.795l-8.647 8.648a.5.5 0 0 0 .707.707l9.49-9.49a.498.498 0 0 0 0-.73l-9.49-9.49Z",clipRule:"evenodd"})))},zo=(0,n.memo)(SvgArrowRightLarge),Go=m.default.section.withConfig({displayName:"templateDetails__Panel",componentId:"sc-1cvs5jb-0"})(["padding:16vh 0 14vh 0;"]),Ho=m.default.div.withConfig({displayName:"templateDetails__Container",componentId:"sc-1cvs5jb-1"})(["position:relative;width:76%;max-width:","px;margin:0 auto;"],1459.2),jo=m.default.div.withConfig({displayName:"templateDetails__Inner",componentId:"sc-1cvs5jb-2"})(["display:flex;align-items:start;"]),Vo=m.default.section.attrs({"aria-label":(0,l.__)("Template Details","web-stories")}).withConfig({displayName:"templateDetails__DetailContainer",componentId:"sc-1cvs5jb-3"})(["padding:0 0 0 60px;margin-right:auto;"]),$o=m.default.div.withConfig({displayName:"templateDetails__TemplateDetails",componentId:"sc-1cvs5jb-4"})(["position:relative;display:flex;width:500px;"]),Wo=(m.default.section.attrs({"aria-label":(0,l.__)("Related Templates","web-stories")}).withConfig({displayName:"templateDetails__RowContainer",componentId:"sc-1cvs5jb-5"})(["display:flex;flex-wrap:wrap;padding-bottom:40px;margin:0 80px 0;& > h3{padding-bottom:32px;}& > div{width:100%;}"]),(0,m.default)(Go).withConfig({displayName:"content__StyledPanel",componentId:"sc-jxjpbh-0"})(["padding:0 0 48px 0;"])),Ko=(0,m.default)(Sa.Text.Paragraph).withConfig({displayName:"content__ByLineText",componentId:"sc-jxjpbh-1"})(["color:",";margin:8px 0 24px;"],(e=>{let{theme:t}=e;return t.colors.fg.tertiary})),qo=(0,m.default)(Sa.Text.Paragraph).withConfig({displayName:"content__DescriptionText",componentId:"sc-jxjpbh-2"})(["margin-bottom:24px;"]),Xo=m.default.div.withConfig({displayName:"content__PaginationContainer",componentId:"sc-jxjpbh-3"})(["position:absolute;top:","px;",""],235,(e=>{let{alignLeft:t}=e;return t?"\n left: 0;\n transform: translate(-187.5%, -50%);\n ":"\n right: 0;\n transform: translate(187.5%, -50%);\n "})),Yo=(0,m.default)(Mo.default).attrs({forwardedAs:"li"}).withConfig({displayName:"content__TemplateTag",componentId:"sc-jxjpbh-4"})(["margin-right:12px;margin-bottom:12px;> span{color:"," !important;}"],(e=>{let{theme:t}=e;return t.colors.fg.primary})),Zo=m.default.div.withConfig({displayName:"content__MetadataContainer",componentId:"sc-jxjpbh-5"})(["margin-bottom:24px;display:flex;flex-wrap:wrap;align-items:center;"]);const Jo=function DetailsContent(e){let{activeTemplateIndex:t,isRTL:a,filteredTemplatesLength:r,switchToTemplateByOffset:o,template:i}=e;const{postersByPage:s,title:c,description:d,tags:u,colors:p}=i||{},[m,f]=(0,h.useState)([]);(0,h.useEffect)((()=>{s&&f(Object.values(s).map(((e,t)=>({id:t,...e}))))}),[s]);const{NextButton:g,PrevButton:b}=(0,h.useMemo)((()=>{const e=a?t-1:t+1,i=a?t+1:t-1,s=a?!r||t===r-1:!r||0===t,c=a?!r||0===t:!r||t===r-1,d=n.createElement(Bt.Button,{type:Mt.ButtonType.Tertiary,size:Mt.ButtonSize.Small,variant:Mt.ButtonVariant.Square,"aria-label":(0,l.__)("View previous template","web-stories"),onClick:()=>{o(i),f([])},disabled:s},n.createElement(Uo.default,{height:32,width:32})),u=n.createElement(Bt.Button,{type:Mt.ButtonType.Tertiary,size:Mt.ButtonSize.Small,variant:Mt.ButtonVariant.Square,"aria-label":(0,l.__)("View next template","web-stories"),onClick:()=>{o(e),f([])},disabled:c},n.
(0,l.__)("By %s","web-stories"),i.createdBy):null;return n.createElement(Wo,null,n.createElement(Ho,null,n.createElement(Xo,{alignLeft:!0},b),n.createElement(jo,null,n.createElement(Vt,{galleryPosters:m,isRTL:a,galleryLabel:(0,l.__)("Template details by page","web-stories")}),n.createElement($o,null,n.createElement(Vo,null,n.createElement(Gn,{size:Ya.TextSize.Small,as:"h3","data-testid":"template-details-title"},c),n.createElement(Ko,{size:Ya.TextSize.Medium},_),n.createElement(qo,{size:Ya.TextSize.Medium},d),n.createElement(Zo,{role:"list","aria-label":(0,l.__)("Template tags","web-stories")},u.map((e=>n.createElement(Yo,{key:e,disabled:!0},e)))),n.createElement(Zo,null,n.createElement(ga,{colors:p,size:32,"aria-label":(0,l.__)("Template colors","web-stories")}))))),n.createElement(Xo,null,g)))};const Qo=function TemplateDetailsModal(e){let{activeTemplateIndex:t,activeTemplate:a,filteredTemplatesLength:r,isDetailsViewOpen:o,templateActions:s}=e;const{isRTL:c,apiCallbacks:d}=y(),u=Boolean(d?.createStoryFromTemplate),{handleDetailsToggle:p,switchToTemplateByOffset:m}=s||{};return n.createElement(xo.default,{isOpen:o,onClose:p,contentLabel:(0,X.default)(/* translators: %s: template title */
(0,l.__)("Template Details for %s","web-stories"),a?.title),overlayStyles:{backgroundColor:`${i.theme.colors.opacity.overlayDark}`},contentStyles:{display:"block",height:"90vh",width:"90vw",backgroundColor:`${i.theme.colors.standard.white}`}},n.createElement(Ro,{templateTitle:a?.title,templateId:a?.id,templateActions:s,canCreateStory:u}),n.createElement(Jo,{activeTemplateIndex:t,isRTL:c,filteredTemplatesLength:r,switchToTemplateByOffset:m,template:a}))};function ExploreTemplatesView(){const e=(0,Zn.default)(),[t,a]=(0,h.useState)(!1),[r,o]=(0,h.useState)(null),[i,s]=(0,h.useState)(0),{templateIdParam:c,replace:d}=er((e=>{let{actions:t,state:a}=e;return{templateIdParam:a.queryParams.id,replace:t.replace}})),u=(0,h.useRef)(c),{allPagesFetched:p,isLoading:m,templates:f,templatesOrderById:g,totalPages:b,totalTemplates:_,createStoryFromTemplate:y,fetchExternalTemplates:S}=hn((e=>{let{state:{templates:{allPagesFetched:t,isLoading:a,templates:r,templatesOrderById:n,totalPages:l,totalTemplates:o}},actions:{storyApi:{createStoryFromTemplate:i},templateApi:{fetchExternalTemplates:s}}}=e;return{allPagesFetched:t,isLoading:a,templates:r,templatesOrderById:n,totalPages:l,totalTemplates:o,createStoryFromTemplate:i,fetchExternalTemplates:s}})),{filters:w,sortObject:v,filtersObject:T}=_o((e=>{let{state:{filters:t,sortObject:a,filtersObject:r}}=e;return{filters:t,sortObject:a,filtersObject:r}})),{page:C,view:I}=function(e){let{totalPages:t,sortObject:a=Me.sort,filtersObject:r=Me.filters}=e;const[n,l]=(0,h.useState)(a),[o,i]=(0,h.useState)(r),[s,c]=(0,h.useState)(1),{pageSize:d}=nn({isGrid:!0}),u=(0,h.useCallback)((e=>{c(ln(e,{MIN:1,MAX:t}))}),[t]),p=(0,h.useCallback)((()=>u(s+1)),[s,u]),m=(0,h.useCallback)((e=>{l(e),u(1)}),[u]),f=(0,h.useCallback)((e=>{i(e),u(1)}),[u]);return(0,h.useMemo)((()=>({view:{style:Qe.GRID,pageSize:d},sort:{value:n.orderby,direction:n.order,set:m},filters:{value:o,set:f},page:{value:s,set:c,requestNextPage:p}})),[d,n,m,s,p,o,f])}({filtersObject:T,sortObject:v,totalPages:b}),[k]=(0,h.useMemo)((()=>{const e=w.find((e=>{let{key:t}=e;return"search"===t}));return[e?.filterId]}),[w]),L=(0,h.useMemo)((()=>so(f)),[f]),A=(0,h.useMemo)((()=>k?L.filter((e=>e.label.toLowerCase().includes(k.toLowerCase()))):L),[L,k]),x=(0,h.useMemo)((()=>g.map((e=>f[e])).filter(co(A))),[g,f,A]),O=(0,h.useMemo)((()=>_!==x.length?x.length:_),[x,_]),D=(0,h.useMemo)((()=>(0,ro.default)(A,"label")),[A]),N=(0,h.useCallback)((e=>{const t=f[e];(0,E.trackEvent)("use_template",{name:t.title,template_id:t.id}),y(t)}),[y,f]),P=(0,h.useCallback)((e=>{const t=x.find((t=>t.id===e));o(t),s(x.findIndex((t=>t.id===e))),u.current&&(u.current=void 0),d(`?id=${t.id}&isLocal=${t.isLocal}`)}),[d,x]),R=(0,h.useCallback)(((t,r)=>{a((a=>{const n=!a;return r&&(0,E.trackScreenView)(r),n&&t&&P(t),n||(d(""),e((0,l.__)("Exit detail templates view","web-stories"))),n}))}),[d,e,P]),B=(0,h.useCallback)((t=>{const a=x[t];o(a),s(t),d(`?id=${a.id}&isLocal=${a.isLocal}`),e((0,X.default)(/* translators: %s: template title */
(0,l.__)("Viewing %s","web-stories"),a.title))}),[x,d,e]),M=(0,h.useMemo)((()=>({createStoryFromTemplate:N,handleDetailsToggle:R,switchToTemplateByOffset:B})),[N,R,B]);return(0,h.useEffect)((()=>{S()}),[S]),(0,h.useEffect)((()=>{if(u.current&&x.length){if(!x.some((e=>e.id===parseInt(u.current))))return void d("");a(!0),P(parseInt(u.current))}}),[x,d,P]),n.createElement(Ua.Provider,null,n.createElement(Lo,{isLoading:m&&!_,totalTemplates:O,searchOptions:D,view:I}),n.createElement(ko,{isLoading:m,allPagesFetched:p,page:C,templates:x,totalTemplates:O,search:k,view:I,templateActions:M}),n.createElement(Ua.Fixed,null,n.createElement(vr,null)),n.createElement(Qo,{activeTemplate:r,activeTemplateIndex:i,isDetailsViewOpen:t,templateActions:M,filteredTemplatesLength:x.length}))}function ExploreTemplates(){return n.createElement(TemplateFiltersProvider,null,n.createElement(ExploreTemplatesView,null))}const ei=function(){const{storyError:e,templateError:t}=hn((e=>{let{state:{stories:{error:t},templates:{error:a}}}=e;return{storyError:t,templateError:a}})),{showSnackbar:a}=(0,il.useSnackbar)(),r=(0,h.useDebouncedCallback)((e=>a({message:e,dismissible:!0})),200);(0,h.useEffect)((()=>{e?.id&&r(e.message)}),[e,r]),(0,h.useEffect)((()=>{t?.id&&r(t.message)}),[t,r])};function ti(){return ti=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},ti.apply(this,arguments)}const ai=e=>{let{additionalRoutes:t}=e;const{currentPath:a,templateId:r,availableRoutes:o}=er((e=>{let{state:t}=e;return{...t,templateId:t.queryParams.id}})),{push:i,setAvailableRoutes:s}=er((e=>{let{actions:t}=e;return t})),{canViewDefaultTemplates:c,leftRailSecondaryNavigation:d=[],documentTitleSuffix:u=(0,l.__)("Web Stories","web-stories")}=y(),{addInitialFetchListener:p}=hn((e=>{let{actions:{storyApi:{addInitialFetchListener:t}},state:{templates:{templates:a}}}=e;return{currentTemplate:void 0!==r?a[r]?.title:void 0,addInitialFetchListener:t}})),m=(0,h.useRef)(a===Ye.DASHBOARD),[f,g]=(0,h.useState)(!m.current);(0,h.useEffect)((()=>p?.((e=>{e?.all<=0&&m.current&&c&&(i(Ye.TEMPLATES_GALLERY),m.current=!1),g(!0)}))),[p,i,a,c]),(0,h.useEffect)((()=>{if(o.length>0)return;const e=t?t.map((e=>{let{path:t}=e;return t})):[];s([...Object.values(Ye),...e])}),[t,o.length,s]),(0,h.useEffect)((()=>{if(!f)return;const e=d.find((e=>e.value===a)),t=Ze[a]||e?.label||Ze.DEFAULT;document.title=(0,X.default)(/* translators: Admin screen title. 1: Admin screen name, 2: Network or site name. */
(0,l.__)("%1$s %2$s","web-stories"),t,u),(0,E.trackScreenView)(t)}),[a,f,d,u]),ei();const{clearSnackbar:b,removeSnack:_,placement:S,currentSnacks:w}=(0,il.useSnackbar)(),v=(0,h.usePrevious)(a);return(0,h.useEffect)((()=>{a!==v&&b()}),[b,a,v]),n.createElement(n.Fragment,null,n.createElement(za,null,n.createElement(hr,null),n.createElement(Ga,null,o.length>0&&n.createElement(n.Fragment,null,n.createElement(ar,{exact:!0,isDefault:!0,path:Ye.DASHBOARD,component:n.createElement(MyStories,null)}),c&&n.createElement(ar,{path:Ye.TEMPLATES_GALLERY,component:n.createElement(ExploreTemplates,null)}),t&&t.map((e=>n.createElement(ar,ti({key:e.path},e))))))),n.createElement(sl.default,{notifications:w,onRemove:_,placement:S,max:1}))};var ri=a(15705),ni=a(19167),li=a(88272);window.wp.domReady;a(20691);function oi(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"https";return/^(http:\/\/|https:\/\/|tel:|mailto:)/.test(e)?e:`${t}://${e}`}var ii=a(20886);const si=window.wp.apiFetch,ci=["id","title","status","date","date_gmt","modified","modified_gmt","story_poster","link","preview_link","edit_link","_links","_embedded","body","status","headers"].join(","),di=["id","title"],ui=["title","link"],pi="wp:lock,author",mi={EDIT:"wp:action-edit",DELETE:"wp:action-delete"};function fi(e){const{id:t,title:a,status:r,date:n,date_gmt:l,modified:o,modified_gmt:i,link:s,preview_link:c,edit_link:d,story_poster:u,_embedded:{author:p,"wp:lock":m}={},_links:f={}}=e;if(!t)return null;const{locked:g=!1,user:h={id:0,name:""}}=m?.[0]||{},b=p?.[0]||{id:0,name:""},_={hasEditAction:Object.prototype.hasOwnProperty.call(f,mi.EDIT),hasDeleteAction:Object.prototype.hasOwnProperty.call(f,mi.DELETE)};return{id:t,status:r,title:a.raw,created:n,createdGmt:`${l}Z`,modified:o,modifiedGmt:`${i}Z`,author:{id:b.id,name:b.name},locked:g,lockUser:{...h,avatar:h?.avatar?.[96]||null},bottomTargetAction:d,featuredMediaUrl:u?.url,editStoryLink:d,previewLink:c,link:s,capabilities:_}}function gi(e,t){const{page:a=1,perPage:r=nt,filters:n={},sort:l={}}=t,o={...{_embed:pi,context:"edit",_web_stories_envelope:!0,_fields:ci,...me.filters,...me.sort},page:a,per_page:r,...n,...l};return si({path:(0,ii.default)(e.api.stories,o)}).then((e=>{let{body:t,headers:a}=e;const r=a&&parseInt(a["X-WP-TotalPages"]),n=a&&JSON.parse(a["X-WP-TotalByStatus"]),l=[];return{stories:t.reduce(((e,t)=>t?(l.push(t.id),e[t.id]=fi(t),e):e),{}),fetchedStoryIds:l,totalPages:r,totalStoriesByStatus:n}}))}function hi(e,t){const a=(0,ii.default)(`${e.api.stories}${t}`,{_method:"DELETE"});return si({path:a,method:"POST"})}function bi(e,t){const a=(0,ii.default)(`${e.api.stories}${t.id}/`,{_embed:pi}),r={id:t.id,author:t.author.id,title:t.title?.raw||t.title};return si({path:a,data:r,method:"POST"}).then(fi)}const _i=(e,t)=>{const a=(0,ii.default)(e.api.stories,{_fields:"edit_link"}),{pages:r,version:n,colors:l}=t,o={featuredMedia:{id:0,url:""},publisherLogo:{url:""},title:""},i={pages:r,featuredMedia:o.featuredMedia,title:o.title,status:"auto-draft",meta:{web_stories_publisher_logo:o.publisherLogo.id}},s=l.map((e=>{let{color:t}=e;return(0,pa.default)(t)})),{globalPageDuration:c=7,globalAutoAdvance:d=!0}=e;return si({path:a,data:{...i,story_data:{pages:r,version:n,autoAdvance:d,defaultPageDuration:c,currentStoryStyles:{colors:s}}},method:"POST"}).then(ni.snakeToCamelCaseObjectKeys)};function yi(e,t){const a=(0,ii.default)(e.api.stories,{_embed:pi,_fields:ci});return si({path:a,data:{original_id:t.id,status:"draft"},method:"POST"}).then(fi)}function Ei(e,t){return si({path:(0,ii.default)(e.api.users,{per_page:"100",capabilities:e.editPostsCapabilityName,search:t})})}async function Si(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=await si({path:(0,ii.default)(e.api.taxonomies,{type:"web-story",context:"edit",...t})});return Object.values(a).map((e=>(e.restPath=e._links?.["wp:items"]?.[0]?.href,delete e._links,(0,ni.snakeToCamelCaseObjectKeys)(e,["capabilities","visibility"]))))}function wi(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return si({url:(0
(0,l.__)("Example: %s","web-stories"),"/123456789/a4a/amp_story_dfp_example"),SLOT_ID_PLACEHOLDER:(0,l.__)("Enter your Slot ID","web-stories"),SLOT_ID_LABEL:(0,l.__)("Google Ad Manager Slot ID","web-stories"),INPUT_ERROR:(0,l.__)("Invalid ID format","web-stories"),SUBMIT_BUTTON:(0,l.__)("Save","web-stories")};const Ts=function GoogleAdManagerSettings(e){let{slotId:t,handleUpdate:a}=e;const[r,l]=(0,h.useState)(t),[o,i]=(0,h.useState)(""),s=r!==t&&!o,c=!s;(0,h.useEffect)((()=>{l(t)}),[t]);const d=(0,h.useCallback)((e=>{const{value:t}=e.target;l(t),0===t.length||function(){return Boolean((arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").toLowerCase().match(ws))}(t)?i(""):i(vs.INPUT_ERROR)}),[]),u=(0,h.useCallback)((()=>{s&&a(r)}),[s,r,a]),p=(0,h.useCallback)((e=>{"Enter"===e.key&&(e.preventDefault(),u())}),[u]);return n.createElement(n.Fragment,null,n.createElement(gs,null,n.createElement(hs,{htmlFor:"adManagerSlotId"},vs.SLOT_ID_LABEL),n.createElement(bs,{id:"adManagerSlotId","aria-label":vs.SLOT_ID_LABEL,value:r,onChange:d,onKeyDown:p,placeholder:vs.SLOT_ID_PLACEHOLDER,hasError:Boolean(o),hint:o}),n.createElement(ms,{type:Mt.ButtonType.Secondary,size:Mt.ButtonSize.Small,disabled:c,onClick:u},vs.SUBMIT_BUTTON)),n.createElement(rs,{size:Ya.TextSize.Small},vs.SLOT_ID_CONTEXT))},Cs=/^(ca-)?pub-\d{16}$/;const Is=/^\d{10}$/;const ks={PUBLISHER_ID_CONTEXT:(0,X.default)(/* translators: 1: first example. 2: second example. */
(0,l.__)("Example: %1$s or %2$s. <a>Find your AdSense Publisher ID</a>.","web-stories"),"pub-1234567891234567","ca-pub-1234567891234567"),PUBLISHER_ID_CONTEXT_LINK:(0,l.__)("https://support.google.com/adsense/answer/105516","web-stories"),PUBLISHER_ID_PLACEHOLDER:(0,l.__)("Enter your Publisher ID","web-stories"),PUBLISHER_ID_LABEL:(0,l.__)("Google AdSense Publisher ID","web-stories"),SLOT_ID_CONTEXT:(0,X.default)(/* translators: %s: example value. */
(0,l.__)("Example: %s. Copy the slot ID from <a>your ad units code</a>. The same ad unit will be used for all of your Web Stories.","web-stories"),"1234567890"),SLOT_ID_CONTEXT_LINK:(0,l.__)("https://support.google.com/adsense/answer/9274019","web-stories"),SLOT_ID_PLACEHOLDER:(0,l.__)("Enter your Slot ID","web-stories"),SLOT_ID_LABEL:(0,l.__)("Google AdSense Slot ID","web-stories"),INPUT_ERROR:(0,l.__)("Invalid ID format","web-stories"),SUBMIT_BUTTON:(0,l.__)("Save","web-stories")};const Ls=function GoogleAdSenseSettings(e){let{publisherId:t,slotId:a,handleUpdatePublisherId:r,handleUpdateSlotId:l}=e;const[o,i]=(0,h.useState)(t),[s,c]=(0,h.useState)(""),d=o!==t&&!s,u=!d,[p,m]=(0,h.useState)(a),[f,g]=(0,h.useState)(""),b=p!==a&&!f,_=!b;(0,h.useEffect)((()=>{i(t)}),[t]);const y=(0,h.useCallback)((e=>{const{value:t}=e.target;i(t),0===t.length||function(){return Boolean((arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").toLowerCase().match(Cs))}(t)?c(""):c(ks.INPUT_ERROR)}),[]),S=(0,h.useCallback)((()=>{d&&r(o)}),[d,o,r]),w=(0,h.useCallback)((e=>{"Enter"===e.key&&(e.preventDefault(),S())}),[S]);(0,h.useEffect)((()=>{m(a)}),[a]);const v=(0,h.useCallback)((e=>{const{value:t}=e.target;m(t),0===t.length||function(){return Boolean((arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").toLowerCase().match(Is))}(t)?g(""):g(ks.INPUT_ERROR)}),[]),T=(0,h.useCallback)((()=>{b&&l(p)}),[b,p,l]),C=(0,h.useCallback)((e=>{"Enter"===e.key&&(e.preventDefault(),T())}),[T]),I=(0,h.useCallback)((e=>(0,E.trackClick)(e,"click_adsense_publisher_id_docs")),[]);return n.createElement(n.Fragment,null,n.createElement(gs,null,n.createElement(hs,{htmlFor:"adSensePublisherId"},ks.PUBLISHER_ID_LABEL),n.createElement(bs,{"aria-label":ks.PUBLISHER_ID_LABEL,id:"adSensePublisherId",name:"adSensePublisherId","data-testid":"adSensePublisherId",value:o,onChange:y,onKeyDown:w,placeholder:ks.PUBLISHER_ID_PLACEHOLDER,hasError:Boolean(s),hint:s}),n.createElement(ms,{type:Mt.ButtonType.Secondary,size:Mt.ButtonSize.Small,disabled:u,onClick:S,"data-testid":"adSensePublisherIdButton"},ks.SUBMIT_BUTTON)),n.createElement(rs,{size:Ya.TextSize.Small},n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:ks.PUBLISHER_ID_CONTEXT_LINK,rel:"noreferrer",target:"_blank",onClick:I,size:Ya.TextSize.Small})}},ks.PUBLISHER_ID_CONTEXT)),n.createElement(gs,null,n.createElement(hs,{htmlFor:"adSenseSlotId"},ks.SLOT_ID_LABEL),n.createElement(bs,{id:"adSenseSlotId","aria-label":ks.SLOT_ID_LABEL,name:"adSenseSlotId","data-testid":"adSenseSlotId",value:p,onChange:v,onKeyDown:C,placeholder:ks.SLOT_ID_PLACEHOLDER,hasError:Boolean(f),hint:f}),n.createElement(ms,{type:Mt.ButtonType.Secondary,size:Mt.ButtonSize.Small,disabled:_,onClick:T,"data-testid":"adSenseSlotIdButton"},ks.SUBMIT_BUTTON)),n.createElement(rs,{size:Ya.TextSize.Small},n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:ks.SLOT_ID_CONTEXT_LINK,rel:"noreferrer",target:"_blank",size:Ya.TextSize.Small})}},ks.SLOT_ID_CONTEXT)))},As=/^\d{7,20}$/;const xs={WIDGET_ID_CONTEXT:(0,X.default)(/* translators: %s: example value. */
(0,l.__)("Example: %s","web-stories"),"1234567"),WIDGET_ID_PLACEHOLDER:(0,l.__)("Enter your MGID Widget ID","web-stories"),WIDGET_ID_LABEL:(0,l.__)("Widget ID","web-stories"),INPUT_ERROR:(0,l.__)("Invalid ID format","web-stories"),SUBMIT_BUTTON:(0,l.__)("Save","web-stories")};const Os=function MgidSettings(e){let{widgetId:t,handleUpdate:a}=e;const[r,l]=(0,h.useState)(t),[o,i]=(0,h.useState)(""),s=r!==t&&!o,c=!s;(0,h.useEffect)((()=>{l(t)}),[t]);const d=(0,h.useCallback)((e=>{const{value:t}=e.target;l(t),0===t.length||function(){return Boolean((arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").toLowerCase().match(As))}(t)?i(""):i(xs.INPUT_ERROR)}),[]),u=(0,h.useCallback)((()=>{s&&a(r)}),[s,r,a]),p=(0,h.useCallback)((e=>{"Enter"===e.key&&(e.preventDefault(),u())}),[u]);return n.createElement(n.Fragment,null,n.createElement(gs,null,n.createElement(hs,{htmlFor:"mgidWidgetId"},xs.WIDGET_ID_LABEL),n.createElement(bs,{id:"mgidWidgetId","aria-label":xs.WIDGET_ID_LABEL,value:r,onChange:d,onKeyDown:p,placeholder:xs.WIDGET_ID_PLACEHOLDER,hasError:Boolean(o),hint:o}),n.createElement(ms,{type:Mt.ButtonType.Secondary,size:Mt.ButtonSize.Small,disabled:c,onClick:u},xs.SUBMIT_BUTTON)),n.createElement(rs,{size:Ya.TextSize.Small},xs.WIDGET_ID_CONTEXT))},Ds={SECTION_HEADING:(0,l.__)("Monetization","web-stories"),HELPER_MESSAGE_NONE:(0,l.__)("Monetize your content by showing ads in your Web Stories. <a>Learn more</a>.","web-stories"),HELPER_LINK_NONE:(0,l.__)("https://amp.dev/documentation/guides-and-tutorials/develop/advertise_amp_stories/","web-stories"),SITE_KIT_NOT_INSTALLED:(0,l.__)("Install <a>Site Kit by Google</a> to easily enable Google AdSense for Web Stories.","web-stories"),SITE_KIT_INSTALLED:(0,l.__)("Use Site Kit by Google to easily<a>activate Google AdSense</a> for Web Stories.","web-stories"),SITE_KIT_IN_USE:(0,l.__)("Site Kit by Google has already enabled Google AdSense for your Web Stories, all changes to your ad configuration should occur there.","web-stories")};const Ns=function AdManagement(e){let{updateSettings:t,adNetwork:a,publisherId:r,adSenseSlotId:l,adManagerSlotId:o,mgidWidgetId:i,siteKitStatus:s}=e;const{adsenseActive:c,installed:d,adsenseLink:u}=s,p=(0,h.useCallback)((e=>(0,E.trackClick)(e,"monetization","dashboard",Ds.HELPER_LINK_NONE)),[]),m=(0,h.useCallback)((e=>t({adSensePublisherId:e})),[t]),f=(0,h.useCallback)((e=>t({adSenseSlotId:e})),[t]),g=(0,h.useCallback)((e=>t({adManagerSlotId:e})),[t]),b=(0,h.useCallback)((e=>t({mgidWidgetId:e})),[t]),_=(0,h.useCallback)((e=>{t({adNetwork:e}),(0,E.trackEvent)("change_ad_network",{name:e})}),[t]),y=(0,h.useCallback)((e=>(0,E.trackClick)(e,"click_site_kit_link")),[]),S=(0,h.useMemo)((()=>c?null:n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:u,rel:"noreferrer",target:"_blank",size:Ya.TextSize.Small,onClick:y})}},d?Ds.SITE_KIT_INSTALLED:Ds.SITE_KIT_NOT_INSTALLED)),[c,d,u,y]);return n.createElement(_s,{onSubmit:e=>e.preventDefault()},n.createElement("div",null,n.createElement(Zi,null,Ds.SECTION_HEADING),n.createElement(rs,{size:Ya.TextSize.Small},n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:Ds.HELPER_LINK_NONE,rel:"noreferrer",target:"_blank",onClick:p,size:Ya.TextSize.Small})}},Ds.HELPER_MESSAGE_NONE)),n.createElement(as,{size:Ya.TextSize.Small},S)),c?n.createElement("div",null,n.createElement(rs,{size:Ya.TextSize.Small},Ds.SITE_KIT_IN_USE)):n.createElement("div",null,n.createElement(Ss,{handleUpdate:_,adNetwork:a}),Oi===a&&n.createElement(Ls,{handleUpdatePublisherId:m,handleUpdateSlotId:f,publisherId:r,slotId:l,siteKitStatus:s}),Di===a&&n.createElement(Ts,{handleUpdate:g,slotId:o}),Ni===a&&n.createElement(Os,{handleUpdate:b,widgetId:i})))};var Ps=a(25252);Pt.shape({value:Pt.number,set:Pt.func}).isRequired,Pt.number,Pt.bool,Pt.arrayOf(Pt.shape({disabled:Pt.bool,href:Pt.string,label:Pt.string.isRequired,openNewTab:Pt.bool,onClick:Pt.func,onFocus:Pt.func})).isRequired,Pt.func.isRequired,Pt.shape({url:Pt.string,title:Pt.string,id:Pt.number,active:Pt.bool}).isRequired;const Rs=function PopoverLogoContextMenu(e){let{isActive:t,id
(0,l.__)("Publisher logo menu for %s","web-stories"),r.title),onClick:e=>{e.preventDefault(),i(c?null:r.id),u(c?-1:r.id)},onFocus:()=>{i(c?null:r.id)}},n.createElement(Ps.default,{"aria-hidden":"true"})),n.createElement(Jt.default,{animate:!0,isOpen:c,"data-testid":`publisher-logo-context-menu-${a}`,onDismiss:p},s.map((e=>{let{label:t,separator:a,...r}=e;const l=r.href?la:oa.default;return n.createElement(h.Fragment,{key:t},"top"===a&&n.createElement(ia.default,null),n.createElement(l,r,t),"bottom"===a&&n.createElement(ia.default,null))}))))},Bs=(0,h.forwardRef)(((e,t)=>{let{contextMenuId:a,index:r,onMenuItemToggle:o,onRemoveLogo:i,onUpdateDefaultLogo:s,publisherLogo:c,setFocusedPublisherLogoId:d,showLogoContextMenu:u,isFocused:p}=e;const m=[{label:(0,l.__)("Set as Default","web-stories"),onClick:e=>{e.preventDefault(),s(c)},disabled:c.active},{label:(0,l.__)("Delete","web-stories"),onClick:e=>{e.preventDefault(),i(c,r)}}];return n.createElement(ss,{ref:t,role:"listitem",active:c.active,"data-testid":`publisher-logo-${r}`},n.createElement(cs,{onFocus:()=>{d(c.id)},"data-testid":`uploaded-publisher-logo-${r}`,isSelected:p,tabIndex:p?0:-1,onClick:e=>{e.preventDefault(),d(c.id)},"aria-label":(0,X.default)(/* translators: %s: logo title.*/
(0,l.__)("Publisher Logo %s","web-stories"),c.title)},n.createElement(ds,{src:c.url,alt:c.title})),c.active&&n.createElement(ts,{size:Ya.TextSize.XSmall},(0,l.__)("Default","web-stories")),u&&n.createElement(Rs,{isActive:p,idx:r,items:m,publisherLogo:c,onMenuItemToggle:o,contextMenuId:a}))}));Bs.displayName="GridItem";const Ms={SECTION_HEADING:(0,l.__)("Publisher Logo","web-stories"),UPLOAD_CONTEXT:(0,l.__)("Upload your logos here and they will become available to any stories you create.","web-stories"),CLICK_CONTEXT:(0,l.__)("Click on logo to set as default if you want that logo to be used on default logo for all your stories.","web-stories"),REMOVAL:(0,l.__)("Removing a logo from your settings won't remove it from any stories using that logo.","web-stories"),INSTRUCTIONS:(0,l.__)("Avoid vector files, such as svg or eps. Logos should be at least 96x96 pixels and a perfect square. The background should not be transparent.","web-stories"),SUBMIT:(0,l.__)("Upload logo","web-stories"),ARIA_LABEL:(0,l.__)("Click to upload a new logo","web-stories"),HELPER_UPLOAD:(0,l.__)("Drag a jpg, png, or static gif in this box. Or click “Upload logo” below.","web-stories")};const Us=function PublisherLogoSettings(e){let{canUploadFiles:t,onAddLogos:a,onRemoveLogo:r,onUpdateDefaultLogo:o,isLoading:i,publisherLogos:s,uploadError:c}=e;const{isRTL:d,allowedImageMimeTypes:u}=y(),p=(0,h.useRef)(),m=(0,h.useRef)(),f=(0,h.useRef)({}),[g,b]=(0,h.useState)(null),[_,E]=(0,h.useState)(null),[S,w]=(0,h.useState)(null),v=1===s.length,T=(0,h.useRef)(s.length),C=(0,h.useCallback)(((e,t)=>{w(-1),r?.(e),E(t),T.current=s.length}),[r,s.length]),I=(0,h.useCallback)((e=>{w(-1),o?.(e)}),[o]);(0,h.useEffect)((()=>{if(Boolean(_?.toString())&&s.length!==T.current){if(0===s.length)return p.current?.getElementsByTagName("input")[0].focus();const e=_>0?s[_-1]:s[0];return b(e.id),f.current[e.id].firstChild.focus(),E(null)}}),[_,s,b]),(0,Nt.default)({containerRef:p,gridRef:m,itemRefs:f,isRTL:d,currentItemId:g,items:s});const k=(0,h.useCallback)((e=>{b(e)}),[]);return(0,h.useFocusOut)(p,(()=>{b(null),w(null)}),[]),n.createElement(Yi,null,n.createElement("div",null,n.createElement(Zi,null,Ms.SECTION_HEADING),n.createElement(as,{size:Ya.TextSize.Small},Ms.UPLOAD_CONTEXT),n.createElement(as,{size:Ya.TextSize.Small},Ms.CLICK_CONTEXT),n.createElement(as,{size:Ya.TextSize.Small},Ms.REMOVAL)),n.createElement("div",{ref:p,"data-testid":"publisher-logos-container"},s.length>0&&n.createElement(is,{tabIndex:0,ref:m,role:"list","aria-label":(0,l.__)("Viewing existing publisher logos","web-stories")},s.map(((e,t)=>n.createElement(Bs,{key:e.id,ref:t=>{f.current[e.id]=t},contextMenuId:{set:w,value:S},index:t,isFocused:g===e.id,onMenuItemToggle:k,onRemoveLogo:C,onUpdateDefaultLogo:I,publisherLogo:e,setFocusedPublisherLogoId:b,showLogoContextMenu:!v})))),c&&n.createElement(os,{role:"alert"},c),t&&n.createElement(n.Fragment,null,n.createElement(La,{onSubmit:a,id:"settings_publisher_logos",isLoading:i,label:Ms.SUBMIT,isMultiple:!0,ariaLabel:Ms.ARIA_LABEL,instructionalText:Ms.HELPER_UPLOAD,acceptableFormats:Object.values(u)}),n.createElement(as,{size:Ya.TextSize.Small},Ms.INSTRUCTIONS))))};var Fs=a(45431),zs=a(83308);function TelemetrySettings(e){let{selected:t,onCheckboxSelected:a,disabled:r}=e;const o=(0,h.useMemo)((()=>`telemetry-opt-in-${(0,Fs.default)()}`),[]);return n.createElement(Yi,null,n.createElement("div",null,n.createElement(Zi,null,(0,l.__)("Data Sharing Opt-in","web-stories"))),n.createElement("div",null,n.createElement(ns,{htmlFor:o},n.createElement(zs.default,{id:o,"data-testid":"telemetry-settings-checkbox",disabled:r,onChange:a,checked:Boolean(t)}),n.createElement(ls,{size:Ya.TextSize.Small,"aria-checked":Boolean(t)},n.createElement(dn.default,{mapping:{a:n.createElement("a",{href:(0,l.__)("https://policies.google.com/privacy","web-stories"),rel:"noreferrer",target:"_blank","aria-label":(0,l.__)("Learn more by visiting Google Privacy Policy","web-stories")})}},(0,l.__)("Check the box to help us improve the Web Stories plugin by allowing tracking of product usage sta
(0,l.__)("Turn off the default archive page at <code>%s</code>. Users will see a 404 Not Found page when trying to access the default archive page.","web-stories"),d))),Pi.CUSTOM===t&&n.createElement(rs,{size:Ya.TextSize.Small},Gs.SUB_TEXT_CUSTOM),Pi.CUSTOM===t&&n.createElement(js,null,n.createElement(el,{placeholder:(0,l.__)("Select page","web-stories"),selectedValue:p,options:f,handleSearchValueChange:y,emptyText:(0,l.__)("No pages available","web-stories"),onMenuItemClick:_})),Pi.DISABLED!==t&&n.createElement(rs,{size:Ya.TextSize.Small},n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:d,rel:"noreferrer",target:"_blank",size:Ya.TextSize.Small}),code:n.createElement("code",null)}},o&&d!==r?(0,X.default)(/* translators: 1. current archive url, 2. default archive url. */
(0,l.__)("Visit archive page at <a>%1$s</a>. <code>%2$s</code> will automatically redirect to this page.","web-stories"),d,r):(0,X.default)(/* translators: %s: archive url. */
(0,l.__)("Visit archive page at <a>%1$s</a>.","web-stories"),d)))))}var Vs=a(37169),$s=a(48068);const Ws=/^ua-\d+-\d+|g-\w+$/;const Ks=(0,m.default)(Vs.default).withConfig({displayName:"googleAnalytics__StyledNotificationBubble",componentId:"sc-svg62t-0"})(["display:inline-block;margin-left:10px;"]),qs={CONTEXT:(0,l.__)("The story editor will append a default, configurable AMP analytics configuration to your story. If youre interested in going beyond what the default configuration, read this <a>article</a>.","web-stories"),CONTEXT_LINK:"https://blog.amp.dev/2019/08/28/analytics-for-your-amp-stories/",SECTION_HEADING:(0,l.__)("Google Analytics","web-stories"),PLACEHOLDER:(0,l.__)("Enter your Google Analytics Measurement ID","web-stories"),ARIA_LABEL:(0,l.__)("Enter your Google Analytics Measurement ID","web-stories"),INPUT_ERROR:(0,l.__)("Invalid ID format","web-stories"),SUBMIT_BUTTON:(0,l.__)("Save","web-stories"),SITE_KIT_NOT_INSTALLED:(0,l.__)("Install <a>Site Kit by Google</a> to easily enable Google Analytics for Web Stories.","web-stories"),SITE_KIT_INSTALLED:(0,l.__)("Use Site Kit by Google to easily<a>activate Google Analytics</a> for Web Stories.","web-stories"),SITE_KIT_IN_USE:(0,l.__)("Site Kit by Google has already enabled Google Analytics for your Web Stories, all changes to your analytics tracking should occur there.","web-stories")},Xs=m.default.div.withConfig({displayName:"googleAnalytics__WarningContainer",componentId:"sc-svg62t-1"})(["display:flex;gap:8px;margin:14px auto;border:1px solid ",";border-radius:",";padding:8px;"],(e=>{let{theme:t}=e;return t.colors.border.defaultNormal}),(e=>{let{theme:t}=e;return t.borders.radius.small})),Ys=(0,m.default)($s.default).withConfig({displayName:"googleAnalytics__WarningIcon",componentId:"sc-svg62t-2"})(["width:32px;height:100%;color:",";"],(e=>{let{theme:t}=e;return t.colors.status.warning})),Zs=(0,m.default)(Sa.Text.Paragraph).attrs({size:Ya.TextSize.Small}).withConfig({displayName:"googleAnalytics__Message",componentId:"sc-svg62t-3"})(["max-width:calc(100% - 40px);"]);const Js=function GoogleAnalyticsSettings(e){let{googleAnalyticsId:t,handleUpdateAnalyticsId:a,usingLegacyAnalytics:r,handleMigrateLegacyAnalytics:o,siteKitStatus:i={}}=e;const[s,c]=(0,h.useState)(t),[d,u]=(0,h.useState)(""),p=s!==t&&!d,m=!p,{analyticsActive:f,installed:g,analyticsLink:b}=i;(0,h.useEffect)((()=>{c(t)}),[t]);const _=(0,h.useCallback)((e=>{const{value:t}=e.target;c(t),0===t.length||function(){return Boolean((arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").toLowerCase().match(Ws))}(t)?u(""):u(qs.INPUT_ERROR)}),[]),y=(0,h.useCallback)((()=>{p&&a(s)}),[p,s,a]),S=(0,h.useCallback)((e=>{"Enter"===e.key&&(e.preventDefault(),y())}),[y]),w=(0,h.useCallback)((e=>{e.preventDefault(),o(),(0,E.trackEvent)("migrate_story_auto_analytics")}),[o]),v=(0,h.useCallback)((e=>(0,E.trackClick)(e,"click_auto_analytics_link")),[]),T=(0,h.useCallback)((e=>(0,E.trackClick)(e,"click_site_kit_link")),[]),C=(0,h.useCallback)((e=>(0,E.trackClick)(e,"click_analytics_docs")),[]),I=(0,h.useMemo)((()=>f?null:n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:b,rel:"noreferrer",target:"_blank",size:Ya.TextSize.Small,onClick:T})}},g?qs.SITE_KIT_INSTALLED:qs.SITE_KIT_NOT_INSTALLED)),[f,g,b,T]);return n.createElement(Yi,{onSubmit:e=>e.preventDefault()},n.createElement("div",null,n.createElement(Zi,{htmlFor:"gaTrackingID",as:"h3"},qs.SECTION_HEADING,r&&n.createElement(Ks,{notificationCount:1,isSmall:!0})),n.createElement(as,{size:Ya.TextSize.Small},I),r&&n.createElement(n.Fragment,null,n.createElement(as,{size:Ya.TextSize.Small},n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:"https://wp.stories.google/docs/seo/",rel:"noreferrer",target:"_blank",size:Ya.TextSize.Small,onClick:v})}},(0,l.__)("An improved analytics configuration is now available. <a>Learn more</a>.","web-stories"))),n.createElement(as,{size:Ya.TextSize.Small},n.createElement(ms,{type:Mt.ButtonType.Secondary,size:Mt.ButtonSize.Small,onClick:w},(0,l.__)("Migrate","web-stories"))))),n.createElement("div",null,f?n.
(0,l.__)("Getting font data failed, please ensure the URL points directly to a %s file.","web-stories"),(0,Qs.default)(gc)))}try{await a({...t,url:e}),s("")}catch(e){(0,E.trackError)("add_custom_font",e?.message),d((0,X.default)(/* translators: %s: font name. */
(0,l.__)("A font with the name %s already exists.","web-stories"),t.family))}}}),[a,g,i]),L=(0,h.useCallback)((e=>{"Enter"===e.key&&(e.preventDefault(),k())}),[k]);(0,h.useEffect)((()=>{const e=_.current[`row-${y}`];e&&(e.focus(),v(e.id))}),[y]);const A=e=>y===e,x=(0,h.useCallback)((e=>{const{key:a}=e;"ArrowUp"===a?(e.preventDefault(),S((e=>Math.max(0,e-1)))):"ArrowDown"===a&&(e.preventDefault(),S((e=>Math.min(t.length-1,e+1))))}),[t]);return n.createElement(Yi,{onSubmit:e=>e.preventDefault()},n.createElement("div",null,n.createElement(Zi,{as:"h3"},rc.SECTION_HEADING),n.createElement(as,{size:Ya.TextSize.Small},rc.ADD_CONTEXT),n.createElement(as,{size:Ya.TextSize.Small},rc.REMOVAL)),n.createElement(lc,null,n.createElement(gs,null,n.createElement(bs,{value:i,onChange:C,onKeyDown:L,hasError:Boolean(c),hint:c,label:rc.LABEL}),n.createElement(nc,{type:Mt.ButtonType.Primary,size:Mt.ButtonSize.Small,disabled:!g,onClick:k},rc.SUBMIT_BUTTON)),n.createElement(rs,{size:Ya.TextSize.Small},rc.INPUT_CONTEXT),t?.length>0&&n.createElement(oc,null,n.createElement(ic,null,rc.FONTS_HEADING),n.createElement(sc,{ref:b,role:"listbox",tabIndex:0,onKeyDown:x,"aria-activedescendant":w||t[0]?.id},t.map(((e,t)=>{let{id:a,family:r,url:o}=e;return n.createElement(dc,{id:`font-${a}`,ref:e=>_.current[`row-${t}`]=e,key:r,role:"option",onClick:()=>{S(t)},"aria-selected":A(t)},n.createElement(uc,null,n.createElement(pc,null,r),n.createElement(fc,null),n.createElement(mc,null,o)),n.createElement(Tooltip,{hasTail:!0,title:(0,l.__)("Delete font","web-stories")},n.createElement(cc,{"aria-label":(0,X.default)(/*translators: %s: font family. */
(0,l.__)("Delete %s","web-stories"),r),type:Mt.ButtonType.Tertiary,size:Mt.ButtonSize.Small,variant:Mt.ButtonVariant.Square,onClick:()=>{f(a),p(!0)}},n.createElement(ec.default,null))))}))),n.createElement(rs,{size:Ya.TextSize.Small},rc.FONTS_CONTEXT))),u&&n.createElement(tc,{onClose:()=>p(!1),onPrimary:I}))};var bc=a(40918);const _c=/[\w-]+\.myshopify\.com/i;function yc(){return Boolean((arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").toLowerCase().match(_c))}const Ec=m.default.div.withConfig({displayName:"shopify__Loading",componentId:"sc-ur0gaq-0"})(["position:relative;margin-top:10px;"]),Sc=m.default.div.withConfig({displayName:"shopify__Spinner",componentId:"sc-ur0gaq-1"})(["position:absolute;top:0;"]),wc={HOST_CONTEXT:(0,X.default)(/* translators: 1: first example. 2: second example. */
(0,l.__)("Without <code>%1$s</code> or <code>%2$s</code>. Example: %3$s. <a>Find your URL</a>.","web-stories"),"https://","www.","yourstore.myshopify.com"),HOST_CONTEXT_LINK:(0,l.__)("https://help.shopify.com/en/manual/domains","web-stories"),HOST_PLACEHOLDER:(0,l.__)("Enter your .myshopify.com domain","web-stories"),HOST_LABEL:(0,l.__)("Shopify Domain","web-stories"),ACCESS_TOKEN_CONTEXT:(0,l.__)("<a>Learn how to get one</a>.","web-stories"),ACCESS_TOKEN_CONTEXT_LINK:(0,l.__)("https://help.shopify.com/en/manual/apps/custom-apps#get-the-api-credentials-for-a-custom-app","web-stories"),ACCESS_TOKEN_PLACEHOLDER:(0,l.__)("Enter your API access token","web-stories"),ACCESS_TOKEN_LABEL:(0,l.__)("Storefront API Access Token","web-stories"),INPUT_ERROR:(0,l.__)("Invalid format","web-stories"),SUBMIT_BUTTON:(0,l.__)("Save","web-stories"),CONNECTION_TEST_BUTTON:(0,l.__)("Test connection","web-stories"),CONNECTION_CHECKING:(0,l.__)("Testing connection…","web-stories"),CONNECTION_SUCCESS:(0,l.__)("Connection successful","web-stories"),CONNECTION_ERROR_DEFAULT:(0,l.__)("Connection failed. Please try again.","web-stories")};const vc=function ShopifySettings(e){let{host:t,accessToken:a,handleUpdateHost:r,handleUpdateAccessToken:o}=e;const i=(0,Zn.default)(),[s,c]=(0,h.useState)(t),[d,u]=(0,h.useState)(""),p=s!==t&&!d,m=!p,[f,g]=(0,h.useState)(a),[b,_]=(0,h.useState)(""),S=f!==a&&!b,w=!S,{apiCallbacks:{getProducts:v}}=y(),[T,C]=(0,h.useState)(!1),[I,k]=(0,h.useState)(""),[L,A]=(0,h.useState)(!1);(0,h.useEffect)((()=>{c(t)}),[t]),(0,h.useEffect)((()=>{g(a)}),[a]);const x=(0,h.useCallback)((e=>{const{value:t}=e.target;c(t),0===t.length||yc(t)?u(""):u(wc.INPUT_ERROR)}),[]),O=(0,h.useCallback)((e=>{const{value:t}=e.target;yc(t)&&c(t.match(_c)[0])}),[]),D=(0,h.useCallback)((()=>{p&&r(s)}),[p,s,r]),N=(0,h.useCallback)((e=>{"Enter"===e.key&&(e.preventDefault(),D())}),[D]),P=(0,h.useCallback)((e=>{const{value:t}=e.target;_(""),g(t)}),[]),R=(0,h.useCallback)((()=>{S&&o(f)}),[S,f,o]),B=(0,h.useCallback)((e=>{"Enter"===e.key&&(e.preventDefault(),R())}),[R]),M=(0,h.useCallback)((async()=>{A(!1),C(!0),i(wc.CONNECTION_CHECKING),(0,E.trackEvent)("test_shopping_connection");try{await v((new Date).getTime()),k(wc.CONNECTION_SUCCESS),i(wc.CONNECTION_SUCCESS)}catch(e){(0,E.trackError)("test_shopping_connection",e?.message),A(!0),k(wc.CONNECTION_ERROR_DEFAULT),i(wc.CONNECTION_ERROR_DEFAULT)}finally{C(!1)}}),[v,i]),U=s&&!d&&f&&!b&&!T,F=(0,h.useCallback)((e=>(0,E.trackClick)(e,"click_shopify_docs")),[]);return n.createElement(n.Fragment,null,n.createElement(gs,null,n.createElement(hs,{htmlFor:"shopifyHost"},wc.HOST_LABEL),n.createElement(bs,{"aria-label":wc.HOST_LABEL,id:"shopifyHost",name:"shopifyHost","data-testid":"shopifyHost",value:s,onChange:x,onKeyDown:N,onBlur:O,placeholder:wc.HOST_PLACEHOLDER,hasError:Boolean(d),hint:d}),n.createElement(ms,{type:Mt.ButtonType.Secondary,size:Mt.ButtonSize.Small,disabled:m,onClick:D,"data-testid":"shopifyHostButton"},wc.SUBMIT_BUTTON)),n.createElement(rs,{size:Ya.TextSize.Small},n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:wc.HOST_CONTEXT_LINK,rel:"noreferrer",target:"_blank",onClick:F,size:Ya.TextSize.Small})}},wc.HOST_CONTEXT)),n.createElement(gs,null,n.createElement(hs,{htmlFor:"shopifyAccessToken"},wc.ACCESS_TOKEN_LABEL),n.createElement(bs,{id:"shopifyAccessToken","aria-label":wc.ACCESS_TOKEN_LABEL,name:"shopifyAccessToken","data-testid":"shopifyAccessToken",value:f,onChange:P,onKeyDown:B,placeholder:wc.ACCESS_TOKEN_PLACEHOLDER,hasError:Boolean(b),hint:b}),n.createElement(ms,{type:Mt.ButtonType.Secondary,size:Mt.ButtonSize.Small,disabled:w,onClick:R,"data-testid":"shopifyAccessTokenButton"},wc.SUBMIT_BUTTON)),n.createElement(rs,{size:Ya.TextSize.Small},n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:wc.ACCESS_TOKEN_CONTEXT_LINK,rel:"noreferrer",target:"_blank",size:Ya.TextSize.Small})}},wc.ACCESS_TOKEN_CONTEXT)),n.createElement(fs,{onFocus:()=>k(""),type:Mt.ButtonType.Secondary,size:Mt.ButtonSize.Small,disabled:!U,onClick:M},T?wc.CONNECTION_CHECKING:wc.CONNECTION_TEST_BUTTON)
(0,l._n)("Duration between %1$d and %2$d second.","Duration between %1$d and %2$d seconds.",xc.MAX,"web-stories"),xc.MIN,xc.MAX)},Dc=m.default.div.withConfig({displayName:"pageAdvancement__InputsWrapper",componentId:"sc-9snl1y-0"})(["margin-top:8px;"]),Nc=(0,m.default)(Lc.default).withConfig({displayName:"pageAdvancement__StyledSwitch",componentId:"sc-9snl1y-1"})(["width:186px;"]);const Pc=function PageAdvancementSettings(e){let{updateSettings:t,autoAdvance:a,defaultPageDuration:r}=e;const[o,i]=(0,h.useState)(a),s=(0,h.useCallback)((()=>{(0,E.trackEvent)("change_auto_advance",{value:!a}),i(!a),t({autoAdvance:!a})}),[a,t]);(0,h.useEffect)((()=>{i(a)}),[a]);const c=(0,h.useCallback)(((e,a)=>{t({defaultPageDuration:a}),(0,E.trackEvent)("change_default_page_duration",{value:a})}),[t]);return n.createElement(_s,{onSubmit:e=>e.preventDefault()},n.createElement("div",null,n.createElement(Zi,{as:"h3"},Oc.SECTION_HEADING),n.createElement(as,{size:Ya.TextSize.Small},Oc.CONTEXT)),n.createElement(Dc,null,n.createElement(gs,null,n.createElement(Nc,{groupLabel:Oc.SWITCH_LABEL,name:"page-advancement-switch",value:o,onLabel:Oc.LABEL_AUTO,offLabel:Oc.LABEL_MANUAL,onChange:s,darkTheme:!1})),o&&n.createElement(n.Fragment,null,n.createElement(gs,null,n.createElement(Ac.default,{unit:` ${(0,l.__)("seconds","web-stories")}`,suffix:Oc.INPUT_SUFFIX,value:r,onChange:c,"aria-label":Oc.INPUT_SUFFIX,min:xc.MIN,max:xc.MAX})),n.createElement(rs,{size:Ya.TextSize.Small},Oc.INPUT_HELPER))))},Rc=m.default.div.withConfig({displayName:"editorSettings__BodyViewOptionsHeader",componentId:"sc-1yxjpva-0"})([""]);const Bc=function EditorSettings(){const{fetchSettings:e,updateSettings:t,googleAnalyticsId:a,usingLegacyAnalytics:r,adSensePublisherId:o,adSenseSlotId:i,adManagerSlotId:s,mgidWidgetId:c,adNetwork:d,uploadMedia:u,newlyCreatedMediaIds:p,isMediaLoading:m,videoCache:f,dataRemoval:g,archive:b,archivePageId:_,searchPages:S,getPageById:w,customFonts:v,addCustomFont:T,deleteCustomFont:C,fetchCustomFonts:I,publisherLogos:k,addPublisherLogo:L,fetchPublisherLogos:A,removePublisherLogo:x,setPublisherLogoAsDefault:O,shoppingProvider:D,shopifyHost:N,shopifyAccessToken:P,autoAdvance:R,defaultPageDuration:B}=Gi((e=>{let{actions:{fontsApi:{addCustomFont:t,deleteCustomFont:a,fetchCustomFonts:r},settingsApi:{fetchSettings:n,updateSettings:l},pagesApi:{searchPages:o,getPageById:i},mediaApi:{uploadMedia:s},publisherLogosApi:{fetchPublisherLogos:c,addPublisherLogo:d,removePublisherLogo:u,setPublisherLogoAsDefault:p}},state:{settings:{googleAnalyticsId:m,usingLegacyAnalytics:f,adSensePublisherId:g,adSenseSlotId:h,adManagerSlotId:b,mgidWidgetId:_,adNetwork:y,videoCache:E,dataRemoval:S,archive:w,archivePageId:v,shoppingProvider:T,shopifyHost:C,shopifyAccessToken:I,autoAdvance:k,defaultPageDuration:L},media:{isLoading:A,newlyCreatedMediaIds:x},publisherLogos:{publisherLogos:O},customFonts:D}}=e;return{fetchSettings:n,updateSettings:l,googleAnalyticsId:m,usingLegacyAnalytics:f,adSensePublisherId:g,adSenseSlotId:h,adManagerSlotId:b,mgidWidgetId:_,adNetwork:y,uploadMedia:s,isMediaLoading:A,newlyCreatedMediaIds:x,videoCache:E,dataRemoval:S,archive:w,archivePageId:v,searchPages:o,getPageById:i,customFonts:D,addCustomFont:t,deleteCustomFont:a,fetchCustomFonts:r,fetchPublisherLogos:c,addPublisherLogo:d,removePublisherLogo:u,setPublisherLogoAsDefault:p,publisherLogos:O,shoppingProvider:T,shopifyHost:C,shopifyAccessToken:I,autoAdvance:k,defaultPageDuration:L}})),{capabilities:{canUploadFiles:M,canManageSettings:U}={},plugins:{siteKit:F={},woocommerce:z={}},maxUpload:G,maxUploadFormatted:H,allowedImageMimeTypes:j,archiveURL:V,defaultArchiveURL:$,vendors:W}=y(),{disabled:K,toggleWebStoriesTrackingOptIn:q,optedIn:Y}=$i(),{disabled:Z,toggleWebStoriesMediaOptimization:J,mediaOptimization:Q}=function(){const{showSnackbar:e}=(0,il.useSnackbar)(),{currentUser:t,toggleWebStoriesMediaOptimization:a}=Gi((e=>{let{state:{currentUser:t},actions:{usersApi:{toggleWebStoriesMediaOptimization:a}}}=e;return{currentUser:t,toggleWebStoriesMediaOptimization:a}})),r=Boolean(t.data.meta?.webStoriesMediaOpti
(0,l.__)("Sorry, this file is too big. Make sure your logo is under %s.","web-stories"),H):(0,X.default)(/* translators: %s: max upload size for media */
(0,l.__)("Sorry, one or more of these files are too big. Make sure your logos are all under %s.","web-stories"),H);return te(t)}if(!a){const t=1===e.length?(0,l.__)("Sorry, this file type is not supported. Only jpg, png, and static gifs are supported for publisher logos.","web-stories"):(0,l.__)("Sorry, one or more of these files are of an unsupported file type. Only jpg, png, and static gifs are supported for publisher logos.","web-stories");return te(t)}const o=await Promise.all(n).catch((()=>{r=!0}));if(r){const t=1===e.length?(0,l.__)("Sorry, there was an error processing your upload. Please try again.","web-stories"):(0,l.__)("Sorry, there was an error processing one or more of your uploads. Please try again.","web-stories");return te(t)}if(!o.every((e=>{let{height:t,width:a}=e;return t>=96&&a>=96}))){const t=1===e.length?(0,X.default)(/* translators: 1 = minimum width, 2 = minimum height */
(0,l.__)("Sorry, this file is too small. Make sure your logo is larger than %s.","web-stories"),(0,X.default)("%1$dx%2$dpx",96,96)):(0,X.default)(/* translators: %s: image dimensions in pixels. */
(0,l.__)("Sorry, one or more files are too small. Make sure your logos are all larger than %s.","web-stories"),(0,X.default)("%1$dx%2$dpx",96,96));return te(t)}return te(""),u(e)}),[G,H,u,j]),le=(0,h.useCallback)((e=>{x(e.id)}),[x]),oe=(0,h.useCallback)((e=>O(e.id)),[O]);return n.createElement(Ua.Provider,null,n.createElement(qi,{"data-testid":"editor-settings"},n.createElement(ll,{heading:(0,l.__)("Settings","web-stories")}),n.createElement(ha,null,n.createElement(Rc,{id:"body-view-options-header"})),n.createElement(Ua.Scrollable,null,n.createElement(Xi,null,U&&n.createElement(n.Fragment,null,n.createElement(Js,{googleAnalyticsId:a,handleUpdateAnalyticsId:ae,usingLegacyAnalytics:r,handleMigrateLegacyAnalytics:re,siteKitStatus:F}),n.createElement(Us,{onAddLogos:ne,onRemoveLogo:le,onUpdateDefaultLogo:oe,publisherLogos:k,canUploadFiles:M,isLoading:m,uploadError:ee})),n.createElement(hc,{customFonts:v,addCustomFont:T,deleteCustomFont:C}),n.createElement(TelemetrySettings,{disabled:K,onCheckboxSelected:q,selected:Y}),M&&n.createElement(MediaOptimizationSettings,{disabled:Z,onCheckboxSelected:J,selected:Q}),U&&n.createElement(n.Fragment,null,n.createElement(VideoCacheSettings,{isEnabled:f,updateSettings:t}),n.createElement(DataRemovalSettings,{isEnabled:g,updateSettings:t}),n.createElement(ArchiveSettings,{archive:b,archiveURL:V,defaultArchiveURL:$,updateSettings:t,searchPages:S,archivePageId:_,getPageById:w}),n.createElement(Ns,{updateSettings:t,adNetwork:d,publisherId:o,adSenseSlotId:i,adManagerSlotId:s,mgidWidgetId:c,siteKitStatus:F}),n.createElement(kc,{updateSettings:t,shoppingProvider:D,shopifyHost:N,shopifyAccessToken:P,vendors:W,woocommerce:z}),n.createElement(Pc,{updateSettings:t,autoAdvance:R,defaultPageDuration:B}))))))};function Mc(){const[e,t]=(0,h.useState)({}),[a,r]=(0,h.useState)(!1),{api:{currentUser:n}}=y();(0,h.useEffect)((()=>{var a;Object.keys(e).length||(a=n,si({path:a}).then(ni.snakeToCamelCaseObjectKeys)).then(t)}),[n,e]);return{api:{toggleWebStoriesTrackingOptIn:(0,h.useCallback)((async()=>{r(!0);try{t(await function(e,t){return si({path:e,data:{meta:{web_stories_tracking_optin:!t.meta.webStoriesTrackingOptin}},method:"POST"}).then(ni.snakeToCamelCaseObjectKeys)}(n,e))}finally{r(!1)}}),[n,e]),toggleWebStoriesMediaOptimization:(0,h.useCallback)((async()=>{r(!0);try{t(await function(e,t){return si({path:e,data:{meta:{web_stories_media_optimization:!t.meta.webStoriesMediaOptimization}},method:"POST"}).then(ni.snakeToCamelCaseObjectKeys)}(n,e))}finally{r(!1)}}),[n,e])},currentUser:{data:e,isUpdating:a}}}const Uc={LOADING_MEDIA:"loading_media",ADD_MEDIA_SUCCESS:"add_media_success",ADD_MEDIA_FAILURE:"add_media_failure"},Fc={error:{},isLoading:!1,newlyCreatedMediaIds:[]};const zc=function(e,t){switch(t.type){case Uc.LOADING_MEDIA:return{...e,isLoading:!0,newlyCreatedMediaIds:[]};case Uc.ADD_MEDIA_FAILURE:return{...e,error:{...t.payload,id:Date.now()},isLoading:!1};case Uc.ADD_MEDIA_SUCCESS:return{...e,error:{},isLoading:!1,newlyCreatedMediaIds:t.payload.newlyCreatedMediaIds||e.newlyCreatedMediaIds};default:return e}};function Gc(){const[e,t]=(0,h.useReducer)(zc,Fc),{api:{media:a}}=y();return{media:e,api:{uploadMedia:(0,h.useCallback)((async e=>{t({type:Uc.LOADING_MEDIA});try{const r=await function(e,t){return Promise.all(Object.values(t).map((t=>{const a=new window.FormData;return a.append("file",t,t.name||t.type.replace("/",".")),si({path:e,body:a,method:"POST"}).then(ni.snakeToCamelCaseObjectKeys)})))}(a,e);t({type:Uc.ADD_MEDIA_SUCCESS,payload:{media:r,newlyCreatedMediaIds:r.map((e=>{let{id:t}=e;return t}))}})}catch(a){t({type:Uc.ADD_MEDIA_FAILURE,payload:{message:ki.UPLOAD_PUBLISHER_LOGO[e.length>1?"MESSAGE_PLURAL":"MESSAGE"]}})}}),[a])}}}const Hc={UPDATE_SETTINGS_SUCCESS:"update_settings_success",UPDATE_SETTINGS_FAILURE:"update_settings_failure",SETTING_SAVED:"setting_saved",FETCH_SETTINGS_SUCCESS:"fetch_settings_success",FETCH_SETTINGS_FAILURE:"fetch_settings_failure"},jc={error:{},googleAnalyticsId:"",usingLegacyAnalytics:!1,adSensePublisherId:"",adSenseSlotId:"",adManagerSlotId:"",mgidWidgetId:"",adN