import{$ as I}from"./DJPYbysN.js";import{L as d,b6 as x,aH as L,u as _}from"./QlNHqkx-.js";const{getTitleLabel:p,joinMeta:s,isArticle:a,isExpandBook:N,sortIndexMetas:O,indexMetas:R,getSpecifiedIndexTitle:A,getSpecifiedIndexAuthor:D,getSpecifiedIndexPage:H}=x(),S=()=>{const h=(e,t)=>e?p(t):s(t?.meta,"t02450").substring(0,200),T=e=>(e?.meta?.t03006?`${s(e?.meta,"t07731")} p.${s(e.meta,"t03006")}`:s(e?.meta,"t07731")).substring(0,40),P=(e,t,n,r)=>{const{$langLabel:o}=_();return e?e.map(i=>({articleTitle:i.articleTitle,articleAuthor:i.articleAuthor,articlePage:i.articlePage,note:"",others:[],deliveryType:"DELIVERY_TYPE_SHIPPING",color:"MONOCHROME",isError:!1,isDeleted:!1})):[{articleTitle:r?o(I.rcopyInput.indexOnly):a(t)?s(t?.meta,"t02450").substring(0,200):"",articleAuthor:a(t)?s(t?.meta,"t0245c").substring(0,40):"",articlePage:a(t)?n:"",note:"",others:r?["index"]:[],deliveryType:"DELIVERY_TYPE_SHIPPING",color:"MONOCHROME",isError:!1,isDeleted:!1}]},c=e=>e.filter(t=>t.articleTitle?.trim()||t.articleAuthor?.trim()||t.articlePage?.trim()||t.note?.trim()||t.others.length),u=e=>e.forEach(t=>{Object.assign(t,{patronNote:l(t)}),Object.assign(t,{tocIndex:-1}),delete t.note,delete t.others,delete t.color,delete t.isError,delete t.isDeleted,delete t.deliveryType}),g=(e,t)=>{const n=l(e);return e.toc?.length?e.toc.map(r=>{const o=O(R(t))[r];return{tocIndex:r,articleTitle:A(o,!1),articleAuthor:D(o),articlePage:H(o,!0),patronNote:n}}):e.note||e.others.length?[{tocIndex:-1,articleTitle:"",articleAuthor:"",articlePage:"",patronNote:n}]:[]},m=(e,t,n)=>{const r=c(e);u(r);const o=g(t,n);if(t.toc?.length&&!o?.length){const{sendErrorLog:i}=L();i({case:"カートボタン押下時のリクエスト作成の不具合",message:"#18804 目次を指定したが、カート追加のリクエスト情報が空になっている",inputInfoList:e,tocInfo:t})}return r.concat(o)};function l(e){return JSON.stringify({note:e.note||"",option_cover:!!e.others?.includes("cover"),option_index:!!e.others?.includes("index"),option_colophon:!!e.others?.includes("colophon"),color_type:e.deliveryType==="DELIVERY_TYPE_SHIPPING"?e.color:"",deliveryType:e.deliveryType})}function E(e){return e?e.length>200?e.substring(0,200)+"...":e:""}function y(e,t){return N(e)?p(e):t}function f(e){return e==="DELIVERY_TYPE_SHIPPING"?d.remoteCopy:d.pdfDownload}return{getTitle:h,getPageOutput:T,getInputInfoList:P,filterRequestInput:c,mappingPatronNote:u,createRequestToc:g,createRequestInput:m,createPatronInfo:l,shortenTitle:E,getRcopyTitle:y,getHelpLink:f}};export{S as u};