1import{PageElementBase as C}from"./CdQXFjpm.js";import{G as o}from"./Djdj2BlS.js";import{g as T,h as B,f as h,a as O}from"./D17UyvE-.js";import{G as b}from"./DA0pkXRu.js";import{G as f}from"./D_6K3OQ2.js";import{t as F}from"./CATxlt2j.js";import{TypographyModel as I}from"./C8oKskU6.js";import{u as w}from"./B0QrDZnb.js";import{z as K}from"./CL6gNd-P.js";import{d as L}from"./ghde6Rcn.js";import"./CXTOca8g.js";import"./0xmjySIm.js";import"./lp-gTeWl.js";import"./DhOWJ3tu.js";import"./WUj_y4n6.js";import"./CrX2__Gh.js";import"./T-kpnD9n.js";class k extends C{constructor(t="root",e){super(t,e),this.widgetType="WidgetCardNews",this.widgetName="News Card",this.component="WidgetCardNews",this.icon={icon:"news",pack:"cms"},this.pseudoWidgetType="card",this.variant="stacked",this.aspect="aspect-video",this.transition="image-scale",this.style=new f({theme:"light"}),this.stackBackgroundImage=new b,this.title=new I({size:"lg",font:"secondary",fontWeight:"bold",lineClamp:3,alignment:"start"}),this.showOverlay=!0,this.stackPadding="small",this.borderRadius=void 0,this.query=new o({type:"news",count:1,method:"getLatest",manualFillIds:null,autofillOptions:null,offset:0,contentFill:"auto-fill",params:void 0}),this.buildLayoutFields=a=>{const{getRootElementById:i}=w(),s=i(a.uuid);return[{heading:"Card Style",options:[{type:"radio",subType:"row",attributeKey:"variant",options:[{label:"Stacked",id:"stacked"},{label:"Cover",id:"cover"},{label:"Transparent",id:"transparent"}]},{type:"radio",subType:"row",disabled:(s==null?void 0:s.widgetType)==="hero",attributeKey:"aspect",options:[{label:"Landscape",id:"aspect-video"},{label:"Portrait",id:"aspect-tall"},{label:"Square",id:"aspect-square"}]}]},{heading:"Display",disabled:a.variant!=="cover",options:[{attributeKey:"showOverlay",type:"switch",label:"Overlay"}]}]},this.buildStyleFields=()=>[{heading:"Theme",options:[{type:"radio",subType:"list",attributeKey:["style","theme"],options:[{label:"Light",id:"light"},{label:"Dark",id:"dark"},{label:"Accent",id:"club"}]}]},{heading:"Background",type:"tabs",tabsOptions:{variant:"fill"},tabs:[{title:"Colour",value:"color",index:0,options:[{type:"color-input",attributeKey:["style","backgroundColor"]}]},{title:"Image",value:"image",index:1,options:[{heading:"Stack Background Image",type:"image-picker",attributeKey:["stackBackgroundImage"]}]}],options:[]},{heading:"Text Colour",options:[{type:"color-input",attributeKey:["style","color"]}]}],this.getSidebarTabs=a=>[{name:"Layout",fields:this.buildLayoutFields(a)},{name:"Content",fields:this.buildContentFields(a),default:!0},{name:"Style",fields:this.buildStyleFields()}],e!=null&&e.widgetType&&!("version"in e)?Object.assign(this,this.normalizeLegacyElement(e,t)):Object.assign(this,F(e)),this.query=this.getQuery(e)}normalizeLegacyElement(t,e){var n,l,d,u,y,p,c,m,g;const{getElementById:a,getRootElementById:i}=w(),s=a(e),r=i(e),v=T(s,r),q=B(s,r);return{aspect:void 0,variant:void 0,style:new f({theme:O(((n=t.style)==null?void 0:n.theme)||"light"),backgroundColor:h((d=(l=t.style)==null?void 0:l.background)==null?void 0:d.color),color:h((u=t.style)==null?void 0:u.color)}),query:new o(t.contents),title:v,stackBackgroundImage:new b({...(p=(y=t.style)==null?void 0:y.background)==null?void 0:p.image,image:((g=(m=(c=t.style)==null?void 0:c.background)==null?void 0:m.image)==null?void 0:g.image)??""}),transition:"raise",showOverlay:!0,stackPadding:"small",borderRadius:q}}serializeElement(){return{...super.serializeBaseElement(),widgetType:"WidgetCardNews",component:"WidgetCardNews",title:this.title,aspect:this.aspect,variant:this.variant,transition:this.transition??"image-scale",query:this.query,style:this.style,stackBackgroundImage:this.stackBackgroundImage,showOverlay:this.showOverlay,stackPadding:this.stackPadding,borderRadius:this.borderRadius}}getQuery(t){if(t&&"query"in t)return new o(t.query);if(t&&"contents"in t){const e=new o(t.contents);return e.count=1,e.params=e.createParams(e.type,e.offset??0,e.method,e.count),e}return new o({type:"news",count:12,method:"getLatest",manualFillIds:null,autofillOptions:null,offset:0,contentFill:"auto-fill"})}buildContentFields(t){const{$gc:e}=K(),a=e().news.web().getCategories().then(i=>i&&i.length?i.map(s=>({name:s.newsCategory,id:s.newsCategoryID})):[]);return[{heading:"Title",options:[{type:"typography-input",attributeKey:["title"],exclude:["content"]}]},{type:"tabs",tabsOptions:{variant:"fill"},tabsAttributeKey:["query","contentFill"],tabs:[{title:"Auto-Fill",value:"auto-fill",index:0,options:[{type:"query-builder",attributeKey:["query"],queryType:"news",multiSelect:!1,ctaText:"Select from Modal",callback:i=>{t.query=Object.assign(t.query,i)}},{heading:"Query Type",type:"select",attributeKey:["query","method"],items:[{name:"Latest",id:"getLatest"},{name:"By Category",id:"getByCategory"},{name:"By Featured",id:"getIsFeatured"}]},{heading:"",type:"select",attributeKey:["query","autofillOptions","category"],hidden:(t==null?void 0:t.query.method)!=="getByCategory",items:a},{heading:"Listing Offset",subHeading:"Determines which position in the listing to populate from. e.g. '5' will populate from the 5th item in the listing.",type:"number",min:0,max:50,attributeKey:["query","offset"]}]},{title:"Manual Fill",value:"manual-fill",index:1,options:[{type:"query-builder",attributeKey:["query"],queryType:"news",multiSelect:!1,ctaText:"Select from Modal",callback:i=>{t.query=Object.assign(t.query,i)}}]}],options:[]}]}duplicateElement(){return new k(this.parentID,L({...this,uuid:void 0}))}}export{k as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.