import{j as s,R as C,S as N,h as l}from"./vendor-ClLR6ncd.js";import{u as M,i as B,S as F}from"./initStatement-DliSOXN8.js";import{d as p}from"./configs-Cm_sEDXb.js";import{k as q}from"./lodash-ZyeDnt0e.js";import{n as W,L as I,h as k,i as z,f as U}from"./index-OtVJl4GC.js";import{E as y}from"./Messages-BRmQDxrZ.js";import{p as H}from"./pluralize-BF8NJH6e.js";import{u as P,A as _}from"./useDefaultMutationOptions-CUrzq21a.js";import{u as G}from"./useNamespaces-B-2wwTCG.js";import{V as Q}from"./highlightSearch-BTHB3jgf.js";import{u as J}from"./model-Dfrorm_S.js";import"./ui-DKzyPIqx.js";import{u as b}from"./model-Cx9iH8L7.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";import"./index-BpKmttxq.js";import"./model-mC-LLJuv.js";import"./DialogContent-DR8Wx7Lo.js";import"./DialogTitle-i0lt2jWQ.js";import"./DialogContentText-5YOBSelz.js";import"./Link-BLwKPJFF.js";import"./model-DgFcCvKB.js";import"./WithMeasure-BDk9QPMF.js";import"./TableRow-CGDSOtFZ.js";import"./TableSortLabel-BJFq2axQ.js";import"./Box-Co2WcNPC.js";import"./TypographyWithTooltip-BFAG3Va9.js";import"./Autocomplete-Cjt7Q9VV.js";import"./Chip-DoCs8Smb.js";function K({statements:t,columns:e}){const r=G(),a=3,n=J(t.every(o=>!!o[a])?e:e.slice(0,a),r,!1,!1),{value:i}=W();return r.isLoading?s.jsx(I,{}):s.jsx("div",{style:{height:"100%"},children:s.jsx(Q,{rows:t,columns:n,dense:i})})}const j=B();function X(){const[{statements:t,invalid:e},r]=C.useState({statements:{[j.id]:j},invalid:!0});return{deleteMatching:t[q(t)[0]],isInvalidDeleteMatching:e,updateStatement:M(r)}}function Y(t){return k((e,r)=>z({url:U(r,"statements"),method:"delete",params:Object.assign({},...p.filter(({key:a})=>t[a]!=="*").map(({queryParameter:a,key:n})=>({[a]:t[n]||"null"})))}),P())}const Z=t=>{const e=t.values[0][0];return{total:Number.parseInt(e.slice(1,e.slice(1).indexOf('"')+1),10)}},u=(t,e)=>t==="*"?e:t,tt=t=>t==="*"?"":t,v="?s",S="?p",$="?o",et="?g";function st({Graph:t,Subject:e,Predicate:r,Object:a},n){const i=u(e,v),o=u(r,S),R=u(a,$),w=`select ${v} ${S} ${$} ${t===""?"":et}`,c=`${i} ${o} ${R}`,m=`{ ${c} }`,E=`{ graph ${t} { ${c} } }`,d=t==="*"?`{ ${m} UNION { GRAPH ?g ${m}  } }`:t===""?m:E,f="PREFIX franzOption_defaultDatasetBehavior: <franz:rdf>",h=`${f} ${w} ${d}`,x=`${f} SELECT (COUNT(*) as ?Triples) WHERE ${d}`,T=[e,r,a,t].map(tt),D=b(h,[h],{enabled:n,queryOptions:{limit:1e3},transformResponse:g=>({...g,values:g.values.map(O=>O.map((V,A)=>V||T[A]))})}),L=b(x,[x],{enabled:n,queryOptions:{},transformResponse:Z});return{statementsToDelete:D,countQueries:L}}const rt=p.map(({key:t})=>t);function at({statementsToDelete:t,countQueries:e}){if(t.isIdle||e.isIdle)return s.jsx(l,{textAlign:"center",color:"text.disabled",children:"After filling filter above there will be a table of statements to be deleted"});if(t.isLoading||e.isLoading)return s.jsx(I,{});if(t.isError)return s.jsx(y,{error:t.error});if(e.isError)return s.jsx(y,{error:e.error});const r=e.data.total;return s.jsxs(s.Fragment,{children:[s.jsxs(l,{children:[Number.isInteger(r)?r:"..."," ",H("statement",r)," will be deleted",r>t.data.values.length?`. Showing only ${t.data.values.length}`:""]}),s.jsx(K,{statements:t.data.values,columns:rt})]})}const nt=t=>p.every(({key:e})=>t[e]==="*");function Ct(){const{deleteMatching:t,isInvalidDeleteMatching:e,updateStatement:r}=X(),a=nt(t),n=Y(t),{statementsToDelete:i,countQueries:o}=st(t,!a&&!e);return s.jsx(_,{description:`To specify a node or literal in any of the four fields, use syntax resembling N-triples:
- <http://example.com/node20>
- "a literal with a \\n newline"
- "a literal with a type"^^<http://example.com/type2>
- "un littéral avec une langue"@fr
- xsd:integer
- *

"*" is interpreted as a wildcard. "xsd:integer" only works if you have a namespace prefix 'xsd' defined. Unicode characters can be escaped, as "\\u00e9" in "littéral".`,action:s.jsx(F,{sx:{mb:1,pb:2},disabled:n.isLoading,statement:t,updateStatement:r,statementInputs:p,Header:s.jsx(l,{variant:"h6",children:"Delete statements"})}),extraInfo:s.jsx(N,{justifyContent:"center",flexGrow:1,spacing:1,children:a?s.jsx(l,{align:"center",color:"error.main",variant:"h4",children:"All statements in the repository will be deleted!"}):s.jsx(at,{statementsToDelete:i,countQueries:o})}),actionKind:"deleted",applyButtonLabel:"Delete statements",applyButtonDisabled:e,applyButtonTooltip:e?"Input fields are empty":"",mutation:n,actionTitle:"Input filter to delete statements"})}export{Ct as default};
