1import{R as c,r as k,j as e}from"./jsx-runtime-kF-aRxYe.js";import{C as se}from"./Card-S6K8GLCp.js";import{p as Ce,i as B,v as Ze,f as Ye,g as Ge,c as A,z as Ke,A as Je,C as Qe,B as z,T as D,I as P,b as ke,P as Xe,a as et,t as ge,d as tt}from"./Page-RCHDyLd1.js";import{C as he}from"./Checkbox-BPrTdIr3.js";import{u as st,c as nt,B as Le,A as at}from"./components-Bg6F3iAF.js";import{B as de}from"./Banner-BTCmU1jz.js";import{L as ue}from"./Layout-BAcNQvwh.js";import{i as lt,F as it,T as ot}from"./Toast-BSkyrb3p.js";import{h as fe,d as rt,E as Fe}from"./context-ClUtXUi6.js";import{S as ct,a as dt,A as ut}from"./AfterInitialMount-vjkVt0KT.js";import{S as ht}from"./Sticky-DatVYi8Y.js";import"./banner-context-BgvF_mjc.js";import"./XIcon.svg-BFgNHS0e.js";import"./set-root-property-BPOnANDm.js";import"./Modal-DoQWO5ot.js";import"./context-DqE-dl7J.js";function mt(o){return function(d,s){const{firstVisibleColumnIndex:t,tableLeftVisibleEdge:n,tableRightVisibleEdge:i}=o,r=d.offsetLeft,b=r+d.offsetWidth,a=Re(r,n,i,"left"),u=Re(b,n,i,"right"),m=a||u,p=d.offsetWidth;return m&&(o.firstVisibleColumnIndex=Math.min(t,s)),{leftEdge:r,rightEdge:b,isVisible:m,width:p,index:s}}}function Re(o,d,s,t){return o>=d+(t==="left"?0:30)&&o<=s-30}function pt(o,d){const{firstVisibleColumnIndex:s}=o,t=Math.max(s-1,0),n=d[t],i=d[s];return{previousColumn:n,currentColumn:i}}var h={DataTable:"Polaris-DataTable",condensed:"Polaris-DataTable--condensed",Navigation:"Polaris-DataTable__Navigation",Pip:"Polaris-DataTable__Pip","Pip-visible":"Polaris-DataTable__Pip--visible",ScrollContainer:"Polaris-DataTable__ScrollContainer",Table:"Polaris-DataTable__Table",TableRow:"Polaris-DataTable__TableRow",Cell:"Polaris-DataTable__Cell",IncreasedTableDensity:"Polaris-DataTable__IncreasedTableDensity",ZebraStripingOnData:"Polaris-DataTable__ZebraStripingOnData",RowCountIsEven:"Polaris-DataTable__RowCountIsEven",ShowTotalsInFooter:"Polaris-DataTable__ShowTotalsInFooter","Cell-separate":"Polaris-DataTable__Cell--separate","Cell-firstColumn":"Polaris-DataTable__Cell--firstColumn","Cell-numeric":"Polaris-DataTable__Cell--numeric","Cell-truncated":"Polaris-DataTable__Cell--truncated","Cell-header":"Polaris-DataTable__Cell--header","Cell-sortable":"Polaris-DataTable__Cell--sortable","Heading-left":"Polaris-DataTable__Heading--left","Cell-verticalAlignTop":"Polaris-DataTable__Cell--verticalAlignTop","Cell-verticalAlignBottom":"Polaris-DataTable__Cell--verticalAlignBottom","Cell-verticalAlignMiddle":"Polaris-DataTable__Cell--verticalAlignMiddle","Cell-verticalAlignBaseline":"Polaris-DataTable__Cell--verticalAlignBaseline",hoverable:"Polaris-DataTable--hoverable","Cell-hovered":"Polaris-DataTable__Cell--hovered",Icon:"Polaris-DataTable__Icon",Heading:"Polaris-DataTable__Heading",StickyHeaderEnabled:"Polaris-DataTable__StickyHeaderEnabled",StickyHeaderWrapper:"Polaris-DataTable__StickyHeaderWrapper","Cell-sorted":"Polaris-DataTable__Cell--sorted","Cell-total":"Polaris-DataTable__Cell--total",ShowTotals:"Polaris-DataTable__ShowTotals","Cell-total-footer":"Polaris-DataTable--cellTotalFooter",Footer:"Polaris-DataTable__Footer",StickyHeaderInner:"Polaris-DataTable__StickyHeaderInner","StickyHeaderInner-isSticky":"Polaris-DataTable__StickyHeaderInner--isSticky",StickyHeaderTable:"Polaris-DataTable__StickyHeaderTable",FixedFirstColumn:"Polaris-DataTable__FixedFirstColumn",StickyTableHeadingsRow:"Polaris-DataTable__StickyTableHeadingsRow",TooltipContent:"Polaris-DataTable__TooltipContent"};function oe({content:o,contentType:d,nthColumn:s,firstColumn:t,truncate:n,header:i,total:r,totalInFooter:b,sorted:a,sortable:u,sortDirection:m,inFixedNthColumn:p,verticalAlign:l="top",defaultSortDirection:C="ascending",onSort:f,colSpan:v,setRef:j=()=>{},stickyHeadingCell:E=!1,stickyCellWidth:I,hovered:_=!1,handleFocus:V=()=>{},hasFixedNthColumn:w=!1,fixedCellVisible:Y=!1,firstColumnMinWidth:F,style:R,lastFixedFirstColumn:L}){const S=Ce(),M=d==="numeric",U=B(h.Cell,h[`Cell-${Ze("verticalAlign",l)}`],t&&h["Cell-firstColumn"],n&&h["Cell-truncated"],i&&h["Cell-header"],r&&h["Cell-total"],b&&h["Cell-total-footer"],M&&h["Cell-numeric"],u&&h["Cell-sortable"],a&&h["Cell-sorted"],E&&h.StickyHeaderCell,_&&h["Cell-hovered"],L&&p&&Y&&h["Cell-separate"],s&&p&&E&&h.FixedFirstColumn),X=B(i&&h.Heading,i&&d==="text"&&h["Heading-left"]),ne=B(u&&h.Icon),G=a&&m?m:C,ae=G==="descending"?ct:dt,le=m==="ascending"?"descending":"ascending",q=S.translate("Polaris.DataTable.sortAccessibilityLabel",{direction:a?le:G}),K=c.createElement("span",{className:ne},c.createElement(Ge,{source:ae,accessibilityLabel:q})),ee=!(E&&w&&s&&!p),W=u?c.createElement("button",{className:X,onClick:f,onFocus:V,tabIndex:ee?0:-1},K,o):o,$=v&&v>1?{colSpan:v}:{},y=s&&F?{minWidth:F}:{minWidth:I},T=c.createElement("th",Object.assign({ref:j},fe.props,$,{className:U,"aria-sort":m,style:{...R,...y},"data-index-table-sticky-heading":!0}),W),Z=i?c.createElement("th",Object.assign({},fe.props,{"aria-sort":m},$,{ref:j,className:U,scope:"col",style:{...y}}),W):c.createElement("th",Object.assign({},$,{ref:j,className:U,scope:"row",style:{...y}}),n?c.createElement(bt,{className:h.TooltipContent},o):o),J=i||t||s?Z:c.createElement("td",Object.assign({className:U},$),o);return E?T:J}const bt=({children:o,className:d=""})=>{const s=k.useRef(null),{current:t}=s,n=c.createElement("span",{ref:s,className:d},o);return(t==null?void 0:t.scrollWidth)>(t==null?void 0:t.offsetWidth)?c.createElement(Ye,{content:s.current.innerText},n):n};function gt({columnVisibilityData:o,isScrolledFarthestLeft:d,isScrolledFarthestRight:s,navigateTableLeft:t,navigateTableRight:n,fixedFirstColumns:i,setRef:r=()=>{}}){const b=Ce(),a=o.map((p,l)=>{if(l<i)return;const C=B(h.Pip,p.isVisible&&h["Pip-visible"]);return c.createElement("div",{className:C,key:`pip-${l}`})}),u=b.translate("Polaris.DataTable.navAccessibilityLabel",{direction:"left"}),m=b.translate("Polaris.DataTable.navAccessibilityLabel",{direction:"right"});return c.createElement("div",{className:h.Navigation,ref:r},c.createElement(A,{variant:"tertiary",icon:Ke,disabled:d,accessibilityLabel:u,onClick:t}),a,c.createElement(A,{variant:"tertiary",icon:Je,disabled:s,accessibilityLabel:m,onClick:n}))}const Pe=o=>{const d=[];return o&&o.forEach(s=>{d.push(s.clientHeight)}),d};
1class ft extends k.PureComponent{constructor(...d){super(...d),this.state={condensed:!1,columnVisibilityData:[],isScrolledFarthestLeft:!0,isScrolledFarthestRight:!1,rowHovered:void 0},this.dataTable=k.createRef(),this.scrollContainer=k.createRef(),this.table=k.createRef(),this.stickyTable=k.createRef(),this.stickyNav=null,this.headerNav=null,this.tableHeadings=[],this.stickyHeadings=[],this.tableHeadingWidths=[],this.stickyHeaderActive=!1,this.scrollStopTimer=null,this.handleResize=rt(()=>{const{table:{current:s},scrollContainer:{current:t}}=this;let n=!1;s&&t&&(n=s.scrollWidth>t.clientWidth+1),this.setState({condensed:n,...this.calculateColumnVisibilityData(n)})}),this.setCellRef=({ref:s,index:t,inStickyHeader:n})=>{if(s!=null)if(n){this.stickyHeadings[t]=s;const i=s.querySelector("button");if(i==null)return;i.addEventListener("focus",this.handleHeaderButtonFocus)}else this.tableHeadings[t]=s,this.tableHeadingWidths[t]=s.clientWidth},this.changeHeadingFocus=()=>{const{tableHeadings:s,stickyHeadings:t,stickyNav:n,headerNav:i}=this,r=t.findIndex(C=>{var f;return C===((f=document.activeElement)==null?void 0:f.parentElement)}),b=s.findIndex(C=>{var f;return C===((f=document.activeElement)==null?void 0:f.parentElement)}),a=n==null?void 0:n.querySelectorAll("button"),u=i==null?void 0:i.querySelectorAll("button");let m=-1;a==null||a.forEach((C,f)=>{C===document.activeElement&&(m=f)});let p=-1;if(u==null||u.forEach((C,f)=>{C===document.activeElement&&(p=f)}),r<0&&b<0&&m<0&&p<0)return null;let l;if(r>=0?l=s[r].querySelector("button"):b>=0&&(l=t[b].querySelector("button")),m>=0?l=u==null?void 0:u[m]:p>=0&&(l=a==null?void 0:a[p]),l==null)return null;l.style.visibility="visible",l.focus(),l.style.removeProperty("visibility")},this.calculateColumnVisibilityData=s=>{const t=this.fixedFirstColumns(),{table:{current:n},scrollContainer:{current:i},dataTable:{current:r}}=this,{stickyHeader:b}=this.props;if((b||s)&&n&&i&&r){const a=n.querySelectorAll(fe.selector),u=a[t-1],m=t?u.offsetLeft+u.offsetWidth:0;if(a.length>0){const p=a.length-1,l=i.scrollLeft+m,C=i.scrollLeft+r.offsetWidth,f={firstVisibleColumnIndex:p,tableLeftVisibleEdge:l,tableRightVisibleEdge:C},v=[...a].map(mt(f)),j=v[v.length-1],E=t?l===m:l===0;return{columnVisibilityData:v,...pt(f,v),isScrolledFarthestLeft:E,isScrolledFarthestRight:j.rightEdge<=C}}}return{columnVisibilityData:[],previousColumn:void 0,currentColumn:void 0}},this.handleHeaderButtonFocus=s=>{var l;const t=this.fixedFirstColumns();if(this.scrollContainer.current==null||s.target==null||this.state.columnVisibilityData.length===0)return;const i=s.target.parentNode,r=this.scrollContainer.current.scrollLeft,b=this.scrollContainer.current.offsetWidth,a=r+b,u=this.state.columnVisibilityData.length>0?(l=this.state.columnVisibilityData[t])==null?void 0:l.rightEdge:0,m=i.offsetLeft,p=i.offsetLeft+i.offsetWidth;r>m-u&&(this.scrollContainer.current.scrollLeft=m-u),p>a&&(this.scrollContainer.current.scrollLeft=p-b)},this.stickyHeaderScrolling=()=>{const{current:s}=this.stickyTable,{current:t}=this.scrollContainer;s==null||t==null||(s.scrollLeft=t.scrollLeft)},this.scrollListener=()=>{var s;this.scrollStopTimer&&clearTimeout(this.scrollStopTimer),this.scrollStopTimer=setTimeout(()=>{this.setState(t=>({...this.calculateColumnVisibilityData(t.condensed)}))},100),this.setState({isScrolledFarthestLeft:((s=this.scrollContainer.current)==null?void 0:s.scrollLeft)===0}),this.props.stickyHeader&&this.stickyHeaderActive&&this.stickyHeaderScrolling()},this.handleHover=s=>()=>{this.setState({rowHovered:s})},this.handleFocus=s=>{var u;const t=this.fixedFirstColumns();if(this.scrollContainer.current==null||s.target==null)return;const n=s.target.parentNode,r=this.props?(u=this.state.columnVisibilityData[t])==null?void 0:u.rightEdge:0,a=n.offsetLeft-r;this.scrollContainer.current.scrollLeft>a&&(this.scrollContainer.current.scrollLeft=a)},this.navigateTable=s=>{var m;const t=this.fixedFirstColumns(),{currentColumn:n,previousColumn:i}=this.state,r=(m=this.state.columnVisibilityData[t-1])==null?void 0:m.rightEdge;if(!n||!i)return;let b=0;for(let p=0;p<n.index;p++)b+=this.state.columnVisibilityData[p].width;const{current:a}=this.scrollContainer;return()=>{let p=0;t?p=s==="right"?b-r+n.width:b-i.width-r:p=s==="right"?n.rightEdge:i.leftEdge,a&&(a.scrollLeft=p,requestAnimationFrame(()=>{this.setState(l=>({...this.calculateColumnVisibilityData(l.condensed)}))}))}},this.renderHeading=({heading:s,headingIndex:t,inFixedNthColumn:n,inStickyHeader:i})=>{var R;const{sortable:r,truncate:b=!1,columnContentTypes:a,defaultSortDirection:u,initialSortColumnIndex:m=0,verticalAlign:p,firstColumnMinWidth:l}=this.props,C=this.fixedFirstColumns(),{sortDirection:f=u,sortedColumnIndex:v=m,isScrolledFarthestLeft:j}=this.state;let E;const I=`heading-cell-${t}`,_=`stickyheader-${t}`,V=i?_:I;if(r){const L=r[t],S=L&&v===t;E={defaultSortDirection:u,sorted:S,sortable:L,sortDirection:S?f:"none",onSort:this.defaultOnSort(t),fixedNthColumn:C,inFixedNthColumn:C}}const w=i?this.tableHeadingWidths[t]:void 0,Y=!j,F={header:!0,stickyHeadingCell:i,content:s,contentType:a[t],nthColumn:t<C,fixedFirstColumns:C,truncate:b,headingIndex:t,...E,verticalAlign:p,handleFocus:this.handleFocus,stickyCellWidth:w,fixedCellVisible:Y,firstColumnMinWidth:l};return n&&i?[c.createElement(oe,Object.assign({key:V},F,{setRef:L=>{this.setCellRef({ref:L,index:t,inStickyHeader:i})},inFixedNthColumn:!1})),c.createElement(oe,Object.assign({key:`${V}-sticky`},F,{setRef:L=>{this.setCellRef({ref:L,index:t,inStickyHeader:i})},inFixedNthColumn:!!C,lastFixedFirstColumn:t===C-1,style:{left:(R=this.state.columnVisibilityData[t])==null?void 0:R.leftEdge}}))]:c.createElement(oe,Object.assign({key:V},F,{setRef:L=>{this.setCellRef({ref:L,index:t,inStickyHeader:i})},lastFixedFirstColumn:t===C-1,inFixedNthColumn:n}))},this.totalsRowHeading=()=>{const{i18n:s,totals:t,totalsName:n}=this.props,i=n||{singular:s.translate("Polaris.DataTable.totalRowHeading"),plural:s.translate("Polaris.DataTable.totalsRowHeading")};return t&&t.filter(r=>r!=="").length>1?i.plural:i.singular},this.renderTotals=({total:s,index:t})=>{const n=this.fixedFirstColumns(),i=`totals-cell-${t}`,{truncate:r=!1,verticalAlign:b,columnContentTypes:a}=this.props;let u,m;t===0&&(u=this.totalsRowHeading()),s!==""&&t>0&&(m=a[t],u=s);const p=this.props.showTotalsInFooter;return c.createElement(oe,{total:!0,totalInFooter:p,nthColumn:t<=n-1,firstColumn:t===0,key:i,content:u,contentType:m,truncate:r,verticalAlign:b})},this.getColSpan=(s,t,n,i)=>{if(this.fixedFirstColumns())return 1;const b=s||1,a=t||n,u=Math.floor(a/b),m=a%b;return i===0?u+m:u},this.defaultRenderRow=({row:s,index:t,inFixedNthColumn:n,rowHeights:i})=>{const{columnContentTypes:r,truncate:b=!1,verticalAlign:a,hoverable:u=!0,headings:m}=this.props,{condensed:p}=this.state,l=this.fixedFirstColumns(),C=B(h.TableRow,u&&h.hoverable);return c.createElement("tr",{key:`row-${t}`,className:C,onMouseEnter:this.handleHover(t),onMouseLeave:this.handleHover()},s.map((f,v)=>{const j=t===this.state.rowHovered,E=`cell-${v}-row-${t}`,I=this.getColSpan(s.length,m.length,r.length,v);return c.createElement(oe,{key:E,content:f,contentType:r[v],nthColumn:v<=l-1,firstColumn:v===0,truncate:b,verticalAlign:a,colSpan:I,hovered:j,style:i?{height:`${i[t]}px`}:{},inFixedNthColumn:p&&n})}))},this.defaultOnSort=s=>{const{onSort:t,defaultSortDirection:n="ascending",initialSortColumnIndex:i}=this.props,{sortDirection:r=n,sortedColumnIndex:b=i}=this.state;let a=n;return b===s&&(a=r==="ascending"?"descending":"ascending"),()=>{this.setState({sortDirection:a,sortedColumnIndex:s},()=>{t&&t(s,a)})}}}componentDidMount(){this.handleResize()}componentDidUpdate(d){lt(d,this.props)||this.handleResize()}componentWillUnmount(){this.handleResize.cancel()}render(){var te,W,$;const{headings:d,totals:s,showTotalsInFooter:t,rows:n,footerContent:i,hideScrollIndicator:r=!1,increasedTableDensity:b=!1,hasZebraStripingOnData:a=!1,stickyHeader:u=!1,hasFixedFirstColumn:m=!1,pagination:p}=this.props,{condensed:l,columnVisibilityData:C,isScrolledFarthestLeft:f,isScrolledFarthestRight:v}=this.state,j=this.fixedFirstColumns(),E=n.length%2===0,I=B(h.DataTable,l&&h.condensed,s&&h.ShowTotals,t&&h.ShowTotalsInFooter,a&&h.ZebraStripingOnData,a&&E&&h.RowCountIsEven),_=B(h.TableWrapper,l&&h.condensed,b&&h.IncreasedTableDensity,u&&h.StickyHeaderEnabled),V=c.createElement("tr",null,d.map((y,T)=>this.renderHeading({heading:y,headingIndex:T,inFixedNthColumn:!1,inStickyHeader:!1}))),w=s?c.createElement("tr",null,s.map((y,T)=>this.renderTotals({total:y,index:T}))):null,Y=n.map(y=>y.slice(0,j)),F=d.slice(0,j),R=s==null?void 0:s.slice(0,j),L=(te=this.table.current)==null?void 0:te.children[0].childNodes,S=(W=this.table.current)==null?void 0:W.children[1].childNodes,M=Pe(L),U=Pe(S),X=l&&j!==0&&
1c.createElement("table",{className:B(h.FixedFirstColumn,!f&&h.separate),style:{width:`${($=C[j-1])==null?void 0:$.rightEdge}px`}},c.createElement("thead",null,c.createElement("tr",{style:{height:`${M[0]}px`}},F.map((y,T)=>this.renderHeading({heading:y,headingIndex:T,inFixedNthColumn:!0,inStickyHeader:!1}))),s&&!t&&c.createElement("tr",{style:{height:`${M[1]}px`}},R==null?void 0:R.map((y,T)=>this.renderTotals({total:y,index:T})))),c.createElement("tbody",null,Y.map((y,T)=>this.defaultRenderRow({row:y,index:T,inFixedNthColumn:!0,rowHeights:U}))),s&&t&&c.createElement("tfoot",null,c.createElement("tr",null,R==null?void 0:R.map((y,T)=>this.renderTotals({total:y,index:T}))))),ne=n.map((y,T)=>this.defaultRenderRow({row:y,index:T,inFixedNthColumn:!1})),G=i?c.createElement("div",{className:h.Footer},i):null,ae=p?c.createElement(Qe,Object.assign({type:"table"},p)):null,le=t?null:w,q=t?c.createElement("tfoot",null,w):null,K=y=>r?null:c.createElement(gt,{columnVisibilityData:C,isScrolledFarthestLeft:f,isScrolledFarthestRight:v,navigateTableLeft:this.navigateTable("left"),navigateTableRight:this.navigateTable("right"),fixedFirstColumns:j,setRef:T=>{y==="header"?this.headerNav=T:y==="sticky"&&(this.stickyNav=T)}}),ee=u?c.createElement(ut,null,c.createElement("div",{className:h.StickyHeaderWrapper,role:"presentation"},c.createElement(ht,{boundingElement:this.dataTable.current,onStickyChange:y=>{this.changeHeadingFocus(),this.stickyHeaderActive=y}},y=>{const T=B(h.StickyHeaderInner,y&&h["StickyHeaderInner-isSticky"]),Z=B(h.StickyHeaderTable,!f&&h.separate);return c.createElement("div",{className:T},c.createElement("div",null,K("sticky")),c.createElement("table",{className:Z,ref:this.stickyTable},c.createElement("thead",null,c.createElement("tr",{className:h.StickyTableHeadingsRow},d.map((J,re)=>this.renderHeading({heading:J,headingIndex:re,inFixedNthColumn:!!(re<=j-1&&j),inStickyHeader:!0}))))))}))):null;return c.createElement("div",{className:_,ref:this.dataTable},ee,K("header"),c.createElement("div",{className:I},c.createElement("div",{className:h.ScrollContainer,ref:this.scrollContainer},c.createElement(Fe,{event:"resize",handler:this.handleResize}),c.createElement(Fe,{capture:!0,passive:!0,event:"scroll",handler:this.scrollListener}),X,c.createElement("table",{className:h.Table,ref:this.table},c.createElement("thead",null,V,le),c.createElement("tbody",null,ne),q)),ae,G))}fixedFirstColumns(){const{hasFixedFirstColumn:d,fixedFirstColumns:s=0,headings:t}=this.props,n=d&&!s?1:s;return n>=t.length?0:n}}function Ct(o){const d=Ce();return c.createElement(ft,Object.assign({},o,{i18n:d}))}function kt(o,d,s,t,n,i){return o.map(r=>{var m,p;const b=(n==null?void 0:n.id)===r.id&&(n==null?void 0:n.action)==="edit",a=b?e.jsx(ke,{name:`to-${r.id}`,value:n.newTo||r.pathTo,onChange:l=>s(r.id,l),placeholder:i("redirectPlaceholder","/new-url"),autoComplete:"off"},`textfield-${r.id}`):e.jsx(D,{as:"p",fontWeight:"medium",children:r.pathTo}),u=e.jsxs(P,{gap:"100",children:[b?e.jsx(A,{primary:!0,size:"slim",disabled:!n.newTo||n.newTo.trim()==="",children:i("tableSave","Save")}):e.jsx(A,{onClick:()=>t(r),accessibilityLabel:"Edit Redirect",variant:"plain",children:i("tableEdit","âï¸ Edit")}),e.jsxs(d.Form,{method:"post",replace:!0,style:{display:"inline"},children:[e.jsx("input",{type:"hidden",name:"action",value:"delete_redirect"}
1),e.jsx("input",{type:"hidden",name:"id",value:r.id}),e.jsx(A,{submit:!0,variant:"plain",tone:"critical",accessibilityLabel:"Delete Redirect",loading:((m=d.submission)==null?void 0:m.formData.get("id"))===r.id&&((p=d.submission)==null?void 0:p.formData.get("action"))==="delete_redirect",children:i("tableDelete","ðï¸ Delete")})]})]});return[r.pathFrom,a,new Date(r.createdAt).toLocaleDateString(),u]})}const yt=c.memo(({item:o,fetcher:d,redirectInputs:s,handleRedirectInputChange:t,t:n})=>{var m,p,l,C;const i=k.useMemo(()=>{try{return new URL(o.url).pathname}catch{return o.url}},[o.url]),r=s[o.id]||"",{isSelected:b,onToggleSelect:a}=o,u=k.useMemo(()=>o.status===404?n("brokenLinkText","Broken Link"):o.status>=300&&o.status<400?n("redirectedStatus","Redirected"):o.status>=200&&o.status<300?n("okStatus","OK"):n("unknownStatus","Unknown"),[o.status,n]);return e.jsx(se,{sectioned:!0,children:e.jsxs(z,{gap:"200",children:[e.jsx(he,{label:n("selectLink","Sélectionner ce lien"),checked:!!b,onChange:f=>a(o.id,f)}),e.jsxs(D,{as:"p",variant:"headingSm",tone:"critical",children:["ð¨ ",e.jsxs("strong",{style:{color:"#d9534f"},children:[n("linkItemURL","Found Broken URL"),":"]})," ",o.url]}
1),e.jsxs(P,{gap:"200",blockAlign:"center",children:[e.jsxs(D,{as:"p",tone:"subdued",children:[n("linkItemStatus","Status"),": ",o.status," (",u,") "]}),e.jsx("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"},children:e.jsxs(A,{variant:"tertiary",size:"micro",children:["ð ",n("visitLinkBtn","Visit Link")," "]})})]}),e.jsxs(P,{gap:"200",blockAlign:"end",wrap:!1,children:[e.jsxs(d.Form,{method:"post",replace:!0,children:[e.jsx("input",{type:"hidden",name:"action",value:"redirect_and_delete"}),e.jsx("input",{type:"hidden",name:"id",value:o.id}),e.jsx("input",{type:"hidden",name:"from",value:i}),e.jsxs(P,{gap:"200",blockAlign:"end",children:[e.jsx(ke,{label:n("redirectLabel","Redirect to Path/URL"),labelHidden:!0,placeholder:n("redirectPlaceholder","/new-url"),name:"to",value:r,onChange:f=>t(o.id,f),autoComplete:"off",monospaced:!0}),e.jsx(A,{submit:!0,primary:!0,loading:((m=d.submission)==null?void 0:m.formData.get("id"))===o.id&&((p=d.submission)==null?void 0:p.formData.get("action"))==="redirect_and_delete",disabled:!r.trim(),children:n("redirectBtn","Redirect")})]})]}),e.jsxs(d.Form,{method:"post",replace:!0,children:[e.jsx("input",{type:"hidden",name:"action",value:"delete_broken"}),e.jsx("input",{type:"hidden",name:"id",value:o.id}),e.jsxs(A,{submit:!0,tone:"critical",variant:"plain",size:"micro",accessibilityLabel:"Delete broken link entry",loading:((l=d.submission)==null?void 0:l.formData.get("id"))===o.id&&((C=d.submission)==null?void 0:C.formData.get("action"))==="delete_broken",children:["ðï¸ ",n("deleteBrokenBtn","Supprimer ce lien")]})]})]})]})},o.id)}),xt=({manualFetcher:o,manualUrlInput:d,setManualUrlInput:s,t})=>{const n=o.state!=="idle";return e.jsx(se,{padding:"400",children:e.jsxs(z,{gap:"300",children:[e.jsxs(D,{variant:"headingMd",as:"h3",children:["ð ",t("manualAddTitle","Manually Check or Add URL")]}),e.jsxs(o.Form,{method:"post",replace:!0,children:[e.jsx("input",{type:"hidden",name:"action",value:"add_manual"}),e.jsxs(P,{gap:"200",blockAlign:"center",children:[e.jsx("div",{style:{flex:1},children:e.jsx(ke,{type:"text",name:"manualUrl",value:d,onChange:s,placeholder:t("manualAddPlaceholder","/my-missing-page or https://your-shop.com/some/path"),required:!0,autoComplete:"off",monospaced:!0,label:t("manualAddLabel","URL or Relative Path"),labelHidden:!0},"manual-url-input-key")}),e.jsxs(A,{submit:!0,primary:!0,loading:n,disabled:!d.trim(),children:["â
",t("manualAddBtn","Check / Add")," "]})]}),n&&e.jsx(D,{as:"p",tone:"subdued",paddingBlockStart:"100",children:t("manualAddChecking","Checking this URL...")}),e.jsx(D,{as:"p",tone:"subdued",alignment:"start",paddingBlockStart:"100",children:t("manualAddSubtext","If you pass a relative path (e.g., /missing-page), the app will check the full URL for your store.")})]})]})})};function Vt(){var ve,Te,Se,je,De,Ae,Ee,_e;const{brokenLinks:o,redirectEntries:d,isAppActive:s,storeDomain:t,translations:n,currentLanguage:i,totalBrokenCount:r}=st(),b=nt(),a=Le(),u=Le(),m=at(),p=(g,x)=>{if(n[i]){const H=g.split(".");let N=n[i];for(const ce of H)if(N&&N[ce])N=N[ce];else{if(i!=="en"&&n.en){let Q=n.en;for(const ie of H)if(Q&&Q[ie])Q=Q[ie];else return x;return Q}return x}return N}return x},l=(g,x)=>p(`BrokenLinks.${g}`,x),C=r??o.length,[f,v]=k.useState(s),[j,E]=k.useState(!1),[I,_]=k.useState(""),[V,w]=k.useState(!1),[Y,F]=k.useState({}),[R,L]=k.useState(""),[S,M]=k.useState(null),[U,X]=k.useState(!1),[ne,G]=k.useState(!1),[ae,le]=k.useState(!1),[q,K]=k.useState(!1),[ee,te]=k.useState(!1),[W,$]=k.useState(!0),[y,T]=k.useState(!1),[Z,J]=k.useState([]),re=((ve=a.submission)==null?void 0:ve.formData.get("action"))==="recheck_all",ye=((Te=a.submission)==null?void 0:Te.formData.get("action"))==="bulk_apply";k.useEffect(()=>{q&&a.state==="idle"&&K(!1)},[a.state,q]);const O=(o||[]).filter(g=>g.status===404),me=Z.length||O.length,He=g=>{J(g?O.map(x=>x.id):[])},we=(g,x)=>{J(H=>x?Array.from(new Set([...H,g])):H.filter(N=>N!==g))},Ne=k.useCallback((g,x)=>{F(H=>({...H,[g]:x}))},[]),Be=()=>{const g={};o.forEach(x=>{g[x.id]="/"}),F(g)},xe=k.useCallback(()=>{const x=`https://admin.shopify.com/store/${t.replace(".myshopify.com","")}/themes/current/editor?context=apps&activateAppId=63613c447644d2972927afbd6750beda%2Fbroken_links_redirect`;window.open(x,"_blank")},[t]),Ie=k.useCallback(()=>{const g=f?"Deactivate":"Activate";v(!f),a.submit({action:g},{method:"post",replace:!0})},[f,a]),Ve=k.useCallback(g=>{M({id:g.id,action:"edit",newTo:g.pathTo})},[]),pe=k.useCallback(()=>{M(null)},[]),Me=k.useCallback(()=>{S&&S.id&&S.newTo&&(a.submit({action:"edit_redirect",id:S.id,to:S.newTo},{method:"post",replace:!0}),pe())},[S,a,pe]),We=k.useCallback(g=>{M(x=>x?{...x,newTo:g}:null)},[]);k.useEffect(()=>{a.state==="idle"&&(X(!1),G(!1),le(!1),te(!1))},[a.state]),k.useEffect(()=>{var g,x,H;if(a.state==="idle"&&a.data){if(a.data.error)(((g=a.submission)==null?void 0:g.formData.get("action"))==="Activate"||((x=a.submission)==null?void 0:x.formData.get("action"))==="Deactivate")&&v(a.submission.formData.get("action")==="Deactivate"),w(!0),_(a.data.error);else if(a.submission){const N=a.submission.formData.get("action"),ce=a.submission.formData.get("id");switch(N){case"Activate":case"Deactivate":a.data.success&&_(`App ${N==="Activate"?"Activated":"Deactivated"} successfully`);break;case"redirect_and_delete":F(Q=>{const ie={...Q};return delete ie[ce],ie}),_("Redirect created and link removed.");break;case"delete_redirect":_("Redirect deleted successfully.");break;case"edit_redirect":_("Redirect updated successfully.");break;case"redirect_all_home":_((H=a.data)!=null&&H.redirected?`${a.data.redirected} redirects created to homepage.`:"Redirects created to homepage."),m.revalidate();break;default:_("Action completed successfully.");break}w(!1)}a.submission&&E(!0)}},[a.state,a.data,a.submission,m,F,v,w,_]),u.state!=="idle"&&((Se=u.submission)==null||Se.formData.get("action"));const $e=k.useCallback(()=>E(g=>!g),[]),Oe=j?e.jsx(it,{children:e.jsx(ot,{content:I,onDismiss:$e,error:V})}):null,ze=[l("tablePathFrom","Path From"),l("tableRedirectTo","Redirect To"),l("tableCreatedAt","Created At"),l("tableActions","Actions")],be=((je=a.submission)==null?void 0:je.formData.get("id"))===(S==null?void 0:S.id)&&((De=a.submission)==null?void 0:De.formData.get("action"))==="edit_redirect",Ue=f?null:e.jsx(de,{title:l("themeActivationTitle","Theme Activation Required"),tone:"info",icon:e.jsx("div",{style:{fontSize:"1.25rem"},children:"âï¸"}),children:e.jsxs(z,{gap:"200",children:[e.jsx(D,{as:"p",children:l("themeActivationBody","To activate the **Broken Links** feature, click **Activate App** above, then click the button below to enable the App Embed Block in your theme settings.")}),e.jsxs(A,{size:"large",onClick:xe,style:{backgroundColor:"#202223",color:"#ffffff"},children:[l("themeSettingsBtn","Go to Theme Settings")," "]})]})}),qe=f?e.jsx(de,{tone:"success",title:l("appActivationOkTitle","Application Active"),children:e.jsx(D,{as:"p",children:l("appActivationOkBody","Your application is correctly activated in your theme.")})}):null;return e.jsxs(Xe,{backAction:{content:"Back to Apps",onAction:()=>b("/app")},title:`ð« ${l("pageTitle","Liens en erreur")}`,subtitle:l("pageSubtitle","Gérez les liens en erreur et leurs redirections."),primaryAction:f?void 0:{content:l("activateBtn","Activate App"),tone:"success",onAction:Ie,loading:((Ae=a.submission)==null?void 0:Ae.formData.get("action"))==="Activate"}
1,secondaryActions:f?[]:[{content:l("themeBtn","Enable App in Theme"),onAction:xe,disabled:!1}],children:[e.jsxs(ue,{children:[e.jsx(ue.Section,{children:e.jsx(se,{roundedAbove:"sm",children:e.jsxs(z,{gap:"400",children:[e.jsxs(P,{align:"space-between",blockAlign:"center",children:[e.jsxs(z,{gap:"100",children:[e.jsx(D,{variant:"headingLg",as:"h2",children:l("statusTitle","App Status")}),e.jsx(D,{as:"p",tone:"subdued",children:l("statusSubtitle","Current status of the app's background logic on your store.")})]}),e.jsx(et,{tone:f?"success":"critical",children:f?l("statusActive","Active"):l("statusInactive","Inactive")})]}),Ue,qe]})})}),e.jsx(ue.Section,{children:e.jsx(se,{roundedAbove:"sm",children:e.jsxs(z,{gap:"400",children:[e.jsxs(P,{align:"space-between",blockAlign:"center",children:[e.jsx(D,{variant:"headingLg",as:"h2",children:l("listTitleCount","Liens en erreur ({count})").replace("{count}",C)}),e.jsxs(P,{gap:"200",children:[e.jsxs(a.Form,{method:"post",replace:!0,children:[e.jsx("input",{type:"hidden",name:"action",value:"scan"}),e.jsxs(A,{submit:!0,onClick:()=>X(!0),loading:U||((Ee=a.submission)==null?void 0:Ee.formData.get("action"))==="scan",primary:!0,size:"large",children:["â±ï¸ ",l("scanBtn","Scan Store")]})]}),e.jsx(A,{variant:"secondary",onClick:Be,children:l("fillAllWithHomeBtn","Rediriger tous vers la page dâaccueil")}),e.jsxs(a.Form,{method:"post",replace:!0,children:[e.jsx("input",{type:"hidden",name:"action",value:"recheck_all"}),e.jsx(A,{submit:!0,onClick:()=>K(!0),loading:q||re,variant:"secondary",tone:"success",size:"large",children:l("recheckBtn","Re-Check Existing")})]}),e.jsxs(a.Form,{method:"post",replace:!0,children:[e.jsx("input",{type:"hidden",name:"action",value:"delete_all_broken"}),e.jsxs(A,{submit:!0,onClick:()=>G(!0),loading:ne||((_e=a.submission)==null?void 0:_e.formData.get("action"))==="delete_all_broken",tone:"critical",variant:"secondary",size:"large",children:["ðï¸ ",l("deleteAllBtn","Supprimer tous les liens")]})]})]}),ae&&e.jsxs(P,{gap:"100",blockAlign:"center",children:[e.jsx(ge,{size:"small"}),e.jsx(D,{as:"p",tone:"subdued",children:l("redirectAllProgress",`Redirections en cours... (${O.length} éléments)`).replace("{count}",O.length)})]}),q&&e.jsxs(P,{gap:"100",blockAlign:"center",children:[e.jsx(ge,{size:"small"}),e.jsx(D,{as:"p",tone:"subdued",children:l("recheckProgress",`Re-checking existing... (${C} éléments)`).replace("{count}",C)})]}),e.jsx(se,{children:e.jsxs(z,{gap:"200",children:[e.jsxs(P,{gap:"200",blockAlign:"center",children:[e.jsx(he,{label:l("bulkSelectAll","Tout sélectionner"),checked:Z.length===O.length&&O.length>0,onChange:He,disabled:O.length===0}),e.jsx(he,{label:l("bulkRedirectLabel","Redirect to homepage"),checked:W,onChange:g=>$(g)}),e.jsx(he,{label:l("bulkDeleteLabel","Supprimer les liens"),checked:y,onChange:g=>T(g)}),e.jsxs(a.Form,{method:"post",replace:!0,children:[e.jsx("input",{type:"hidden",name:"action",value:"bulk_apply"}),e.jsx("input",{type:"hidden",name:"applyRedirect",value:W?"on":""}),e.jsx("input",{type:"hidden",name:"applyDelete",value:y?"on":""}),Z.map(g=>e.jsx("input",{type:"hidden",name:"selectedIds",value:g},g)),e.jsx(A,{submit:!0,onClick:()=>te(!0),tone:"success",variant:"primary",size:"large",loading:ee||ye,disabled:!W&&!y||me===0,children:l("bulkApplyBtn","Appliquer les actions")})]})]}),(ee||ye)&&e.jsxs(P,{gap:"100",blockAlign:"center",children:[e.jsx(ge,{size:"small"}),e.jsx(D,{as:"p",tone:"subdued",children:l("bulkApplying",`Application des actions... (${me} éléments)`).replace("{count}",me)})]})]})})]}),e.jsx(xt,{manualFetcher:u,manualUrlInput:R,setManualUrlInput:L,t:(g,x)=>l(g,x)}),O.length===0?e.jsx(de,{title:l("noLinksTitle","No Broken Links Found"),tone:"success",children:e.jsx(D,{as:"p",children:l("noLinksText","Congratulations, your last scan shows no 404 broken links. You can run a full store scan or manually add a URL to check.")})}):e.jsx(z,{gap:"300",children:O.map(g=>e.jsx(yt,{item:{...g,isSelected:Z.includes(g.id),onToggleSelect:we},fetcher:a,redirectInputs:Y,handleRedirectInputChange:Ne,t:(x,H)=>l(x,H)},g.id))})]})})}
1),e.jsx(ue.Section,{children:e.jsx(se,{roundedAbove:"sm",children:e.jsxs(z,{gap:"400",children:[e.jsx(D,{variant:"headingLg",as:"h2",children:l("redirectsTitleCount","Existing Custom Redirects ({count})").replace("{count}",d.length)}),d.length===0?e.jsx(de,{title:l("noRedirectsTitle","No Custom Redirects"),tone:"info",children:e.jsx(D,{as:"p",children:l("noRedirectsText","You haven't created any custom redirects yet. Use the tool above to add redirects for broken links.")})}):e.jsxs("div",{children:[e.jsx(Ct,{columnContentTypes:["text","text","text","text"],headings:ze,rows:kt(d,a,We,Ve,S,l)}),S&&S.action==="edit"&&e.jsx(tt,{paddingBlockStart:"400",children:e.jsxs(P,{gap:"200",align:"end",children:[e.jsx(A,{onClick:pe,variant:"secondary",disabled:be,children:l("tableCancel","Cancel Edit")}),e.jsx(A,{onClick:Me,primary:!0,loading:be,disabled:!S.newTo||S.newTo.trim()===""||be,children:l("tableSave","Save Redirect")})]})})]})]})})})]}),Oe]})}export{Vt 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.